=> Bootstrap dependency digest>=20211023: found digest-20220214 ===> Skipping vulnerability checks. WARNING: No /usr/pkg/pkgdb/pkg-vulnerabilities file found. WARNING: To fix run: `/usr/sbin/pkg_admin -K /usr/pkg/pkgdb fetch-pkg-vulnerabilities'. ===> Building for xemacs-nox11-21.5.35nb6 Resetting `src/sheap-adjust.h'. Producing `src/Emacs.ad.h' from `etc/Emacs.ad'. cp /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/PROBLEMS etc/PROBLEMS if test -n "/pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo"; then cd /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/man && /usr/bin/make -j 8 CC='gcc' CFLAGS='-Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include' LDFLAGS='-Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib' CPPFLAGS='-DTERMINFO -I/usr/pkg/include -I/usr/include' MAKEINFO='/pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo' info; fi --- ../info/beta.info --- --- ../info/cl.info --- --- ../info/emodules.info --- --- ../info/external-widget.info --- --- ../info/info.info --- --- ../info/internals.info --- --- ../info/lispref.info --- --- ../info/new-users-guide.info --- --- ../info/beta.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -o ../info/beta.info beta.texi --- ../info/cl.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -o ../info/cl.info cl.texi --- ../info/emodules.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -o ../info/emodules.info emodules.texi --- ../info/external-widget.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -o ../info/external-widget.info external-widget.texi --- ../info/info.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -o ../info/info.info info.texi --- ../info/internals.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -P internals -o ../info/internals.info internals/internals.texi --- ../info/lispref.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -P lispref -o ../info/lispref.info lispref/lispref.texi --- ../info/standards.info --- --- ../info/new-users-guide.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -P new-users-guide -o ../info/new-users-guide.info new-users-guide/new-users-guide.texi --- ../info/termcap.info --- --- ../info/widget.info --- --- ../info/standards.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -o ../info/standards.info standards.texi --- ../info/termcap.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -o ../info/termcap.info termcap.texi --- ../info/widget.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -o ../info/widget.info widget.texi --- ../info/xemacs.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -P xemacs -o ../info/xemacs.info xemacs/xemacs.texi --- ../info/xemacs-faq.info --- /pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo -o ../info/xemacs-faq.info xemacs-faq.texi xemacs-faq.texi:7: warning: unrecognized encoding name `UTF-8'. --- ../info/internals.info --- internals/internals.texi:7396: warning: `.' or `,' must follow @xref, not `)'. --- ../info/lispref.info --- /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/man/lispref//searching.texi:1557: warning: unlikely character ( in @var. /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/man/lispref//searching.texi:1557: warning: unlikely character ) in @var. /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/man/lispref//mule.texi:6: warning: unrecognized encoding name `UTF-8'. cd ./lib-src && /usr/bin/make -j 8 CC='gcc' CFLAGS='-Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include' LDFLAGS='-Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib' CPPFLAGS='-DTERMINFO -I/usr/pkg/include -I/usr/include' MAKEINFO='/pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo' all --- gnuslib.o --- --- ellcc --- --- getopt.o --- --- getopt1.o --- --- regex.o --- --- b2m --- --- fakemail --- --- profile --- --- gnuslib.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/gnuslib.c --- ellcc --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/ellcc.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o ellcc --- getopt.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/getopt.c --- getopt1.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/getopt1.c --- regex.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include -DINHIBIT_STRING_HEADER /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src/regex.c --- fakemail --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/fakemail.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o fakemail --- b2m --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/b2m.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o b2m --- profile --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/profile.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o profile In file included from /usr/include/stdio.h:595, from /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/profile.c:35: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/profile.c: In function 'get_time': /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/profile.c:86:25: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'time_t' {aka 'long long int'} [-Wformat=] 86 | sprintf (time_string, "%lu.%06lu", | ^~~~~~~~~~~ 87 | (unsigned long) TV2.tv_sec - TV1.tv_sec, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | time_t {aka long long int} /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/profile.c:86:28: note: format string is defined here 86 | sprintf (time_string, "%lu.%06lu", | ~~^ | | | long unsigned int | %llu --- make-docfile --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/make-docfile.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o make-docfile --- digest-doc --- --- sorted-doc --- --- digest-doc --- gcc -Demacs -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/digest-doc.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o digest-doc --- cvtmail --- --- sorted-doc --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/sorted-doc.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o sorted-doc --- hexl --- --- cvtmail --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/cvtmail.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o cvtmail --- hexl --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/hexl.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o hexl --- mmencode --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/mmencode.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o mmencode --- make-path --- gcc -Demacs -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/make-path.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o make-path --- make-dump-id --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/make-dump-id.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o make-dump-id --- insert-data-in-exec --- --- gnuclient --- --- insert-data-in-exec --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/insert-data-in-exec.c -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o insert-data-in-exec --- gnuclient --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/gnuclient.c gnuslib.o -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o gnuclient --- gnuserv --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/gnuserv.c gnuslib.o -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o gnuserv --- etags --- --- ootags --- --- movemail --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/movemail.c /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/pop.c getopt.o getopt1.o regex.o -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o movemail --- etags --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include -DEMACS_NAME='"XEmacs"' -DVERSION='"21.5-b35"' /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c getopt.o getopt1.o regex.o -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o etags --- ootags --- gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include -DVERSION='"21.5-b35"' /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/ootags.c getopt.o getopt1.o regex.o -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o ootags --- etags --- In function 'xrealloc', inlined from 'linebuffer_setlen' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6913:7, inlined from 'find_entries' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:2000:3: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6934:16: warning: argument 2 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=] 6934 | PTR result = (PTR) realloc (ptr, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:157: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c: In function 'find_entries': /usr/include/stdlib.h:120:7: note: in a call to allocation function 'realloc' declared here 120 | void *realloc(void *, size_t); | ^~~~~~~ In function 'xrealloc', inlined from 'linebuffer_setlen' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6913:7, inlined from 'HTML_labels' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:5343:3: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6934:16: warning: argument 2 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=] 6934 | PTR result = (PTR) realloc (ptr, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:157: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c: In function 'HTML_labels': /usr/include/stdlib.h:120:7: note: in a call to allocation function 'realloc' declared here 120 | void *realloc(void *, size_t); | ^~~~~~~ In function 'xrealloc', inlined from 'linebuffer_setlen' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6913:7, inlined from 'HTML_labels' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:5414:6: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6934:16: warning: argument 2 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=] 6934 | PTR result = (PTR) realloc (ptr, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:157: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c: In function 'HTML_labels': /usr/include/stdlib.h:120:7: note: in a call to allocation function 'realloc' declared here 120 | void *realloc(void *, size_t); | ^~~~~~~ --- ctags --- gcc -DCTAGS -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -I. -I../src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DTERMINFO -I/usr/pkg/include -I/usr/include -DHAVE_CONFIG_H -I/usr/pkg/include -DEMACS_NAME='"XEmacs"' -DVERSION='"21.5-b35"' /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c getopt.o getopt1.o regex.o -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil -o ctags In function 'xrealloc', inlined from 'linebuffer_setlen' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6913:7, inlined from 'find_entries' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:2000:3: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6934:16: warning: argument 2 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=] 6934 | PTR result = (PTR) realloc (ptr, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:157: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c: In function 'find_entries': /usr/include/stdlib.h:120:7: note: in a call to allocation function 'realloc' declared here 120 | void *realloc(void *, size_t); | ^~~~~~~ In function 'xrealloc', inlined from 'linebuffer_setlen' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6913:7, inlined from 'HTML_labels' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:5343:3: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6934:16: warning: argument 2 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=] 6934 | PTR result = (PTR) realloc (ptr, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:157: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c: In function 'HTML_labels': /usr/include/stdlib.h:120:7: note: in a call to allocation function 'realloc' declared here 120 | void *realloc(void *, size_t); | ^~~~~~~ In function 'xrealloc', inlined from 'linebuffer_setlen' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6913:7, inlined from 'HTML_labels' at /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:5414:6: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:6934:16: warning: argument 2 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=] 6934 | PTR result = (PTR) realloc (ptr, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c:157: /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lib-src/etags.c: In function 'HTML_labels': /usr/include/stdlib.h:120:7: note: in a call to allocation function 'realloc' declared here 120 | void *realloc(void *, size_t); | ^~~~~~~ cd ./src && /usr/bin/make -j 8 CC='gcc' CFLAGS='-Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include' LDFLAGS='-Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib' CPPFLAGS='-DTERMINFO -I/usr/pkg/include -I/usr/include' MAKEINFO='/pbulk/work/editors/xemacs-current-nox11/work/.tools/bin/makeinfo' all --- console-tty.o --- --- device-tty.o --- --- event-tty.o --- --- fontcolor-tty.o --- --- frame-tty.o --- --- redisplay-tty.o --- --- database.o --- --- mule-ccl.o --- --- console-tty.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include console-tty.c --- device-tty.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include device-tty.c --- event-tty.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include event-tty.c --- fontcolor-tty.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include fontcolor-tty.c --- frame-tty.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include frame-tty.c --- redisplay-tty.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include redisplay-tty.c --- database.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include database.c --- mule-ccl.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include mule-ccl.c mule-ccl.c: In function 'ccl_driver': mule-ccl.c:2001:48: warning: format '%zx' expects argument of type 'size_t', but argument 5 has type 'long int' [-Wformat=] 2001 | "\nCCL: Invalid command %lx (ccl_code = %zx) at %zd.", | ~~^ | | | unsigned int | %lx 2002 | code & 0x1F, code, this_ic); | ~~~~ | | | long int mule-ccl.c:2001:56: warning: format '%zd' expects argument of type 'signed size_t', but argument 6 has type 'long int' [-Wformat=] 2001 | "\nCCL: Invalid command %lx (ccl_code = %zx) at %zd.", | ~~^ | | | int | %ld 2002 | code & 0x1F, code, this_ic); | ~~~~~~~ | | | long int mule-ccl.c:2007:56: warning: format '%zx' expects argument of type 'size_t', but argument 5 has type 'long int' [-Wformat=] 2007 | "\nCCL: Invalid charset (command %x, ccl_code = %zx)" | ~~^ | | | unsigned int | %lx 2008 | " at %zd.", (int) (code & 0x1F), code, this_ic); | ~~~~ | | | long int mule-ccl.c:2007:6: warning: format '%zd' expects argument of type 'signed size_t', but argument 6 has type 'long int' [-Wformat=] 2007 | "\nCCL: Invalid charset (command %x, ccl_code = %zx)" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2008 | " at %zd.", (int) (code & 0x1F), code, this_ic); | ~~~~~~~ | | | long int mule-ccl.c:2008:34: note: format string is defined here 2008 | " at %zd.", (int) (code & 0x1F), code, this_ic); | ~~^ | | | int | %ld mule-ccl.c:2013:6: warning: format '%zx' expects argument of type 'size_t', but argument 5 has type 'long int' [-Wformat=] 2013 | "\nCCL: Conversion error (command %x, " | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | "ccl_code = %zx) at %zd.", (int) (code & 0x1F), 2015 | code, this_ic); | ~~~~ | | | long int mule-ccl.c:2014:41: note: format string is defined here 2014 | "ccl_code = %zx) at %zd.", (int) (code & 0x1F), | ~~^ | | | unsigned int | %lx mule-ccl.c:2013:6: warning: format '%zd' expects argument of type 'signed size_t', but argument 6 has type 'long int' [-Wformat=] 2013 | "\nCCL: Conversion error (command %x, " | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | "ccl_code = %zx) at %zd.", (int) (code & 0x1F), 2015 | code, this_ic); | ~~~~~~~ | | | long int mule-ccl.c:2014:49: note: format string is defined here 2014 | "ccl_code = %zx) at %zd.", (int) (code & 0x1F), | ~~^ | | | int | %ld mule-ccl.c:2033:12: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Wformat=] 2033 | " %zd", | ~~^ | | | int | %ld 2034 | ccl_backtrace_table[i])); | ~~~~~~~~~~~~~~~~~~~~~~ | | | long int --- mule-charset.o --- --- mule-coding.o --- --- mule-charset.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include mule-charset.c --- mule-coding.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include mule-coding.c --- abbrev.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include abbrev.c --- alloc.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include alloc.c --- alloca.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include alloca.c --- array.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include array.c --- alloc.o --- alloc.c: In function 'old_alloc_sized_lcrecord': alloc.c:450:14: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Bytecount' {aka 'long int'} [-Wformat=] 450 | stderr_out ("allocating %s (size %zd)\n", type, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...... 540 | INCREMENT_CONS_COUNTER (size, implementation->name); | ~~~~ | | | Bytecount {aka long int} alloc.c:540:3: note: in expansion of macro 'INCREMENT_CONS_COUNTER' 540 | INCREMENT_CONS_COUNTER (size, implementation->name); | ^~~~~~~~~~~~~~~~~~~~~~ alloc.c:450:37: note: format string is defined here 450 | stderr_out ("allocating %s (size %zd)\n", type, \ | ~~^ | | | int | %ld --- blocktype.o --- --- alloc.o --- alloc.c: In function 'allocate_big_string_chars': alloc.c:450:14: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Bytecount' {aka 'long int'} [-Wformat=] 450 | stderr_out ("allocating %s (size %zd)\n", type, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...... 2599 | INCREMENT_CONS_COUNTER (length, "string chars"); | ~~~~~~ | | | Bytecount {aka long int} alloc.c:2599:3: note: in expansion of macro 'INCREMENT_CONS_COUNTER' 2599 | INCREMENT_CONS_COUNTER (length, "string chars"); | ^~~~~~~~~~~~~~~~~~~~~~ alloc.c:450:37: note: format string is defined here 450 | stderr_out ("allocating %s (size %zd)\n", type, \ | ~~^ | | | int | %ld alloc.c: In function 'allocate_string_chars_struct': alloc.c:450:14: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Bytecount' {aka 'long int'} [-Wformat=] 450 | stderr_out ("allocating %s (size %zd)\n", type, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...... 2635 | INCREMENT_CONS_COUNTER (fullsize, "string chars"); | ~~~~~~~~ | | | Bytecount {aka long int} alloc.c:2635:3: note: in expansion of macro 'INCREMENT_CONS_COUNTER' 2635 | INCREMENT_CONS_COUNTER (fullsize, "string chars"); | ^~~~~~~~~~~~~~~~~~~~~~ alloc.c:450:37: note: format string is defined here 450 | stderr_out ("allocating %s (size %zd)\n", type, \ | ~~^ | | | int | %ld alloc.c: In function 'resize_string': --- blocktype.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include blocktype.c --- alloc.o --- alloc.c:450:14: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Bytecount' {aka 'long int'} [-Wformat=] 450 | stderr_out ("allocating %s (size %zd)\n", type, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...... 2762 | INCREMENT_CONS_COUNTER (newfullsize, "string chars"); | ~~~~~~~~~~~ | | | Bytecount {aka long int} alloc.c:2762:4: note: in expansion of macro 'INCREMENT_CONS_COUNTER' 2762 | INCREMENT_CONS_COUNTER (newfullsize, "string chars"); | ^~~~~~~~~~~~~~~~~~~~~~ alloc.c:450:37: note: format string is defined here 450 | stderr_out ("allocating %s (size %zd)\n", type, \ | ~~^ | | | int | %ld --- buffer.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include buffer.c --- bytecode.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include bytecode.c --- callint.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include callint.c --- buffer.o --- buffer.c: In function 'Fgenerate_new_buffer_name': buffer.c:792:54: warning: format '%zd' expects argument of type 'signed size_t', but argument 5 has type 'long int' [-Wformat=] 792 | clen = emacs_snprintf (candidate, csize, "%s<%zd>", XSTRING_DATA (name), | ~~^ | | | int | %ld 793 | ++count); | ~~~~~~~ | | | long int --- bytecode.o --- bytecode.c: In function 'check_constants_index': bytecode.c:1996:59: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Wformat=] 1996 | "reference %d to constants array out of range 0, %zd", | ~~^ | | | int | %ld bytecode.c: In function 'print_compiled_function': bytecode.c:2462:43: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Charcount' {aka 'long int'} [-Wformat=] 2462 | write_fmt_string (printcharfun, "\"...(%zd)\"", | ~~^ | | | int | %ld --- casefiddle.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include casefiddle.c --- casetab.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include casetab.c --- chartab.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include chartab.c --- cm.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include cm.c --- cmdloop.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include cmdloop.c --- cmds.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include cmds.c --- console-stream.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include console-stream.c --- console.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include console.c --- data.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include data.c --- debug.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include debug.c --- device.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include device.c --- dired.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include dired.c --- doc.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include doc.c --- doprnt.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include doprnt.c --- dumper.o --- --- editfns.o --- --- dumper.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include dumper.c --- editfns.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include editfns.c --- doprnt.o --- In file included from doprnt.c:47: doprnt.c: In function 'emacs_vsnprintf': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:585:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 585 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->outbuf = buf; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ doprnt.c:3709:7: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 3709 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (stream, output, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:586:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 586 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->size = bsize; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ doprnt.c:3709:7: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 3709 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (stream, output, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ doprnt.c: In function 'emacs_vsnprintf_ascbyte': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:585:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 585 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->outbuf = buf; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ doprnt.c:3793:3: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 3793 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (stream, (Ibyte *) output, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:586:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 586 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->size = bsize; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ doprnt.c:3793:3: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 3793 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (stream, (Ibyte *) output, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- elhash.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include elhash.c --- emacs.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include emacs.c --- emodules.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include emodules.c --- elhash.o --- elhash.c: In function 'print_hash_table': elhash.c:543:44: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Elemcount' {aka 'long int'} [-Wformat=] 543 | write_fmt_string (printcharfun, " :size %zd", ht->count); | ~~^ ~~~~~~~~~ | | | | int Elemcount {aka long int} | %ld elhash.c:545:44: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Elemcount' {aka 'long int'} [-Wformat=] 545 | write_fmt_string (printcharfun, " :size %zd/%zd", ht->count, | ~~^ ~~~~~~~~~ | | | | int Elemcount {aka long int} | %ld elhash.c:545:48: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'Elemcount' {aka 'long int'} [-Wformat=] 545 | write_fmt_string (printcharfun, " :size %zd/%zd", ht->count, | ~~^ | | | int | %ld 546 | ht->size); | ~~~~~~~~ | | | Elemcount {aka long int} --- emodules.o --- emodules.c: In function 'emodules_load': emodules.c:385:80: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'long int' [-Wformat=] 385 | signal_ferror (Qdll_error, "Invalid dynamic module: Unsupported version `%zd(%zd)'", *ellcc_rev, EMODULES_REVISION); | ~~^ ~~~~~~~~~~ | | | | int long int | %ld emodules.c:385:84: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Wformat=] 385 | signal_ferror (Qdll_error, "Invalid dynamic module: Unsupported version `%zd(%zd)'", *ellcc_rev, EMODULES_REVISION); | ~~^ | | | int | %ld --- eval.o --- --- emacs.o --- In file included from /usr/include/stdio.h:595, from lisp.h:114, from emacs.c:425: emacs.c: In function 'assert_equal_failed': emacs.c:3937:20: warning: format '%zd' expects argument of type 'signed size_t', but argument 6 has type 'long int' [-Wformat=] 3937 | sprintf (bigstr, "%s (%zd) should == %s (%zd) but doesn't", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | exprx, x, expry, y); | ~ | | | long int --- eval.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include eval.c --- emacs.o --- emacs.c:3937:27: note: format string is defined here 3937 | sprintf (bigstr, "%s (%zd) should == %s (%zd) but doesn't", | ~~^ | | | int | %ld In file included from /usr/include/stdio.h:595, from lisp.h:114, from emacs.c:425: emacs.c:3937:20: warning: format '%zd' expects argument of type 'signed size_t', but argument 8 has type 'long int' [-Wformat=] 3937 | sprintf (bigstr, "%s (%zd) should == %s (%zd) but doesn't", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | exprx, x, expry, y); | ~ | | | long int emacs.c:3937:46: note: format string is defined here 3937 | sprintf (bigstr, "%s (%zd) should == %s (%zd) but doesn't", | ~~^ | | | int | %ld --- event-stream.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include event-stream.c --- eval.o --- eval.c: In function 'print_multiple_value': eval.c:4742:56: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Elemcount' {aka 'long int'} [-Wformat=] 4742 | "#", | ~~^ | | | int | %ld 4752 | index); | ~~~~~ | | | Elemcount {aka long int} --- event-stream.o --- In file included from event-stream.c:79: event-stream.c: In function 'echo_key_event': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:585:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 585 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->outbuf = buf; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ event-stream.c:649:3: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 649 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:586:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 586 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->size = bsize; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ event-stream.c:649:3: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 649 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- event-unixoid.o --- --- events.o --- --- event-unixoid.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include event-unixoid.c --- events.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include events.c events.c: In function 'print_event': events.c:284:52: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'long int' [-Wformat=] 284 | write_fmt_string (printcharfun, "#pos < 0 ? soe->pos : | ~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int 1040 | object_memxpos_to_bytexpos (obj, soe->pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ extents.c:1038:42: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Memxpos' {aka 'long int'} [-Wformat=] 1038 | stderr_out ("SOE pos is %zd (memxpos %zd)\n", | ~~^ | | | int | %ld ...... 1041 | soe->pos); | ~~~~~~~~ | | | Memxpos {aka long int} extents.c: In function 'soe_move': extents.c:1144:36: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1144 | stderr_out ("Moving SOE from %zd (memxpos %zd) to %zd (memxpos %zd)\n", | ~~^ | | | int | %ld 1145 | soe->pos < 0 ? soe->pos : | ~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int 1146 | object_memxpos_to_bytexpos (obj, soe->pos), soe->pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ extents.c:1144:49: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Memxpos' {aka 'long int'} [-Wformat=] 1144 | stderr_out ("Moving SOE from %zd (memxpos %zd) to %zd (memxpos %zd)\n", | ~~^ | | | int | %ld 1145 | soe->pos < 0 ? soe->pos : 1146 | object_memxpos_to_bytexpos (obj, soe->pos), soe->pos, | ~~~~~~~~ | | | Memxpos {aka long int} extents.c:1144:57: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'Bytexpos' {aka 'long int'} [-Wformat=] 1144 | stderr_out ("Moving SOE from %zd (memxpos %zd) to %zd (memxpos %zd)\n", | ~~^ | | | int | %ld ...... 1147 | object_memxpos_to_bytexpos (obj, pos), pos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | Bytexpos {aka long int} extents.c:1144:70: warning: format '%zd' expects argument of type 'signed size_t', but argument 5 has type 'Memxpos' {aka 'long int'} [-Wformat=] 1144 | stderr_out ("Moving SOE from %zd (memxpos %zd) to %zd (memxpos %zd)\n", | ~~^ | | | int | %ld ...... 1147 | object_memxpos_to_bytexpos (obj, pos), pos); | ~~~ | | | Memxpos {aka long int} extents.c: In function 'print_extent_1': extents.c:2798:40: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Wformat=] 2798 | "%zd, %zd", | ~~^ | | | int | %ld extents.c:2798:45: warning: format '%zd' expects argument of type 'signed size_t', but argument 5 has type 'long int' [-Wformat=] 2798 | "%zd, %zd", | ~~^ | | | int | %ld --- file-coding.o --- In file included from file-coding.c:76: file-coding.c: In function 'coding_stream_coding_system': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file-coding.h:1146:36: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1146 | #define CODING_STREAM_DATA(stream) LSTREAM_TYPE_DATA (stream, coding) | ^~~~~~~~~~~~~~~~~ file-coding.c:2558:10: note: in expansion of macro 'CODING_STREAM_DATA' 2558 | return CODING_STREAM_DATA (stream)->codesys; | ^~~~~~~~~~~~~~~~~~ file-coding.c: In function 'detect_coding_type': file-coding.c:4464:52: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'Bytecount' {aka 'long int'} [-Wformat=] 4464 | debug_out ("detect_coding_type: processing %zd bytes\n", n); | ~~^ ~ | | | | int Bytecount {aka long int} | %ld --- fileio.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include fileio.c --- filelock.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include filelock.c --- filemode.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include filemode.c --- floatfns.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include floatfns.c --- fns.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include fns.c --- font-lock.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include font-lock.c --- fontcolor.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include fontcolor.c --- frame.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include frame.c --- gc.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include gc.c --- general.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include general.c --- gc.o --- gc.c: In function 'lispdesc_indirect_count_1': gc.c:212:69: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Wformat=] 212 | stderr_out ("Unsupported count type : %d (line = %d, code = %zd)\n", | ~~^ | | | int | %ld 213 | idesc[line].type, line, code); | ~~~~ | | | long int --- glyphs-widget.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include glyphs-widget.c --- glyphs.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include glyphs.c glyphs.c: In function 'print_image_instance': glyphs.c:970:41: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'long int' [-Wformat=] 970 | write_fmt_string (printcharfun, "%zd", | ~~^ | | | int | %ld glyphs.c:976:41: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'long int' [-Wformat=] 976 | write_fmt_string (printcharfun, "%zd", | ~~^ | | | int | %ld --- gui.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include gui.c --- gutter.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include gutter.c --- imgproc.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include imgproc.c --- indent.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include indent.c --- inline.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include inline.c --- insdel.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include insdel.c --- intl.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include intl.c --- keymap.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include keymap.c --- lastfile.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include lastfile.c --- line-number.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include line-number.c --- linuxplay.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include linuxplay.c --- keymap.o --- keymap.c: In function 'print_keymap': keymap.c:302:43: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'long int' [-Wformat=] 302 | write_fmt_string (printcharfun, "size %zd 0x%x>", | ~~^ | | | int | %ld In file included from keymap.c:31: keymap.c: In function 'where_is_to_Ibyte': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:585:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 585 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->outbuf = buf; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ keymap.c:3895:3: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 3895 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (stream, buffer, bufsize); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:586:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 586 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->size = bsize; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ keymap.c:3895:3: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 3895 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (stream, buffer, bufsize); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- lread.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include lread.c --- lstream.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include lstream.c --- macros.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include macros.c --- lstream.o --- In file included from lstream.c:31: lstream.c: In function 'stdio_rewinder': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c:1076:35: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1076 | #define STDIO_STREAM_DATA(stream) LSTREAM_TYPE_DATA (stream, stdio) | ^~~~~~~~~~~~~~~~~ lstream.c:1153:11: note: in expansion of macro 'STDIO_STREAM_DATA' 1153 | rewind (STDIO_STREAM_DATA (stream)->file); | ^~~~~~~~~~~~~~~~~ lstream.c: In function 'filedesc_rewinder': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c:1206:38: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1206 | #define FILEDESC_STREAM_DATA(stream) LSTREAM_TYPE_DATA (stream, filedesc) | ^~~~~~~~~~~~~~~~~ lstream.c:1464:14: note: in expansion of macro 'FILEDESC_STREAM_DATA' 1464 | lseek (FILEDESC_STREAM_DATA (stream)->fd, str->starting_pos, | ^~~~~~~~~~~~~~~~~~~~ lstream.c: In function 'fixed_buffer_rewinder': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.c:1694:3: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 1694 | FIXED_BUFFER_STREAM_DATA (stream)->offset = 0; | ^~~~~~~~~~~~~~~~~~~~~~~~ lstream.c: In function 'fixed_buffer_input_stream_ptr': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.c:1702:10: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 1702 | return FIXED_BUFFER_STREAM_DATA (stream)->inbuf; | ^~~~~~~~~~~~~~~~~~~~~~~~ lstream.c: In function 'fixed_buffer_output_stream_ptr': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.c:1709:10: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 1709 | return FIXED_BUFFER_STREAM_DATA (stream)->outbuf; | ^~~~~~~~~~~~~~~~~~~~~~~~ lstream.c: In function 'make_resizing_buffer_output_stream': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c:1715:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1715 | LSTREAM_TYPE_DATA (stream, resizing_buffer) | ^~~~~~~~~~~~~~~~~ lstream.c:1738:3: note: in expansion of macro 'RESIZING_BUFFER_STREAM_DATA' 1738 | RESIZING_BUFFER_STREAM_DATA (stream)->extent_info | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c: In function 'resizing_buffer_rewinder': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c:1715:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1715 | LSTREAM_TYPE_DATA (stream, resizing_buffer) | ^~~~~~~~~~~~~~~~~ lstream.c:1775:3: note: in expansion of macro 'RESIZING_BUFFER_STREAM_DATA' 1775 | RESIZING_BUFFER_STREAM_DATA (stream)->stored = 0; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from lisp.h:1841, from lstream.c:26: lstream.c: In function 'resizing_buffer_extent_info': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lrecord.h:1616:25: note: in definition of macro 'XRECORD' 1616 | error_check_##c_name (x, __FILE__, __LINE__) | ^ lstream.c:1795:10: note: in expansion of macro 'XEXTENT_INFO' 1795 | return XEXTENT_INFO (RESIZING_BUFFER_STREAM_DATA (stream)->extent_info); | ^~~~~~~~~~~~ lstream.c:1715:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1715 | LSTREAM_TYPE_DATA (stream, resizing_buffer) | ^~~~~~~~~~~~~~~~~ lstream.c:1795:24: note: in expansion of macro 'RESIZING_BUFFER_STREAM_DATA' 1795 | return XEXTENT_INFO (RESIZING_BUFFER_STREAM_DATA (stream)->extent_info); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from lstream.c:31: lstream.c: In function 'resizing_buffer_stream_ptr': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c:1715:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1715 | LSTREAM_TYPE_DATA (stream, resizing_buffer) | ^~~~~~~~~~~~~~~~~ lstream.c:1801:10: note: in expansion of macro 'RESIZING_BUFFER_STREAM_DATA' 1801 | return RESIZING_BUFFER_STREAM_DATA (stream)->buf; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c: In function 'resizing_buffer_to_lisp_string': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c:1715:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1715 | LSTREAM_TYPE_DATA (stream, resizing_buffer) | ^~~~~~~~~~~~~~~~~ lstream.c:1810:25: note: in expansion of macro 'RESIZING_BUFFER_STREAM_DATA' 1810 | result = make_string (RESIZING_BUFFER_STREAM_DATA (stream)->buf, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c: In function 'make_dynarr_output_stream': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c:1874:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1874 | LSTREAM_TYPE_DATA (stream, dynarr) | ^~~~~~~~~~~~~~~~~ lstream.c:1888:3: note: in expansion of macro 'DYNARR_STREAM_DATA' 1888 | DYNARR_STREAM_DATA (XLSTREAM (obj))->dyn = dyn; | ^~~~~~~~~~~~~~~~~~ In file included from lisp.h:1885, from lstream.c:26: lstream.c: In function 'dynarr_rewinder': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ array.h:458:45: note: in definition of macro 'Dynarr_reset' 458 | #define Dynarr_reset(d) Dynarr_set_lengthr (d, 0) | ^ lstream.c:1874:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1874 | LSTREAM_TYPE_DATA (stream, dynarr) | ^~~~~~~~~~~~~~~~~ lstream.c:1904:17: note: in expansion of macro 'DYNARR_STREAM_DATA' 1904 | Dynarr_reset (DYNARR_STREAM_DATA (stream)->dyn); | ^~~~~~~~~~~~~~~~~~ In file included from lstream.c:31: lstream.c: In function 'lisp_buffer_stream_startpos': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.c:1921:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 1921 | LSTREAM_TYPE_DATA (stream, lisp_buffer) | ^~~~~~~~~~~~~~~~~ lstream.c:2122:27: note: in expansion of macro 'LISP_BUFFER_STREAM_DATA' 2122 | return marker_position (LISP_BUFFER_STREAM_DATA (stream)->start); | ^~~~~~~~~~~~~~~~~~~~~~~ --- marker.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include marker.c marker.c: In function 'print_marker': marker.c:51:45: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Charbpos' {aka 'long int'} [-Wformat=] 51 | write_fmt_string (printcharfun, "at %zd in ", | ~~^ | | | int | %ld 52 | marker_position (obj)); | ~~~~~~~~~~~~~~~~~~~~~ | | | Charbpos {aka long int} --- md5.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include md5.c --- minibuf.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include minibuf.c --- miscplay.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include miscplay.c --- number-gmp.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include number-gmp.c --- number.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include number.c --- opaque.o --- --- print.o --- --- opaque.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include opaque.c --- print.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include print.c --- number-gmp.o --- number-gmp.c: In function 'bigfloat_to_string': number-gmp.c:182:37: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Wformat=] 182 | "E%zd", expt); | ~~^ ~~~~ | | | | int long int | %ld --- process-unix.o --- --- opaque.o --- opaque.c: In function 'print_opaque': opaque.c:50:55: warning: format '%zu' expects argument of type 'size_t', but argument 3 has type 'long unsigned int' [-Wformat=] 50 | "#", | ~~^ | | | unsigned int | %lu 51 | (EMACS_UINT)(p->size), LISP_OBJECT_UID (obj)); | ~~~~~~~~~~~~~~~~~~~~~ | | | long unsigned int opaque.c: In function 'hash_opaque': opaque.c:105:14: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 105 | return *((Hashcode *) XOPAQUE_DATA (obj)); | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- process-unix.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include process-unix.c --- print.o --- print.c: In function 'printing_major_badness': print.c:1644:63: warning: format '%zd' expects argument of type 'signed size_t', but argument 6 has type 'long int' [-Wformat=] 1644 | emacs_snprintf (buf, sizeof (buf), "%s type %d object %zd", | ~~^ | | | int | %ld 1645 | badness_string, type, (EMACS_INT) val); | ~~~~~~~~~~~~~~~ | | | long int print.c: In function 'print_gensym_or_circle': print.c:1894:47: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'long int' [-Wformat=] 1894 | write_fmt_string (printcharfun, "#%zd#", | ~~^ | | | int | %ld 1895 | (XFIXNUM (seen) & PRINT_NUMBER_ORDINAL_MASK) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | >> PRINT_NUMBER_ORDINAL_SHIFT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int print.c:1903:47: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'long int' [-Wformat=] 1903 | write_fmt_string (printcharfun, "#%zd=", | ~~^ | | | int | %ld 1904 | (XFIXNUM (seen) & PRINT_NUMBER_ORDINAL_MASK) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | >> PRINT_NUMBER_ORDINAL_SHIFT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int print.c: In function 'debug_p4': print.c:2813:21: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 2813 | debug_out ("%zd", XFIXNUM (obj)); | ~~^ | | | int | %ld print.c:2827:28: warning: format '%zx' expects argument of type 'size_t', but argument 3 has type 'long int' [-Wformat=] 2827 | debug_out ("#<%s addr=0x%zx uid=0x%zx>", | ~~^ | | | unsigned int | %lx 2828 | LHEADER_IMPLEMENTATION (header)->name, 2829 | (EMACS_INT) header, | ~~~~~~~~~~~~~~~~~~ | | | long int print.c:2827:38: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'long int' [-Wformat=] 2827 | debug_out ("#<%s addr=0x%zx uid=0x%zx>", | ~~^ | | | unsigned int | %lx ...... 2830 | (EMACS_INT) ((struct lrecord_header *) header)->uid); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int --- process.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include process.c --- profile.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include profile.c --- ralloc.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include ralloc.c --- process-unix.o --- process-unix.c: In function 'unix_init_process_io_handles': process-unix.c:842:52: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Wformat=] 842 | "failed setting pipe (fd %zd) to nonblocking mode", | ~~^ | | | int | %ld 843 | (EMACS_INT) in); | ~~~~~~~~~~~~~~ | | | long int process-unix.c: In function 'unix_open_network_stream': process-unix.c:1901:36: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Wformat=] 1901 | "%zd", XFIXNUM (service)); | ~~^ | | | int | %ld --- rangetab.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include rangetab.c --- realpath.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include realpath.c --- redisplay-output.o --- --- rangetab.o --- rangetab.c: In function 'print_range_table': rangetab.c:125:44: warning: format '%zd' expects argument of type 'signed size_t', but argument 4 has type 'long int' [-Wformat=] 125 | write_fmt_string (printcharfun, "%c%zd %zd%c ", | ~~^ | | | int | %ld 126 | print_readably ? '(' : so ? '(' : '[', 127 | (Bytecount) (rte.first - so), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int rangetab.c:125:48: warning: format '%zd' expects argument of type 'signed size_t', but argument 5 has type 'long int' [-Wformat=] 125 | write_fmt_string (printcharfun, "%c%zd %zd%c ", | ~~^ | | | int | %ld ...... 128 | (Bytecount) (rte.last - ec), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int --- redisplay-output.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include redisplay-output.c --- redisplay.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include redisplay.c --- regex.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include regex.c --- search.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include search.c --- select.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include select.c --- regex.o --- regex.c: In function 'print_partial_compiled_pattern': regex.c:851:18: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 851 | printf ("%zd:\t", (Bytecount)(p - start)); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~ | | | | int long int | %ld regex.c:953:19: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 953 | printf ("(0x%zx)", (Bytecount)first); | ~~^ ~~~~~~~~~~~~~~~~ | | | | | long int | unsigned int | %lx regex.c:960:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 960 | printf ("(0x%zx)", (Bytecount)last); | ~~^ ~~~~~~~~~~~~~~~ | | | | | long int | unsigned int | %lx regex.c:979:37: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 979 | printf ("/on_failure_jump to %zd", (Bytecount)(p + mcnt - start)); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int long int | %ld regex.c:984:49: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 984 | printf ("/on_failure_keep_string_jump to %zd", | ~~^ | | | int | %ld 985 | (Bytecount)(p + mcnt - start)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:990:40: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 990 | printf ("/dummy_failure_jump to %zd", | ~~^ | | | int | %ld 991 | (Bytecount)(p + mcnt - start)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:1000:36: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1000 | printf ("/maybe_pop_jump to %zd", (Bytecount)(p + mcnt - start)); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int long int | %ld regex.c:1005:38: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1005 | printf ("/pop_failure_jump to %zd", (Bytecount)(p + mcnt - start)); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int long int | %ld regex.c:1010:35: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1010 | printf ("/jump_past_alt to %zd", (Bytecount)(p + mcnt - start)); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int long int | %ld regex.c:1015:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1015 | printf ("/jump to %zd", (Bytecount)(p + mcnt - start)); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int long int | %ld regex.c:1021:29: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1021 | printf ("/succeed_n to %zd, %d times", | ~~^ | | | int | %ld 1022 | (Bytecount)(p + mcnt - start), mcnt2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:1028:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1028 | printf ("/jump_n to %zd, %d times", | ~~^ | | | int | %ld 1029 | (Bytecount)(p + mcnt - start), mcnt2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:1035:39: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1035 | printf ("/set_number_at location %zd to %d", | ~~^ | | | int | %ld 1036 | (Bytecount)(p + mcnt - start), mcnt2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:1119:14: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1119 | printf ("%zd:\tend of pattern.\n", (Bytecount)(p - start)); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~ | | | | int long int | %ld regex.c: In function 'print_compiled_pattern': regex.c:1129:14: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'Bytecount' {aka 'long int'} [-Wformat=] 1129 | printf ("%zd bytes used/%zd bytes allocated.\n", bufp->used, | ~~^ ~~~~~~~~~~ | | | | int Bytecount {aka long int} | %ld regex.c:1129:29: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'Bytecount' {aka 'long int'} [-Wformat=] 1129 | printf ("%zd bytes used/%zd bytes allocated.\n", bufp->used, | ~~^ | | | int | %ld 1130 | bufp->allocated); | ~~~~~~~~~~~~~~~ | | | Bytecount {aka long int} regex.c:1138:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1138 | printf ("re_nsub: %zd\t", (Bytecount)bufp->re_nsub); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int long int | %ld regex.c:1139:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1139 | printf ("re_ngroups: %zd\t", (Bytecount)bufp->re_ngroups); | ~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | int long int | %ld regex.c: In function 're_match_2_internal': regex.c:5796:27: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ^~~~~~~~~~~ ~~~~~~~~~~~~~ | | | long int regex.c:789:50: note: in definition of macro 'DEBUG_MATCH_PRINT2' 789 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2) | ^~ regex.c:5796:34: note: format string is defined here 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~^ | | | unsigned int | %lx regex.c:6202:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ^~~~~~~~~~~~~~~~~~~~~~~ regex.c:789:50: note: in definition of macro 'DEBUG_MATCH_PRINT2' 789 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2) | ^~ regex.c:6202:45: note: format string is defined here 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~^ | | | int | %ld regex.c:6206:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ^~~~~~~~~~~~~~~~~~~ regex.c:789:50: note: in definition of macro 'DEBUG_MATCH_PRINT2' 789 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2) | ^~ regex.c:6206:41: note: format string is defined here 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~^ | | | int | %ld regex.c:6249:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ^~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:789:50: note: in definition of macro 'DEBUG_MATCH_PRINT2' 789 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2) | ^~ regex.c:6249:47: note: format string is defined here 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~^ | | | int | %ld regex.c:6252:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ^~~~~~~~~~~~~~~~~~~~~ regex.c:789:50: note: in definition of macro 'DEBUG_MATCH_PRINT2' 789 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2) | ^~ regex.c:6252:43: note: format string is defined here 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~^ | | | int | %ld regex.c:1731:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1732 | (Bytecount) (fail_stack).avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1731:56: note: format string is defined here 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ~~^ | | | int | %ld --- sequence.o --- --- regex.o --- regex.c:1733:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1734 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1733:56: note: format string is defined here 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~^ | | | int | %ld regex.c:1737:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1737:45: note: format string is defined here 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ~~^ | | | int | %ld --- sequence.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include sequence.c --- regex.o --- regex.c:1756:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1757 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1756:55: note: format string is defined here 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ~~^ | | | int | %ld regex.c:1758:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1758:45: note: format string is defined here 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ~~^ | | | int | %ld regex.c:1777:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~ 1778 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1777:39: note: format string is defined here 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1779:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~ 1780 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1779:37: note: format string is defined here 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1781:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~ 1782 | * (long *) (®_info[this_reg])); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1781:38: note: format string is defined here 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ~~^ | | | unsigned int | %lx regex.c:1814:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1815 | (Bytecount) pattern_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1816 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1814:49: note: format string is defined here 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ~~^ | | | unsigned int | %lx regex.c:1817:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6370:7: note: in expansion of macro 'PUSH_FAILURE_POINT' 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1817:48: note: format string is defined here 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~^ | | | unsigned int | %lx regex.c:6534:31: warning: format '%zx' expects argument of type 'size_t', but argument 3 has type 'long int' [-Wformat=] 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ^~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:791:50: note: in definition of macro 'DEBUG_MATCH_PRINT3' 791 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2, x3) | ^~ regex.c:6534:44: note: format string is defined here 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~^ | | | unsigned int | %lx regex.c:1731:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1732 | (Bytecount) (fail_stack).avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1731:56: note: format string is defined here 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ~~^ | | | int | %ld regex.c:1733:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1734 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1733:56: note: format string is defined here 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~^ | | | int | %ld regex.c:1737:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1737:45: note: format string is defined here 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ~~^ | | | int | %ld regex.c:1756:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1757 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1756:55: note: format string is defined here 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ~~^ | | | int | %ld regex.c:1758:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1758:45: note: format string is defined here 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ~~^ | | | int | %ld regex.c:1777:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~ 1778 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1777:39: note: format string is defined here 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1779:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~ 1780 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1779:37: note: format string is defined here 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1781:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~ 1782 | * (long *) (®_info[this_reg])); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1781:38: note: format string is defined here 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ~~^ | | | unsigned int | %lx regex.c:1814:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1815 | (Bytecount) pattern_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1816 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1814:49: note: format string is defined here 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ~~^ | | | unsigned int | %lx regex.c:1817:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ --- redisplay.o --- In file included from redisplay.c:50: redisplay.c: In function 'add_disp_table_entry_runes_1': lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:585:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 585 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->outbuf = buf; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ redisplay.c:1552:11: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 1552 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (format_buf_lispobj, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- regex.o --- 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- redisplay.o --- lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:586:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 586 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->size = bsize; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ redisplay.c:1552:11: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 1552 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (format_buf_lispobj, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- regex.o --- 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- redisplay.o --- lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:585:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 585 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->outbuf = buf; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ redisplay.c:1566:15: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 1566 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (format_buf_lispobj, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- regex.o --- 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | --- redisplay.o --- lstream.h:315:4: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 315 | ((struct type##_stream *) \ | ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 316 | Lstream_data (error_check_lstream_type (lstr, lstream_##type))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lstream.h:562:3: note: in expansion of macro 'LSTREAM_TYPE_DATA' 562 | LSTREAM_TYPE_DATA (stream, fixed_buffer) | ^~~~~~~~~~~~~~~~~ lstream.h:586:7: note: in expansion of macro 'FIXED_BUFFER_STREAM_DATA' 586 | FIXED_BUFFER_STREAM_DATA (&(lname##u.l))->size = bsize; \ | ^~~~~~~~~~~~~~~~~~~~~~~~ redisplay.c:1566:15: note: in expansion of macro 'INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM' 1566 | INIT_STACK_FIXED_BUFFER_OUTPUT_STREAM (format_buf_lispobj, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- regex.o --- 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6537:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1817:48: note: format string is defined here 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~^ | | | unsigned int | %lx regex.c:6558:31: warning: format '%zx' expects argument of type 'size_t', but argument 3 has type 'long int' [-Wformat=] 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ^~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:791:50: note: in definition of macro 'DEBUG_MATCH_PRINT3' 791 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2, x3) | ^~ regex.c:6558:44: note: format string is defined here 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~^ | | | unsigned int | %lx --- signal.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include signal.c --- regex.o --- regex.c:1731:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1732 | (Bytecount) (fail_stack).avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1731:56: note: format string is defined here 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ~~^ | | | int | %ld regex.c:1733:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1734 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1733:56: note: format string is defined here 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~^ | | | int | %ld regex.c:1737:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1737:45: note: format string is defined here 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ~~^ | | | int | %ld regex.c:1756:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1757 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1756:55: note: format string is defined here 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ~~^ | | | int | %ld regex.c:1758:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1758:45: note: format string is defined here 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ~~^ | | | int | %ld regex.c:1777:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~ 1778 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1777:39: note: format string is defined here 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1779:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~ 1780 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1779:37: note: format string is defined here 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1781:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~ 1782 | * (long *) (®_info[this_reg])); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1781:38: note: format string is defined here 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ~~^ | | | unsigned int | %lx regex.c:1814:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1815 | (Bytecount) pattern_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1816 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1814:49: note: format string is defined here 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ~~^ | | | unsigned int | %lx regex.c:1817:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6590:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1817:48: note: format string is defined here 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~^ | | | unsigned int | %lx --- sound.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include sound.c --- specifier.o --- --- regex.o --- regex.c:1877:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6767:13: note: in expansion of macro 'POP_FAILURE_POINT' 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ^~~~~~~~~~~~~~~~~ regex.c:1877:55: note: format string is defined here 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~^ | | | int | %ld regex.c:1879:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6767:13: note: in expansion of macro 'POP_FAILURE_POINT' 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ^~~~~~~~~~~~~~~~~ regex.c:1879:55: note: format string is defined here 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~^ | | | int | %ld --- specifier.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include specifier.c --- regex.o --- regex.c:1901:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ | | | long int 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6591 | break; | ~~~~~~ 6592 | | 6593 | | 6594 | /* A smart repeat ends with `maybe_pop_jump'. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6595 | We change it to either `pop_failure_jump' or `jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6596 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6597 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6598 | DEBUG_MATCH_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6599 | { | ~ 6600 | REGISTER const unsigned char *p2 = p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6601 | | 6602 | /* Compare the beginning of the repeat with what in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6603 | pattern follows its end. If we can establish that there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6604 | is nothing that they would both match, i.e., that we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6605 | would have to backtrack because of (as in, e.g., `a*a') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6606 | then we can change to pop_failure_jump, because we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6607 | never have to backtrack. | ~~~~~~~~~~~~~~~~~~~~~~~~ 6608 | | 6609 | This is not true in the case of alternatives: in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6610 | `(a|ab)*' we do need to backtrack to the `ab' alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6611 | (e.g., if the string was `ab'). But instead of trying to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6612 | detect that here, the alternative has put on a dummy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6613 | failure point which is what we will end up popping. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6614 | | 6615 | /* Skip over open/close-group commands. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6616 | If what follows this loop is a ...+ construct, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6617 | look at what begins its body, since we will have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6618 | match at least one of that. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6619 | while (1) | ~~~~~~~~~ 6620 | { | ~ 6621 | if (p2 + 2 < pend | ~~~~~~~~~~~~~~~~~ 6622 | && ((re_opcode_t) *p2 == stop_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6623 | || (re_opcode_t) *p2 == start_memory)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6624 | p2 += 3; | ~~~~~~~~ 6625 | else if (p2 + 6 < pend | ~~~~~~~~~~~~~~~~~~~~~~ 6626 | && (re_opcode_t) *p2 == dummy_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6627 | p2 += 6; | ~~~~~~~~ 6628 | else | ~~~~ 6629 | break; | ~~~~~~ 6630 | } | ~ 6631 | | 6632 | p1 = p + mcnt; | ~~~~~~~~~~~~~~ 6633 | /* p1[0] ... p1[2] are the `on_failure_jump' corresponding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6634 | to the `maybe_finalize_jump' of this case. Examine what | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6635 | follows. */ | ~~~~~~~~~~~~ 6636 | | 6637 | /* If we're at the end of the pattern, we can change. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6638 | if (p2 == pend) | ~~~~~~~~~~~~~~~ 6639 | { | ~ 6640 | /* Consider what happens when matching ":\(.*\)" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6641 | against ":/". I don't really understand this code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6642 | yet. */ | ~~~~~~~~ 6643 | ((unsigned char *)p)[-3] = (re_char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6644 | DEBUG_MATCH_PRINT1 | ~~~~~~~~~~~~~~~~~~ 6645 | (" End of pattern: change to `pop_failure_jump'.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6646 | } | ~ 6647 | | 6648 | else if ((re_opcode_t) *p2 == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6649 | || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6650 | { | ~ 6651 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6652 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6653 | | 6654 | if ((re_opcode_t) p1[3] == exactn && p1[5] != c) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6655 | { | ~ 6656 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6657 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6658 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6659 | c, p1[5]); | ~~~~~~~~~~ 6660 | } | ~ 6661 | | 6662 | else if ((re_opcode_t) p1[3] == charset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6663 | || (re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6664 | { | ~ 6665 | int not_p = (re_opcode_t) p1[3] == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6666 | | 6667 | if (c < (unsigned char) (p1[4] * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6668 | && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6669 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6670 | | 6671 | /* `not_p' is equal to 1 if c would match, which means | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6672 | that we can't change to pop_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6673 | if (!not_p) | ~~~~~~~~~~~ 6674 | { | ~ 6675 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6676 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6677 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6678 | } | ~ 6679 | } | ~ 6680 | } | ~ 6681 | else if ((re_opcode_t) *p2 == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6682 | { | ~ 6683 | #ifdef DEBUG | ~~~~~~~~~~~~ 6684 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6685 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6686 | #endif | ~~~~~~ 6687 | | 6688 | if ((re_opcode_t) p1[3] == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6689 | && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6690 | && (p2[2 + p1[5] / BYTEWIDTH] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6691 | & (1 << (p1[5] % BYTEWIDTH))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6692 | { | ~ 6693 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6694 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6695 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6696 | c, p1[5]); | ~~~~~~~~~~ 6697 | } | ~ 6698 | | 6699 | else if ((re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6700 | { | ~ 6701 | int idx; | ~~~~~~~~ 6702 | /* We win if the charset_not inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6703 | lists every character listed in the charset after. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6704 | for (idx = 0; idx < (int) p2[1]; idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6705 | if (! (p2[2 + idx] == 0 | ~~~~~~~~~~~~~~~~~~~~~~~ 6706 | || (idx < (int) p1[4] | ~~~~~~~~~~~~~~~~~~~~~ 6707 | && ((p2[2 + idx] & ~ p1[5 + idx]) == 0)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6708 | break; | ~~~~~~ 6709 | | 6710 | if (idx == p2[1]) | ~~~~~~~~~~~~~~~~~ 6711 | { | ~ 6712 | unsigned char *p3 = (unsigned char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6713 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6714 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6715 | } | ~ 6716 | } | ~ 6717 | else if ((re_opcode_t) p1[3] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6718 | { | ~ 6719 | int idx; | ~~~~~~~~ 6720 | /* We win if the charset inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6721 | has no overlap with the one after the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6722 | for (idx = 0; | ~~~~~~~~~~~~~ 6723 | idx < (int) p2[1] && idx < (int) p1[4]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6724 | idx++) | ~~~~~~ 6725 | if ((p2[2 + idx] & p1[5 + idx]) != 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6726 | break; | ~~~~~~ 6727 | | 6728 | if (idx == p2[1] || idx == p1[4]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6729 | { | ~ 6730 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6731 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6732 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6733 | } | ~ 6734 | } | ~ 6735 | } | ~ 6736 | } | ~ 6737 | p -= 2; /* Point at relative address again. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6738 | if ((re_opcode_t) p[-1] != pop_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6739 | { | ~ 6740 | p[-1] = (unsigned char) jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6741 | DEBUG_MATCH_PRINT1 (" Match => jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6742 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6743 | } | ~ 6744 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6745 | | 6746 | | 6747 | /* The end of a simple repeat has a pop_failure_jump back to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6748 | its matching on_failure_jump, where the latter will push a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6749 | failure point. The pop_failure_jump takes off failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6750 | points put on by this pop_failure_jump's matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6751 | on_failure_jump; we got through the pattern to here from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6752 | matching on_failure_jump, so didn't fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6753 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6754 | { | ~ 6755 | /* We need to pass separate storage for the lowest and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6756 | highest registers, even though we don't care about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6757 | actual values. Otherwise, we will restore only one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6758 | register from the stack, since lowest will == highest in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6759 | `pop_failure_point'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6760 | int dummy_low_reg, dummy_high_reg; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6761 | unsigned char *pdummy; | ~~~~~~~~~~~~~~~~~~~~~~ 6762 | re_char *sdummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~ 6763 | | 6764 | USED (sdummy); /* Silence warning. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6765 | | 6766 | DEBUG_MATCH_PRINT1 ("EXECUTING pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6767:13: note: in expansion of macro 'POP_FAILURE_POINT' 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ^~~~~~~~~~~~~~~~~ regex.c:1901:48: note: format string is defined here 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~^ | | | unsigned int | %lx regex.c:1905:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ | | | long int 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6591 | break; | ~~~~~~ 6592 | | 6593 | | 6594 | /* A smart repeat ends with `maybe_pop_jump'. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6595 | We change it to either `pop_failure_jump' or `jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6596 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6597 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6598 | DEBUG_MATCH_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6599 | { | ~ 6600 | REGISTER const unsigned char *p2 = p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6601 | | 6602 | /* Compare the beginning of the repeat with what in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6603 | pattern follows its end. If we can establish that there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6604 | is nothing that they would both match, i.e., that we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6605 | would have to backtrack because of (as in, e.g., `a*a') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6606 | then we can change to pop_failure_jump, because we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6607 | never have to backtrack. | ~~~~~~~~~~~~~~~~~~~~~~~~ 6608 | | 6609 | This is not true in the case of alternatives: in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6610 | `(a|ab)*' we do need to backtrack to the `ab' alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6611 | (e.g., if the string was `ab'). But instead of trying to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6612 | detect that here, the alternative has put on a dummy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6613 | failure point which is what we will end up popping. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6614 | | 6615 | /* Skip over open/close-group commands. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6616 | If what follows this loop is a ...+ construct, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6617 | look at what begins its body, since we will have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6618 | match at least one of that. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6619 | while (1) | ~~~~~~~~~ 6620 | { | ~ 6621 | if (p2 + 2 < pend | ~~~~~~~~~~~~~~~~~ 6622 | && ((re_opcode_t) *p2 == stop_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6623 | || (re_opcode_t) *p2 == start_memory)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6624 | p2 += 3; | ~~~~~~~~ 6625 | else if (p2 + 6 < pend | ~~~~~~~~~~~~~~~~~~~~~~ 6626 | && (re_opcode_t) *p2 == dummy_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6627 | p2 += 6; | ~~~~~~~~ 6628 | else | ~~~~ 6629 | break; | ~~~~~~ 6630 | } | ~ 6631 | | 6632 | p1 = p + mcnt; | ~~~~~~~~~~~~~~ 6633 | /* p1[0] ... p1[2] are the `on_failure_jump' corresponding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6634 | to the `maybe_finalize_jump' of this case. Examine what | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6635 | follows. */ | ~~~~~~~~~~~~ 6636 | | 6637 | /* If we're at the end of the pattern, we can change. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6638 | if (p2 == pend) | ~~~~~~~~~~~~~~~ 6639 | { | ~ 6640 | /* Consider what happens when matching ":\(.*\)" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6641 | against ":/". I don't really understand this code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6642 | yet. */ | ~~~~~~~~ 6643 | ((unsigned char *)p)[-3] = (re_char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6644 | DEBUG_MATCH_PRINT1 | ~~~~~~~~~~~~~~~~~~ 6645 | (" End of pattern: change to `pop_failure_jump'.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6646 | } | ~ 6647 | | 6648 | else if ((re_opcode_t) *p2 == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6649 | || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6650 | { | ~ 6651 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6652 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6653 | | 6654 | if ((re_opcode_t) p1[3] == exactn && p1[5] != c) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6655 | { | ~ 6656 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6657 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6658 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6659 | c, p1[5]); | ~~~~~~~~~~ 6660 | } | ~ 6661 | | 6662 | else if ((re_opcode_t) p1[3] == charset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6663 | || (re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6664 | { | ~ 6665 | int not_p = (re_opcode_t) p1[3] == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6666 | | 6667 | if (c < (unsigned char) (p1[4] * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6668 | && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6669 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6670 | | 6671 | /* `not_p' is equal to 1 if c would match, which means | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6672 | that we can't change to pop_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6673 | if (!not_p) | ~~~~~~~~~~~ 6674 | { | ~ 6675 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6676 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6677 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6678 | } | ~ 6679 | } | ~ 6680 | } | ~ 6681 | else if ((re_opcode_t) *p2 == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6682 | { | ~ 6683 | #ifdef DEBUG | ~~~~~~~~~~~~ 6684 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6685 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6686 | #endif | ~~~~~~ 6687 | | 6688 | if ((re_opcode_t) p1[3] == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6689 | && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6690 | && (p2[2 + p1[5] / BYTEWIDTH] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6691 | & (1 << (p1[5] % BYTEWIDTH))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6692 | { | ~ 6693 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6694 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6695 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6696 | c, p1[5]); | ~~~~~~~~~~ 6697 | } | ~ 6698 | | 6699 | else if ((re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6700 | { | ~ 6701 | int idx; | ~~~~~~~~ 6702 | /* We win if the charset_not inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6703 | lists every character listed in the charset after. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6704 | for (idx = 0; idx < (int) p2[1]; idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6705 | if (! (p2[2 + idx] == 0 | ~~~~~~~~~~~~~~~~~~~~~~~ 6706 | || (idx < (int) p1[4] | ~~~~~~~~~~~~~~~~~~~~~ 6707 | && ((p2[2 + idx] & ~ p1[5 + idx]) == 0)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6708 | break; | ~~~~~~ 6709 | | 6710 | if (idx == p2[1]) | ~~~~~~~~~~~~~~~~~ 6711 | { | ~ 6712 | unsigned char *p3 = (unsigned char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6713 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6714 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6715 | } | ~ 6716 | } | ~ 6717 | else if ((re_opcode_t) p1[3] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6718 | { | ~ 6719 | int idx; | ~~~~~~~~ 6720 | /* We win if the charset inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6721 | has no overlap with the one after the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6722 | for (idx = 0; | ~~~~~~~~~~~~~ 6723 | idx < (int) p2[1] && idx < (int) p1[4]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6724 | idx++) | ~~~~~~ 6725 | if ((p2[2 + idx] & p1[5 + idx]) != 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6726 | break; | ~~~~~~ 6727 | | 6728 | if (idx == p2[1] || idx == p1[4]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6729 | { | ~ 6730 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6731 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6732 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6733 | } | ~ 6734 | } | ~ 6735 | } | ~ 6736 | } | ~ 6737 | p -= 2; /* Point at relative address again. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6738 | if ((re_opcode_t) p[-1] != pop_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6739 | { | ~ 6740 | p[-1] = (unsigned char) jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6741 | DEBUG_MATCH_PRINT1 (" Match => jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6742 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6743 | } | ~ 6744 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6745 | | 6746 | | 6747 | /* The end of a simple repeat has a pop_failure_jump back to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6748 | its matching on_failure_jump, where the latter will push a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6749 | failure point. The pop_failure_jump takes off failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6750 | points put on by this pop_failure_jump's matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6751 | on_failure_jump; we got through the pattern to here from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6752 | matching on_failure_jump, so didn't fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6753 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6754 | { | ~ 6755 | /* We need to pass separate storage for the lowest and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6756 | highest registers, even though we don't care about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6757 | actual values. Otherwise, we will restore only one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6758 | register from the stack, since lowest will == highest in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6759 | `pop_failure_point'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6760 | int dummy_low_reg, dummy_high_reg; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6761 | unsigned char *pdummy; | ~~~~~~~~~~~~~~~~~~~~~~ 6762 | re_char *sdummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~ 6763 | | 6764 | USED (sdummy); /* Silence warning. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6765 | | 6766 | DEBUG_MATCH_PRINT1 ("EXECUTING pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6767:13: note: in expansion of macro 'POP_FAILURE_POINT' 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ^~~~~~~~~~~~~~~~~ regex.c:1905:49: note: format string is defined here 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~^ | | | unsigned int | %lx regex.c:1920:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'Bytecount' {aka 'long int'} [-Wformat=] 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | Bytecount {aka long int} regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6767:13: note: in expansion of macro 'POP_FAILURE_POINT' 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ^~~~~~~~~~~~~~~~~ regex.c:1920:40: note: format string is defined here 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1922:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6767:13: note: in expansion of macro 'POP_FAILURE_POINT' 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ^~~~~~~~~~~~~~~~~ regex.c:1922:39: note: format string is defined here 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1924:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6767:13: note: in expansion of macro 'POP_FAILURE_POINT' 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ^~~~~~~~~~~~~~~~~ regex.c:1924:41: note: format string is defined here 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:6781:31: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 6781 | DEBUG_MATCH_PRINT2 ("(to 0x%zx).\n", (Bytecount) p); | ^~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ | | | long int regex.c:789:50: note: in definition of macro 'DEBUG_MATCH_PRINT2' 789 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2) | ^~ regex.c:6781:40: note: format string is defined here 6781 | DEBUG_MATCH_PRINT2 ("(to 0x%zx).\n", (Bytecount) p); | ~~^ | | | unsigned int | %lx regex.c:1731:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1732 | (Bytecount) (fail_stack).avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1731:56: note: format string is defined here 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ~~^ | | | int | %ld regex.c:1733:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1734 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1733:56: note: format string is defined here 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~^ | | | int | %ld regex.c:1737:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1737:45: note: format string is defined here 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ~~^ | | | int | %ld regex.c:1756:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1757 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1756:55: note: format string is defined here 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ~~^ | | | int | %ld regex.c:1758:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1758:45: note: format string is defined here 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ~~^ | | | int | %ld regex.c:1777:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~ 1778 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1777:39: note: format string is defined here 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1779:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~ 1780 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1779:37: note: format string is defined here 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1781:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~ 1782 | * (long *) (®_info[this_reg])); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1781:38: note: format string is defined here 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ~~^ | | | unsigned int | %lx regex.c:1814:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1815 | (Bytecount) pattern_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int 1816 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6591 | break; | ~~~~~~ 6592 | | 6593 | | 6594 | /* A smart repeat ends with `maybe_pop_jump'. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6595 | We change it to either `pop_failure_jump' or `jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6596 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6597 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6598 | DEBUG_MATCH_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6599 | { | ~ 6600 | REGISTER const unsigned char *p2 = p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6601 | | 6602 | /* Compare the beginning of the repeat with what in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6603 | pattern follows its end. If we can establish that there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6604 | is nothing that they would both match, i.e., that we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6605 | would have to backtrack because of (as in, e.g., `a*a') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6606 | then we can change to pop_failure_jump, because we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6607 | never have to backtrack. | ~~~~~~~~~~~~~~~~~~~~~~~~ 6608 | | 6609 | This is not true in the case of alternatives: in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6610 | `(a|ab)*' we do need to backtrack to the `ab' alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6611 | (e.g., if the string was `ab'). But instead of trying to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6612 | detect that here, the alternative has put on a dummy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6613 | failure point which is what we will end up popping. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6614 | | 6615 | /* Skip over open/close-group commands. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6616 | If what follows this loop is a ...+ construct, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6617 | look at what begins its body, since we will have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6618 | match at least one of that. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6619 | while (1) | ~~~~~~~~~ 6620 | { | ~ 6621 | if (p2 + 2 < pend | ~~~~~~~~~~~~~~~~~ 6622 | && ((re_opcode_t) *p2 == stop_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6623 | || (re_opcode_t) *p2 == start_memory)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6624 | p2 += 3; | ~~~~~~~~ 6625 | else if (p2 + 6 < pend | ~~~~~~~~~~~~~~~~~~~~~~ 6626 | && (re_opcode_t) *p2 == dummy_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6627 | p2 += 6; | ~~~~~~~~ 6628 | else | ~~~~ 6629 | break; | ~~~~~~ 6630 | } | ~ 6631 | | 6632 | p1 = p + mcnt; | ~~~~~~~~~~~~~~ 6633 | /* p1[0] ... p1[2] are the `on_failure_jump' corresponding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6634 | to the `maybe_finalize_jump' of this case. Examine what | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6635 | follows. */ | ~~~~~~~~~~~~ 6636 | | 6637 | /* If we're at the end of the pattern, we can change. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6638 | if (p2 == pend) | ~~~~~~~~~~~~~~~ 6639 | { | ~ 6640 | /* Consider what happens when matching ":\(.*\)" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6641 | against ":/". I don't really understand this code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6642 | yet. */ | ~~~~~~~~ 6643 | ((unsigned char *)p)[-3] = (re_char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6644 | DEBUG_MATCH_PRINT1 | ~~~~~~~~~~~~~~~~~~ 6645 | (" End of pattern: change to `pop_failure_jump'.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6646 | } | ~ 6647 | | 6648 | else if ((re_opcode_t) *p2 == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6649 | || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6650 | { | ~ 6651 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6652 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6653 | | 6654 | if ((re_opcode_t) p1[3] == exactn && p1[5] != c) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6655 | { | ~ 6656 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6657 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6658 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6659 | c, p1[5]); | ~~~~~~~~~~ 6660 | } | ~ 6661 | | 6662 | else if ((re_opcode_t) p1[3] == charset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6663 | || (re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6664 | { | ~ 6665 | int not_p = (re_opcode_t) p1[3] == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6666 | | 6667 | if (c < (unsigned char) (p1[4] * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6668 | && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6669 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6670 | | 6671 | /* `not_p' is equal to 1 if c would match, which means | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6672 | that we can't change to pop_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6673 | if (!not_p) | ~~~~~~~~~~~ 6674 | { | ~ 6675 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6676 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6677 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6678 | } | ~ 6679 | } | ~ 6680 | } | ~ 6681 | else if ((re_opcode_t) *p2 == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6682 | { | ~ 6683 | #ifdef DEBUG | ~~~~~~~~~~~~ 6684 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6685 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6686 | #endif | ~~~~~~ 6687 | | 6688 | if ((re_opcode_t) p1[3] == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6689 | && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6690 | && (p2[2 + p1[5] / BYTEWIDTH] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6691 | & (1 << (p1[5] % BYTEWIDTH))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6692 | { | ~ 6693 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6694 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6695 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6696 | c, p1[5]); | ~~~~~~~~~~ 6697 | } | ~ 6698 | | 6699 | else if ((re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6700 | { | ~ 6701 | int idx; | ~~~~~~~~ 6702 | /* We win if the charset_not inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6703 | lists every character listed in the charset after. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6704 | for (idx = 0; idx < (int) p2[1]; idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6705 | if (! (p2[2 + idx] == 0 | ~~~~~~~~~~~~~~~~~~~~~~~ 6706 | || (idx < (int) p1[4] | ~~~~~~~~~~~~~~~~~~~~~ 6707 | && ((p2[2 + idx] & ~ p1[5 + idx]) == 0)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6708 | break; | ~~~~~~ 6709 | | 6710 | if (idx == p2[1]) | ~~~~~~~~~~~~~~~~~ 6711 | { | ~ 6712 | unsigned char *p3 = (unsigned char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6713 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6714 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6715 | } | ~ 6716 | } | ~ 6717 | else if ((re_opcode_t) p1[3] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6718 | { | ~ 6719 | int idx; | ~~~~~~~~ 6720 | /* We win if the charset inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6721 | has no overlap with the one after the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6722 | for (idx = 0; | ~~~~~~~~~~~~~ 6723 | idx < (int) p2[1] && idx < (int) p1[4]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6724 | idx++) | ~~~~~~ 6725 | if ((p2[2 + idx] & p1[5 + idx]) != 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6726 | break; | ~~~~~~ 6727 | | 6728 | if (idx == p2[1] || idx == p1[4]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6729 | { | ~ 6730 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6731 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6732 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6733 | } | ~ 6734 | } | ~ 6735 | } | ~ 6736 | } | ~ 6737 | p -= 2; /* Point at relative address again. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6738 | if ((re_opcode_t) p[-1] != pop_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6739 | { | ~ 6740 | p[-1] = (unsigned char) jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6741 | DEBUG_MATCH_PRINT1 (" Match => jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6742 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6743 | } | ~ 6744 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6745 | | 6746 | | 6747 | /* The end of a simple repeat has a pop_failure_jump back to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6748 | its matching on_failure_jump, where the latter will push a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6749 | failure point. The pop_failure_jump takes off failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6750 | points put on by this pop_failure_jump's matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6751 | on_failure_jump; we got through the pattern to here from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6752 | matching on_failure_jump, so didn't fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6753 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6754 | { | ~ 6755 | /* We need to pass separate storage for the lowest and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6756 | highest registers, even though we don't care about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6757 | actual values. Otherwise, we will restore only one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6758 | register from the stack, since lowest will == highest in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6759 | `pop_failure_point'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6760 | int dummy_low_reg, dummy_high_reg; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6761 | unsigned char *pdummy; | ~~~~~~~~~~~~~~~~~~~~~~ 6762 | re_char *sdummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~ 6763 | | 6764 | USED (sdummy); /* Silence warning. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6765 | | 6766 | DEBUG_MATCH_PRINT1 ("EXECUTING pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6768 | dummy_low_reg, dummy_high_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6769 | reg_dummy, reg_dummy, reg_info_dummy); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6770 | USED (pdummy); | ~~~~~~~~~~~~~~ 6771 | } | ~ 6772 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6773 | | 6774 | | 6775 | /* Unconditionally jump (without popping any failure points). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6776 | case jump: | ~~~~~~~~~~ 6777 | unconditional_jump: | ~~~~~~~~~~~~~~~~~~~ 6778 | EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6779 | DEBUG_MATCH_PRINT2 ("EXECUTING jump %d ", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6780 | p += mcnt; /* Do the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6781 | DEBUG_MATCH_PRINT2 ("(to 0x%zx).\n", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6782 | break; | ~~~~~~ 6783 | | 6784 | | 6785 | /* We need this opcode so we can detect where alternatives end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6786 | in `group_match_null_string_p' et al. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6787 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 6788 | DEBUG_MATCH_PRINT1 ("EXECUTING jump_past_alt.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6789 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6790 | | 6791 | | 6792 | /* Normally, the on_failure_jump pushes a failure point, which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6793 | then gets popped at pop_failure_jump. We will end up at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6794 | pop_failure_jump, also, and with a pattern of, say, `a+', we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6795 | are skipping over the on_failure_jump, so we have to push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6796 | something meaningless for pop_failure_jump to pop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6797 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6798 | DEBUG_MATCH_PRINT1 ("EXECUTING dummy_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6799 | /* It doesn't matter what we push for the string here. What | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6800 | the code at `fail' tests is the value for the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1814:49: note: format string is defined here 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ~~^ | | | unsigned int | %lx regex.c:1817:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6591 | break; | ~~~~~~ 6592 | | 6593 | | 6594 | /* A smart repeat ends with `maybe_pop_jump'. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6595 | We change it to either `pop_failure_jump' or `jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6596 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6597 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6598 | DEBUG_MATCH_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6599 | { | ~ 6600 | REGISTER const unsigned char *p2 = p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6601 | | 6602 | /* Compare the beginning of the repeat with what in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6603 | pattern follows its end. If we can establish that there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6604 | is nothing that they would both match, i.e., that we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6605 | would have to backtrack because of (as in, e.g., `a*a') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6606 | then we can change to pop_failure_jump, because we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6607 | never have to backtrack. | ~~~~~~~~~~~~~~~~~~~~~~~~ 6608 | | 6609 | This is not true in the case of alternatives: in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6610 | `(a|ab)*' we do need to backtrack to the `ab' alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6611 | (e.g., if the string was `ab'). But instead of trying to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6612 | detect that here, the alternative has put on a dummy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6613 | failure point which is what we will end up popping. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6614 | | 6615 | /* Skip over open/close-group commands. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6616 | If what follows this loop is a ...+ construct, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6617 | look at what begins its body, since we will have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6618 | match at least one of that. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6619 | while (1) | ~~~~~~~~~ 6620 | { | ~ 6621 | if (p2 + 2 < pend | ~~~~~~~~~~~~~~~~~ 6622 | && ((re_opcode_t) *p2 == stop_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6623 | || (re_opcode_t) *p2 == start_memory)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6624 | p2 += 3; | ~~~~~~~~ 6625 | else if (p2 + 6 < pend | ~~~~~~~~~~~~~~~~~~~~~~ 6626 | && (re_opcode_t) *p2 == dummy_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6627 | p2 += 6; | ~~~~~~~~ 6628 | else | ~~~~ 6629 | break; | ~~~~~~ 6630 | } | ~ 6631 | | 6632 | p1 = p + mcnt; | ~~~~~~~~~~~~~~ 6633 | /* p1[0] ... p1[2] are the `on_failure_jump' corresponding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6634 | to the `maybe_finalize_jump' of this case. Examine what | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6635 | follows. */ | ~~~~~~~~~~~~ 6636 | | 6637 | /* If we're at the end of the pattern, we can change. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6638 | if (p2 == pend) | ~~~~~~~~~~~~~~~ 6639 | { | ~ 6640 | /* Consider what happens when matching ":\(.*\)" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6641 | against ":/". I don't really understand this code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6642 | yet. */ | ~~~~~~~~ 6643 | ((unsigned char *)p)[-3] = (re_char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6644 | DEBUG_MATCH_PRINT1 | ~~~~~~~~~~~~~~~~~~ 6645 | (" End of pattern: change to `pop_failure_jump'.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6646 | } | ~ 6647 | | 6648 | else if ((re_opcode_t) *p2 == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6649 | || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6650 | { | ~ 6651 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6652 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6653 | | 6654 | if ((re_opcode_t) p1[3] == exactn && p1[5] != c) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6655 | { | ~ 6656 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6657 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6658 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6659 | c, p1[5]); | ~~~~~~~~~~ 6660 | } | ~ 6661 | | 6662 | else if ((re_opcode_t) p1[3] == charset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6663 | || (re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6664 | { | ~ 6665 | int not_p = (re_opcode_t) p1[3] == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6666 | | 6667 | if (c < (unsigned char) (p1[4] * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6668 | && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6669 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6670 | | 6671 | /* `not_p' is equal to 1 if c would match, which means | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6672 | that we can't change to pop_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6673 | if (!not_p) | ~~~~~~~~~~~ 6674 | { | ~ 6675 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6676 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6677 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6678 | } | ~ 6679 | } | ~ 6680 | } | ~ 6681 | else if ((re_opcode_t) *p2 == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6682 | { | ~ 6683 | #ifdef DEBUG | ~~~~~~~~~~~~ 6684 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6685 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6686 | #endif | ~~~~~~ 6687 | | 6688 | if ((re_opcode_t) p1[3] == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6689 | && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6690 | && (p2[2 + p1[5] / BYTEWIDTH] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6691 | & (1 << (p1[5] % BYTEWIDTH))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6692 | { | ~ 6693 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6694 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6695 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6696 | c, p1[5]); | ~~~~~~~~~~ 6697 | } | ~ 6698 | | 6699 | else if ((re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6700 | { | ~ 6701 | int idx; | ~~~~~~~~ 6702 | /* We win if the charset_not inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6703 | lists every character listed in the charset after. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6704 | for (idx = 0; idx < (int) p2[1]; idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6705 | if (! (p2[2 + idx] == 0 | ~~~~~~~~~~~~~~~~~~~~~~~ 6706 | || (idx < (int) p1[4] | ~~~~~~~~~~~~~~~~~~~~~ 6707 | && ((p2[2 + idx] & ~ p1[5 + idx]) == 0)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6708 | break; | ~~~~~~ 6709 | | 6710 | if (idx == p2[1]) | ~~~~~~~~~~~~~~~~~ 6711 | { | ~ 6712 | unsigned char *p3 = (unsigned char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6713 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6714 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6715 | } | ~ 6716 | } | ~ 6717 | else if ((re_opcode_t) p1[3] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6718 | { | ~ 6719 | int idx; | ~~~~~~~~ 6720 | /* We win if the charset inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6721 | has no overlap with the one after the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6722 | for (idx = 0; | ~~~~~~~~~~~~~ 6723 | idx < (int) p2[1] && idx < (int) p1[4]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6724 | idx++) | ~~~~~~ 6725 | if ((p2[2 + idx] & p1[5 + idx]) != 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6726 | break; | ~~~~~~ 6727 | | 6728 | if (idx == p2[1] || idx == p1[4]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6729 | { | ~ 6730 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6731 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6732 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6733 | } | ~ 6734 | } | ~ 6735 | } | ~ 6736 | } | ~ 6737 | p -= 2; /* Point at relative address again. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6738 | if ((re_opcode_t) p[-1] != pop_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6739 | { | ~ 6740 | p[-1] = (unsigned char) jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6741 | DEBUG_MATCH_PRINT1 (" Match => jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6742 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6743 | } | ~ 6744 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6745 | | 6746 | | 6747 | /* The end of a simple repeat has a pop_failure_jump back to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6748 | its matching on_failure_jump, where the latter will push a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6749 | failure point. The pop_failure_jump takes off failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6750 | points put on by this pop_failure_jump's matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6751 | on_failure_jump; we got through the pattern to here from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6752 | matching on_failure_jump, so didn't fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6753 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6754 | { | ~ 6755 | /* We need to pass separate storage for the lowest and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6756 | highest registers, even though we don't care about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6757 | actual values. Otherwise, we will restore only one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6758 | register from the stack, since lowest will == highest in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6759 | `pop_failure_point'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6760 | int dummy_low_reg, dummy_high_reg; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6761 | unsigned char *pdummy; | ~~~~~~~~~~~~~~~~~~~~~~ 6762 | re_char *sdummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~ 6763 | | 6764 | USED (sdummy); /* Silence warning. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6765 | | 6766 | DEBUG_MATCH_PRINT1 ("EXECUTING pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6768 | dummy_low_reg, dummy_high_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6769 | reg_dummy, reg_dummy, reg_info_dummy); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6770 | USED (pdummy); | ~~~~~~~~~~~~~~ 6771 | } | ~ 6772 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6773 | | 6774 | | 6775 | /* Unconditionally jump (without popping any failure points). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6776 | case jump: | ~~~~~~~~~~ 6777 | unconditional_jump: | ~~~~~~~~~~~~~~~~~~~ 6778 | EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6779 | DEBUG_MATCH_PRINT2 ("EXECUTING jump %d ", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6780 | p += mcnt; /* Do the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6781 | DEBUG_MATCH_PRINT2 ("(to 0x%zx).\n", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6782 | break; | ~~~~~~ 6783 | | 6784 | | 6785 | /* We need this opcode so we can detect where alternatives end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6786 | in `group_match_null_string_p' et al. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6787 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 6788 | DEBUG_MATCH_PRINT1 ("EXECUTING jump_past_alt.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6789 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6790 | | 6791 | | 6792 | /* Normally, the on_failure_jump pushes a failure point, which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6793 | then gets popped at pop_failure_jump. We will end up at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6794 | pop_failure_jump, also, and with a pattern of, say, `a+', we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6795 | are skipping over the on_failure_jump, so we have to push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6796 | something meaningless for pop_failure_jump to pop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6797 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6798 | DEBUG_MATCH_PRINT1 ("EXECUTING dummy_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6799 | /* It doesn't matter what we push for the string here. What | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6800 | the code at `fail' tests is the value for the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6801:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1817:48: note: format string is defined here 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~^ | | | unsigned int | %lx regex.c:1731:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1732 | (Bytecount) (fail_stack).avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1731:56: note: format string is defined here 1731 | DEBUG_FAIL_PRINT2 (" Before push, next avail: %zd\n", \ | ~~^ | | | int | %ld regex.c:1733:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1734 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1733:56: note: format string is defined here 1733 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~^ | | | int | %ld regex.c:1737:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1737:45: note: format string is defined here 1737 | DEBUG_FAIL_PRINT2 (" available: %zd\n", \ | ~~^ | | | int | %ld regex.c:1756:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1757 | (Bytecount) (fail_stack).size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1756:55: note: format string is defined here 1756 | DEBUG_FAIL_PRINT2 ("\n Doubled stack; size now: %zd\n", \ | ~~^ | | | int | %ld regex.c:1758:23: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1758:45: note: format string is defined here 1758 | DEBUG_FAIL_PRINT2 (" slots available: %zd\n", \ | ~~^ | | | int | %ld regex.c:1777:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~ 1778 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1777:39: note: format string is defined here 1777 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1779:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~ 1780 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1779:37: note: format string is defined here 1779 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1781:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~ 1782 | * (long *) (®_info[this_reg])); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1781:38: note: format string is defined here 1781 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n ", \ | ~~^ | | | unsigned int | %lx regex.c:1814:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1815 | (Bytecount) pattern_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int 1816 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better --- strftime.o --- --- regex.o --- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | --- strftime.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include strftime.c --- regex.o --- 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6591 | break; | ~~~~~~ 6592 | | 6593 | | 6594 | /* A smart repeat ends with `maybe_pop_jump'. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6595 | We change it to either `pop_failure_jump' or `jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6596 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6597 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6598 | DEBUG_MATCH_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6599 | { | ~ 6600 | REGISTER const unsigned char *p2 = p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6601 | | 6602 | /* Compare the beginning of the repeat with what in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6603 | pattern follows its end. If we can establish that there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6604 | is nothing that they would both match, i.e., that we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6605 | would have to backtrack because of (as in, e.g., `a*a') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6606 | then we can change to pop_failure_jump, because we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6607 | never have to backtrack. | ~~~~~~~~~~~~~~~~~~~~~~~~ 6608 | | 6609 | This is not true in the case of alternatives: in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6610 | `(a|ab)*' we do need to backtrack to the `ab' alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6611 | (e.g., if the string was `ab'). But instead of trying to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6612 | detect that here, the alternative has put on a dummy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6613 | failure point which is what we will end up popping. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6614 | | 6615 | /* Skip over open/close-group commands. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6616 | If what follows this loop is a ...+ construct, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6617 | look at what begins its body, since we will have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6618 | match at least one of that. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6619 | while (1) | ~~~~~~~~~ 6620 | { | ~ 6621 | if (p2 + 2 < pend | ~~~~~~~~~~~~~~~~~ 6622 | && ((re_opcode_t) *p2 == stop_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6623 | || (re_opcode_t) *p2 == start_memory)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6624 | p2 += 3; | ~~~~~~~~ 6625 | else if (p2 + 6 < pend | ~~~~~~~~~~~~~~~~~~~~~~ 6626 | && (re_opcode_t) *p2 == dummy_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6627 | p2 += 6; | ~~~~~~~~ 6628 | else | ~~~~ 6629 | break; | ~~~~~~ 6630 | } | ~ 6631 | | 6632 | p1 = p + mcnt; | ~~~~~~~~~~~~~~ 6633 | /* p1[0] ... p1[2] are the `on_failure_jump' corresponding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6634 | to the `maybe_finalize_jump' of this case. Examine what | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6635 | follows. */ | ~~~~~~~~~~~~ 6636 | | 6637 | /* If we're at the end of the pattern, we can change. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6638 | if (p2 == pend) | ~~~~~~~~~~~~~~~ 6639 | { | ~ 6640 | /* Consider what happens when matching ":\(.*\)" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6641 | against ":/". I don't really understand this code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6642 | yet. */ | ~~~~~~~~ 6643 | ((unsigned char *)p)[-3] = (re_char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6644 | DEBUG_MATCH_PRINT1 | ~~~~~~~~~~~~~~~~~~ 6645 | (" End of pattern: change to `pop_failure_jump'.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6646 | } | ~ 6647 | | 6648 | else if ((re_opcode_t) *p2 == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6649 | || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6650 | { | ~ 6651 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6652 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6653 | | 6654 | if ((re_opcode_t) p1[3] == exactn && p1[5] != c) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6655 | { | ~ 6656 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6657 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6658 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6659 | c, p1[5]); | ~~~~~~~~~~ 6660 | } | ~ 6661 | | 6662 | else if ((re_opcode_t) p1[3] == charset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6663 | || (re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6664 | { | ~ 6665 | int not_p = (re_opcode_t) p1[3] == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6666 | | 6667 | if (c < (unsigned char) (p1[4] * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6668 | && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6669 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6670 | | 6671 | /* `not_p' is equal to 1 if c would match, which means | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6672 | that we can't change to pop_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6673 | if (!not_p) | ~~~~~~~~~~~ 6674 | { | ~ 6675 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6676 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6677 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6678 | } | ~ 6679 | } | ~ 6680 | } | ~ 6681 | else if ((re_opcode_t) *p2 == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6682 | { | ~ 6683 | #ifdef DEBUG | ~~~~~~~~~~~~ 6684 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6685 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6686 | #endif | ~~~~~~ 6687 | | 6688 | if ((re_opcode_t) p1[3] == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6689 | && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6690 | && (p2[2 + p1[5] / BYTEWIDTH] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6691 | & (1 << (p1[5] % BYTEWIDTH))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6692 | { | ~ 6693 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6694 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6695 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6696 | c, p1[5]); | ~~~~~~~~~~ 6697 | } | ~ 6698 | | 6699 | else if ((re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6700 | { | ~ 6701 | int idx; | ~~~~~~~~ 6702 | /* We win if the charset_not inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6703 | lists every character listed in the charset after. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6704 | for (idx = 0; idx < (int) p2[1]; idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6705 | if (! (p2[2 + idx] == 0 | ~~~~~~~~~~~~~~~~~~~~~~~ 6706 | || (idx < (int) p1[4] | ~~~~~~~~~~~~~~~~~~~~~ 6707 | && ((p2[2 + idx] & ~ p1[5 + idx]) == 0)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6708 | break; | ~~~~~~ 6709 | | 6710 | if (idx == p2[1]) | ~~~~~~~~~~~~~~~~~ 6711 | { | ~ 6712 | unsigned char *p3 = (unsigned char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6713 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6714 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6715 | } | ~ 6716 | } | ~ 6717 | else if ((re_opcode_t) p1[3] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6718 | { | ~ 6719 | int idx; | ~~~~~~~~ 6720 | /* We win if the charset inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6721 | has no overlap with the one after the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6722 | for (idx = 0; | ~~~~~~~~~~~~~ 6723 | idx < (int) p2[1] && idx < (int) p1[4]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6724 | idx++) | ~~~~~~ 6725 | if ((p2[2 + idx] & p1[5 + idx]) != 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6726 | break; | ~~~~~~ 6727 | | 6728 | if (idx == p2[1] || idx == p1[4]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6729 | { | ~ 6730 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6731 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6732 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6733 | } | ~ 6734 | } | ~ 6735 | } | ~ 6736 | } | ~ 6737 | p -= 2; /* Point at relative address again. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6738 | if ((re_opcode_t) p[-1] != pop_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6739 | { | ~ 6740 | p[-1] = (unsigned char) jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6741 | DEBUG_MATCH_PRINT1 (" Match => jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6742 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6743 | } | ~ 6744 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6745 | | 6746 | | 6747 | /* The end of a simple repeat has a pop_failure_jump back to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6748 | its matching on_failure_jump, where the latter will push a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6749 | failure point. The pop_failure_jump takes off failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6750 | points put on by this pop_failure_jump's matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6751 | on_failure_jump; we got through the pattern to here from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6752 | matching on_failure_jump, so didn't fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6753 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6754 | { | ~ 6755 | /* We need to pass separate storage for the lowest and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6756 | highest registers, even though we don't care about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6757 | actual values. Otherwise, we will restore only one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6758 | register from the stack, since lowest will == highest in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6759 | `pop_failure_point'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6760 | int dummy_low_reg, dummy_high_reg; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6761 | unsigned char *pdummy; | ~~~~~~~~~~~~~~~~~~~~~~ 6762 | re_char *sdummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~ 6763 | | 6764 | USED (sdummy); /* Silence warning. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6765 | | 6766 | DEBUG_MATCH_PRINT1 ("EXECUTING pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6768 | dummy_low_reg, dummy_high_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6769 | reg_dummy, reg_dummy, reg_info_dummy); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6770 | USED (pdummy); | ~~~~~~~~~~~~~~ 6771 | } | ~ 6772 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6773 | | 6774 | | 6775 | /* Unconditionally jump (without popping any failure points). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6776 | case jump: | ~~~~~~~~~~ 6777 | unconditional_jump: | ~~~~~~~~~~~~~~~~~~~ 6778 | EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6779 | DEBUG_MATCH_PRINT2 ("EXECUTING jump %d ", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6780 | p += mcnt; /* Do the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6781 | DEBUG_MATCH_PRINT2 ("(to 0x%zx).\n", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6782 | break; | ~~~~~~ 6783 | | 6784 | | 6785 | /* We need this opcode so we can detect where alternatives end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6786 | in `group_match_null_string_p' et al. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6787 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 6788 | DEBUG_MATCH_PRINT1 ("EXECUTING jump_past_alt.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6789 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6790 | | 6791 | | 6792 | /* Normally, the on_failure_jump pushes a failure point, which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6793 | then gets popped at pop_failure_jump. We will end up at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6794 | pop_failure_jump, also, and with a pattern of, say, `a+', we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6795 | are skipping over the on_failure_jump, so we have to push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6796 | something meaningless for pop_failure_jump to pop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6797 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6798 | DEBUG_MATCH_PRINT1 ("EXECUTING dummy_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6799 | /* It doesn't matter what we push for the string here. What | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6800 | the code at `fail' tests is the value for the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6802 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6803 | | 6804 | | 6805 | /* At the end of an alternative, we need to push a dummy failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6806 | point in case we are followed by a `pop_failure_jump', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6807 | we don't want the failure point for the alternative to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6808 | popped. For example, matching `(a|ab)*' against `aab' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6809 | requires that we match the `ab' alternative. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6810 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6811 | DEBUG_MATCH_PRINT1 ("EXECUTING push_dummy_failure.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6812 | /* See comments just above at `dummy_failure_jump' about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6813 | two zeroes. */ | ~~~~~~~~~~~~~~~ 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1814:49: note: format string is defined here 1814 | DEBUG_FAIL_PRINT2 (" Pushing pattern 0x%zx: \n", \ | ~~^ | | | unsigned int | %lx regex.c:1817:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 1818 | (Bytecount) string_place); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int 1819 | DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1820 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1821 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1822 | DEBUG_FAIL_PRINT2 (" Pushing failure id: %u\n", failure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1823 | } \ | ~~~~~~~~~~~ 1824 | } while (0) | ~~~~~~~~~~~ 1825 | | 1826 | /* This is the number of items that are pushed and popped on the stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1827 | for each register. */ | ~~~~~~~~~~~~~~~~~~~~~~ 1828 | #define NUM_REG_ITEMS 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 1829 | | 1830 | /* Individual items aside from the registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1831 | #ifdef DEBUG | ~~~~~~~~~~~~ 1832 | #define NUM_NONREG_ITEMS 5 /* Includes failure point id. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1833 | #else | ~~~~~ 1834 | #define NUM_NONREG_ITEMS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1835 | #endif | ~~~~~~ 1836 | | 1837 | /* We push at most this many items on the stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1838 | /* We used to use (num_regs - 1), which is the number of registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1839 | this regexp will save; but that was changed to 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1840 | to avoid stack overflow for a regexp with lots of parens. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1841 | #define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1842 | | 1843 | /* We actually push this many items. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1844 | #define NUM_FAILURE_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1845 | ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1846 | + NUM_NONREG_ITEMS) | ~~~~~~~~~~~~~~~~~~~ 1847 | | 1848 | /* How many items can still be added to the stack without overflowing it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1849 | #define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1850 | | 1851 | | 1852 | /* Pops what PUSH_FAIL_STACK pushes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1853 | | 1854 | We restore into the following parameters, all of which should be lvalues: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1855 | STR -- the saved data position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1856 | PAT -- the saved pattern position. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1857 | LOW_REG, HIGH_REG -- the highest and lowest active registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1858 | REGSTART, REGEND -- arrays of string positions. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1859 | REG_INFO -- array of information about each subexpression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1860 | | 1861 | Also assumes the variables `fail_stack' and (if debugging), `bufp', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1862 | `pend', `string1', `size1', `string2', and `size2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1863 | | 1864 | #define POP_FAILURE_POINT(str, pat, low_reg, high_reg, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1865 | regstart, regend, reg_info) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1866 | do { \ | ~~~~~~~~~~~~~~ 1867 | DEBUG_STATEMENT (int ffailure_id;) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1868 | int this_reg; \ | ~~~~~~~~~~~~~~~~~~~~~~ 1869 | const unsigned char *string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1870 | \ | ~ 1871 | /* Remove failure points and point to how many regs pushed. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1872 | assert (fail_stack.avail >= NUM_NONREG_ITEMS); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1873 | \ | ~ 1874 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1875 | { \ | ~~~~~~~~~~~ 1876 | DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1881 | } \ | ~~~~~~~~~~~ 1882 | \ | ~ 1883 | DEBUG_STATEMENT (ffailure_id = POP_FAILURE_INT()); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1884 | \ | ~ 1885 | /* If the saved string location is NULL, it came from an \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1886 | on_failure_keep_string_jump opcode, and we want to throw away the \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1887 | saved NULL, thus retaining our current position in the string. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1888 | string_temp = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1889 | if (string_temp != NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1890 | str = string_temp; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 1891 | \ | ~ 1892 | pat = (unsigned char *) POP_FAILURE_POINTER (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1893 | \ | ~ 1894 | /* Restore register info. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1895 | high_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1896 | low_reg = POP_FAILURE_INT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1897 | \ | ~ 1898 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1899 | { \ | ~~~~~~~~~~~ 1900 | DEBUG_FAIL_PRINT2 (" Popping failure id: %d\n", ffailure_id); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ --- symbols.o --- --- regex.o --- | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | --- symbols.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include symbols.c --- regex.o --- 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6591 | break; | ~~~~~~ 6592 | | 6593 | | 6594 | /* A smart repeat ends with `maybe_pop_jump'. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6595 | We change it to either `pop_failure_jump' or `jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6596 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6597 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6598 | DEBUG_MATCH_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6599 | { | ~ 6600 | REGISTER const unsigned char *p2 = p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6601 | | 6602 | /* Compare the beginning of the repeat with what in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6603 | pattern follows its end. If we can establish that there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6604 | is nothing that they would both match, i.e., that we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6605 | would have to backtrack because of (as in, e.g., `a*a') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6606 | then we can change to pop_failure_jump, because we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6607 | never have to backtrack. | ~~~~~~~~~~~~~~~~~~~~~~~~ 6608 | | 6609 | This is not true in the case of alternatives: in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6610 | `(a|ab)*' we do need to backtrack to the `ab' alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6611 | (e.g., if the string was `ab'). But instead of trying to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6612 | detect that here, the alternative has put on a dummy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6613 | failure point which is what we will end up popping. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6614 | | 6615 | /* Skip over open/close-group commands. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6616 | If what follows this loop is a ...+ construct, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6617 | look at what begins its body, since we will have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6618 | match at least one of that. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6619 | while (1) | ~~~~~~~~~ 6620 | { | ~ 6621 | if (p2 + 2 < pend | ~~~~~~~~~~~~~~~~~ 6622 | && ((re_opcode_t) *p2 == stop_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6623 | || (re_opcode_t) *p2 == start_memory)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6624 | p2 += 3; | ~~~~~~~~ 6625 | else if (p2 + 6 < pend | ~~~~~~~~~~~~~~~~~~~~~~ 6626 | && (re_opcode_t) *p2 == dummy_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6627 | p2 += 6; | ~~~~~~~~ 6628 | else | ~~~~ 6629 | break; | ~~~~~~ 6630 | } | ~ 6631 | | 6632 | p1 = p + mcnt; | ~~~~~~~~~~~~~~ 6633 | /* p1[0] ... p1[2] are the `on_failure_jump' corresponding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6634 | to the `maybe_finalize_jump' of this case. Examine what | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6635 | follows. */ | ~~~~~~~~~~~~ 6636 | | 6637 | /* If we're at the end of the pattern, we can change. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6638 | if (p2 == pend) | ~~~~~~~~~~~~~~~ 6639 | { | ~ 6640 | /* Consider what happens when matching ":\(.*\)" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6641 | against ":/". I don't really understand this code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6642 | yet. */ | ~~~~~~~~ 6643 | ((unsigned char *)p)[-3] = (re_char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6644 | DEBUG_MATCH_PRINT1 | ~~~~~~~~~~~~~~~~~~ 6645 | (" End of pattern: change to `pop_failure_jump'.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6646 | } | ~ 6647 | | 6648 | else if ((re_opcode_t) *p2 == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6649 | || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6650 | { | ~ 6651 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6652 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6653 | | 6654 | if ((re_opcode_t) p1[3] == exactn && p1[5] != c) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6655 | { | ~ 6656 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6657 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6658 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6659 | c, p1[5]); | ~~~~~~~~~~ 6660 | } | ~ 6661 | | 6662 | else if ((re_opcode_t) p1[3] == charset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6663 | || (re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6664 | { | ~ 6665 | int not_p = (re_opcode_t) p1[3] == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6666 | | 6667 | if (c < (unsigned char) (p1[4] * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6668 | && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6669 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6670 | | 6671 | /* `not_p' is equal to 1 if c would match, which means | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6672 | that we can't change to pop_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6673 | if (!not_p) | ~~~~~~~~~~~ 6674 | { | ~ 6675 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6676 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6677 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6678 | } | ~ 6679 | } | ~ 6680 | } | ~ 6681 | else if ((re_opcode_t) *p2 == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6682 | { | ~ 6683 | #ifdef DEBUG | ~~~~~~~~~~~~ 6684 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6685 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6686 | #endif | ~~~~~~ 6687 | | 6688 | if ((re_opcode_t) p1[3] == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6689 | && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6690 | && (p2[2 + p1[5] / BYTEWIDTH] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6691 | & (1 << (p1[5] % BYTEWIDTH))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6692 | { | ~ 6693 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6694 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6695 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6696 | c, p1[5]); | ~~~~~~~~~~ 6697 | } | ~ 6698 | | 6699 | else if ((re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6700 | { | ~ 6701 | int idx; | ~~~~~~~~ 6702 | /* We win if the charset_not inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6703 | lists every character listed in the charset after. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6704 | for (idx = 0; idx < (int) p2[1]; idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6705 | if (! (p2[2 + idx] == 0 | ~~~~~~~~~~~~~~~~~~~~~~~ 6706 | || (idx < (int) p1[4] | ~~~~~~~~~~~~~~~~~~~~~ 6707 | && ((p2[2 + idx] & ~ p1[5 + idx]) == 0)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6708 | break; | ~~~~~~ 6709 | | 6710 | if (idx == p2[1]) | ~~~~~~~~~~~~~~~~~ 6711 | { | ~ 6712 | unsigned char *p3 = (unsigned char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6713 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6714 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6715 | } | ~ 6716 | } | ~ 6717 | else if ((re_opcode_t) p1[3] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6718 | { | ~ 6719 | int idx; | ~~~~~~~~ 6720 | /* We win if the charset inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6721 | has no overlap with the one after the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6722 | for (idx = 0; | ~~~~~~~~~~~~~ 6723 | idx < (int) p2[1] && idx < (int) p1[4]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6724 | idx++) | ~~~~~~ 6725 | if ((p2[2 + idx] & p1[5 + idx]) != 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6726 | break; | ~~~~~~ 6727 | | 6728 | if (idx == p2[1] || idx == p1[4]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6729 | { | ~ 6730 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6731 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6732 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6733 | } | ~ 6734 | } | ~ 6735 | } | ~ 6736 | } | ~ 6737 | p -= 2; /* Point at relative address again. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6738 | if ((re_opcode_t) p[-1] != pop_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6739 | { | ~ 6740 | p[-1] = (unsigned char) jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6741 | DEBUG_MATCH_PRINT1 (" Match => jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6742 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6743 | } | ~ 6744 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6745 | | 6746 | | 6747 | /* The end of a simple repeat has a pop_failure_jump back to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6748 | its matching on_failure_jump, where the latter will push a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6749 | failure point. The pop_failure_jump takes off failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6750 | points put on by this pop_failure_jump's matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6751 | on_failure_jump; we got through the pattern to here from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6752 | matching on_failure_jump, so didn't fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6753 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6754 | { | ~ 6755 | /* We need to pass separate storage for the lowest and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6756 | highest registers, even though we don't care about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6757 | actual values. Otherwise, we will restore only one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6758 | register from the stack, since lowest will == highest in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6759 | `pop_failure_point'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6760 | int dummy_low_reg, dummy_high_reg; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6761 | unsigned char *pdummy; | ~~~~~~~~~~~~~~~~~~~~~~ 6762 | re_char *sdummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~ 6763 | | 6764 | USED (sdummy); /* Silence warning. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6765 | | 6766 | DEBUG_MATCH_PRINT1 ("EXECUTING pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6768 | dummy_low_reg, dummy_high_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6769 | reg_dummy, reg_dummy, reg_info_dummy); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6770 | USED (pdummy); | ~~~~~~~~~~~~~~ 6771 | } | ~ 6772 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6773 | | 6774 | | 6775 | /* Unconditionally jump (without popping any failure points). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6776 | case jump: | ~~~~~~~~~~ 6777 | unconditional_jump: | ~~~~~~~~~~~~~~~~~~~ 6778 | EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6779 | DEBUG_MATCH_PRINT2 ("EXECUTING jump %d ", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6780 | p += mcnt; /* Do the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6781 | DEBUG_MATCH_PRINT2 ("(to 0x%zx).\n", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6782 | break; | ~~~~~~ 6783 | | 6784 | | 6785 | /* We need this opcode so we can detect where alternatives end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6786 | in `group_match_null_string_p' et al. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6787 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 6788 | DEBUG_MATCH_PRINT1 ("EXECUTING jump_past_alt.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6789 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6790 | | 6791 | | 6792 | /* Normally, the on_failure_jump pushes a failure point, which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6793 | then gets popped at pop_failure_jump. We will end up at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6794 | pop_failure_jump, also, and with a pattern of, say, `a+', we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6795 | are skipping over the on_failure_jump, so we have to push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6796 | something meaningless for pop_failure_jump to pop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6797 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6798 | DEBUG_MATCH_PRINT1 ("EXECUTING dummy_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6799 | /* It doesn't matter what we push for the string here. What | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6800 | the code at `fail' tests is the value for the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6802 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6803 | | 6804 | | 6805 | /* At the end of an alternative, we need to push a dummy failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6806 | point in case we are followed by a `pop_failure_jump', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6807 | we don't want the failure point for the alternative to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6808 | popped. For example, matching `(a|ab)*' against `aab' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6809 | requires that we match the `ab' alternative. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6810 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6811 | DEBUG_MATCH_PRINT1 ("EXECUTING push_dummy_failure.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6812 | /* See comments just above at `dummy_failure_jump' about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6813 | two zeroes. */ | ~~~~~~~~~~~~~~~ 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:6814:11: note: in expansion of macro 'PUSH_FAILURE_POINT' 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ^~~~~~~~~~~~~~~~~~ regex.c:1817:48: note: format string is defined here 1817 | DEBUG_FAIL_PRINT2 (" Pushing string 0x%zx: `", \ | ~~^ | | | unsigned int | %lx regex.c:6828:36: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 6828 | DEBUG_MATCH_PRINT3 (" Setting 0x%zx to %d.\n", (Bytecount) p, | ^~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ | | | long int regex.c:791:50: note: in definition of macro 'DEBUG_MATCH_PRINT3' 791 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2, x3) | ^~ regex.c:6828:51: note: format string is defined here 6828 | DEBUG_MATCH_PRINT3 (" Setting 0x%zx to %d.\n", (Bytecount) p, | ~~^ | | | unsigned int | %lx regex.c:6834:35: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 6834 | DEBUG_MATCH_PRINT2 (" Setting two bytes from 0x%zx to no_op.\n", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6835 | (Bytecount) (p+2)); | ~~~~~~~~~~~~~~~~~ | | | long int regex.c:789:50: note: in definition of macro 'DEBUG_MATCH_PRINT2' 789 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2) | ^~ regex.c:6834:65: note: format string is defined here 6834 | DEBUG_MATCH_PRINT2 (" Setting two bytes from 0x%zx to no_op.\n", | ~~^ | | | unsigned int | %lx regex.c:6868:33: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 6868 | DEBUG_MATCH_PRINT3 (" Setting 0x%zx to %d.\n", (Bytecount) p2, | ^~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ | | | long int regex.c:791:50: note: in definition of macro 'DEBUG_MATCH_PRINT3' 791 | if (debug_regexps & RE_DEBUG_MATCHING) printf (x1, x2, x3) | ^~ regex.c:6868:48: note: format string is defined here 6868 | DEBUG_MATCH_PRINT3 (" Setting 0x%zx to %d.\n", (Bytecount) p2, | ~~^ | | | unsigned int | %lx regex.c:1877:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1878 | (Bytecount) fail_stack.avail); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:7173:11: note: in expansion of macro 'POP_FAILURE_POINT' 7173 | POP_FAILURE_POINT (d, p, | ^~~~~~~~~~~~~~~~~ regex.c:1877:55: note: format string is defined here 1877 | DEBUG_FAIL_PRINT2 (" Before pop, next avail: %zd\n", \ | ~~^ | | | int | %ld regex.c:1879:26: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'long int' [-Wformat=] 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1880 | (Bytecount) fail_stack.size); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:7173:11: note: in expansion of macro 'POP_FAILURE_POINT' 7173 | POP_FAILURE_POINT (d, p, | ^~~~~~~~~~~~~~~~~ regex.c:1879:55: note: format string is defined here 1879 | DEBUG_FAIL_PRINT2 (" size: %zd\n", \ | ~~^ | | | int | %ld regex.c:1901:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ | | | long int 1902 | DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1903 | string2, size2); \ | ~~~~~~~~~~~~~~~~~~~~ 1904 | DEBUG_FAIL_PRINT1 ("'\n"); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6591 | break; | ~~~~~~ 6592 | | 6593 | | 6594 | /* A smart repeat ends with `maybe_pop_jump'. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6595 | We change it to either `pop_failure_jump' or `jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6596 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6597 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6598 | DEBUG_MATCH_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6599 | { | ~ 6600 | REGISTER const unsigned char *p2 = p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6601 | | 6602 | /* Compare the beginning of the repeat with what in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6603 | pattern follows its end. If we can establish that there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6604 | is nothing that they would both match, i.e., that we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6605 | would have to backtrack because of (as in, e.g., `a*a') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6606 | then we can change to pop_failure_jump, because we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6607 | never have to backtrack. | ~~~~~~~~~~~~~~~~~~~~~~~~ 6608 | | 6609 | This is not true in the case of alternatives: in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6610 | `(a|ab)*' we do need to backtrack to the `ab' alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6611 | (e.g., if the string was `ab'). But instead of trying to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6612 | detect that here, the alternative has put on a dummy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6613 | failure point which is what we will end up popping. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6614 | | 6615 | /* Skip over open/close-group commands. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6616 | If what follows this loop is a ...+ construct, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6617 | look at what begins its body, since we will have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6618 | match at least one of that. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6619 | while (1) | ~~~~~~~~~ 6620 | { | ~ 6621 | if (p2 + 2 < pend | ~~~~~~~~~~~~~~~~~ 6622 | && ((re_opcode_t) *p2 == stop_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6623 | || (re_opcode_t) *p2 == start_memory)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6624 | p2 += 3; | ~~~~~~~~ 6625 | else if (p2 + 6 < pend | ~~~~~~~~~~~~~~~~~~~~~~ 6626 | && (re_opcode_t) *p2 == dummy_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6627 | p2 += 6; | ~~~~~~~~ 6628 | else | ~~~~ 6629 | break; | ~~~~~~ 6630 | } | ~ 6631 | | 6632 | p1 = p + mcnt; | ~~~~~~~~~~~~~~ 6633 | /* p1[0] ... p1[2] are the `on_failure_jump' corresponding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6634 | to the `maybe_finalize_jump' of this case. Examine what | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6635 | follows. */ | ~~~~~~~~~~~~ 6636 | | 6637 | /* If we're at the end of the pattern, we can change. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6638 | if (p2 == pend) | ~~~~~~~~~~~~~~~ 6639 | { | ~ 6640 | /* Consider what happens when matching ":\(.*\)" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6641 | against ":/". I don't really understand this code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6642 | yet. */ | ~~~~~~~~ 6643 | ((unsigned char *)p)[-3] = (re_char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6644 | DEBUG_MATCH_PRINT1 | ~~~~~~~~~~~~~~~~~~ 6645 | (" End of pattern: change to `pop_failure_jump'.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6646 | } | ~ 6647 | | 6648 | else if ((re_opcode_t) *p2 == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6649 | || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6650 | { | ~ 6651 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6652 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6653 | | 6654 | if ((re_opcode_t) p1[3] == exactn && p1[5] != c) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6655 | { | ~ 6656 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6657 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6658 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6659 | c, p1[5]); | ~~~~~~~~~~ 6660 | } | ~ 6661 | | 6662 | else if ((re_opcode_t) p1[3] == charset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6663 | || (re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6664 | { | ~ 6665 | int not_p = (re_opcode_t) p1[3] == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6666 | | 6667 | if (c < (unsigned char) (p1[4] * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6668 | && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6669 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6670 | | 6671 | /* `not_p' is equal to 1 if c would match, which means | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6672 | that we can't change to pop_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6673 | if (!not_p) | ~~~~~~~~~~~ 6674 | { | ~ 6675 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6676 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6677 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6678 | } | ~ 6679 | } | ~ 6680 | } | ~ 6681 | else if ((re_opcode_t) *p2 == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6682 | { | ~ 6683 | #ifdef DEBUG | ~~~~~~~~~~~~ 6684 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6685 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6686 | #endif | ~~~~~~ 6687 | | 6688 | if ((re_opcode_t) p1[3] == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6689 | && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6690 | && (p2[2 + p1[5] / BYTEWIDTH] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6691 | & (1 << (p1[5] % BYTEWIDTH))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6692 | { | ~ 6693 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6694 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6695 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6696 | c, p1[5]); | ~~~~~~~~~~ 6697 | } | ~ 6698 | | 6699 | else if ((re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6700 | { | ~ 6701 | int idx; | ~~~~~~~~ 6702 | /* We win if the charset_not inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6703 | lists every character listed in the charset after. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6704 | for (idx = 0; idx < (int) p2[1]; idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6705 | if (! (p2[2 + idx] == 0 | ~~~~~~~~~~~~~~~~~~~~~~~ 6706 | || (idx < (int) p1[4] | ~~~~~~~~~~~~~~~~~~~~~ 6707 | && ((p2[2 + idx] & ~ p1[5 + idx]) == 0)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6708 | break; | ~~~~~~ 6709 | | 6710 | if (idx == p2[1]) | ~~~~~~~~~~~~~~~~~ 6711 | { | ~ 6712 | unsigned char *p3 = (unsigned char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6713 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6714 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6715 | } | ~ 6716 | } | ~ 6717 | else if ((re_opcode_t) p1[3] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6718 | { | ~ 6719 | int idx; | ~~~~~~~~ 6720 | /* We win if the charset inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6721 | has no overlap with the one after the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6722 | for (idx = 0; | ~~~~~~~~~~~~~ 6723 | idx < (int) p2[1] && idx < (int) p1[4]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6724 | idx++) | ~~~~~~ 6725 | if ((p2[2 + idx] & p1[5 + idx]) != 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6726 | break; | ~~~~~~ 6727 | | 6728 | if (idx == p2[1] || idx == p1[4]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6729 | { | ~ 6730 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6731 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6732 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6733 | } | ~ 6734 | } | ~ 6735 | } | ~ 6736 | } | ~ 6737 | p -= 2; /* Point at relative address again. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6738 | if ((re_opcode_t) p[-1] != pop_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6739 | { | ~ 6740 | p[-1] = (unsigned char) jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6741 | DEBUG_MATCH_PRINT1 (" Match => jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6742 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6743 | } | ~ 6744 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6745 | | 6746 | | 6747 | /* The end of a simple repeat has a pop_failure_jump back to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6748 | its matching on_failure_jump, where the latter will push a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6749 | failure point. The pop_failure_jump takes off failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6750 | points put on by this pop_failure_jump's matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6751 | on_failure_jump; we got through the pattern to here from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6752 | matching on_failure_jump, so didn't fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6753 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6754 | { | ~ 6755 | /* We need to pass separate storage for the lowest and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6756 | highest registers, even though we don't care about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6757 | actual values. Otherwise, we will restore only one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6758 | register from the stack, since lowest will == highest in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6759 | `pop_failure_point'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6760 | int dummy_low_reg, dummy_high_reg; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6761 | unsigned char *pdummy; | ~~~~~~~~~~~~~~~~~~~~~~ 6762 | re_char *sdummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~ 6763 | | 6764 | USED (sdummy); /* Silence warning. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6765 | | 6766 | DEBUG_MATCH_PRINT1 ("EXECUTING pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6768 | dummy_low_reg, dummy_high_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6769 | reg_dummy, reg_dummy, reg_info_dummy); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6770 | USED (pdummy); | ~~~~~~~~~~~~~~ 6771 | } | ~ 6772 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6773 | | 6774 | | 6775 | /* Unconditionally jump (without popping any failure points). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6776 | case jump: | ~~~~~~~~~~ 6777 | unconditional_jump: | ~~~~~~~~~~~~~~~~~~~ 6778 | EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6779 | DEBUG_MATCH_PRINT2 ("EXECUTING jump %d ", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6780 | p += mcnt; /* Do the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6781 | DEBUG_MATCH_PRINT2 ("(to 0x%zx).\n", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6782 | break; | ~~~~~~ 6783 | | 6784 | | 6785 | /* We need this opcode so we can detect where alternatives end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6786 | in `group_match_null_string_p' et al. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6787 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 6788 | DEBUG_MATCH_PRINT1 ("EXECUTING jump_past_alt.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6789 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6790 | | 6791 | | 6792 | /* Normally, the on_failure_jump pushes a failure point, which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6793 | then gets popped at pop_failure_jump. We will end up at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6794 | pop_failure_jump, also, and with a pattern of, say, `a+', we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6795 | are skipping over the on_failure_jump, so we have to push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6796 | something meaningless for pop_failure_jump to pop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6797 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6798 | DEBUG_MATCH_PRINT1 ("EXECUTING dummy_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6799 | /* It doesn't matter what we push for the string here. What | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6800 | the code at `fail' tests is the value for the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6802 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6803 | | 6804 | | 6805 | /* At the end of an alternative, we need to push a dummy failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6806 | point in case we are followed by a `pop_failure_jump', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6807 | we don't want the failure point for the alternative to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6808 | popped. For example, matching `(a|ab)*' against `aab' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6809 | requires that we match the `ab' alternative. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6810 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6811 | DEBUG_MATCH_PRINT1 ("EXECUTING push_dummy_failure.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6812 | /* See comments just above at `dummy_failure_jump' about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6813 | two zeroes. */ | ~~~~~~~~~~~~~~~ 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6815 | break; | ~~~~~~ 6816 | | 6817 | /* Have to succeed matching what follows at least n times. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6818 | After that, handle like `on_failure_jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6819 | case succeed_n: | ~~~~~~~~~~~~~~~ 6820 | EXTRACT_NONNEGATIVE (mcnt, p + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6821 | DEBUG_MATCH_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6822 | | 6823 | /* Originally, this is how many times we HAVE to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6824 | if (mcnt) | ~~~~~~~~~ 6825 | { | ~ 6826 | mcnt--; | ~~~~~~~ 6827 | p += 2; | ~~~~~~~ 6828 | DEBUG_MATCH_PRINT3 (" Setting 0x%zx to %d.\n", (Bytecount) p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6829 | mcnt); | ~~~~~~ 6830 | STORE_MATCH_NUMBER_AND_INCR (p, mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6831 | } | ~ 6832 | else | ~~~~ 6833 | { | ~ 6834 | DEBUG_MATCH_PRINT2 (" Setting two bytes from 0x%zx to no_op.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6835 | (Bytecount) (p+2)); | ~~~~~~~~~~~~~~~~~~~ 6836 | STORE_MATCH_NUMBER (p + 2, no_op); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6837 | goto on_failure; | ~~~~~~~~~~~~~~~~ 6838 | } | ~ 6839 | break; | ~~~~~~ 6840 | | 6841 | case jump_n: | ~~~~~~~~~~~~ 6842 | EXTRACT_NONNEGATIVE (mcnt, p + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6843 | DEBUG_MATCH_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6844 | | 6845 | /* Originally, this is how many times we CAN jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6846 | if (mcnt) | ~~~~~~~~~ 6847 | { | ~ 6848 | mcnt--; | ~~~~~~~ 6849 | STORE_MATCH_NUMBER (p + 2, mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6850 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6851 | } | ~ 6852 | /* If don't have to jump any more, skip over the rest of command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6853 | else | ~~~~ 6854 | p += 4; | ~~~~~~~ 6855 | break; | ~~~~~~ 6856 | | 6857 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 6858 | { | ~ 6859 | unsigned char *p2; /* Location of the counter. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6860 | DEBUG_MATCH_PRINT1 ("EXECUTING set_number_at.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6861 | | 6862 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6863 | /* Discard 'const', making re_match_2_internal() | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6864 | non-reentrant. */ | ~~~~~~~~~~~~~~~~~~ 6865 | p2 = (unsigned char *) p + mcnt; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6866 | EXTRACT_NONNEGATIVE_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6867 | | 6868 | DEBUG_MATCH_PRINT3 (" Setting 0x%zx to %d.\n", (Bytecount) p2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6869 | mcnt); | ~~~~~~ 6870 | STORE_MATCH_NUMBER (p2, mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6871 | break; | ~~~~~~ 6872 | } | ~ 6873 | | 6874 | case wordbound: | ~~~~~~~~~~~~~~~ 6875 | DEBUG_MATCH_PRINT1 ("EXECUTING wordbound.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6876 | should_succeed = 1; | ~~~~~~~~~~~~~~~~~~~ 6877 | matchwordbound: | ~~~~~~~~~~~~~~~ 6878 | { | ~ 6879 | /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~ 6880 | /* Straightforward and (I hope) correct implementation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6881 | /* emch1 is the character before d, syn1 is the syntax of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6882 | emch1, emch2 is the character at d, and syn2 is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6883 | syntax of emch2. */ | ~~~~~~~~~~~~~~~~~~~ 6884 | Ichar emch1, emch2; | ~~~~~~~~~~~~~~~~~~~ 6885 | int syn1 = 0, | ~~~~~~~~~~~~~ 6886 | syn2 = 0; | ~~~~~~~~~ 6887 | re_char *d_before, *d_after; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6888 | int result, | ~~~~~~~~~~~ 6889 | at_beg = AT_STRINGS_BEG (d), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6890 | at_end = AT_STRINGS_END (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6891 | | 6892 | if (at_beg && at_end) | ~~~~~~~~~~~~~~~~~~~~~ 6893 | { | ~ 6894 | result = 0; | ~~~~~~~~~~~ 6895 | } | ~ 6896 | else | ~~~~ 6897 | { | ~ 6898 | if (!at_beg) | ~~~~~~~~~~~~ 6899 | { | ~ 6900 | d_before = POS_BEFORE_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6901 | DEC_IBYTEPTR_FMT (d_before, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6902 | emch1 = itext_ichar_fmt (d_before, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6903 | #ifdef emacs | ~~~~~~~~~~~~ 6904 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6905 | UPDATE_SYNTAX_CACHE (scache, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6906 | offset_to_bytexpos | ~~~~~~~~~~~~~~~~~~ 6907 | (lispobj, PTR_TO_OFFSET (d_before))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6908 | #endif | ~~~~~~ 6909 | syn1 = SYNTAX_FROM_CACHE (scache, emch1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6910 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 6911 | } | ~ 6912 | if (!at_end) | ~~~~~~~~~~~~ 6913 | { | ~ 6914 | d_after = POS_AFTER_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6915 | emch2 = itext_ichar_fmt (d_after, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6916 | #ifdef emacs | ~~~~~~~~~~~~ 6917 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6918 | UPDATE_SYNTAX_CACHE_FORWARD (scache, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6919 | offset_to_bytexpos | ~~~~~~~~~~~~~~~~~~ 6920 | (lispobj, PTR_TO_OFFSET (d))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6921 | #endif | ~~~~~~ 6922 | syn2 = SYNTAX_FROM_CACHE (scache, emch2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6923 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 6924 | } | ~ 6925 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6926 | | 6927 | if (at_beg) | ~~~~~~~~~~~ 6928 | result = (syn2 == Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6929 | else if (at_end) | ~~~~~~~~~~~~~~~~ 6930 | result = (syn1 == Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6931 | else | ~~~~ 6932 | result = ((syn1 == Sword) != (syn2 == Sword)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6933 | } | ~ 6934 | | 6935 | if (result == should_succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6936 | break; | ~~~~~~ 6937 | goto fail; | ~~~~~~~~~~ 6938 | } | ~ 6939 | | 6940 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 6941 | DEBUG_MATCH_PRINT1 ("EXECUTING notwordbound.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6942 | should_succeed = 0; | ~~~~~~~~~~~~~~~~~~~ 6943 | goto matchwordbound; | ~~~~~~~~~~~~~~~~~~~~ 6944 | | 6945 | case wordbeg: | ~~~~~~~~~~~~~ 6946 | DEBUG_MATCH_PRINT1 ("EXECUTING wordbeg.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6947 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6948 | goto fail; | ~~~~~~~~~~ 6949 | { | ~ 6950 | /* XEmacs: this originally read: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6951 | | 6952 | if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6953 | break; | ~~~~~~ 6954 | | 6955 | */ | ~~ 6956 | re_char *dtmp = POS_AFTER_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6957 | Ichar emch = itext_ichar_fmt (dtmp, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6958 | int tempres; | ~~~~~~~~~~~~ 6959 | | 6960 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6961 | #ifdef emacs | ~~~~~~~~~~~~ 6962 | UPDATE_SYNTAX_CACHE | ~~~~~~~~~~~~~~~~~~~ 6963 | (scache, | ~~~~~~~~ 6964 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (d))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6965 | #endif | ~~~~~~ 6966 | tempres = (SYNTAX_FROM_CACHE (scache, emch) != Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6967 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 6968 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6969 | if (tempres) | ~~~~~~~~~~~~ 6970 | goto fail; | ~~~~~~~~~~ 6971 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6972 | break; | ~~~~~~ 6973 | dtmp = POS_BEFORE_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6974 | DEC_IBYTEPTR_FMT (dtmp, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6975 | emch = itext_ichar_fmt (dtmp, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6976 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6977 | #ifdef emacs | ~~~~~~~~~~~~ 6978 | UPDATE_SYNTAX_CACHE_BACKWARD | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6979 | (scache, | ~~~~~~~~ 6980 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (dtmp))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6981 | #endif | ~~~~~~ 6982 | tempres = (SYNTAX_FROM_CACHE (scache, emch) != Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6983 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 6984 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6985 | if (tempres) | ~~~~~~~~~~~~ 6986 | break; | ~~~~~~ 6987 | goto fail; | ~~~~~~~~~~ 6988 | } | ~ 6989 | | 6990 | case wordend: | ~~~~~~~~~~~~~ 6991 | DEBUG_MATCH_PRINT1 ("EXECUTING wordend.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6992 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6993 | goto fail; | ~~~~~~~~~~ 6994 | { | ~ 6995 | /* XEmacs: this originally read: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6996 | | 6997 | if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6998 | && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6999 | break; | ~~~~~~ 7000 | | 7001 | The or condition is incorrect (reversed). | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7002 | */ | ~~ 7003 | re_char *dtmp; | ~~~~~~~~~~~~~~ 7004 | Ichar emch; | ~~~~~~~~~~~ 7005 | int tempres; | ~~~~~~~~~~~~ 7006 | #ifdef emacs | ~~~~~~~~~~~~ 7007 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7008 | UPDATE_SYNTAX_CACHE | ~~~~~~~~~~~~~~~~~~~ 7009 | (scache, | ~~~~~~~~ 7010 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (d))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7011 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7012 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7013 | #endif | ~~~~~~ 7014 | dtmp = POS_BEFORE_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7015 | DEC_IBYTEPTR_FMT (dtmp, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7016 | emch = itext_ichar_fmt (dtmp, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7017 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7018 | tempres = (SYNTAX_FROM_CACHE (scache, emch) != Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7019 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7020 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7021 | if (tempres) | ~~~~~~~~~~~~ 7022 | goto fail; | ~~~~~~~~~~ 7023 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 7024 | break; | ~~~~~~ 7025 | dtmp = POS_AFTER_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7026 | emch = itext_ichar_fmt (dtmp, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7027 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7028 | #ifdef emacs | ~~~~~~~~~~~~ 7029 | { | ~ 7030 | re_char *next = d; | ~~~~~~~~~~~~~~~~~~ 7031 | INC_IBYTEPTR_FMT (next, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7032 | UPDATE_SYNTAX_CACHE_FORWARD | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7033 | (scache, | ~~~~~~~~ 7034 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (next))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7035 | } | ~ 7036 | #endif | ~~~~~~ 7037 | tempres = (SYNTAX_FROM_CACHE (scache, emch) != Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7038 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7039 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7040 | if (tempres) | ~~~~~~~~~~~~ 7041 | break; | ~~~~~~ 7042 | goto fail; | ~~~~~~~~~~ 7043 | } | ~ 7044 | | 7045 | #ifdef emacs | ~~~~~~~~~~~~ 7046 | case before_dot: | ~~~~~~~~~~~~~~~~ 7047 | DEBUG_MATCH_PRINT1 ("EXECUTING before_dot.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7048 | if (!BUFFERP (lispobj) | ~~~~~~~~~~~~~~~~~~~~~~ 7049 | || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7050 | >= BUF_PT (XBUFFER (lispobj)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7051 | goto fail; | ~~~~~~~~~~ 7052 | break; | ~~~~~~ 7053 | | 7054 | case at_dot: | ~~~~~~~~~~~~ 7055 | DEBUG_MATCH_PRINT1 ("EXECUTING at_dot.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7056 | if (!BUFFERP (lispobj) | ~~~~~~~~~~~~~~~~~~~~~~ 7057 | || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7058 | != BUF_PT (XBUFFER (lispobj)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7059 | goto fail; | ~~~~~~~~~~ 7060 | break; | ~~~~~~ 7061 | | 7062 | case after_dot: | ~~~~~~~~~~~~~~~ 7063 | DEBUG_MATCH_PRINT1 ("EXECUTING after_dot.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7064 | if (!BUFFERP (lispobj) | ~~~~~~~~~~~~~~~~~~~~~~ 7065 | || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7066 | <= BUF_PT (XBUFFER (lispobj)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7067 | goto fail; | ~~~~~~~~~~ 7068 | break; | ~~~~~~ 7069 | | 7070 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 7071 | DEBUG_MATCH_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7072 | mcnt = *p++; | ~~~~~~~~~~~~ 7073 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 7074 | | 7075 | case wordchar: | ~~~~~~~~~~~~~~ 7076 | DEBUG_MATCH_PRINT1 ("EXECUTING Emacs wordchar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7077 | mcnt = (int) Sword; | ~~~~~~~~~~~~~~~~~~~ 7078 | matchsyntax: | ~~~~~~~~~~~~ 7079 | should_succeed = 1; | ~~~~~~~~~~~~~~~~~~~ 7080 | matchornotsyntax: | ~~~~~~~~~~~~~~~~~ 7081 | { | ~ 7082 | int matches; | ~~~~~~~~~~~~ 7083 | Ichar emch; | ~~~~~~~~~~~ 7084 | | 7085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 7086 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7087 | UPDATE_SYNTAX_CACHE | ~~~~~~~~~~~~~~~~~~~ 7088 | (scache, | ~~~~~~~~ 7089 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (d))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7090 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7091 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7092 | | 7093 | emch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7094 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7095 | matches = (SYNTAX_FROM_CACHE (scache, emch) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7096 | (enum syntaxcode) mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~ 7097 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7098 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7099 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 7100 | if (matches != should_succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7101 | goto fail; | ~~~~~~~~~~ 7102 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 7103 | } | ~ 7104 | break; | ~~~~~~ 7105 | | 7106 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 7107 | DEBUG_MATCH_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7108 | mcnt = *p++; | ~~~~~~~~~~~~ 7109 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 7110 | | 7111 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 7112 | DEBUG_MATCH_PRINT1 ("EXECUTING Emacs notwordchar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7113 | mcnt = (int) Sword; | ~~~~~~~~~~~~~~~~~~~ 7114 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 7115 | should_succeed = 0; | ~~~~~~~~~~~~~~~~~~~ 7116 | goto matchornotsyntax; | ~~~~~~~~~~~~~~~~~~~~~~ 7117 | | 7118 | #ifdef MULE | ~~~~~~~~~~~ 7119 | /* 97/2/17 jhod Mule category code patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7120 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 7121 | should_succeed = 1; | ~~~~~~~~~~~~~~~~~~~ 7122 | matchornotcategory: | ~~~~~~~~~~~~~~~~~~~ 7123 | { | ~ 7124 | Ichar emch; | ~~~~~~~~~~~ 7125 | | 7126 | mcnt = *p++; | ~~~~~~~~~~~~ 7127 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 7128 | emch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7129 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 7130 | if (check_char_in_category (emch, BUFFER_CATEGORY_TABLE (lispbuf), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7131 | mcnt, should_succeed)) | ~~~~~~~~~~~~~~~~~~~~~~ 7132 | goto fail; | ~~~~~~~~~~ 7133 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 7134 | } | ~ 7135 | break; | ~~~~~~ 7136 | | 7137 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 7138 | should_succeed = 0; | ~~~~~~~~~~~~~~~~~~~ 7139 | goto matchornotcategory; | ~~~~~~~~~~~~~~~~~~~~~~~~ 7140 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7141 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 7142 | #else /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~ 7143 | case wordchar: | ~~~~~~~~~~~~~~ 7144 | DEBUG_MATCH_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7145 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 7146 | if (!WORDCHAR_P ((int) (*d))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7147 | goto fail; | ~~~~~~~~~~ 7148 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 7149 | d++; | ~~~~ 7150 | break; | ~~~~~~ 7151 | | 7152 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 7153 | DEBUG_MATCH_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7154 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 7155 | if (!WORDCHAR_P ((int) (*d))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7156 | goto fail; | ~~~~~~~~~~ 7157 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 7158 | d++; | ~~~~ 7159 | break; | ~~~~~~ 7160 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 7161 | | 7162 | default: | ~~~~~~~~ 7163 | ABORT (); | ~~~~~~~~~ 7164 | } | ~ 7165 | continue; /* Successfully executed one pattern command; keep going. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7166 | | 7167 | | 7168 | /* We goto here if a matching operation fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7169 | fail: | ~~~~~ 7170 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7171 | { /* A restart point is known. Restore to that state. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7172 | DEBUG_MATCH_PRINT1 ("\nFAIL:\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7173 | POP_FAILURE_POINT (d, p, | ~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:7173:11: note: in expansion of macro 'POP_FAILURE_POINT' 7173 | POP_FAILURE_POINT (d, p, | ^~~~~~~~~~~~~~~~~ regex.c:1901:48: note: format string is defined here 1901 | DEBUG_FAIL_PRINT2 (" Popping string 0x%zx: `", (Bytecount) str); \ | ~~^ | | | unsigned int | %lx regex.c:1905:26: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ | | | long int 1906 | DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | DEBUG_FAIL_PRINT2 (" Popping high active reg: %d\n", high_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1908 | DEBUG_FAIL_PRINT2 (" Popping low active reg: %d\n", low_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1909 | } \ | ~~~~~~~~~~~ 1910 | \ | ~ 1911 | for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1912 | { \ | ~~~~~~~~~~~ 1913 | reg_info[this_reg].word = POP_FAILURE_ELT (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1914 | regend[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1915 | regstart[this_reg] = POP_FAILURE_RELOCATABLE (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1916 | \ | ~ 1917 | if (DEBUG_RUNTIME_FLAGS & RE_DEBUG_FAILURE_POINT) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1918 | { \ | ~~~~~~~~~~ 1919 | DEBUG_FAIL_PRINT2 (" Popping reg: %d\n", this_reg); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1926 | } \ | ~~~~~~~~~~ 1927 | } \ | ~~~~~~~~~~~ 1928 | \ | ~ 1929 | set_regs_matched_done = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1930 | DEBUG_STATEMENT (nfailure_points_popped++); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1931 | } while (0) /* POP_FAILURE_POINT */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1932 | | 1933 | | ~ 1934 | /* Structure for per-register (a.k.a. per-group) information. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1935 | Other register information, such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1936 | starting and ending positions (which are addresses), and the list of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1937 | inner groups (which is a bits list) are maintained in separate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1938 | variables. | ~~~~~~~~~~ 1939 | | 1940 | We are making a (strictly speaking) nonportable assumption here: that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1941 | the compiler will pack our bit fields into something that fits into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1942 | the type of `word', i.e., is something that fits into one item on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1943 | failure stack. */ | ~~~~~~~~~~~~~~~~~~ 1944 | | 1945 | typedef union | ~~~~~~~~~~~~~ 1946 | { | ~ 1947 | fail_stack_elt_t word; | ~~~~~~~~~~~~~~~~~~~~~~ 1948 | struct | ~~~~~~ 1949 | { | ~ 1950 | /* This field is one if this group can match the empty string, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1951 | zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1952 | #define MATCH_NULL_UNSET_VALUE 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1953 | unsigned int match_null_string_p : 2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1954 | unsigned int is_active : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1955 | unsigned int matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1956 | unsigned int ever_matched_something : 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1957 | } bits; | ~~~~~~~ 1958 | } register_info_type; | ~~~~~~~~~~~~~~~~~~~~~ 1959 | | 1960 | #define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1961 | #define IS_ACTIVE(R) ((R).bits.is_active) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1962 | #define MATCHED_SOMETHING(R) ((R).bits.matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1963 | #define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1964 | | 1965 | | 1966 | /* Call this when have matched a real character; it sets `matched' flags | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1967 | for the subexpressions which we are currently inside. Also records | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1968 | that those subexprs have matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1969 | #define SET_REGS_MATCHED() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1970 | do \ | ~~~~~~~~~~~~ 1971 | { \ | ~~~~~~~~~~~ 1972 | if (!set_regs_matched_done) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1973 | { \ | ~~~~~~~~~~ 1974 | int r; \ | ~~~~~~~~~~~~~~ 1975 | set_regs_matched_done = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1976 | for (r = lowest_active_reg; r <= highest_active_reg; r++) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1977 | { \ | ~~~~~~~~~~ 1978 | MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1979 | = EVER_MATCHED_SOMETHING (reg_info[r]) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1980 | = 1; \ | ~~~~~~~~~~~~ 1981 | } \ | ~~~~~~~~~~ 1982 | } \ | ~~~~~~~~~~ 1983 | } \ | ~~~~~~~~~~~ 1984 | while (0) | ~~~~~~~~~ 1985 | | ~ 1986 | /* Subroutine declarations and macros for regex_compile. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1987 | | 1988 | /* Fetch the next character in the uncompiled pattern---translating it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1989 | if necessary. */ | ~~~~~~~~~~~~~~~~~ 1990 | #define PATFETCH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1991 | do { \ | ~~~~~~~~~~~~~~ 1992 | PATFETCH_RAW (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 1993 | c = RE_TRANSLATE (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1994 | } while (0) | ~~~~~~~~~~~ 1995 | | 1996 | /* Fetch the next character in the uncompiled pattern, with no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1997 | translation. */ | ~~~~~~~~~~~~~~~~ 1998 | #define PATFETCH_RAW(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1999 | do {if (p == pend) return REG_EEND; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2000 | assert (p < pend); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2001 | c = itext_ichar (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2002 | INC_IBYTEPTR (p); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2003 | } while (0) | ~~~~~~~~~~~ 2004 | | 2005 | /* Go backwards one character in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2006 | #define PATUNFETCH DEC_IBYTEPTR (p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2007 | | 2008 | /* If `translate' is non-null, return translate[D], else just D. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2009 | cast the subscript to translate because some data is declared as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2010 | `char *', to avoid warnings when a string constant is passed. But | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2011 | when we use a character as a subscript we must make it unsigned. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2012 | #define RE_TRANSLATE(d) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2013 | (TRANSLATE_P (translate) ? RE_TRANSLATE_1 (d) : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2014 | | 2015 | /* Macros for outputting the compiled pattern into `buffer'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2016 | | 2017 | /* If the buffer isn't allocated when it comes in, use this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2018 | #define INIT_BUF_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2019 | | 2020 | /* Make sure we have at least N more bytes of space in buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2021 | #define GET_BUFFER_SPACE(n) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2022 | while (buf_end - bufp->buffer + (n) > (ptrdiff_t) bufp->allocated) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2023 | EXTEND_BUFFER () | ~~~~~~~~~~~~~~~~ 2024 | | 2025 | /* Make sure we have one more byte of buffer space and then add C to it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2026 | #define BUF_PUSH(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2027 | do { \ | ~~~~~~~~~~~~~~ 2028 | GET_BUFFER_SPACE (1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2029 | *buf_end++ = (unsigned char) (c); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2030 | } while (0) | ~~~~~~~~~~~ 2031 | | 2032 | | 2033 | /* Ensure we have two more bytes of buffer space and then append C1 and C2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2034 | #define BUF_PUSH_2(c1, c2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2035 | do { \ | ~~~~~~~~~~~~~~ 2036 | GET_BUFFER_SPACE (2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2037 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2038 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2039 | } while (0) | ~~~~~~~~~~~ 2040 | | 2041 | | 2042 | /* As with BUF_PUSH_2, except for three bytes. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2043 | #define BUF_PUSH_3(c1, c2, c3) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2044 | do { \ | ~~~~~~~~~~~~~~ 2045 | GET_BUFFER_SPACE (3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2046 | *buf_end++ = (unsigned char) (c1); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2047 | *buf_end++ = (unsigned char) (c2); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2048 | *buf_end++ = (unsigned char) (c3); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2049 | } while (0) | ~~~~~~~~~~~ 2050 | | 2051 | | 2052 | /* Store a jump with opcode OP at LOC to location TO. We store a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2053 | relative address offset by the three bytes the jump itself occupies. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2054 | #define STORE_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2055 | store_op1 (op, loc, (to) - (loc) - 3) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2056 | | 2057 | /* Likewise, for a two-argument jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2058 | #define STORE_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2059 | store_op2 (op, loc, (to) - (loc) - 3, arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2060 | | 2061 | /* Like `STORE_JUMP', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2062 | buffer end. */ | ~~~~~~~~~~~~~~~ 2063 | #define INSERT_JUMP(op, loc, to) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2064 | insert_op1 (op, loc, (to) - (loc) - 3, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2065 | | 2066 | /* Like `STORE_JUMP2', but for inserting. Assume `buf_end' is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2067 | buffer end. */ | ~~~~~~~~~~~~~~~ 2068 | #define INSERT_JUMP2(op, loc, to, arg) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2069 | insert_op2 (op, loc, (to) - (loc) - 3, arg, buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2070 | | 2071 | /* Extend the buffer by twice its current size via realloc and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2072 | reset the pointers that pointed into the old block to point to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2073 | correct places in the new one. If extending the buffer results in it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2074 | being larger than RE_MAX_BUF_SIZE, then flag memory exhausted. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2075 | #define EXTEND_BUFFER() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2076 | do { \ | ~~~~~~~~~~~~~~~ 2077 | re_char *old_buffer = bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2078 | if (bufp->allocated == RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2079 | return REG_ESIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2080 | bufp->allocated <<= 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2081 | if (bufp->allocated > RE_MAX_BUF_SIZE) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2082 | bufp->allocated = RE_MAX_BUF_SIZE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2083 | bufp->buffer = \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2084 | (unsigned char *) xrealloc (bufp->buffer, bufp->allocated); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2085 | if (bufp->buffer == NULL) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2086 | return REG_ESPACE; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2087 | /* If the buffer moved, move all the pointers into it. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2088 | if (old_buffer != bufp->buffer) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2089 | { \ | ~~~~~~~~~~~~ 2090 | buf_end = (buf_end - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2091 | begalt = (begalt - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2092 | if (fixup_alt_jump) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2093 | fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2094 | if (laststart) \ | ~~~~~~~~~~~~~~~~~~~~~~~ 2095 | laststart = (laststart - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2096 | if (pending_exact) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2097 | pending_exact = (pending_exact - old_buffer) + bufp->buffer; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2098 | } \ | ~~~~~~~~~~~~ 2099 | } while (0) | ~~~~~~~~~~~ 2100 | | 2101 | #define INIT_REG_TRANSLATE_SIZE 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2102 | | 2103 | /* Macros for the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2104 | | 2105 | /* Since offsets can go either forwards or backwards, this type needs to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2106 | able to hold values from -(RE_MAX_BUF_SIZE - 1) to RE_MAX_BUF_SIZE - 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2107 | typedef int pattern_offset_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2108 | | 2109 | typedef struct | ~~~~~~~~~~~~~~ 2110 | { | ~ 2111 | pattern_offset_t begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2112 | pattern_offset_t fixup_alt_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2113 | pattern_offset_t inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2114 | pattern_offset_t laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2115 | regnum_t regnum; | ~~~~~~~~~~~~~~~~ 2116 | } compile_stack_elt_t; | ~~~~~~~~~~~~~~~~~~~~~~ 2117 | | 2118 | | 2119 | typedef struct | ~~~~~~~~~~~~~~ 2120 | { | ~ 2121 | compile_stack_elt_t *stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2122 | int size; | ~~~~~~~~~ 2123 | int avail; /* Offset of next open position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2124 | } compile_stack_type; | ~~~~~~~~~~~~~~~~~~~~~ 2125 | | 2126 | | 2127 | #define INIT_COMPILE_STACK_SIZE 32 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2128 | | 2129 | #define COMPILE_STACK_EMPTY (compile_stack.avail == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2130 | #define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2131 | | 2132 | /* The next available element. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2133 | #define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2134 | | 2135 | /* Set the bit for character C in a bit vector. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2136 | #define SET_LIST_BIT(c) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2137 | (buf_end[((unsigned char) (c)) / BYTEWIDTH] \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2138 | |= 1 << (((unsigned char) c) % BYTEWIDTH)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2139 | | 2140 | #ifdef MULE | ~~~~~~~~~~~ 2141 | | 2142 | /* Set the "bit" for character C in a range table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2143 | #define SET_RANGETAB_BIT(c) put_range_table (rtab, c, c, Qt) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2144 | | 2145 | #endif | ~~~~~~ 2146 | | 2147 | #ifdef emacs | ~~~~~~~~~~~~ 2148 | /* Parse the longest number we can, but don't produce a bignum, that can't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2149 | correspond to anything we're interested in and would needlessly complicate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2150 | code. Also avoid the silent overflow issues of the non-emacs code below. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2151 | If the string at P is not exhausted, leave P pointing at the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2152 | (probable-)non-digit byte encountered. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | #define GET_UNSIGNED_NUMBER(num) do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2154 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2155 | Ibyte *_gus_numend = NULL; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2156 | Lisp_Object _gus_numno; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2157 | /* most-positive-fixnum on 32 bit XEmacs is 10 decimal digits, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2158 | nine will keep us in fixnum territory no matter our \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2159 | architecture */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2160 | Bytecount limit = min (pend - p, 9); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2161 | \ | ~ 2162 | /* Require that any digits are ASCII. We already require that \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2163 | the user type ASCII in order to type {,(,|, etc, and there is \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2164 | the potential for security holes in the future if we allow \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2165 | non-ASCII digits to specify groups in regexps and other \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2166 | code that parses regexps is not aware of this. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2167 | _gus_numno = parse_integer (p, &_gus_numend, limit, 10, 1, \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2168 | Vdigit_fixnum_ascii); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2169 | if (FIXNUMP (_gus_numno) && XREALFIXNUM (_gus_numno) >= 0) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2170 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2171 | num = XREALFIXNUM (_gus_numno); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2172 | p = _gus_numend; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2173 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2174 | } while (0) | ~~~~~~~~~~~ 2175 | #else | ~~~~~ 2176 | /* Get the next unsigned number in the uncompiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2177 | #define GET_UNSIGNED_NUMBER(num) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2178 | { if (p != pend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2179 | { \ | ~~~~~~~~~~~ 2180 | int _gun_do_unfetch = 1; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2181 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~~~ 2182 | while (ISDIGIT (c)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2183 | { \ | ~~~~~~~~~~~ 2184 | if (num < 0) \ | ~~~~~~~~~~~~~~~~~~~~ 2185 | num = 0; \ | ~~~~~~~~~~~~~~~~ 2186 | num = num * 10 + c - '0'; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2187 | if (p == pend) \ | ~~~~~~~~~~~~~~~~~~~~~~ 2188 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2189 | _gun_do_unfetch = 0; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2190 | break; \ | ~~~~~~~~~~~~~~~ 2191 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2192 | PATFETCH (c); \ | ~~~~~~~~~~~~~~~~~~~~ 2193 | } \ | ~~~~~~~~~~~ 2194 | if (_gun_do_unfetch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2195 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2196 | /* Make sure P points to the next non-digit character. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2197 | PATUNFETCH; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2198 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2199 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2200 | } | ~ 2201 | #endif | ~~~~~~ 2202 | | 2203 | /* Map a string to the char class it names (if any). BEG points to the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2204 | to be parsed and LIMIT is the length, in bytes, of that string. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2205 | | 2206 | XEmacs; this only handles the NAME part of the [:NAME:] specification of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2207 | character class name. The GNU emacs version of this function attempts to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2208 | handle the string from [: onwards, and is called re_wctype_parse. Our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2209 | approach means the function doesn't need to be called with every character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2210 | class encountered. | ~~~~~~~~~~~~~~~~~~ 2211 | | 2212 | LENGTH would be a Bytecount if this function didn't need to be compiled | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2213 | also for executables that don't include lisp.h | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2214 | | 2215 | Return RECC_ERROR if STRP doesn't match a known character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2216 | re_wctype_t | ~~~~~~~~~~~ 2217 | re_wctype (const unsigned char *beg, int limit) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2218 | { | ~ 2219 | /* Sort tests in the length=five case by frequency the classes to minimize | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2220 | number of times we fail the comparison. The frequencies of character class | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2221 | names used in Emacs sources as of 2016-07-27: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2222 | | 2223 | $ find \( -name \*.c -o -name \*.el \) -exec grep -h '\[:[a-z]*:]' {} + | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2224 | sed 's/]/]\n/g' |grep -o '\[:[a-z]*:]' |sort |uniq -c |sort -nr | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2225 | 213 [:alnum:] | ~~~~~~~~~~~~~ 2226 | 104 [:alpha:] | ~~~~~~~~~~~~~ 2227 | 62 [:space:] | ~~~~~~~~~~~~ 2228 | 39 [:digit:] | ~~~~~~~~~~~~ 2229 | 36 [:blank:] | ~~~~~~~~~~~~ 2230 | 26 [:word:] | ~~~~~~~~~~~ 2231 | 26 [:upper:] | ~~~~~~~~~~~~ 2232 | 21 [:lower:] | ~~~~~~~~~~~~ 2233 | 10 [:xdigit:] | ~~~~~~~~~~~~~ 2234 | 10 [:punct:] | ~~~~~~~~~~~~ 2235 | 10 [:ascii:] | ~~~~~~~~~~~~ 2236 | 4 [:nonascii:] | ~~~~~~~~~~~~~~ 2237 | 4 [:graph:] | ~~~~~~~~~~~ 2238 | 2 [:print:] | ~~~~~~~~~~~ 2239 | 2 [:cntrl:] | ~~~~~~~~~~~ 2240 | 1 [:ff:] | ~~~~~~~~ 2241 | | 2242 | If you update this list, consider also updating chain of or'ed conditions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2243 | in execute_charset function. XEmacs; our equivalent is the condition | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2244 | checking class_bits in the charset_mule and charset_mule_not opcodes. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2245 | */ | ~~ 2246 | | 2247 | switch (limit) { | ~~~~~~~~~~~~~~~~ 2248 | case 4: | ~~~~~~~ 2249 | if (!memcmp (beg, "word", 4)) return RECC_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2250 | break; | ~~~~~~ 2251 | case 5: | ~~~~~~~ 2252 | if (!memcmp (beg, "alnum", 5)) return RECC_ALNUM; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2253 | if (!memcmp (beg, "alpha", 5)) return RECC_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2254 | if (!memcmp (beg, "space", 5)) return RECC_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2255 | if (!memcmp (beg, "digit", 5)) return RECC_DIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2256 | if (!memcmp (beg, "blank", 5)) return RECC_BLANK; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2257 | if (!memcmp (beg, "upper", 5)) return RECC_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2258 | if (!memcmp (beg, "lower", 5)) return RECC_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2259 | if (!memcmp (beg, "punct", 5)) return RECC_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2260 | if (!memcmp (beg, "ascii", 5)) return RECC_ASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2261 | if (!memcmp (beg, "graph", 5)) return RECC_GRAPH; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2262 | if (!memcmp (beg, "print", 5)) return RECC_PRINT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2263 | if (!memcmp (beg, "cntrl", 5)) return RECC_CNTRL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2264 | break; | ~~~~~~ 2265 | case 6: | ~~~~~~~ 2266 | if (!memcmp (beg, "xdigit", 6)) return RECC_XDIGIT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2267 | break; | ~~~~~~ 2268 | case 7: | ~~~~~~~ 2269 | if (!memcmp (beg, "unibyte", 7)) return RECC_UNIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2270 | break; | ~~~~~~ 2271 | case 8: | ~~~~~~~ 2272 | if (!memcmp (beg, "nonascii", 8)) return RECC_NONASCII; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2273 | break; | ~~~~~~ 2274 | case 9: | ~~~~~~~ 2275 | if (!memcmp (beg, "multibyte", 9)) return RECC_MULTIBYTE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2276 | break; | ~~~~~~ 2277 | } | ~ 2278 | | 2279 | return RECC_ERROR; | ~~~~~~~~~~~~~~~~~~ 2280 | } | ~ 2281 | | 2282 | /* True if CH is in the char class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2283 | int | ~~~ 2284 | re_iswctype (int ch, re_wctype_t cc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2285 | RE_ISWCTYPE_ARG_DECL) | ~~~~~~~~~~~~~~~~~~~~~ 2286 | { | ~ 2287 | switch (cc) | ~~~~~~~~~~~ 2288 | { | ~ 2289 | case RECC_ALNUM: return ISALNUM (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2290 | case RECC_ALPHA: return ISALPHA (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2291 | case RECC_BLANK: return ISBLANK (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2292 | case RECC_CNTRL: return ISCNTRL (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2293 | case RECC_DIGIT: return ISDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2294 | case RECC_GRAPH: return ISGRAPH (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2295 | case RECC_PRINT: return ISPRINT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2296 | case RECC_PUNCT: return ISPUNCT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2297 | case RECC_SPACE: return ISSPACE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2298 | #ifdef emacs | ~~~~~~~~~~~~ 2299 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 2300 | return NILP (lispbuf->case_fold_search) ? ISUPPER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2301 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2302 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 2303 | return NILP (lispbuf->case_fold_search) ? ISLOWER (ch) != 0 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2304 | : !NOCASEP (lispbuf, ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2305 | #else | ~~~~~ 2306 | case RECC_UPPER: return ISUPPER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2307 | case RECC_LOWER: return ISLOWER (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2308 | #endif | ~~~~~~ 2309 | case RECC_XDIGIT: return ISXDIGIT (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2310 | case RECC_ASCII: return ISASCII (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2311 | case RECC_NONASCII: case RECC_MULTIBYTE: return !ISASCII (ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2312 | case RECC_UNIBYTE: return ISUNIBYTE (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2313 | case RECC_WORD: return ISWORD (ch) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2314 | case RECC_ERROR: return false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2315 | } | ~ 2316 | assert (0); | ~~~~~~~~~~~ 2317 | return -1; | ~~~~~~~~~~ 2318 | } | ~ 2319 | | 2320 | #ifdef MULE | ~~~~~~~~~~~ 2321 | | 2322 | static re_bool | ~~~~~~~~~~~~~~ 2323 | re_wctype_can_match_non_ascii (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2324 | { | ~ 2325 | switch (cc) | ~~~~~~~~~~~ 2326 | { | ~ 2327 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 2328 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 2329 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 2330 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 2331 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 2332 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 2333 | return false; | ~~~~~~~~~~~~~ 2334 | default: | ~~~~~~~~ 2335 | return true; | ~~~~~~~~~~~~ 2336 | } | ~ 2337 | } | ~ 2338 | | 2339 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2340 | | 2341 | #ifdef emacs | ~~~~~~~~~~~~ 2342 | | 2343 | /* Return a bit-pattern to use in the range-table bits to match multibyte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2344 | chars of class CC. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2345 | static unsigned char | ~~~~~~~~~~~~~~~~~~~~ 2346 | re_wctype_to_bit (re_wctype_t cc) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2347 | { | ~ 2348 | switch (cc) | ~~~~~~~~~~~ 2349 | { | ~ 2350 | case RECC_PRINT: case RECC_GRAPH: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2351 | case RECC_ALPHA: return BIT_ALPHA; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2352 | case RECC_ALNUM: case RECC_WORD: return BIT_WORD; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2353 | case RECC_LOWER: return BIT_LOWER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2354 | case RECC_UPPER: return BIT_UPPER; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2355 | case RECC_PUNCT: return BIT_PUNCT; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2356 | case RECC_SPACE: return BIT_SPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2357 | case RECC_MULTIBYTE: case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2358 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2359 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2360 | default: | ~~~~~~~~ 2361 | ABORT (); | ~~~~~~~~~ 2362 | return 0; | ~~~~~~~~~ 2363 | } | ~ 2364 | } | ~ 2365 | | 2366 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 2367 | | ~ 2368 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2369 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2370 | static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2371 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2372 | static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2373 | unsigned char *end); | ~~~~~~~~~~~~~~~~~~~~ 2374 | static re_bool at_begline_loc_p (re_char *pattern, re_char *p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2375 | reg_syntax_t syntax); | ~~~~~~~~~~~~~~~~~~~~~ 2376 | static re_bool at_endline_loc_p (re_char *p, re_char *pend, int syntax); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2377 | static re_bool group_in_compile_stack (compile_stack_type compile_stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2378 | regnum_t regnum); | ~~~~~~~~~~~~~~~~~ 2379 | static reg_errcode_t compile_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2380 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2381 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2382 | unsigned char *b); | ~~~~~~~~~~~~~~~~~~ 2383 | #ifdef MULE | ~~~~~~~~~~~ 2384 | static reg_errcode_t compile_extended_range (re_char **p_ptr, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2385 | re_char *pend, | ~~~~~~~~~~~~~~ 2386 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2387 | reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~ 2388 | Lisp_Object rtab); | ~~~~~~~~~~~~~~~~~~ 2389 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 2390 | #ifdef emacs | ~~~~~~~~~~~~ 2391 | reg_errcode_t compile_char_class (re_wctype_t cc, Lisp_Object rtab, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2392 | Bitbyte *flags_out); | ~~~~~~~~~~~~~~~~~~~~ 2393 | #endif | ~~~~~~ 2394 | | 2395 | static re_bool group_match_null_string_p (re_char **p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2396 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2397 | static re_bool alt_match_null_string_p (re_char *p, re_char *end, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2398 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2399 | static re_bool common_op_match_null_string_p (re_char **p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2400 | re_char *end, | ~~~~~~~~~~~~~ 2401 | register_info_type *reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2402 | static int bcmp_translate (re_char *s1, re_char *s2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2403 | REGISTER int len, RE_TRANSLATE_TYPE translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2404 | #ifdef emacs | ~~~~~~~~~~~~ 2405 | , Internal_Format fmt, Lisp_Object lispobj | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2406 | #endif | ~~~~~~ 2407 | ); | ~~ 2408 | static int re_match_2_internal (struct re_pattern_buffer *bufp, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2409 | re_char *string1, int size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2410 | re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2411 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2412 | RE_LISP_CONTEXT_ARGS_DECL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2413 | | ~ 2414 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2415 | | 2416 | /* If we cannot allocate large objects within re_match_2_internal, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2417 | we make the fail stack and register vectors global. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2418 | The fail stack, we grow to the maximum size when a regexp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2419 | is compiled. | ~~~~~~~~~~~~ 2420 | The register vectors, we adjust in size each time we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2421 | compile a regexp, according to the number of registers it needs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2422 | | 2423 | static fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2424 | | 2425 | /* Size with which the following vectors are currently allocated. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2426 | That is so we can make them bigger as needed, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2427 | but never make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2428 | static int regs_allocated_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2429 | | 2430 | static re_char ** regstart, ** regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2431 | static re_char ** old_regstart, ** old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2432 | static re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2433 | static register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2434 | static re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2435 | static register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2436 | | 2437 | /* Make the register vectors big enough for NUM_REGS registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2438 | but don't make them smaller. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2439 | | 2440 | static | ~~~~~~ 2441 | regex_grow_registers (int num_regs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2442 | { | ~ 2443 | if (num_regs > regs_allocated_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2444 | { | ~ 2445 | RETALLOC (regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2446 | RETALLOC (regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2447 | RETALLOC (old_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2448 | RETALLOC (old_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2449 | RETALLOC (best_regstart, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2450 | RETALLOC (best_regend, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2451 | RETALLOC (reg_info, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2452 | RETALLOC (reg_dummy, num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2453 | RETALLOC (reg_info_dummy, num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2454 | | 2455 | regs_allocated_size = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2456 | } | ~ 2457 | } | ~ 2458 | | 2459 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2460 | | ~ 2461 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2462 | Returns one of error codes defined in `regex.h', or zero for success. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2463 | | 2464 | Assumes the `allocated' (and perhaps `buffer') and `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2465 | fields are set in BUFP on entry. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2466 | | 2467 | If it succeeds, results are put in BUFP (if it returns an error, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2468 | contents of BUFP are undefined): | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2469 | `buffer' is the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | `syntax' is set to SYNTAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2471 | `used' is set to the length of the compiled pattern; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2472 | `fastmap_accurate' is zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2473 | `re_ngroups' is the number of groups/subexpressions (including shy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2474 | groups) in PATTERN; | ~~~~~~~~~~~~~~~~~~~ 2475 | `re_nsub' is the number of non-shy groups in PATTERN; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2476 | `not_bol' and `not_eol' are zero; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2477 | | 2478 | The `fastmap' and `newline_anchor' fields are neither | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2479 | examined nor set. */ | ~~~~~~~~~~~~~~~~~~~~~ 2480 | | 2481 | /* Return, freeing storage we allocated. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2482 | #define FREE_STACK_RETURN(value) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2483 | do \ | ~~~~~~~~~~ 2484 | { \ | ~~~~~~~~~ 2485 | xfree (compile_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2486 | return value; \ | ~~~~~~~~~~~~~~~~~~~~ 2487 | } while (0) | ~~~~~~~~~~~ 2488 | | 2489 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 2490 | regex_compile (re_char *pattern, int size, reg_syntax_t syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2491 | struct re_pattern_buffer *bufp) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2492 | { | ~ 2493 | /* We fetch characters from PATTERN here. We declare these as int | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2494 | (or possibly long) so that chars above 127 can be used as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2495 | array indices. The macros that fetch a character from the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2496 | make sure to coerce to unsigned char before assigning, so we won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2497 | get bitten by negative numbers here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2498 | /* XEmacs change: used to be unsigned char. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2499 | REGISTER EMACS_INT c, c1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2500 | | 2501 | /* A random temporary spot in PATTERN. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2502 | re_char *p1; | ~~~~~~~~~~~~ 2503 | | 2504 | /* Points to the end of the buffer, where we should append. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2505 | REGISTER unsigned char *buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2506 | | 2507 | /* Keeps track of unclosed groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2508 | compile_stack_type compile_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2509 | | 2510 | /* Points to the current (ending) position in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2511 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 2512 | re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2513 | | 2514 | /* How to translate the characters in the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2515 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2516 | | 2517 | /* Address of the count-byte of the most recently inserted `exactn' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2518 | command. This makes it possible to tell if a new exact-match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2519 | character can be added to that command or if the character requires | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2520 | a new `exactn' command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2521 | unsigned char *pending_exact = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2522 | | 2523 | /* Address of start of the most recently finished expression. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2524 | This tells, e.g., postfix * where to find the start of its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2525 | operand. Reset at the beginning of groups and alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2526 | unsigned char *laststart = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2527 | | 2528 | /* Address of beginning of regexp, or inside of last group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2529 | unsigned char *begalt; | ~~~~~~~~~~~~~~~~~~~~~~ 2530 | | 2531 | /* Place in the uncompiled pattern (i.e., the {) to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2532 | which to go back if the interval is invalid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2533 | re_char *beg_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 2534 | | 2535 | /* Address of the place where a forward jump should go to the end of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2536 | the containing expression. Each alternative of an `or' -- except the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2537 | last -- ends with a forward jump of this sort. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2538 | unsigned char *fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2539 | | 2540 | /* Counts open-groups as they are encountered. Remembered for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2541 | matching close-group on the compile stack, so the same register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2542 | number is put in the stop_memory as the start_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2543 | regnum_t regnum = 0; | ~~~~~~~~~~~~~~~~~~~~ 2544 | | 2545 | #ifdef DEBUG | ~~~~~~~~~~~~ 2546 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2547 | { | ~ 2548 | int debug_count; | ~~~~~~~~~~~~~~~~ 2549 | | 2550 | DEBUG_PRINT1 ("\nCompiling pattern: "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2551 | for (debug_count = 0; debug_count < size; debug_count++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2552 | putchar (pattern[debug_count]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2553 | putchar ('\n'); | ~~~~~~~~~~~~~~~ 2554 | } | ~ 2555 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 2556 | | 2557 | /* Initialize the compile stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2558 | compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2559 | if (compile_stack.stack == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2560 | return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~ 2561 | | 2562 | compile_stack.size = INIT_COMPILE_STACK_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2563 | compile_stack.avail = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2564 | | 2565 | /* Initialize the pattern buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2566 | bufp->syntax = syntax; | ~~~~~~~~~~~~~~~~~~~~~~ 2567 | bufp->fastmap_accurate = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2568 | bufp->not_bol = bufp->not_eol = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2569 | | 2570 | /* Set `used' to zero, so that if we return an error, the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2571 | printer (for debugging) will think there's no pattern. We reset it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2572 | at the end. */ | ~~~~~~~~~~~~~~~ 2573 | bufp->used = 0; | ~~~~~~~~~~~~~~~ 2574 | | 2575 | /* Always count groups, whether or not bufp->no_sub is set. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2576 | bufp->re_nsub = 0; | ~~~~~~~~~~~~~~~~~~ 2577 | bufp->re_ngroups = 0; | ~~~~~~~~~~~~~~~~~~~~~ 2578 | | 2579 | bufp->warned_about_incompatible_back_references = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2580 | | 2581 | if (bufp->external_to_internal_register == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2582 | { | ~ 2583 | bufp->external_to_internal_register_size = INIT_REG_TRANSLATE_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2584 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2585 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2586 | int); | ~~~~~ 2587 | } | ~ 2588 | | 2589 | { | ~ 2590 | int i; | ~~~~~~ 2591 | | 2592 | bufp->external_to_internal_register[0] = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2593 | for (i = 1; i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2594 | bufp->external_to_internal_register[i] = (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2595 | } | ~ 2596 | | 2597 | #if !defined (emacs) && !defined (SYNTAX_TABLE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2598 | /* Initialize the syntax table. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2599 | init_syntax_once (); | ~~~~~~~~~~~~~~~~~~~~ 2600 | #endif | ~~~~~~ 2601 | | 2602 | if (bufp->allocated == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2603 | { | ~ 2604 | if (bufp->buffer) | ~~~~~~~~~~~~~~~~~ 2605 | { /* If zero allocated, but buffer is non-null, try to realloc | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2606 | enough space. This loses if buffer's address is bogus, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2607 | that is the user's responsibility. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2608 | RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2609 | } | ~ 2610 | else | ~~~~ 2611 | { /* Caller did not allocate a buffer. Do it for them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2612 | bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2613 | } | ~ 2614 | if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2615 | | 2616 | bufp->allocated = INIT_BUF_SIZE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2617 | } | ~ 2618 | | 2619 | begalt = buf_end = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2620 | | 2621 | /* Loop through the uncompiled pattern until we're at the end. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2622 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2623 | { | ~ 2624 | PATFETCH (c); | ~~~~~~~~~~~~~ 2625 | | 2626 | switch (c) | ~~~~~~~~~~ 2627 | { | ~ 2628 | case '^': | ~~~~~~~~~ 2629 | { | ~ 2630 | if ( /* If at start of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2631 | p == pattern + 1 | ~~~~~~~~~~~~~~~~ 2632 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2633 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2634 | /* Otherwise, depends on what's come before. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2635 | || at_begline_loc_p (pattern, p, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2636 | BUF_PUSH (begline); | ~~~~~~~~~~~~~~~~~~~ 2637 | else | ~~~~ 2638 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2639 | } | ~ 2640 | break; | ~~~~~~ 2641 | | 2642 | | 2643 | case '$': | ~~~~~~~~~ 2644 | { | ~ 2645 | if ( /* If at end of pattern, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2646 | p == pend | ~~~~~~~~~ 2647 | /* If context independent, it's an operator. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2648 | || syntax & RE_CONTEXT_INDEP_ANCHORS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2649 | /* Otherwise, depends on what's next. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2650 | || at_endline_loc_p (p, pend, syntax)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2651 | BUF_PUSH (endline); | ~~~~~~~~~~~~~~~~~~~ 2652 | else | ~~~~ 2653 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2654 | } | ~ 2655 | break; | ~~~~~~ 2656 | | 2657 | | 2658 | case '+': | ~~~~~~~~~ 2659 | case '?': | ~~~~~~~~~ 2660 | if ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2661 | || (syntax & RE_LIMITED_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2662 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2663 | handle_plus: | ~~~~~~~~~~~~ 2664 | case '*': | ~~~~~~~~~ 2665 | /* If there is no previous pattern... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2666 | if (!laststart) | ~~~~~~~~~~~~~~~ 2667 | { | ~ 2668 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2669 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2670 | else if (!(syntax & RE_CONTEXT_INDEP_OPS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2671 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 2672 | } | ~ 2673 | | 2674 | { | ~ 2675 | /* true means zero/many matches are allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2676 | re_bool zero_times_ok = c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2677 | re_bool many_times_ok = c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2678 | | 2679 | /* true means match shortest string possible. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2680 | re_bool minimal = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 2681 | | 2682 | /* If there is a sequence of repetition chars, collapse it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2683 | down to just one (the right one). We can't combine | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2684 | interval operators with these because of, e.g., `a{2}*', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2685 | which should only match an even number of `a's. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2686 | while (p != pend) | ~~~~~~~~~~~~~~~~~ 2687 | { | ~ 2688 | PATFETCH (c); | ~~~~~~~~~~~~~ 2689 | | 2690 | if (c == '*' || (!(syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2691 | && (c == '+' || c == '?'))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2692 | ; | ~ 2693 | | 2694 | else if (syntax & RE_BK_PLUS_QM && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2695 | { | ~ 2696 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2697 | | 2698 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2699 | if (!(c1 == '+' || c1 == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2700 | { | ~ 2701 | PATUNFETCH; | ~~~~~~~~~~~ 2702 | PATUNFETCH; | ~~~~~~~~~~~ 2703 | break; | ~~~~~~ 2704 | } | ~ 2705 | | 2706 | c = c1; | ~~~~~~~ 2707 | } | ~ 2708 | else | ~~~~ 2709 | { | ~ 2710 | PATUNFETCH; | ~~~~~~~~~~~ 2711 | break; | ~~~~~~ 2712 | } | ~ 2713 | | 2714 | /* If we get here, we found another repeat character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2715 | if (!(syntax & RE_NO_MINIMAL_MATCHING)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2716 | { | ~ 2717 | /* "*?" and "+?" and "??" are okay (and mean match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2718 | minimally), but other sequences (such as "*??" and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2719 | "+++") are rejected (reserved for future use). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2720 | if (minimal || c != '?') | ~~~~~~~~~~~~~~~~~~~~~~~~ 2721 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2722 | minimal = true; | ~~~~~~~~~~~~~~~ 2723 | } | ~ 2724 | else | ~~~~ 2725 | { | ~ 2726 | zero_times_ok |= c != '+'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2727 | many_times_ok |= c != '?'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2728 | } | ~ 2729 | } | ~ 2730 | | 2731 | /* Star, etc. applied to an empty pattern is equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2732 | to an empty pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 2733 | if (!laststart) | ~~~~~~~~~~~~~~~ 2734 | break; | ~~~~~~ 2735 | | 2736 | /* Now we know whether zero matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2737 | and whether two or more matches is allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2738 | and whether we want minimal or maximal matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2739 | if (minimal) | ~~~~~~~~~~~~ 2740 | { | ~ 2741 | if (!many_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2742 | { | ~ 2743 | /* "a??" becomes: | ~~~~~~~~~~~~~~~~~ 2744 | 0: /on_failure_jump to 6 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2745 | 3: /jump to 9 | ~~~~~~~~~~~~~ 2746 | 6: /exactn/1/A | ~~~~~~~~~~~~~~ 2747 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2748 | */ | ~~ 2749 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2750 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2751 | buf_end += 3; | ~~~~~~~~~~~~~ 2752 | INSERT_JUMP (on_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2753 | buf_end += 3; | ~~~~~~~~~~~~~ 2754 | } | ~ 2755 | else if (zero_times_ok) | ~~~~~~~~~~~~~~~~~~~~~~~ 2756 | { | ~ 2757 | /* "a*?" becomes: | ~~~~~~~~~~~~~~~~~ 2758 | 0: /jump to 6 | ~~~~~~~~~~~~~ 2759 | 3: /exactn/1/A | ~~~~~~~~~~~~~~ 2760 | 6: /on_failure_jump to 3 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2761 | 9: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2762 | */ | ~~ 2763 | GET_BUFFER_SPACE (6); | ~~~~~~~~~~~~~~~~~~~~~ 2764 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2765 | buf_end += 3; | ~~~~~~~~~~~~~ 2766 | STORE_JUMP (on_failure_jump, buf_end, laststart + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2767 | buf_end += 3; | ~~~~~~~~~~~~~ 2768 | } | ~ 2769 | else | ~~~~ 2770 | { | ~ 2771 | /* "a+?" becomes: | ~~~~~~~~~~~~~~~~~ 2772 | 0: /exactn/1/A | ~~~~~~~~~~~~~~ 2773 | 3: /on_failure_jump to 0 | ~~~~~~~~~~~~~~~~~~~~~~~~ 2774 | 6: end of pattern. | ~~~~~~~~~~~~~~~~~~ 2775 | */ | ~~ 2776 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2777 | STORE_JUMP (on_failure_jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2778 | buf_end += 3; | ~~~~~~~~~~~~~ 2779 | } | ~ 2780 | } | ~ 2781 | else | ~~~~ 2782 | { | ~ 2783 | /* Are we optimizing this jump? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2784 | re_bool keep_string_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2785 | | 2786 | if (many_times_ok) | ~~~~~~~~~~~~~~~~~~ 2787 | { /* More than one repetition is allowed, so put in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2788 | at the end a backward relative jump from | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2789 | `buf_end' to before the next jump we're going | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2790 | to put in below (which jumps from laststart to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2791 | after this jump). | ~~~~~~~~~~~~~~~~~ 2792 | | 2793 | But if we are at the `*' in the exact sequence `.*\n', | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2794 | insert an unconditional jump backwards to the ., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2795 | instead of the beginning of the loop. This way we only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2796 | push a failure point once, instead of every time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2797 | through the loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2798 | assert (p - 1 > pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2799 | | 2800 | /* Allocate the space for the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2801 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2802 | | 2803 | /* We know we are not at the first character of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2804 | pattern, because laststart was nonzero. And we've | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2805 | already incremented `p', by the way, to be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2806 | character after the `*'. Do we have to do something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2807 | analogous here for null bytes, because of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2808 | RE_DOT_NOT_NULL? */ | ~~~~~~~~~~~~~~~~~~~ 2809 | if (*(p - 2) == '.' | ~~~~~~~~~~~~~~~~~~~ 2810 | && zero_times_ok | ~~~~~~~~~~~~~~~~ 2811 | && p < pend && *p == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2812 | && !(syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2813 | { /* We have .*\n. */ | ~~~~~~~~~~~~~~~~~~~~~~ 2814 | STORE_JUMP (jump, buf_end, laststart); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2815 | keep_string_p = true; | ~~~~~~~~~~~~~~~~~~~~~ 2816 | } | ~ 2817 | else | ~~~~ 2818 | /* Anything else. */ | ~~~~~~~~~~~~~~~~~~~~~ 2819 | STORE_JUMP (maybe_pop_jump, buf_end, laststart - 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2820 | | 2821 | /* We've added more stuff to the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2822 | buf_end += 3; | ~~~~~~~~~~~~~ 2823 | } | ~ 2824 | | 2825 | /* On failure, jump from laststart to buf_end + 3, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2826 | which will be the end of the buffer after this jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2827 | is inserted. */ | ~~~~~~~~~~~~~~~~ 2828 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2829 | INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2830 | : on_failure_jump, | ~~~~~~~~~~~~~~~~~~ 2831 | laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~ 2832 | buf_end += 3; | ~~~~~~~~~~~~~ 2833 | | 2834 | if (!zero_times_ok) | ~~~~~~~~~~~~~~~~~~~ 2835 | { | ~ 2836 | /* At least one repetition is required, so insert a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2837 | `dummy_failure_jump' before the initial | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2838 | `on_failure_jump' instruction of the loop. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2839 | effects a skip over that instruction the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2840 | we hit that loop. */ | ~~~~~~~~~~~~~~~~~~~~~ 2841 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 2842 | INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2843 | buf_end += 3; | ~~~~~~~~~~~~~ 2844 | } | ~ 2845 | } | ~ 2846 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 2847 | } | ~ 2848 | break; | ~~~~~~ 2849 | | 2850 | | 2851 | case '.': | ~~~~~~~~~ 2852 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2853 | BUF_PUSH (anychar); | ~~~~~~~~~~~~~~~~~~~ 2854 | break; | ~~~~~~ 2855 | | 2856 | #ifdef MULE | ~~~~~~~~~~~ 2857 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2858 | if (ch >= 0x80) do \ | ~~~~~~~~~~~~~~~~~~~~~~ 2859 | { \ | ~~~~~~~ 2860 | goto start_over_with_extended; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2861 | } while (0) | ~~~~~~~~~~~ 2862 | #else | ~~~~~ 2863 | #define MAYBE_START_OVER_WITH_EXTENDED(ch) (void)(ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2864 | #endif | ~~~~~~ 2865 | | 2866 | case '[': | ~~~~~~~~~ 2867 | { | ~ 2868 | /* XEmacs change: this whole section */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2869 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2870 | | 2871 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2872 | | 2873 | /* Ensure that we have enough space to push a charset: the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2874 | opcode, the length count, and the bitset; 34 bytes in all. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2875 | GET_BUFFER_SPACE (34); | ~~~~~~~~~~~~~~~~~~~~~~ 2876 | | 2877 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 2878 | | 2879 | /* We test `*p == '^' twice, instead of using an if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2880 | statement, so we only need one BUF_PUSH. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2881 | BUF_PUSH (*p == '^' ? charset_not : charset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2882 | if (*p == '^') | ~~~~~~~~~~~~~~ 2883 | p++; | ~~~~ 2884 | | 2885 | /* Remember the first position in the bracket expression. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2886 | p1 = p; | ~~~~~~~ 2887 | | 2888 | /* Push the number of bytes in the bitmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2889 | BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2890 | | 2891 | /* Clear the whole map. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2892 | memset (buf_end, 0, (1 << BYTEWIDTH) / BYTEWIDTH); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2893 | | 2894 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2895 | if ((re_opcode_t) buf_end[-2] == charset_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2896 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2897 | SET_LIST_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~ 2898 | | 2899 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2900 | for (;;) | ~~~~~~~~ 2901 | { | ~ 2902 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2903 | | 2904 | PATFETCH (c); | ~~~~~~~~~~~~~ 2905 | | 2906 | /* Frumble-bumble, we may have found some extended chars. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2907 | Need to start over, process everything using the general | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2908 | extended-char mechanism, and need to use charset_mule and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2909 | charset_mule_not instead of charset and charset_not. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2910 | MAYBE_START_OVER_WITH_EXTENDED (c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2911 | | 2912 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2913 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2914 | { | ~ 2915 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2916 | | 2917 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2918 | | 2919 | MAYBE_START_OVER_WITH_EXTENDED (c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2920 | | 2921 | SET_LIST_BIT (c1); | ~~~~~~~~~~~~~~~~~~ 2922 | continue; | ~~~~~~~~~ 2923 | } | ~ 2924 | | 2925 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2926 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2927 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2928 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2929 | break; | ~~~~~~ 2930 | | 2931 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2932 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2933 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2934 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2935 | | 2936 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2937 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2938 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2939 | operator. */ | ~~~~~~~~~~~~~ 2940 | if (c == '-' | ~~~~~~~~~~~~ 2941 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2942 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2943 | && *p != ']') | ~~~~~~~~~~~~~ 2944 | { | ~ 2945 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2946 | | 2947 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 | | 2949 | ret = compile_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2950 | buf_end); | ~~~~~~~~~ 2951 | | 2952 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2953 | } | ~ 2954 | | 2955 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2956 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2957 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 2958 | | 2959 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 2960 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 2961 | | 2962 | MAYBE_START_OVER_WITH_EXTENDED (*(unsigned char *)p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2963 | | 2964 | ret = compile_range (&p, pend, translate, syntax, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2965 | | 2966 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2967 | } | ~ 2968 | | 2969 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2970 | class. */ | ~~~~~~~~~~ 2971 | | 2972 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2973 | { | ~ 2974 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 2975 | | 2976 | PATFETCH (c); | ~~~~~~~~~~~~~ 2977 | c1 = 0; | ~~~~~~~ 2978 | | 2979 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2980 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2981 | | 2982 | for (;;) | ~~~~~~~~ 2983 | { | ~ 2984 | PATFETCH (c); | ~~~~~~~~~~~~~ 2985 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2986 | { | ~ 2987 | break; | ~~~~~~ 2988 | } | ~ 2989 | | 2990 | c1++; | ~~~~~ 2991 | } | ~ 2992 | | 2993 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2994 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2995 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2996 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2997 | { | ~ 2998 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2999 | int ch; | ~~~~~~~ 3000 | | 3001 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3002 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3003 | | 3004 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3005 | class. */ | ~~~~~~~~~~ 3006 | PATFETCH (c); | ~~~~~~~~~~~~~ 3007 | | 3008 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3009 | | 3010 | #ifdef MULE | ~~~~~~~~~~~ 3011 | if (re_wctype_can_match_non_ascii (cc)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3012 | { | ~ 3013 | goto start_over_with_extended; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3014 | } | ~ 3015 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3016 | for (ch = 0; ch < (1 << BYTEWIDTH); ++ch) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3017 | { | ~ 3018 | if (re_iswctype (ch, cc | ~~~~~~~~~~~~~~~~~~~~~~~ 3019 | RE_ISWCTYPE_ARG (current_buffer))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3020 | { | ~ 3021 | SET_LIST_BIT (ch); | ~~~~~~~~~~~~~~~~~~ 3022 | } | ~ 3023 | } | ~ 3024 | | 3025 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3026 | } | ~ 3027 | else | ~~~~ 3028 | { | ~ 3029 | c1++; | ~~~~~ 3030 | while (c1--) | ~~~~~~~~~~~~ 3031 | PATUNFETCH; | ~~~~~~~~~~~ 3032 | SET_LIST_BIT ('['); | ~~~~~~~~~~~~~~~~~~~ 3033 | SET_LIST_BIT (':'); | ~~~~~~~~~~~~~~~~~~~ 3034 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3035 | } | ~ 3036 | } | ~ 3037 | else | ~~~~ 3038 | { | ~ 3039 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3040 | SET_LIST_BIT (c); | ~~~~~~~~~~~~~~~~~ 3041 | } | ~ 3042 | } | ~ 3043 | | 3044 | /* Discard any (non)matching list bytes that are all 0 at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3045 | end of the map. Decrease the map-length byte too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3046 | while ((int) buf_end[-1] > 0 && buf_end[buf_end[-1] - 1] == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3047 | buf_end[-1]--; | ~~~~~~~~~~~~~~ 3048 | buf_end += buf_end[-1]; | ~~~~~~~~~~~~~~~~~~~~~~~ 3049 | } | ~ 3050 | break; | ~~~~~~ 3051 | | 3052 | #ifdef MULE | ~~~~~~~~~~~ 3053 | start_over_with_extended: | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3054 | { | ~ 3055 | REGISTER Lisp_Object rtab = Qnil; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3056 | Bitbyte flags = 0; | ~~~~~~~~~~~~~~~~~~ 3057 | int bytes_needed = sizeof (flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3058 | re_bool had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3059 | | 3060 | /* There are extended chars here, which means we need to use the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3061 | unified range-table format. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3062 | if (buf_end[-2] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3063 | buf_end[-2] = charset_mule; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3064 | else | ~~~~ 3065 | buf_end[-2] = charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3066 | buf_end--; | ~~~~~~~~~~ 3067 | p = p1; /* go back to the beginning of the charset, after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3068 | a possible ^. */ | ~~~~~~~~~~~~~~~~ 3069 | rtab = Vthe_lisp_rangetab; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3070 | Fclear_range_table (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3071 | | 3072 | /* charset_not matches newline according to a syntax bit. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3073 | if ((re_opcode_t) buf_end[-1] == charset_mule_not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3074 | && (syntax & RE_HAT_LISTS_NOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3075 | SET_RANGETAB_BIT ('\n'); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3076 | | 3077 | /* Read in characters and ranges, setting map bits. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3078 | for (;;) | ~~~~~~~~ 3079 | { | ~ 3080 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3081 | | 3082 | PATFETCH (c); | ~~~~~~~~~~~~~ 3083 | | 3084 | /* \ might escape characters inside [...] and [^...]. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3085 | if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3086 | { | ~ 3087 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3088 | | 3089 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3090 | | 3091 | SET_RANGETAB_BIT (c1); | ~~~~~~~~~~~~~~~~~~~~~~ 3092 | continue; | ~~~~~~~~~ 3093 | } | ~ 3094 | | 3095 | /* Could be the end of the bracket expression. If it's | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3096 | not (i.e., when the bracket expression is `[]' so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3097 | far), the ']' character bit gets set way below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3098 | if (c == ']' && p != p1 + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3099 | break; | ~~~~~~ 3100 | | 3101 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3102 | was a character class. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3103 | if (had_char_class && c == '-' && *p != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3104 | FREE_STACK_RETURN (REG_ERANGE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3105 | | 3106 | /* Look ahead to see if it's a range when the last thing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3107 | was a character: if this is a hyphen not at the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3108 | beginning or the end of a list, then it's the range | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3109 | operator. */ | ~~~~~~~~~~~~~ 3110 | if (c == '-' | ~~~~~~~~~~~~ 3111 | && !(p - 2 >= pattern && p[-2] == '[') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3112 | && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3113 | && *p != ']') | ~~~~~~~~~~~~~ 3114 | { | ~ 3115 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3116 | | 3117 | ret = compile_extended_range (&p, pend, translate, syntax, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3118 | rtab); | ~~~~~~ 3119 | | 3120 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3121 | } | ~ 3122 | | 3123 | else if (p[0] == '-' && p[1] != ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3124 | { /* This handles ranges made up of characters only. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3125 | reg_errcode_t ret; | ~~~~~~~~~~~~~~~~~~ 3126 | | 3127 | /* Move past the `-'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3128 | PATFETCH (c1); | ~~~~~~~~~~~~~~ 3129 | | 3130 | ret = compile_extended_range (&p, pend, translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3131 | syntax, rtab); | ~~~~~~~~~~~~~~ 3132 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3133 | } | ~ 3134 | | 3135 | /* See if we're at the beginning of a possible character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3136 | class. */ | ~~~~~~~~~~ 3137 | | 3138 | else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3139 | { | ~ 3140 | re_char *str = p + 1; | ~~~~~~~~~~~~~~~~~~~~~ 3141 | | 3142 | PATFETCH (c); | ~~~~~~~~~~~~~ 3143 | c1 = 0; | ~~~~~~~ 3144 | | 3145 | /* If pattern is `[[:'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3146 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3147 | | 3148 | for (;;) | ~~~~~~~~ 3149 | { | ~ 3150 | PATFETCH (c); | ~~~~~~~~~~~~~ 3151 | if ((c == ':' && *p == ']') || p == pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3152 | { | ~ 3153 | break; | ~~~~~~ 3154 | } | ~ 3155 | | 3156 | c1++; | ~~~~~ 3157 | } | ~ 3158 | | 3159 | /* If isn't a word bracketed by `[:' and `:]': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3160 | undo the ending character, the letters, and leave | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3161 | the leading `:' and `[' (but set bits for them). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3162 | if (c == ':' && *p == ']') | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3163 | { | ~ 3164 | re_wctype_t cc = re_wctype (str, c1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3165 | reg_errcode_t ret = REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3166 | | 3167 | if (cc == RECC_ERROR) | ~~~~~~~~~~~~~~~~~~~~~ 3168 | FREE_STACK_RETURN (REG_ECTYPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3169 | | 3170 | /* Throw away the ] at the end of the character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3171 | class. */ | ~~~~~~~~~~ 3172 | PATFETCH (c); | ~~~~~~~~~~~~~ 3173 | | 3174 | if (p == pend) FREE_STACK_RETURN (REG_EBRACK); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3175 | | 3176 | ret = compile_char_class (cc, rtab, &flags); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3177 | | 3178 | if (ret != REG_NOERROR) FREE_STACK_RETURN (ret); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3179 | | 3180 | had_char_class = true; | ~~~~~~~~~~~~~~~~~~~~~~ 3181 | } | ~ 3182 | else | ~~~~ 3183 | { | ~ 3184 | c1++; | ~~~~~ 3185 | while (c1--) | ~~~~~~~~~~~~ 3186 | PATUNFETCH; | ~~~~~~~~~~~ 3187 | SET_RANGETAB_BIT ('['); | ~~~~~~~~~~~~~~~~~~~~~~~ 3188 | SET_RANGETAB_BIT (':'); | ~~~~~~~~~~~~~~~~~~~~~~~ 3189 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3190 | } | ~ 3191 | } | ~ 3192 | else | ~~~~ 3193 | { | ~ 3194 | had_char_class = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 3195 | SET_RANGETAB_BIT (c); | ~~~~~~~~~~~~~~~~~~~~~ 3196 | } | ~ 3197 | } | ~ 3198 | | 3199 | bytes_needed += unified_range_table_bytes_needed (rtab); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3200 | GET_BUFFER_SPACE (bytes_needed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3201 | *buf_end++ = flags; | ~~~~~~~~~~~~~~~~~~~ 3202 | unified_range_table_copy_data (rtab, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3203 | buf_end += unified_range_table_bytes_used (buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3204 | break; | ~~~~~~ 3205 | } | ~ 3206 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3207 | | 3208 | case '(': | ~~~~~~~~~ 3209 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3210 | goto handle_open; | ~~~~~~~~~~~~~~~~~ 3211 | else | ~~~~ 3212 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3213 | | 3214 | | 3215 | case ')': | ~~~~~~~~~ 3216 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3217 | goto handle_close; | ~~~~~~~~~~~~~~~~~~ 3218 | else | ~~~~ 3219 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3220 | | 3221 | | 3222 | case '\n': | ~~~~~~~~~~ 3223 | if (syntax & RE_NEWLINE_ALT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3224 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3225 | else | ~~~~ 3226 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3227 | | 3228 | | 3229 | case '|': | ~~~~~~~~~ 3230 | if (syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3231 | goto handle_alt; | ~~~~~~~~~~~~~~~~ 3232 | else | ~~~~ 3233 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3234 | | 3235 | | 3236 | case '{': | ~~~~~~~~~ 3237 | if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3238 | goto handle_interval; | ~~~~~~~~~~~~~~~~~~~~~ 3239 | else | ~~~~ 3240 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3241 | | 3242 | | 3243 | case '\\': | ~~~~~~~~~~ 3244 | if (p == pend) FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3245 | | 3246 | /* Do not translate the character after the \, so that we can | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3247 | distinguish, e.g., \B from \b, even if we normally would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3248 | translate, e.g., B to b. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3249 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3250 | | 3251 | switch (c) | ~~~~~~~~~~ 3252 | { | ~ 3253 | case '(': | ~~~~~~~~~ 3254 | if (syntax & RE_NO_BK_PARENS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3255 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3256 | | 3257 | handle_open: | ~~~~~~~~~~~~ 3258 | { | ~ 3259 | regnum_t r = 0; | ~~~~~~~~~~~~~~~ 3260 | re_bool shy = 0, named_nonshy = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3261 | | 3262 | if (!(syntax & RE_NO_SHY_GROUPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3263 | && p != pend && itext_ichar_eql (p, '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3264 | { | ~ 3265 | INC_IBYTEPTR (p); /* Gobble up the '?'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3266 | PATFETCH (c); /* Fetch the next character, which may be a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3267 | digit. */ | ~~~~~~~~~ 3268 | switch (c) | ~~~~~~~~~~ 3269 | { | ~ 3270 | case ':': /* shy groups */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3271 | shy = 1; | ~~~~~~~~ 3272 | break; | ~~~~~~ 3273 | | 3274 | case '1': case '2': case '3': case '4': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3275 | case '5': case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3276 | PATUNFETCH; | ~~~~~~~~~~~ 3277 | GET_UNSIGNED_NUMBER (r); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3278 | if (itext_ichar_eql (p, ':')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3279 | { | ~ 3280 | named_nonshy = 1; | ~~~~~~~~~~~~~~~~~ 3281 | INC_IBYTEPTR (p); /* Gobble up the ':'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3282 | break; | ~~~~~~ 3283 | /* Otherwise, fall through and error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3284 | } | ~ 3285 | | 3286 | /* An explicitly specified regnum must start with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3287 | non-0. */ | ~~~~~~~~~ 3288 | case '0': | ~~~~~~~~~ 3289 | default: | ~~~~~~~~ 3290 | FREE_STACK_RETURN (REG_BADPAT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3291 | } | ~ 3292 | } | ~ 3293 | | 3294 | ++regnum; | ~~~~~~~~~ 3295 | bufp->re_ngroups++; | ~~~~~~~~~~~~~~~~~~~ 3296 | | 3297 | if (bufp->re_ngroups > MAX_REGNUM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3298 | { | ~ 3299 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3300 | } | ~ 3301 | | 3302 | if (!shy) | ~~~~~~~~~ 3303 | { | ~ 3304 | if (named_nonshy) | ~~~~~~~~~~~~~~~~~ 3305 | { | ~ 3306 | if (r < bufp->external_to_internal_register_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3307 | { | ~ 3308 | if (group_in_compile_stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3309 | (compile_stack, | ~~~~~~~~~~~~~~~ 3310 | bufp->external_to_internal_register[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3311 | { | ~ 3312 | /* GNU errors in this context, which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3313 | inconsistent; it otherwise has no problem | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3314 | with named non-shy groups overriding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3315 | previously-assigned group numbers. I choose | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3316 | to error here for consistency with GNU for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3317 | those writing code that should target | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3318 | both. */ | ~~~~~~~~ 3319 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3320 | } | ~ 3321 | } | ~ 3322 | | 3323 | if (r > bufp->re_nsub) | ~~~~~~~~~~~~~~~~~~~~~~ 3324 | { | ~ 3325 | bufp->re_nsub = r; | ~~~~~~~~~~~~~~~~~~ 3326 | } | ~ 3327 | } | ~ 3328 | else | ~~~~ 3329 | { | ~ 3330 | r = ++(bufp->re_nsub); | ~~~~~~~~~~~~~~~~~~~~~~ 3331 | } | ~ 3332 | | 3333 | while (bufp->external_to_internal_register_size <= | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3334 | bufp->re_nsub) | ~~~~~~~~~~~~~~ 3335 | { | ~ 3336 | int i; | ~~~~~~ 3337 | int old_size = | ~~~~~~~~~~~~~~ 3338 | bufp->external_to_internal_register_size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3339 | bufp->external_to_internal_register_size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3340 | += max (old_size + 5, bufp->re_nsub + 5); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3341 | | 3342 | RETALLOC (bufp->external_to_internal_register, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3343 | bufp->external_to_internal_register_size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3344 | int); | ~~~~~ 3345 | | 3346 | for (i = old_size; | ~~~~~~~~~~~~~~~~~~ 3347 | i < bufp->external_to_internal_register_size; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3348 | bufp->external_to_internal_register[i] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3349 | (int) 0xDEADBEEF; | ~~~~~~~~~~~~~~~~~ 3350 | } | ~ 3351 | | 3352 | /* This is explicitly [r] rather than [bufp->re_nsub] for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3353 | the case that the named nonshy group references an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3354 | unused register number less than bufp->re_nsub. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3355 | bufp->external_to_internal_register[r] = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3356 | bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~ 3357 | } | ~ 3358 | | 3359 | if (COMPILE_STACK_FULL) | ~~~~~~~~~~~~~~~~~~~~~~~ 3360 | { | ~ 3361 | RETALLOC (compile_stack.stack, compile_stack.size << 1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3362 | compile_stack_elt_t); | ~~~~~~~~~~~~~~~~~~~~~ 3363 | if (compile_stack.stack == NULL) return REG_ESPACE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3364 | | 3365 | compile_stack.size <<= 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3366 | } | ~ 3367 | | 3368 | /* These are the values to restore when we hit end of this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3369 | group. They are all relative offsets, so that if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3370 | whole pattern moves because of realloc, they will still | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3371 | be valid. */ | ~~~~~~~~~~~~~ 3372 | COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3373 | COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3374 | = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3375 | COMPILE_STACK_TOP.laststart_offset = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3376 | COMPILE_STACK_TOP.regnum = bufp->re_ngroups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3377 | COMPILE_STACK_TOP.inner_group_offset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3378 | = buf_end - bufp->buffer + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3379 | /* We will eventually replace the 0 with the number of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3380 | groups inner to this one, using inner_group_offset, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3381 | above. */ | ~~~~~~~~~ 3382 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3383 | store_op2 (start_memory, buf_end, bufp->re_ngroups, 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3384 | buf_end += 5; | ~~~~~~~~~~~~~ 3385 | | 3386 | compile_stack.avail++; | ~~~~~~~~~~~~~~~~~~~~~~ 3387 | | 3388 | fixup_alt_jump = 0; | ~~~~~~~~~~~~~~~~~~~ 3389 | laststart = 0; | ~~~~~~~~~~~~~~ 3390 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3391 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3392 | } | ~ 3393 | break; | ~~~~~~ 3394 | | 3395 | | 3396 | case ')': | ~~~~~~~~~ 3397 | if (syntax & RE_NO_BK_PARENS) goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3398 | | 3399 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3400 | { | ~ 3401 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3402 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3403 | else | ~~~~ 3404 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3405 | } | ~ 3406 | | 3407 | handle_close: | ~~~~~~~~~~~~~ 3408 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3409 | { /* Push a dummy failure point at the end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3410 | alternative for a possible future | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3411 | `pop_failure_jump' to pop. See comments at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3412 | `push_dummy_failure' in `re_match_2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3413 | BUF_PUSH (push_dummy_failure); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3414 | | 3415 | /* We allocated space for this jump when we assigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3416 | to `fixup_alt_jump', in the `handle_alt' case below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3417 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3418 | } | ~ 3419 | | 3420 | /* See similar code for backslashed left paren above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3421 | if (COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~ 3422 | { | ~ 3423 | if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3424 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3425 | else | ~~~~ 3426 | FREE_STACK_RETURN (REG_ERPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3427 | } | ~ 3428 | | 3429 | /* Since we just checked for an empty stack above, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3430 | ``can't happen''. */ | ~~~~~~~~~~~~~~~~~~~~~ 3431 | assert (compile_stack.avail != 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3432 | { | ~ 3433 | /* We don't just want to restore into `regnum', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3434 | later groups should continue to be numbered higher, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3435 | as in `(ab)c(de)' -- the second group is #2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3436 | regnum_t this_group_regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3437 | unsigned char *inner_group_loc; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3438 | | 3439 | compile_stack.avail--; | ~~~~~~~~~~~~~~~~~~~~~~ 3440 | begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3441 | fixup_alt_jump | ~~~~~~~~~~~~~~ 3442 | = COMPILE_STACK_TOP.fixup_alt_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3443 | ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3444 | : 0; | ~~~~ 3445 | laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3446 | this_group_regnum = COMPILE_STACK_TOP.regnum; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3447 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3448 | | 3449 | /* We're at the end of the group, so now we know how many | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3450 | groups were inside this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3451 | inner_group_loc | ~~~~~~~~~~~~~~~ 3452 | = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3453 | | 3454 | STORE_NUMBER (inner_group_loc, regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3455 | | 3456 | GET_BUFFER_SPACE (5); | ~~~~~~~~~~~~~~~~~~~~~ 3457 | store_op2 (stop_memory, buf_end, this_group_regnum, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3458 | regnum - this_group_regnum); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3459 | buf_end += 5; | ~~~~~~~~~~~~~ 3460 | } | ~ 3461 | break; | ~~~~~~ 3462 | | 3463 | | 3464 | case '|': /* `\|'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3465 | if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3466 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3467 | handle_alt: | ~~~~~~~~~~~ 3468 | if (syntax & RE_LIMITED_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3469 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3470 | | 3471 | /* Insert before the previous alternative a jump which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3472 | jumps to this alternative if the former fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3473 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3474 | INSERT_JUMP (on_failure_jump, begalt, buf_end + 6); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3475 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3476 | buf_end += 3; | ~~~~~~~~~~~~~ 3477 | | 3478 | /* The alternative before this one has a jump after it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3479 | which gets executed if it gets matched. Adjust that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3480 | jump so it will jump to this alternative's analogous | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3481 | jump (put in below, which in turn will jump to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3482 | (if any) alternative's such jump, etc.). The last such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3483 | jump jumps to the correct final destination. A picture: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3484 | _____ _____ | ~~~~~~~~~~~ 3485 | | | | | | ~~~~~~~~~~~ 3486 | | v | v | ~~~~~~~~~~~ 3487 | a | b | c | ~~~~~~~~~~~ 3488 | | 3489 | If we are at `b', then fixup_alt_jump right now points to a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3490 | three-byte space after `a'. We'll put in the jump, set | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3491 | fixup_alt_jump to right after `b', and leave behind three | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3492 | bytes which we'll fill in when we get to after `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3493 | | 3494 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3495 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3496 | | 3497 | /* Mark and leave space for a jump after this alternative, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3498 | to be filled in later either by next alternative or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3499 | when know we're at the end of a series of alternatives. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3500 | fixup_alt_jump = buf_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3501 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3502 | buf_end += 3; | ~~~~~~~~~~~~~ 3503 | | 3504 | laststart = 0; | ~~~~~~~~~~~~~~ 3505 | begalt = buf_end; | ~~~~~~~~~~~~~~~~~ 3506 | break; | ~~~~~~ 3507 | | 3508 | | 3509 | case '{': | ~~~~~~~~~ 3510 | /* If \{ is a literal. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3511 | if (!(syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3512 | /* If we're at `\{' and it's not the open-interval | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3513 | operator. */ | ~~~~~~~~~~~~~ 3514 | || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3515 | || (p - 2 == pattern && p == pend)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3516 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3517 | | 3518 | #define BAD_INTERVAL(errnum) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3519 | do \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3520 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3521 | if (syntax & RE_NO_BK_BRACES) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3522 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3523 | goto unfetch_interval; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3524 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3525 | else \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3526 | { \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3527 | FREE_STACK_RETURN (errnum); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3528 | } \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3529 | } while (0) | ~~~~~~~~~~~ 3530 | | 3531 | handle_interval: | ~~~~~~~~~~~~~~~~ 3532 | { | ~ 3533 | /* If got here, then the syntax allows intervals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3534 | | 3535 | /* At least (most) this many matches must be made. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3536 | int lower_bound = 0, upper_bound = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3537 | | 3538 | beg_interval = p - 1; | ~~~~~~~~~~~~~~~~~~~~~ 3539 | | 3540 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3541 | { | ~ 3542 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3543 | } | ~ 3544 | | 3545 | GET_UNSIGNED_NUMBER (lower_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3546 | | 3547 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3548 | PATFETCH (c); | ~~~~~~~~~~~~~ 3549 | | 3550 | if (c == ',') | ~~~~~~~~~~~~~ 3551 | { | ~ 3552 | if (p == pend || itext_ichar_eql (p, '+')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3553 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3554 | | 3555 | GET_UNSIGNED_NUMBER (upper_bound); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3556 | if (upper_bound < 0) upper_bound = RE_DUP_MAX; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3557 | | 3558 | if (p == pend) BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3559 | PATFETCH (c); | ~~~~~~~~~~~~~ 3560 | } | ~ 3561 | else | ~~~~ 3562 | { | ~ 3563 | /* Interval such as `{1}' => match exactly once. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3564 | upper_bound = lower_bound; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3565 | } | ~ 3566 | | 3567 | if (lower_bound > upper_bound) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3568 | { | ~ 3569 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3570 | } | ~ 3571 | | 3572 | if (upper_bound > RE_DUP_MAX) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3573 | { | ~ 3574 | BAD_INTERVAL (REG_ESIZEBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3575 | } | ~ 3576 | | 3577 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3578 | { | ~ 3579 | if (c != '\\') | ~~~~~~~~~~~~~~ 3580 | FREE_STACK_RETURN (REG_BADBR); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3581 | if (p == pend) | ~~~~~~~~~~~~~~ 3582 | FREE_STACK_RETURN (REG_EESCAPE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3583 | PATFETCH (c); | ~~~~~~~~~~~~~ 3584 | } | ~ 3585 | | 3586 | if (c != '}') | ~~~~~~~~~~~~~ 3587 | { | ~ 3588 | BAD_INTERVAL (REG_EBRACE); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | } | ~ 3590 | | 3591 | /* We just parsed a valid interval. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3592 | | 3593 | /* It's invalid to have no preceding RE. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3594 | if (!laststart) | ~~~~~~~~~~~~~~~ 3595 | { | ~ 3596 | if (syntax & RE_CONTEXT_INVALID_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3597 | FREE_STACK_RETURN (REG_BADRPT); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3598 | else if (syntax & RE_CONTEXT_INDEP_OPS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3599 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3600 | else | ~~~~ 3601 | goto unfetch_interval; | ~~~~~~~~~~~~~~~~~~~~~~ 3602 | } | ~ 3603 | | 3604 | /* If the upper bound is zero, don't want to succeed at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3605 | all; jump from `laststart' to `b + 3', which will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3606 | the end of the buffer after we insert the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3607 | if (upper_bound == 0) | ~~~~~~~~~~~~~~~~~~~~~ 3608 | { | ~ 3609 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3610 | INSERT_JUMP (jump, laststart, buf_end + 3); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3611 | buf_end += 3; | ~~~~~~~~~~~~~ 3612 | } | ~ 3613 | | 3614 | /* Otherwise, we have a nontrivial interval. When | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3615 | we're all done, the pattern will look like: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3616 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3617 | set_number_at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3618 | succeed_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3619 | | ~~~~~~~~~~~~~~ 3620 | jump_n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3621 | (The upper bound and `jump_n' are omitted if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3622 | `upper_bound' is 1, though.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3623 | else | ~~~~ 3624 | { /* If the upper bound is > 1, we need to insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3625 | more at the end of the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3626 | int nbytes = 10 + (upper_bound > 1) * 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3627 | | 3628 | GET_BUFFER_SPACE (nbytes); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3629 | | 3630 | /* Initialize lower bound of the `succeed_n', even | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3631 | though it will be set during matching by its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3632 | attendant `set_number_at' (inserted next), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3633 | because `re_compile_fastmap' needs to know. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3634 | Jump to the `jump_n' we might insert below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3635 | INSERT_JUMP2 (succeed_n, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3636 | buf_end + 5 + (upper_bound > 1) * 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3637 | lower_bound); | ~~~~~~~~~~~~~ 3638 | buf_end += 5; | ~~~~~~~~~~~~~ 3639 | | 3640 | /* Code to initialize the lower bound. Insert | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3641 | before the `succeed_n'. The `5' is the last two | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3642 | bytes of this `set_number_at', plus 3 bytes of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3643 | the following `succeed_n'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3644 | insert_op2 (set_number_at, laststart, 5, lower_bound, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3645 | buf_end += 5; | ~~~~~~~~~~~~~ 3646 | | 3647 | if (upper_bound > 1) | ~~~~~~~~~~~~~~~~~~~~ 3648 | { /* More than one repetition is allowed, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3649 | append a backward jump to the `succeed_n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3650 | that starts this interval. | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3651 | | 3652 | When we've reached this during matching, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- strftime.o --- strftime.c: In function 'add_num_time_t': strftime.c:199:49: warning: format '%zu' expects argument of type 'size_t', but argument 4 has type 'long unsigned int' [-Wformat=] 199 | emacs_snprintf_ascbyte (buf, sizeof (buf), "%zu", (EMACS_UINT) num); | ~~^ ~~~~~~~~~~~~~~~~ | | | | | long unsigned int | unsigned int | %lu --- regex.o --- 3653 | we'll have matched the interval once, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3654 | jump back only `upper_bound - 1' times. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3655 | STORE_JUMP2 (jump_n, buf_end, laststart + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3656 | upper_bound - 1); | ~~~~~~~~~~~~~~~~~ 3657 | buf_end += 5; | ~~~~~~~~~~~~~ 3658 | | 3659 | /* The location we want to set is the second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3660 | parameter of the `jump_n'; that is `b-2' as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3661 | an absolute address. `laststart' will be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3662 | the `set_number_at' we're about to insert; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3663 | `laststart+3' the number to set, the source | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3664 | for the relative address. But we are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3665 | inserting into the middle of the pattern -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3666 | so everything is getting moved up by 5. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3667 | Conclusion: (b - 2) - (laststart + 3) + 5, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3668 | i.e., b - laststart. | ~~~~~~~~~~~~~~~~~~~~ 3669 | | 3670 | We insert this at the beginning of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3671 | so that if we fail during matching, we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3672 | reinitialize the bounds. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3673 | insert_op2 (set_number_at, laststart, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3674 | buf_end - laststart, | ~~~~~~~~~~~~~~~~~~~~ 3675 | upper_bound - 1, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3676 | buf_end += 5; | ~~~~~~~~~~~~~ 3677 | } | ~ 3678 | } | ~ 3679 | pending_exact = 0; | ~~~~~~~~~~~~~~~~~~ 3680 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3681 | } | ~ 3682 | break; | ~~~~~~ 3683 | #undef BAD_INTERVAL | ~~~~~~~~~~~~~~~~~~~ 3684 | | 3685 | unfetch_interval: | ~~~~~~~~~~~~~~~~~ 3686 | /* If an invalid interval, match the characters as literals. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3687 | assert (beg_interval); | ~~~~~~~~~~~~~~~~~~~~~~ 3688 | p = beg_interval; | ~~~~~~~~~~~~~~~~~ 3689 | beg_interval = NULL; | ~~~~~~~~~~~~~~~~~~~~ 3690 | | 3691 | /* normal_char and normal_backslash need `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3692 | PATFETCH (c); | ~~~~~~~~~~~~~ 3693 | | 3694 | if (!(syntax & RE_NO_BK_BRACES)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3695 | { | ~ 3696 | if (p > pattern && p[-1] == '\\') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3697 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3698 | } | ~ 3699 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3700 | | 3701 | #ifdef emacs | ~~~~~~~~~~~~ 3702 | /* There is no way to specify the before_dot and after_dot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3703 | operators. rms says this is ok. --karl */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3704 | case '=': | ~~~~~~~~~ 3705 | BUF_PUSH (at_dot); | ~~~~~~~~~~~~~~~~~~ 3706 | break; | ~~~~~~ 3707 | | 3708 | case 's': | ~~~~~~~~~ 3709 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3710 | PATFETCH (c); | ~~~~~~~~~~~~~ 3711 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3712 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3713 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3714 | BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3715 | break; | ~~~~~~ 3716 | | 3717 | case 'S': | ~~~~~~~~~ 3718 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3719 | PATFETCH (c); | ~~~~~~~~~~~~~ 3720 | /* XEmacs addition */ | ~~~~~~~~~~~~~~~~~~~~~ 3721 | if (c >= 0x80 || syntax_spec_code[c] == 0377) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3722 | FREE_STACK_RETURN (REG_ESYNTAX); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3723 | BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3724 | break; | ~~~~~~ 3725 | | 3726 | #ifdef MULE | ~~~~~~~~~~~ 3727 | /* 97.2.17 jhod merged in to XEmacs from mule-2.3 */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3728 | case 'c': | ~~~~~~~~~ 3729 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3730 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3731 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3732 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3733 | BUF_PUSH_2 (categoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3734 | break; | ~~~~~~ 3735 | | 3736 | case 'C': | ~~~~~~~~~ 3737 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3738 | PATFETCH_RAW (c); | ~~~~~~~~~~~~~~~~~ 3739 | if (c < 32 || c > 127) | ~~~~~~~~~~~~~~~~~~~~~~ 3740 | FREE_STACK_RETURN (REG_ECATEGORY); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3741 | BUF_PUSH_2 (notcategoryspec, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3742 | break; | ~~~~~~ 3743 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3744 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 3745 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 3746 | | 3747 | | 3748 | case 'w': | ~~~~~~~~~ 3749 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3750 | BUF_PUSH (wordchar); | ~~~~~~~~~~~~~~~~~~~~ 3751 | break; | ~~~~~~ 3752 | | 3753 | | 3754 | case 'W': | ~~~~~~~~~ 3755 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3756 | BUF_PUSH (notwordchar); | ~~~~~~~~~~~~~~~~~~~~~~~ 3757 | break; | ~~~~~~ 3758 | | 3759 | | 3760 | case '<': | ~~~~~~~~~ 3761 | BUF_PUSH (wordbeg); | ~~~~~~~~~~~~~~~~~~~ 3762 | break; | ~~~~~~ 3763 | | 3764 | case '>': | ~~~~~~~~~ 3765 | BUF_PUSH (wordend); | ~~~~~~~~~~~~~~~~~~~ 3766 | break; | ~~~~~~ 3767 | | 3768 | case 'b': | ~~~~~~~~~ 3769 | BUF_PUSH (wordbound); | ~~~~~~~~~~~~~~~~~~~~~ 3770 | break; | ~~~~~~ 3771 | | 3772 | case 'B': | ~~~~~~~~~ 3773 | BUF_PUSH (notwordbound); | ~~~~~~~~~~~~~~~~~~~~~~~~ 3774 | break; | ~~~~~~ 3775 | | 3776 | case '`': | ~~~~~~~~~ 3777 | BUF_PUSH (begbuf); | ~~~~~~~~~~~~~~~~~~ 3778 | break; | ~~~~~~ 3779 | | 3780 | case '\'': | ~~~~~~~~~~ 3781 | BUF_PUSH (endbuf); | ~~~~~~~~~~~~~~~~~~ 3782 | break; | ~~~~~~ 3783 | | 3784 | case '1': case '2': case '3': case '4': case '5': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3785 | case '6': case '7': case '8': case '9': | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3786 | { | ~ 3787 | regnum_t reg = -1, regint; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3788 | | 3789 | if (syntax & RE_NO_BK_REFS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3790 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3791 | | 3792 | PATUNFETCH; | ~~~~~~~~~~~ 3793 | GET_UNSIGNED_NUMBER (reg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3794 | | 3795 | /* Progressively divide down the backreference until we find | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3796 | one that corresponds to an existing register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3797 | while (reg > 10 && | ~~~~~~~~~~~~~~~~~~ 3798 | (syntax & RE_NO_MULTI_DIGIT_BK_REFS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3799 | || reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~ 3800 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3801 | == (int) 0xDEADBEEF))) | ~~~~~~~~~~~~~~~~~~~~~~ 3802 | | 3803 | { | ~ 3804 | PATUNFETCH; | ~~~~~~~~~~~ 3805 | reg /= 10; | ~~~~~~~~~~ 3806 | } | ~ 3807 | | 3808 | if (reg > bufp->re_nsub | ~~~~~~~~~~~~~~~~~~~~~~~ 3809 | || (bufp->external_to_internal_register[reg] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3810 | == (int) 0xDEADBEEF)) | ~~~~~~~~~~~~~~~~~~~~~ 3811 | { | ~ 3812 | /* \N with one digit with a non-existing group has always | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3813 | been a syntax error. | ~~~~~~~~~~~~~~~~~~~~ 3814 | | 3815 | GNU as of Fr 27 Mär 2020 16:24:07 GMT do not accept | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3816 | multidigit backreferences; if they did there would be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3817 | an argument for this not being an error for those | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3818 | backreferences that are less than some known named | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3819 | backreference. As it is currently we should error, this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3820 | will give those writing code for XEmacs better | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3821 | feedback. */ | ~~~~~~~~~~~~ 3822 | FREE_STACK_RETURN (REG_ESUBREG); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3823 | } | ~ 3824 | | 3825 | regint = bufp->external_to_internal_register[reg]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3826 | /* Can't back reference to a subexpression if inside of it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3827 | if (group_in_compile_stack (compile_stack, regint)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3828 | { | ~ 3829 | /* Check REG, not REGINT. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3830 | while (reg > 10) | ~~~~~~~~~~~~~~~~ 3831 | { | ~ 3832 | PATUNFETCH; | ~~~~~~~~~~~ 3833 | reg = reg / 10; | ~~~~~~~~~~~~~~~ 3834 | } | ~ 3835 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3836 | } | ~ 3837 | | 3838 | #ifdef emacs | ~~~~~~~~~~~~ 3839 | if (reg > 9 && | ~~~~~~~~~~~~~~ 3840 | bufp->warned_about_incompatible_back_references == 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3841 | { | ~ 3842 | bufp->warned_about_incompatible_back_references = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3843 | warn_when_safe (intern ("regex"), Qinfo, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3844 | "Back reference \\%d now has new " | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3845 | "semantics in %s", reg, pattern); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3846 | } | ~ 3847 | #endif | ~~~~~~ 3848 | | 3849 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3850 | GET_BUFFER_SPACE (3); | ~~~~~~~~~~~~~~~~~~~~~ 3851 | store_op1 (duplicate, buf_end, regint); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3852 | buf_end += 3; | ~~~~~~~~~~~~~ 3853 | } | ~ 3854 | break; | ~~~~~~ 3855 | | 3856 | | 3857 | case '+': | ~~~~~~~~~ 3858 | case '?': | ~~~~~~~~~ 3859 | if (syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3860 | goto handle_plus; | ~~~~~~~~~~~~~~~~~ 3861 | else | ~~~~ 3862 | goto normal_backslash; | ~~~~~~~~~~~~~~~~~~~~~~ 3863 | | 3864 | default: | ~~~~~~~~ 3865 | normal_backslash: | ~~~~~~~~~~~~~~~~~ 3866 | /* You might think it would be useful for \ to mean | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3867 | not to translate; but if we don't translate it, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3868 | it will never match anything. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3869 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 3870 | goto normal_char; | ~~~~~~~~~~~~~~~~~ 3871 | } | ~ 3872 | break; | ~~~~~~ 3873 | | 3874 | | 3875 | default: | ~~~~~~~~ 3876 | /* Expects the character in `c'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3877 | /* `p' points to the location after where `c' came from. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3878 | normal_char: | ~~~~~~~~~~~~ 3879 | { | ~ 3880 | /* The following conditional synced to GNU Emacs 22.1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3881 | /* If no exactn currently being built. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3882 | if (!pending_exact | ~~~~~~~~~~~~~~~~~~ 3883 | | 3884 | /* If last exactn not at current position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3885 | || pending_exact + *pending_exact + 1 != buf_end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3886 | | 3887 | /* We have only one byte following the exactn for the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3888 | || *pending_exact >= (1 << BYTEWIDTH) - MAX_ICHAR_LEN | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3889 | | 3890 | /* If followed by a repetition operator. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3891 | If the lookahead fails because of end of pattern, any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3892 | trailing backslash will get caught later. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3893 | || (p != pend && (*p == '*' || *p == '^')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3894 | || ((syntax & RE_BK_PLUS_QM) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3895 | ? p + 1 < pend && *p == '\\' && (p[1] == '+' || p[1] == '?') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3896 | : p != pend && (*p == '+' || *p == '?')) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3897 | || ((syntax & RE_INTERVALS) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3898 | && ((syntax & RE_NO_BK_BRACES) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3899 | ? p != pend && *p == '{' | ~~~~~~~~~~~~~~~~~~~~~~~~ 3900 | : p + 1 < pend && (p[0] == '\\' && p[1] == '{')))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3901 | { | ~ 3902 | /* Start building a new exactn. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3903 | | 3904 | laststart = buf_end; | ~~~~~~~~~~~~~~~~~~~~ 3905 | | 3906 | BUF_PUSH_2 (exactn, 0); | ~~~~~~~~~~~~~~~~~~~~~~~ 3907 | pending_exact = buf_end - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3908 | } | ~ 3909 | | 3910 | #ifndef MULE | ~~~~~~~~~~~~ 3911 | BUF_PUSH (c); | ~~~~~~~~~~~~~ 3912 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3913 | #else | ~~~~~ 3914 | { | ~ 3915 | Bytecount bt_count; | ~~~~~~~~~~~~~~~~~~~ 3916 | Ibyte tmp_buf[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3917 | int i; | ~~~~~~ 3918 | | 3919 | bt_count = set_itext_ichar (tmp_buf, c); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3920 | | 3921 | for (i = 0; i < bt_count; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3922 | { | ~ 3923 | BUF_PUSH (tmp_buf[i]); | ~~~~~~~~~~~~~~~~~~~~~~ 3924 | (*pending_exact)++; | ~~~~~~~~~~~~~~~~~~~ 3925 | } | ~ 3926 | } | ~ 3927 | #endif | ~~~~~~ 3928 | break; | ~~~~~~ 3929 | } | ~ 3930 | } /* switch (c) */ | ~~~~~~~~~~~~~~~~~~ 3931 | } /* while p != pend */ | ~~~~~~~~~~~~~~~~~~~~~~~ 3932 | | 3933 | | 3934 | /* Through the pattern now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3935 | | 3936 | if (fixup_alt_jump) | ~~~~~~~~~~~~~~~~~~~ 3937 | STORE_JUMP (jump_past_alt, fixup_alt_jump, buf_end); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3938 | | 3939 | if (!COMPILE_STACK_EMPTY) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 3940 | FREE_STACK_RETURN (REG_EPAREN); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3941 | | 3942 | /* If we don't want backtracking, force success | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3943 | the first time we reach the end of the compiled pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3944 | if (syntax & RE_NO_POSIX_BACKTRACKING) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3945 | BUF_PUSH (succeed); | ~~~~~~~~~~~~~~~~~~~ 3946 | | 3947 | xfree (compile_stack.stack); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3948 | | 3949 | /* We have succeeded; set the length of the buffer. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3950 | bufp->used = buf_end - bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3951 | | 3952 | #ifdef DEBUG | ~~~~~~~~~~~~ 3953 | if (debug_regexps & RE_DEBUG_COMPILATION) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3954 | { | ~ 3955 | DEBUG_PRINT1 ("\nCompiled pattern: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3956 | print_compiled_pattern (bufp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3957 | } | ~ 3958 | #endif /* DEBUG */ | ~~~~~~~~~~~~~~~~~~ 3959 | | 3960 | #ifndef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3961 | /* Initialize the failure stack to the largest possible stack. This | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3962 | isn't necessary unless we're trying to avoid calling alloca in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3963 | the search and match routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3964 | { | ~ 3965 | int num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3966 | | 3967 | /* Since DOUBLE_FAIL_STACK refuses to double only if the current size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3968 | is strictly greater than re_max_failures, the largest possible stack | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3969 | is 2 * re_max_failures failure points. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3970 | if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3971 | { | ~ 3972 | fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3973 | | 3974 | if (! fail_stack.stack) | ~~~~~~~~~~~~~~~~~~~~~~~ 3975 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3976 | = (fail_stack_elt_t *) xmalloc (fail_stack.size | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3977 | * sizeof (fail_stack_elt_t)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3978 | else | ~~~~ 3979 | fail_stack.stack | ~~~~~~~~~~~~~~~~ 3980 | = (fail_stack_elt_t *) xrealloc (fail_stack.stack, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3981 | (fail_stack.size | ~~~~~~~~~~~~~~~~ 3982 | * sizeof (fail_stack_elt_t))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3983 | } | ~ 3984 | | 3985 | regex_grow_registers (num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3986 | } | ~ 3987 | #endif /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3988 | | 3989 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 3990 | } /* regex_compile */ | ~~~~~~~~~~~~~~~~~~~~~ 3991 | | ~ 3992 | /* Subroutines for `regex_compile'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3993 | | 3994 | /* Store OP at LOC followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3995 | | 3996 | static void | ~~~~~~~~~~~ 3997 | store_op1 (re_opcode_t op, unsigned char *loc, int arg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3998 | { | ~ 3999 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4000 | STORE_NUMBER (loc + 1, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4001 | } | ~ 4002 | | 4003 | | 4004 | /* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4005 | | 4006 | static void | ~~~~~~~~~~~ 4007 | store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4008 | { | ~ 4009 | *loc = (unsigned char) op; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4010 | STORE_NUMBER (loc + 1, arg1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4011 | STORE_NUMBER (loc + 3, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4012 | } | ~ 4013 | | 4014 | | 4015 | /* Copy the bytes from LOC to END to open up three bytes of space at LOC | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4016 | for OP followed by two-byte integer parameter ARG. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4017 | | 4018 | static void | ~~~~~~~~~~~ 4019 | insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4020 | { | ~ 4021 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4022 | REGISTER unsigned char *pto = end + 3; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4023 | | 4024 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4025 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4026 | | 4027 | store_op1 (op, loc, arg); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4028 | } | ~ 4029 | | 4030 | | 4031 | /* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4032 | | 4033 | static void | ~~~~~~~~~~~ 4034 | insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4035 | unsigned char *end) | ~~~~~~~~~~~~~~~~~~~ 4036 | { | ~ 4037 | REGISTER unsigned char *pfrom = end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4038 | REGISTER unsigned char *pto = end + 5; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4039 | | 4040 | while (pfrom != loc) | ~~~~~~~~~~~~~~~~~~~~ 4041 | *--pto = *--pfrom; | ~~~~~~~~~~~~~~~~~~ 4042 | | 4043 | store_op2 (op, loc, arg1, arg2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4044 | } | ~ 4045 | | 4046 | | 4047 | /* P points to just after a ^ in PATTERN. Return true if that ^ comes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4048 | after an alternative or a begin-subexpression. We assume there is at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4049 | least one character before the ^. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4050 | | 4051 | static re_bool | ~~~~~~~~~~~~~~ 4052 | at_begline_loc_p (re_char *pattern, re_char *p, reg_syntax_t syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4053 | { | ~ 4054 | re_char *prev = p - 2; | ~~~~~~~~~~~~~~~~~~~~~~ 4055 | re_bool prev_prev_backslash = prev > pattern && prev[-1] == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4056 | | 4057 | return | ~~~~~~ 4058 | /* After a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4059 | (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4060 | /* After an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4061 | || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4062 | } | ~ 4063 | | 4064 | | 4065 | /* The dual of at_begline_loc_p. This one is for $. We assume there is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4066 | at least one character after the $, i.e., `P < PEND'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4067 | | 4068 | static re_bool | ~~~~~~~~~~~~~~ 4069 | at_endline_loc_p (re_char *p, re_char *pend, int syntax) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4070 | { | ~ 4071 | re_char *next = p; | ~~~~~~~~~~~~~~~~~~ 4072 | re_bool next_backslash = *next == '\\'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4073 | re_char *next_next = p + 1 < pend ? p + 1 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4074 | | 4075 | return | ~~~~~~ 4076 | /* Before a subexpression? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4077 | (syntax & RE_NO_BK_PARENS ? *next == ')' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4078 | : next_backslash && next_next && *next_next == ')') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4079 | /* Before an alternative? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4080 | || (syntax & RE_NO_BK_VBAR ? *next == '|' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4081 | : next_backslash && next_next && *next_next == '|'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4082 | } | ~ 4083 | | 4084 | | 4085 | /* Returns true if REGNUM is in one of COMPILE_STACK's elements and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4086 | false if it's not. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4087 | | 4088 | static re_bool | ~~~~~~~~~~~~~~ 4089 | group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4090 | { | ~ 4091 | int this_element; | ~~~~~~~~~~~~~~~~~ 4092 | | 4093 | for (this_element = compile_stack.avail - 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4094 | this_element >= 0; | ~~~~~~~~~~~~~~~~~~ 4095 | this_element--) | ~~~~~~~~~~~~~~~ 4096 | if (compile_stack.stack[this_element].regnum == regnum) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4097 | return true; | ~~~~~~~~~~~~ 4098 | | 4099 | return false; | ~~~~~~~~~~~~~ 4100 | } | ~ 4101 | | 4102 | | 4103 | /* Read the ending character of a range (in a bracket expression) from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4104 | uncompiled pattern *P_PTR (which ends at PEND). We assume the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4105 | starting character is in `P[-2]'. (`P[-1]' is the character `-'.) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4106 | Then we set the translation of all bits between the starting and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4107 | ending characters (inclusive) in the compiled pattern B. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4108 | | 4109 | Return an error code. | ~~~~~~~~~~~~~~~~~~~~~ 4110 | | 4111 | We use these short variable names so we can use the same macros as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4112 | `regex_compile' itself. | ~~~~~~~~~~~~~~~~~~~~~~~ 4113 | | 4114 | Under Mule, this is only called when both chars of the range are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4115 | ASCII. */ | ~~~~~~~~~ 4116 | | 4117 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4118 | compile_range (re_char **p_ptr, re_char *pend, RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4119 | reg_syntax_t syntax, unsigned char *buf_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4120 | { | ~ 4121 | Ichar this_char; | ~~~~~~~~~~~~~~~~ 4122 | | 4123 | re_char *p = *p_ptr; | ~~~~~~~~~~~~~~~~~~~~ 4124 | int range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4125 | | 4126 | if (p == pend) | ~~~~~~~~~~~~~~ 4127 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4128 | | 4129 | /* Even though the pattern is a signed `char *', we need to fetch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4130 | with unsigned char *'s; if the high bit of the pattern character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4131 | is set, the range endpoints will be negative if we fetch using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4132 | signed char *. | ~~~~~~~~~~~~~~ 4133 | | 4134 | We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4135 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4136 | /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4137 | range_start = ((const unsigned char *) p)[-2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4138 | range_end = ((const unsigned char *) p)[0]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4139 | | 4140 | /* Have to increment the pointer into the pattern string, so the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4141 | caller isn't still at the ending character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4142 | (*p_ptr)++; | ~~~~~~~~~~~ 4143 | | 4144 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4145 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4146 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4147 | | 4148 | /* Here we see why `this_char' has to be larger than an `unsigned | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4149 | char' -- the range is inclusive, so if `range_end' == 0xff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4150 | (assuming 8-bit characters), we would otherwise go into an infinite | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4151 | loop, since all characters <= 0xff. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4152 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4153 | { | ~ 4154 | SET_LIST_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4155 | } | ~ 4156 | | 4157 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4158 | } | ~ 4159 | | 4160 | #ifdef MULE | ~~~~~~~~~~~ 4161 | | 4162 | static reg_errcode_t | ~~~~~~~~~~~~~~~~~~~~ 4163 | compile_extended_range (re_char **p_ptr, re_char *pend, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4164 | RE_TRANSLATE_TYPE translate, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4165 | reg_syntax_t syntax, Lisp_Object rtab) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4166 | { | ~ 4167 | Ichar this_char, range_start, range_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4168 | const Ibyte *p; | ~~~~~~~~~~~~~~~ 4169 | | 4170 | if (*p_ptr == pend) | ~~~~~~~~~~~~~~~~~~~ 4171 | return REG_ERANGE; | ~~~~~~~~~~~~~~~~~~ 4172 | | 4173 | p = (const Ibyte *) *p_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4174 | range_end = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4175 | p--; /* back to '-' */ | ~~~~~~~~~~~~~~~~~~~~~~ 4176 | DEC_IBYTEPTR (p); /* back to start of range */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4177 | /* We also want to fetch the endpoints without translating them; the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4178 | appropriate translation is done in the bit-setting loop below. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4179 | range_start = itext_ichar (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4180 | INC_IBYTEPTR (*p_ptr); | ~~~~~~~~~~~~~~~~~~~~~~ 4181 | | 4182 | /* If the start is after the end, the range is empty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4183 | if (range_start > range_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4184 | return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4185 | | 4186 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4187 | /* Can't have ranges spanning different charsets, except maybe for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4188 | ranges entirely within the first 256 chars. (The intent of this is that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4189 | the effect of such a range would be unpredictable, since there is no | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4190 | well-defined ordering over charsets and the particular assignment of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4191 | charset ID's is arbitrary.) This does not apply to Unicode, with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4192 | well-defined character values. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4193 | | 4194 | if ((range_start >= 0x100 || range_end >= 0x100) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4195 | && !EQ (old_mule_ichar_charset (range_start), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4196 | old_mule_ichar_charset (range_end))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4197 | return REG_ERANGESPAN; | ~~~~~~~~~~~~~~~~~~~~~~ 4198 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4199 | | 4200 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4201 | { | ~ 4202 | /* #### This might be way inefficient if the range encompasses 10,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4203 | chars or something. To be efficient, you'd have to do something like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4204 | this: | ~~~~~ 4205 | | 4206 | range_table a | ~~~~~~~~~~~~~ 4207 | range_table b; | ~~~~~~~~~~~~~~ 4208 | map_char_table (translation table, [range_start, range_end]) of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4209 | lambda (ch, translation): | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4210 | put (ch, Qt) in a | ~~~~~~~~~~~~~~~~~ 4211 | put (translation, Qt) in b | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4212 | invert the range in a and truncate to [range_start, range_end] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4213 | put the union of a, b in rtab | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4214 | | 4215 | This is to say, we want to map every character that has a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4216 | to its translation, and other characters to themselves. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4217 | | 4218 | This assumes, as is reasonable in practice, that a translation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4219 | table maps individual characters to their translation, and does | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4220 | not generally map multiple characters to the same translation. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4221 | */ | ~~ 4222 | for (this_char = range_start; this_char <= range_end; this_char++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4223 | { | ~ 4224 | SET_RANGETAB_BIT (RE_TRANSLATE (this_char)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4225 | } | ~ 4226 | } | ~ 4227 | else | ~~~~ 4228 | put_range_table (rtab, range_start, range_end, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4229 | | 4230 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4231 | } | ~ 4232 | | 4233 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4234 | | 4235 | #ifdef emacs | ~~~~~~~~~~~~ 4236 | | 4237 | reg_errcode_t | ~~~~~~~~~~~~~ 4238 | compile_char_class (re_wctype_t cc, Lisp_Object rtab, Bitbyte *flags_out) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4239 | { | ~ 4240 | *flags_out |= re_wctype_to_bit (cc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4241 | | 4242 | switch (cc) | ~~~~~~~~~~~ 4243 | { | ~ 4244 | case RECC_ASCII: | ~~~~~~~~~~~~~~~~ 4245 | put_range_table (rtab, 0, 0x7f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4246 | break; | ~~~~~~ 4247 | | 4248 | case RECC_XDIGIT: | ~~~~~~~~~~~~~~~~~ 4249 | put_range_table (rtab, 'a', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4250 | put_range_table (rtab, 'A', 'f', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4251 | /* fallthrough */ | ~~~~~~~~~~~~~~~~~ 4252 | case RECC_DIGIT: | ~~~~~~~~~~~~~~~~ 4253 | put_range_table (rtab, '0', '9', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4254 | break; | ~~~~~~ 4255 | | 4256 | case RECC_BLANK: | ~~~~~~~~~~~~~~~~ 4257 | put_range_table (rtab, ' ', ' ', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4258 | put_range_table (rtab, '\t', '\t', Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4259 | break; | ~~~~~~ 4260 | | 4261 | case RECC_PRINT: | ~~~~~~~~~~~~~~~~ 4262 | put_range_table (rtab, ' ', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4263 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4264 | break; | ~~~~~~ 4265 | | 4266 | case RECC_GRAPH: | ~~~~~~~~~~~~~~~~ 4267 | put_range_table (rtab, '!', 0x7e, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4268 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4269 | break; | ~~~~~~ 4270 | | 4271 | case RECC_NONASCII: | ~~~~~~~~~~~~~~~~~~~ 4272 | case RECC_MULTIBYTE: | ~~~~~~~~~~~~~~~~~~~~ 4273 | put_range_table (rtab, 0x80, CHAR_CODE_LIMIT, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4274 | break; | ~~~~~~ 4275 | | 4276 | case RECC_CNTRL: | ~~~~~~~~~~~~~~~~ 4277 | put_range_table (rtab, 0x00, 0x1f, Qt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4278 | break; | ~~~~~~ 4279 | | 4280 | case RECC_UNIBYTE: | ~~~~~~~~~~~~~~~~~~ 4281 | /* Never true in XEmacs. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4282 | break; | ~~~~~~ 4283 | | 4284 | /* The following all have their own bits in the class_bits argument to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4285 | charset_mule and charset_mule_not, they don't use the range table | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4286 | information. */ | ~~~~~~~~~~~~~~~ 4287 | case RECC_ALPHA: | ~~~~~~~~~~~~~~~~ 4288 | case RECC_WORD: | ~~~~~~~~~~~~~~~ 4289 | case RECC_ALNUM: /* Equivalent to RECC_WORD */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4290 | case RECC_LOWER: | ~~~~~~~~~~~~~~~~ 4291 | case RECC_PUNCT: | ~~~~~~~~~~~~~~~~ 4292 | case RECC_SPACE: | ~~~~~~~~~~~~~~~~ 4293 | case RECC_UPPER: | ~~~~~~~~~~~~~~~~ 4294 | break; | ~~~~~~ 4295 | } | ~ 4296 | | 4297 | return REG_NOERROR; | ~~~~~~~~~~~~~~~~~~~ 4298 | } | ~ 4299 | | 4300 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4301 | | ~ 4302 | /* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4303 | BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4304 | characters can start a string that matches the pattern. This fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4305 | is used by re_search to skip quickly over impossible starting points. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4306 | | 4307 | The caller must supply the address of a (1 << BYTEWIDTH)-byte data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4308 | area as BUFP->fastmap. | ~~~~~~~~~~~~~~~~~~~~~~ 4309 | | 4310 | We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4311 | the pattern buffer. | ~~~~~~~~~~~~~~~~~~~ 4312 | | 4313 | Returns 0 if we succeed, -2 if an internal error. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4314 | | 4315 | int | ~~~ 4316 | re_compile_fastmap (struct re_pattern_buffer *bufp | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4317 | RE_LISP_SHORT_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4318 | { | ~ 4319 | int j, k; | ~~~~~~~~~ 4320 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4321 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4322 | #endif | ~~~~~~ 4323 | /* We don't push any register information onto the failure stack. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4324 | | 4325 | /* &&#### this should be changed for 8-bit-fixed, for efficiency. see | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4326 | comment marked with &&#### in re_search_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4327 | | 4328 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4329 | unsigned char *pattern = bufp->buffer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4330 | long size = bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~ 4331 | re_char *p = pattern; | ~~~~~~~~~~~~~~~~~~~~~ 4332 | REGISTER re_char *pend = pattern + size; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4333 | | 4334 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 4335 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4336 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4337 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4338 | #endif | ~~~~~~ 4339 | | 4340 | /* Assume that each path through the pattern can be null until | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4341 | proven otherwise. We set this false at the bottom of switch | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4342 | statement, to which we get only if a particular path doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4343 | match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4344 | re_bool path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4345 | | 4346 | /* We aren't doing a `succeed_n' to begin with. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4347 | re_bool succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4348 | | 4349 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4350 | /* The pattern comes from string data, not buffer data. We don't access | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4351 | any buffer data, so we don't have to worry about malloc() (but the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4352 | disallowed flag may have been set by a caller). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4353 | int depth = bind_regex_malloc_disallowed (0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4354 | #endif | ~~~~~~ 4355 | | 4356 | assert (fastmap != NULL && p != NULL); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4357 | | 4358 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 4359 | memset (fastmap, 0, 1 << BYTEWIDTH); /* Assume nothing's valid. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4360 | bufp->fastmap_accurate = 1; /* It will be when we're done. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4361 | bufp->can_be_null = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4362 | | 4363 | while (1) | ~~~~~~~~~ 4364 | { | ~ 4365 | if (p == pend || *p == succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4366 | { | ~ 4367 | /* We have reached the (effective) end of pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4368 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4369 | { | ~ 4370 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4371 | | 4372 | /* Reset for next path. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4373 | path_can_be_null = true; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4374 | | 4375 | p = (unsigned char *) fail_stack.stack[--fail_stack.avail].pointer; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4376 | | 4377 | continue; | ~~~~~~~~~ 4378 | } | ~ 4379 | else | ~~~~ 4380 | break; | ~~~~~~ 4381 | } | ~ 4382 | | 4383 | /* We should never be about to go beyond the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4384 | assert (p < pend); | ~~~~~~~~~~~~~~~~~~ 4385 | | 4386 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4387 | { | ~ 4388 | | 4389 | /* I guess the idea here is to simply not bother with a fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4390 | if a backreference is used, since it's too hard to figure out | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4391 | the fastmap for the corresponding group. Setting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4392 | `can_be_null' stops `re_search_2' from using the fastmap, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4393 | that is all we do. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4394 | case duplicate: | ~~~~~~~~~~~~~~~ 4395 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4396 | goto done; | ~~~~~~~~~~ 4397 | | 4398 | | 4399 | /* Following are the cases which match a character. These end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4400 | with `break'. */ | ~~~~~~~~~~~~~~~~~ 4401 | | 4402 | case exactn: | ~~~~~~~~~~~~ 4403 | fastmap[p[1]] = 1; | ~~~~~~~~~~~~~~~~~~ 4404 | break; | ~~~~~~ 4405 | | 4406 | | 4407 | case charset: | ~~~~~~~~~~~~~ 4408 | /* XEmacs: Under Mule, these bit vectors will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4409 | only contain values for characters below 0x80. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4410 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4411 | if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4412 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4413 | break; | ~~~~~~ 4414 | | 4415 | | 4416 | case charset_not: | ~~~~~~~~~~~~~~~~~ 4417 | /* Chars beyond end of map must be allowed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4418 | #ifdef MULE | ~~~~~~~~~~~ 4419 | for (j = *p * BYTEWIDTH; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4420 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4421 | /* And all extended characters must be allowed, too. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4422 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4423 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4424 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4425 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4426 | for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4427 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4428 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4429 | | 4430 | for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4431 | if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4432 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4433 | break; | ~~~~~~ 4434 | | 4435 | #ifdef MULE | ~~~~~~~~~~~ 4436 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 4437 | { | ~ 4438 | int nentries; | ~~~~~~~~~~~~~ 4439 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4440 | | 4441 | if (flags) | ~~~~~~~~~~ 4442 | { | ~ 4443 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4444 | work. */ | ~~~~~~~~ 4445 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4446 | goto done; | ~~~~~~~~~~ 4447 | } | ~ 4448 | | 4449 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4450 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4451 | { | ~ 4452 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4453 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4454 | int jj; | ~~~~~~~ 4455 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4456 | | 4457 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4458 | &dummy_val); | ~~~~~~~~~~~~ 4459 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4460 | for (jj = first; jj <= last && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4461 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4462 | /* Ranges below 0x100 can span charsets, but there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4463 | are only two (Control-1 and Latin-1), and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4464 | either first or last has to be in them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4465 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4466 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4467 | if (last < 0x100) | ~~~~~~~~~~~~~~~~~ 4468 | { | ~ 4469 | set_itext_ichar (strr, last); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4470 | fastmap[*strr] = 1; | ~~~~~~~~~~~~~~~~~~~ 4471 | } | ~ 4472 | else if (CHAR_CODE_LIMIT == last) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4473 | { | ~ 4474 | /* This is RECC_MULTIBYTE or RECC_NONASCII; true for all | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4475 | non-ASCII characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 4476 | jj = 0x80; | ~~~~~~~~~~ 4477 | while (jj < 0xA0) | ~~~~~~~~~~~~~~~~~ 4478 | { | ~ 4479 | fastmap[jj++] = 1; | ~~~~~~~~~~~~~~~~~~ 4480 | } | ~ 4481 | } | ~ 4482 | #else | ~~~~~ 4483 | /* Ranges can span charsets. We depend on the fact that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4484 | lead bytes are monotonically non-decreasing as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4485 | character values increase. @@#### This is a fairly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4486 | reasonable assumption in general (but DOES NOT WORK in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4487 | old Mule due to the ordering of private dimension-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4488 | chars before official dimension-2 chars), and introduces | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4489 | a dependency on the particular representation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4490 | { | ~ 4491 | Ibyte strrlast[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4492 | set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4493 | set_itext_ichar (strrlast, min (last, CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4494 | for (jj = *strr; jj <= *strrlast; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4495 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4496 | } | ~ 4497 | #endif /* not UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4498 | } | ~ 4499 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4500 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4501 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4502 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4503 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4504 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4505 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4506 | } | ~ 4507 | break; | ~~~~~~ 4508 | | 4509 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 4510 | { | ~ 4511 | int nentries; | ~~~~~~~~~~~~~ 4512 | int smallest_prev = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 4513 | Bitbyte flags = *p++; | ~~~~~~~~~~~~~~~~~~~~~ 4514 | | 4515 | if (flags) | ~~~~~~~~~~ 4516 | { | ~ 4517 | /* We need to consult the syntax table, fastmap won't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4518 | work. */ | ~~~~~~~~ 4519 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4520 | goto done; | ~~~~~~~~~~ 4521 | } | ~ 4522 | | 4523 | nentries = unified_range_table_nentries ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4524 | #ifndef UNICODE_INTERNAL | ~~~~~~~~~~~~~~~~~~~~~~~~ 4525 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4526 | { | ~ 4527 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4528 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4529 | int jj; | ~~~~~~~ 4530 | | 4531 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4532 | &dummy_val); | ~~~~~~~~~~~~ 4533 | for (jj = smallest_prev; jj < first && jj < 0x80; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4534 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4535 | smallest_prev = last + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4536 | if (smallest_prev >= 0x80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4537 | break; | ~~~~~~ 4538 | } | ~ 4539 | | 4540 | /* Also set lead bytes after the end */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4541 | for (j = smallest_prev; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4542 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4543 | | 4544 | /* Calculating which lead bytes are actually allowed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4545 | here is rather difficult, so we just punt and allow | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4546 | all of them. | ~~~~~~~~~~~~ 4547 | */ | ~~ 4548 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4549 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4550 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4551 | #else | ~~~~~ 4552 | for (j = 0; j < nentries; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4553 | { | ~ 4554 | EMACS_INT first, last; | ~~~~~~~~~~~~~~~~~~~~~~ 4555 | /* This denotes a range of lead bytes that are not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4556 | in the fastmap. */ | ~~~~~~~~~~~~~~~~~~ 4557 | int firstlead, lastlead; | ~~~~~~~~~~~~~~~~~~~~~~~~ 4558 | Lisp_Object dummy_val; | ~~~~~~~~~~~~~~~~~~~~~~ 4559 | int jj; | ~~~~~~~ 4560 | | 4561 | unified_range_table_get_range ((void *) p, j, &first, &last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4562 | &dummy_val); | ~~~~~~~~~~~~ 4563 | /* With Unicode-internal, lead bytes that are entirely | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4564 | within the range and not including the beginning or end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4565 | are definitely not in the fastmap. Leading bytes that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4566 | include the beginning or ending characters will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4567 | the fastmap unless the beginning or ending characters | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4568 | are the first or last character, respectively, that uses | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4569 | this lead byte. | ~~~~~~~~~~~~~~~ 4570 | | 4571 | @@#### WARNING! In order to determine whether we are the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4572 | first or last character using a lead byte we use and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4573 | embed in the code some knowledge of how UTF-8 works -- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4574 | at least, the fact that the the first character using a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4575 | particular lead byte has the minimum-numbered trailing | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4576 | byte in all its trailing bytes, and the last character | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4577 | using a particular lead byte has the maximum-numbered | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4578 | trailing byte in all its trailing bytes. We abstract | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4579 | away the actual minimum/maximum trailing byte numbers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4580 | at least. We could perhaps do this more portably by | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4581 | just looking at the representation of the character one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4582 | higher or lower and seeing if the lead byte changes, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4583 | you'd run into the problem of invalid characters, e.g. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4584 | if you're at the edge of the range of surrogates or are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4585 | the top-most allowed character. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4586 | */ | ~~ 4587 | if (first < 0x80) | ~~~~~~~~~~~~~~~~~ 4588 | firstlead = first; | ~~~~~~~~~~~~~~~~~~ 4589 | else | ~~~~ 4590 | { | ~ 4591 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4592 | Bytecount slen = set_itext_ichar (strr, first); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4593 | int kk; | ~~~~~~~ 4594 | /* Determine if we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4595 | leading byte. */ | ~~~~~~~~~~~~~~~~ 4596 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4597 | if (strr[kk] != FIRST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4598 | { | ~ 4599 | /* If not, this leading byte might occur, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4600 | make sure it gets added to the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4601 | firstlead = *strr + 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4602 | break; | ~~~~~~ 4603 | } | ~ 4604 | /* Otherwise, we're the first character using our | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4605 | leading byte, and we don't need to add the leading | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4606 | byte to the fastmap. (If our range doesn't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4607 | completely cover the leading byte, it will get added | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4608 | anyway by the code handling the other end of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4609 | range.) */ | ~~~~~~~~~~ 4610 | firstlead = *strr; | ~~~~~~~~~~~~~~~~~~ 4611 | } | ~ 4612 | if (last < 0x80) | ~~~~~~~~~~~~~~~~ 4613 | lastlead = last; | ~~~~~~~~~~~~~~~~ 4614 | else | ~~~~ 4615 | { | ~ 4616 | Ibyte strr[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4617 | Bytecount slen | ~~~~~~~~~~~~~~ 4618 | = set_itext_ichar (strr, | ~~~~~~~~~~~~~~~~~~~~~~~~ 4619 | min (last, | ~~~~~~~~~~ 4620 | CHAR_CODE_LIMIT - 1)); | ~~~~~~~~~~~~~~~~~~~~~~ 4621 | int kk; | ~~~~~~~ 4622 | /* Same as above but for the last character using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4623 | our leading byte. */ | ~~~~~~~~~~~~~~~~~~~~ 4624 | for (kk = 1; kk < slen; kk++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4625 | if (strr[kk] != LAST_TRAILING_BYTE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4626 | { | ~ 4627 | lastlead = *strr - 1; | ~~~~~~~~~~~~~~~~~~~~~ 4628 | break; | ~~~~~~ 4629 | } | ~ 4630 | lastlead = *strr; | ~~~~~~~~~~~~~~~~~ 4631 | } | ~ 4632 | /* Now, FIRSTLEAD and LASTLEAD are set to the beginning and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4633 | end, inclusive, of a range of lead bytes that cannot be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4634 | in the fastmap. Essentially, we want to set all the other | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4635 | bytes to be in the fastmap. Here we handle those after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4636 | the previous range and before this one. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4637 | for (jj = smallest_prev; jj < firstlead; jj++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4638 | fastmap[jj] = 1; | ~~~~~~~~~~~~~~~~ 4639 | smallest_prev = lastlead + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4640 | } | ~ 4641 | | 4642 | /* Also set lead bytes after the end of the final range. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4643 | for (j = smallest_prev; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4644 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4645 | | 4646 | /* If it's not a possible first byte, it can't be in the fastmap. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4647 | In UTF-8, lead bytes are not contiguous with ASCII, so a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4648 | range spanning the ASCII/non-ASCII boundary will put | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4649 | extraneous bytes in the range [0x80 - 0xBF] in the fastmap. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4650 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4651 | if (!ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4652 | fastmap[j] = 0; | ~~~~~~~~~~~~~~~ 4653 | #endif /* UNICODE_INTERNAL */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4654 | } | ~ 4655 | break; | ~~~~~~ 4656 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4657 | | 4658 | | 4659 | case anychar: | ~~~~~~~~~~~~~ 4660 | { | ~ 4661 | int fastmap_newline = fastmap['\n']; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4662 | | 4663 | /* `.' matches anything ... */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4664 | #ifdef MULE | ~~~~~~~~~~~ 4665 | /* "anything" only includes bytes that can be the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4666 | first byte of a character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4667 | for (j = 0; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4668 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4669 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4670 | #else | ~~~~~ 4671 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4672 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4673 | #endif | ~~~~~~ 4674 | | 4675 | /* ... except perhaps newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4676 | if (!(bufp->syntax & RE_DOT_NEWLINE)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4677 | fastmap['\n'] = fastmap_newline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4678 | | 4679 | /* Return if we have already set `can_be_null'; if we have, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4680 | then the fastmap is irrelevant. Something's wrong here. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4681 | else if (bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4682 | goto done; | ~~~~~~~~~~ 4683 | | 4684 | /* Otherwise, have to check alternative paths. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4685 | break; | ~~~~~~ 4686 | } | ~ 4687 | | 4688 | #ifndef emacs | ~~~~~~~~~~~~~ 4689 | case wordchar: | ~~~~~~~~~~~~~~ 4690 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4691 | if (SYNTAX (ignored, j) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4692 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4693 | break; | ~~~~~~ 4694 | | 4695 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4696 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4697 | if (SYNTAX (ignored, j) != Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4698 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4699 | break; | ~~~~~~ 4700 | #else /* emacs */ | ~~~~~~~~~~~~~~~~~ 4701 | case wordchar: | ~~~~~~~~~~~~~~ 4702 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4703 | case wordbound: | ~~~~~~~~~~~~~~~ 4704 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4705 | case wordbeg: | ~~~~~~~~~~~~~ 4706 | case wordend: | ~~~~~~~~~~~~~ 4707 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4708 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4709 | /* This match depends on text properties. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4710 | aborting optimizations. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4711 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4712 | goto done; | ~~~~~~~~~~ 4713 | #if 0 /* all of the following code is unused now that the `syntax-table' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4714 | property exists -- it's trickier to do this than just look in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4715 | the buffer. &&#### but we could just use the syntax-cache stuff | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4716 | instead; why don't we? --ben */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4717 | case wordchar: | ~~~~~~~~~~~~~~ 4718 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4719 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 4720 | | 4721 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 4722 | k = (int) Sword; | ~~~~~~~~~~~~~~~~ 4723 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 4724 | | 4725 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 4726 | k = *p++; | ~~~~~~~~~ 4727 | matchsyntax: | ~~~~~~~~~~~~ 4728 | #ifdef MULE | ~~~~~~~~~~~ 4729 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4730 | if (SYNTAX | ~~~~~~~~~~ 4731 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4732 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4733 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4734 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4735 | lead byte any of whose characters can have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4736 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4737 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4738 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4739 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4740 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4741 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4742 | if (SYNTAX | ~~~~~~~~~~ 4743 | (XCHAR_TABLE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4744 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4745 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4746 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4747 | break; | ~~~~~~ 4748 | | 4749 | | 4750 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 4751 | k = *p++; | ~~~~~~~~~ 4752 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 4753 | #ifdef MULE | ~~~~~~~~~~~ 4754 | for (j = 0; j < 0x80; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4755 | if (SYNTAX | ~~~~~~~~~~ 4756 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4757 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4758 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4759 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4760 | /* @@#### To be correct, we need to set the fastmap for any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4761 | lead byte all of whose characters do not have this syntax code. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4762 | This is hard to calculate so we just punt for now. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4763 | for (j = 0x80; j < 0x100; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4764 | if (ibyte_first_byte_p (j)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4765 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4766 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 4767 | for (j = 0; j < (1 << BYTEWIDTH); j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4768 | if (SYNTAX | ~~~~~~~~~~ 4769 | (XCHAR_TABLE | ~~~~~~~~~~~~ 4770 | (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf)), j) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4771 | (enum syntaxcode) k) | ~~~~~~~~~~~~~~~~~~~~ 4772 | fastmap[j] = 1; | ~~~~~~~~~~~~~~~ 4773 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4774 | break; | ~~~~~~ 4775 | #endif /* 0 */ | ~~~~~~~~~~~~~~ 4776 | | 4777 | #ifdef MULE | ~~~~~~~~~~~ 4778 | /* 97/2/17 jhod category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4779 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 4780 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 4781 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4782 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4783 | return 0; | ~~~~~~~~~ 4784 | /* end if category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4785 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 4786 | | 4787 | /* All cases after this match the empty string. These end with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4788 | `continue'. */ | ~~~~~~~~~~~~~~~ 4789 | case before_dot: | ~~~~~~~~~~~~~~~~ 4790 | case at_dot: | ~~~~~~~~~~~~ 4791 | case after_dot: | ~~~~~~~~~~~~~~~ 4792 | continue; | ~~~~~~~~~ 4793 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 4794 | | 4795 | | 4796 | case no_op: | ~~~~~~~~~~~ 4797 | case begline: | ~~~~~~~~~~~~~ 4798 | case endline: | ~~~~~~~~~~~~~ 4799 | case begbuf: | ~~~~~~~~~~~~ 4800 | case endbuf: | ~~~~~~~~~~~~ 4801 | #ifndef emacs | ~~~~~~~~~~~~~ 4802 | case wordbound: | ~~~~~~~~~~~~~~~ 4803 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 4804 | case wordbeg: | ~~~~~~~~~~~~~ 4805 | case wordend: | ~~~~~~~~~~~~~ 4806 | #endif | ~~~~~~ 4807 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4808 | continue; | ~~~~~~~~~ 4809 | | 4810 | | 4811 | case jump_n: | ~~~~~~~~~~~~ 4812 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 4813 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 4814 | case jump: | ~~~~~~~~~~ 4815 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 4816 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 4817 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4818 | p += j; | ~~~~~~~ 4819 | if (j > 0) | ~~~~~~~~~~ 4820 | continue; | ~~~~~~~~~ 4821 | | 4822 | /* Jump backward implies we just went through the body of a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4823 | loop and matched nothing. Opcode jumped to should be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4824 | `on_failure_jump' or `succeed_n'. Just treat it like an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4825 | ordinary jump. For a * loop, it has pushed its failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4826 | point already; if so, discard that as redundant. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4827 | if ((re_opcode_t) *p != on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4828 | && (re_opcode_t) *p != succeed_n) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4829 | continue; | ~~~~~~~~~ 4830 | | 4831 | p++; | ~~~~ 4832 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4833 | p += j; | ~~~~~~~ 4834 | | 4835 | /* If what's on the stack is where we are now, pop it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4836 | if (!FAIL_STACK_EMPTY () | ~~~~~~~~~~~~~~~~~~~~~~~~ 4837 | && fail_stack.stack[fail_stack.avail - 1].pointer == p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4838 | fail_stack.avail--; | ~~~~~~~~~~~~~~~~~~~ 4839 | | 4840 | continue; | ~~~~~~~~~ 4841 | | 4842 | | 4843 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 4844 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4845 | handle_on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~ 4846 | EXTRACT_NUMBER_AND_INCR (j, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4847 | | 4848 | /* For some patterns, e.g., `(a?)?', `p+j' here points to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4849 | end of the pattern. We don't want to push such a point, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4850 | since when we restore it above, entering the switch will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4851 | increment `p' past the end of the pattern. We don't need | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4852 | to push such a point since we obviously won't find any more | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4853 | fastmap entries beyond `pend'. Such a pattern can match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4854 | the null string, though. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4855 | if (p + j < pend) | ~~~~~~~~~~~~~~~~~ 4856 | { | ~ 4857 | if (!PUSH_PATTERN_OP (p + j, fail_stack)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4858 | { | ~ 4859 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4860 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4861 | return -2; | ~~~~~~~~~~ 4862 | } | ~ 4863 | } | ~ 4864 | else | ~~~~ 4865 | bufp->can_be_null = 1; | ~~~~~~~~~~~~~~~~~~~~~~ 4866 | | 4867 | if (succeed_n_p) | ~~~~~~~~~~~~~~~~ 4868 | { | ~ 4869 | EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4870 | succeed_n_p = false; | ~~~~~~~~~~~~~~~~~~~~ 4871 | } | ~ 4872 | | 4873 | continue; | ~~~~~~~~~ 4874 | | 4875 | | 4876 | case succeed_n: | ~~~~~~~~~~~~~~~ 4877 | /* Get to the number of times to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4878 | p += 2; | ~~~~~~~ 4879 | | 4880 | /* Increment p past the n for when k != 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4881 | EXTRACT_NONNEGATIVE_AND_INCR (k, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4882 | if (k == 0) | ~~~~~~~~~~~ 4883 | { | ~ 4884 | p -= 4; | ~~~~~~~ 4885 | succeed_n_p = true; /* Spaghetti code alert. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4886 | goto handle_on_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4887 | } | ~ 4888 | continue; | ~~~~~~~~~ 4889 | | 4890 | | 4891 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 4892 | p += 4; | ~~~~~~~ 4893 | continue; | ~~~~~~~~~ 4894 | | 4895 | | 4896 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 4897 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 4898 | p += 4; | ~~~~~~~ 4899 | continue; | ~~~~~~~~~ 4900 | | 4901 | | 4902 | default: | ~~~~~~~~ 4903 | ABORT (); /* We have listed all the cases. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4904 | } /* switch *p++ */ | ~~~~~~~~~~~~~~~~~~~ 4905 | | 4906 | /* Getting here means we have found the possible starting | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4907 | characters for one path of the pattern -- and that the empty | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4908 | string does not match. We need not follow this path further. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4909 | Instead, look at the next alternative (remembered on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4910 | stack), or quit if no more. The test at the top of the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4911 | does these things. */ | ~~~~~~~~~~~~~~~~~~~~~~ 4912 | path_can_be_null = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4913 | p = pend; | ~~~~~~~~~ 4914 | } /* while p */ | ~~~~~~~~~~~~~~~ 4915 | | 4916 | /* Set `can_be_null' for the last path (also the first path, if the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4917 | pattern is empty). */ | ~~~~~~~~~~~~~~~~~~~~~~ 4918 | bufp->can_be_null |= path_can_be_null; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4919 | | 4920 | done: | ~~~~~ 4921 | RESET_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~~ 4922 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4923 | return 0; | ~~~~~~~~~ 4924 | } /* re_compile_fastmap */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4925 | | ~ 4926 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4927 | ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4928 | this memory for recording register information. STARTS and ENDS | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4929 | must be allocated using the malloc library routine, and must each | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4930 | be at least NUM_REGS * sizeof (regoff_t) bytes long. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4931 | | 4932 | If NUM_REGS == 0, then subsequent matches should allocate their own | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4933 | register data. | ~~~~~~~~~~~~~~ 4934 | | 4935 | Unless this function is called, the first search or match using | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4936 | PATTERN_BUFFER will allocate its own register data, without | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4937 | freeing the old data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4938 | | 4939 | void | ~~~~ 4940 | re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4941 | int num_regs, regoff_t *starts, regoff_t *ends) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4942 | { | ~ 4943 | if (num_regs) | ~~~~~~~~~~~~~ 4944 | { | ~ 4945 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4946 | regs->num_regs = num_regs; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4947 | regs->start = starts; | ~~~~~~~~~~~~~~~~~~~~~ 4948 | regs->end = ends; | ~~~~~~~~~~~~~~~~~ 4949 | } | ~ 4950 | else | ~~~~ 4951 | { | ~ 4952 | bufp->regs_allocated = REGS_UNALLOCATED; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4953 | regs->num_regs = 0; | ~~~~~~~~~~~~~~~~~~~ 4954 | regs->start = regs->end = (regoff_t *) 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4955 | } | ~ 4956 | } | ~ 4957 | | ~ 4958 | /* Searching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4959 | | 4960 | /* Like re_search_2, below, but only one string is specified, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4961 | doesn't let you say where to stop matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4962 | | 4963 | int | ~~~ 4964 | re_search (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4965 | int startpos, int range, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4966 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4967 | { | ~ 4968 | return re_search_2 (bufp, NULL, 0, string, size, startpos, range, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4969 | regs, size RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4970 | } | ~ 4971 | | 4972 | /* Using the compiled pattern in BUFP->buffer, first tries to match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4973 | virtual concatenation of STRING1 and STRING2, starting first at index | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4974 | STARTPOS, then at STARTPOS + 1, and so on. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4975 | | 4976 | STRING1 and STRING2 have length SIZE1 and SIZE2, respectively. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4977 | | 4978 | RANGE is how far to scan while trying to match. RANGE = 0 means try | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4979 | only at STARTPOS; in general, the last start tried is STARTPOS + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4980 | RANGE. | ~~~~~~ 4981 | | 4982 | All sizes and positions refer to bytes (not chars); under Mule, the code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4983 | knows about the format of the text and will only check at positions | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4984 | where a character starts. | ~~~~~~~~~~~~~~~~~~~~~~~~~ 4985 | | 4986 | With MULE, RANGE is a byte position, not a char position. The last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4987 | start tried is the character starting <= STARTPOS + RANGE. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4988 | | 4989 | In REGS, return the indices of the virtual concatenation of STRING1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4990 | and STRING2 that matched the entire BUFP->buffer and its contained | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4991 | subexpressions. | ~~~~~~~~~~~~~~~ 4992 | | 4993 | Do not consider matching one past the index STOP in the virtual | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4994 | concatenation of STRING1 and STRING2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4995 | | 4996 | We return either the position in the strings at which the match was | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4997 | found, -1 if no match, or -2 if error (such as failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4998 | stack overflow). */ | ~~~~~~~~~~~~~~~~~~~~ 4999 | | 5000 | int | ~~~ 5001 | re_search_2 (struct re_pattern_buffer *bufp, const char *str1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5002 | int size1, const char *str2, int size2, int startpos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5003 | int range, struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5004 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5005 | { | ~ 5006 | int val; | ~~~~~~~~ 5007 | re_char *string1 = (re_char *) str1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5008 | re_char *string2 = (re_char *) str2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5009 | REGISTER char *fastmap = bufp->fastmap; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5010 | REGISTER RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5011 | int total_size = size1 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5012 | int endpos = startpos + range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5013 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5014 | int anchored_at_begline = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5015 | #endif | ~~~~~~ 5016 | re_char *d; | ~~~~~~~~~~~ 5017 | #ifdef emacs | ~~~~~~~~~~~~ 5018 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5019 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5020 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5021 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5022 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5023 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5024 | 0; | ~~ 5025 | #endif | ~~~~~~ 5026 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5027 | int depth; | ~~~~~~~~~~ 5028 | #endif | ~~~~~~ 5029 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5030 | int forward_search_p; | ~~~~~~~~~~~~~~~~~~~~~ 5031 | | 5032 | /* Check for out-of-range STARTPOS. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5033 | if (startpos < 0 || startpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5034 | return -1; | ~~~~~~~~~~ 5035 | | 5036 | /* Fix up RANGE if it might eventually take us outside | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5037 | the virtual concatenation of STRING1 and STRING2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5038 | if (endpos < 0) | ~~~~~~~~~~~~~~~ 5039 | range = 0 - startpos; | ~~~~~~~~~~~~~~~~~~~~~ 5040 | else if (endpos > total_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5041 | range = total_size - startpos; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5042 | | 5043 | forward_search_p = range > 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5044 | | 5045 | (void) (forward_search_p); /* This is only used with assertions, silence the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5046 | compiler warning when they're turned off. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5047 | | 5048 | /* If the search isn't to be a backwards one, don't waste time in a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5049 | search for a pattern that must be anchored. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5050 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5051 | { | ~ 5052 | if (startpos > 0) | ~~~~~~~~~~~~~~~~~ 5053 | return -1; | ~~~~~~~~~~ 5054 | else | ~~~~ 5055 | { | ~ 5056 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5057 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5058 | range = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5059 | } | ~ 5060 | } | ~ 5061 | | 5062 | #ifdef emacs | ~~~~~~~~~~~~ 5063 | /* In a forward search for something that starts with \=. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5064 | don't keep searching past point. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5065 | if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5066 | { | ~ 5067 | if (!BUFFERP (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~ 5068 | return -1; | ~~~~~~~~~~ 5069 | range = (BYTE_BUF_PT (XBUFFER (lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5070 | - BYTE_BUF_BEGV (XBUFFER (lispobj)) - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5071 | if (range < 0) | ~~~~~~~~~~~~~~ 5072 | return -1; | ~~~~~~~~~~ 5073 | } | ~ 5074 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5075 | | 5076 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5077 | /* Do this after the above return()s. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5078 | depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5079 | #endif | ~~~~~~ 5080 | | 5081 | /* Update the fastmap now if not correct already. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5082 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5083 | if (fastmap && !bufp->fastmap_accurate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5084 | if (re_compile_fastmap (bufp RE_LISP_SHORT_CONTEXT_ARGS) == -2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5085 | { | ~ 5086 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5087 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5088 | return -2; | ~~~~~~~~~~ 5089 | } | ~ 5090 | | 5091 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5092 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5093 | | 5094 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5095 | { | ~ 5096 | long i = 0; | ~~~~~~~~~~~ 5097 | | 5098 | while (i < bufp->used) | ~~~~~~~~~~~~~~~~~~~~~~ 5099 | { | ~ 5100 | if (bufp->buffer[i] == start_memory || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5101 | bufp->buffer[i] == stop_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5102 | i += 4; | ~~~~~~~ 5103 | else | ~~~~ 5104 | break; | ~~~~~~ 5105 | } | ~ 5106 | anchored_at_begline = i < bufp->used && bufp->buffer[i] == begline; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5107 | } | ~ 5108 | #endif | ~~~~~~ 5109 | | 5110 | #ifdef emacs | ~~~~~~~~~~~~ 5111 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5112 | /* Update the mirror syntax table if it's used and dirty. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5113 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5114 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5115 | offset_to_bytexpos (lispobj, startpos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5116 | 1); | ~~~ 5117 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5118 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5119 | #endif | ~~~~~~ 5120 | | 5121 | /* Loop through the string, looking for a place to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5122 | for (;;) | ~~~~~~~~ 5123 | { | ~ 5124 | #ifdef REGEX_BEGLINE_CHECK | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5125 | /* If the regex is anchored at the beginning of a line (i.e. with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5126 | ^), then we can speed things up by skipping to the next | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5127 | beginning-of-line. However, to determine "beginning of line" we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5128 | need to look at the previous char, so can't do this check if at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5129 | beginning of either string. (Well, we could if at the beginning of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5130 | the second string, but it would require additional code, and this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5131 | is just an optimization.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5132 | if (anchored_at_begline && startpos > 0 && startpos != size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5133 | { | ~ 5134 | if (range > 0) | ~~~~~~~~~~~~~~ 5135 | { | ~ 5136 | /* whose stupid idea was it anyway to make this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5137 | function take two strings to match?? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5138 | int lim = 0; | ~~~~~~~~~~~~ 5139 | re_char *orig_d; | ~~~~~~~~~~~~~~~~ 5140 | re_char *stop_d; | ~~~~~~~~~~~~~~~~ 5141 | | 5142 | /* Compute limit as below in fastmap code, so we are guaranteed | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5143 | to remain within a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5144 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5145 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5146 | | 5147 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5148 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5149 | orig_d = d; | ~~~~~~~~~~~ 5150 | stop_d = d + range - lim; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5151 | | 5152 | /* We want to find the next location (including the current | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5153 | one) where the previous char is a newline, so back up one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5154 | and search forward for a newline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5155 | DEC_IBYTEPTR_FMT (d, fmt); /* Ok, since startpos != size1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5156 | | 5157 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5158 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5159 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5160 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5161 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5162 | != '\n') | ~~~~~~~~ 5163 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5164 | else | ~~~~ 5165 | while (d < stop_d && | ~~~~~~~~~~~~~~~~~~~~ 5166 | itext_ichar_ascii_fmt (d, fmt, lispobj) != '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5167 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5168 | | 5169 | /* If we were stopped by a newline, skip forward over it. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5170 | Otherwise we will get in an infloop when our start position | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5171 | was at begline. */ | ~~~~~~~~~~~~~~~~~~ 5172 | if (d < stop_d) | ~~~~~~~~~~~~~~~ 5173 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5174 | range -= d - orig_d; | ~~~~~~~~~~~~~~~~~~~~ 5175 | startpos += d - orig_d; | ~~~~~~~~~~~~~~~~~~~~~~~ 5176 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5177 | } | ~ 5178 | else if (range < 0) | ~~~~~~~~~~~~~~~~~~~ 5179 | { | ~ 5180 | /* We're lazy, like in the fastmap code below */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5181 | Ichar c; | ~~~~~~~~ 5182 | | 5183 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5184 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5185 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5186 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5187 | c = RE_TRANSLATE (c); | ~~~~~~~~~~~~~~~~~~~~~ 5188 | if (c != '\n') | ~~~~~~~~~~~~~~ 5189 | goto advance; | ~~~~~~~~~~~~~ 5190 | } | ~ 5191 | } | ~ 5192 | #endif /* REGEX_BEGLINE_CHECK */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5193 | | 5194 | /* If a fastmap is supplied, skip quickly over characters that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5195 | cannot be the start of a match. If the pattern can match the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5196 | null string, however, we don't need to skip characters; we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5197 | the first null string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5198 | if (fastmap && startpos < total_size && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5199 | { | ~ 5200 | /* For the moment, fastmap always works as if buffer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5201 | is in default format, so convert chars in the search strings | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5202 | into default format as we go along, if necessary. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5203 | | 5204 | &&#### fastmap needs rethinking for 8-bit-fixed so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5205 | it's faster. We need it to reflect the raw | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5206 | 8-bit-fixed values. That isn't so hard if we assume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5207 | that the top 96 bytes represent a single 1-byte | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5208 | charset. For 16-bit/32-bit stuff it's probably not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5209 | worth it to make the fastmap represent the raw, due to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5210 | its nature -- we'd have to use the LSB for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5211 | fastmap, and that causes lots of problems with Mule | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5212 | chars, where it essentially wipes out the usefulness | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5213 | of the fastmap entirely. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5214 | if (range > 0) /* Searching forwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5215 | { | ~ 5216 | int lim = 0; | ~~~~~~~~~~~~ 5217 | int irange = range; | ~~~~~~~~~~~~~~~~~~~ 5218 | | 5219 | if (startpos < size1 && startpos + range >= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5220 | lim = range - (size1 - startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5221 | | 5222 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5223 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5224 | | 5225 | /* Written out as an if-else to avoid testing `translate' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5226 | inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~ 5227 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5228 | { | ~ 5229 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5230 | { | ~ 5231 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5232 | #ifdef MULE | ~~~~~~~~~~~ 5233 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5234 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5235 | RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5236 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5237 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5238 | break; | ~~~~~~ 5239 | #else | ~~~~~ 5240 | if (fastmap[(unsigned char) RE_TRANSLATE_1 (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5241 | break; | ~~~~~~ 5242 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5243 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5244 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5245 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5246 | } | ~ 5247 | } | ~ 5248 | #ifdef MULE | ~~~~~~~~~~~ 5249 | else if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5250 | { | ~ 5251 | while (range > lim) | ~~~~~~~~~~~~~~~~~~~ 5252 | { | ~ 5253 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5254 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5255 | Ichar buf_ch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5256 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5257 | if (fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~ 5258 | break; | ~~~~~~ 5259 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5260 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5261 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5262 | } | ~ 5263 | } | ~ 5264 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5265 | else | ~~~~ 5266 | { | ~ 5267 | while (range > lim && !fastmap[*d]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5268 | { | ~ 5269 | re_char *old_d = d; | ~~~~~~~~~~~~~~~~~~~ 5270 | INC_IBYTEPTR (d); | ~~~~~~~~~~~~~~~~~ 5271 | range -= (d - old_d); | ~~~~~~~~~~~~~~~~~~~~~ 5272 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5273 | } | ~ 5274 | } | ~ 5275 | | 5276 | startpos += irange - range; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5277 | } | ~ 5278 | else /* Searching backwards. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5279 | { | ~ 5280 | /* #### It's not clear why we don't just write a loop, like | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5281 | for the moving-forward case. Perhaps the writer got lazy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5282 | since backward searches aren't so common. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5283 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5284 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5285 | #ifdef MULE | ~~~~~~~~~~~ 5286 | { | ~ 5287 | Ibyte tempch[MAX_ICHAR_LEN]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5288 | Ichar buf_ch = | ~~~~~~~~~~~~~~ 5289 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5290 | set_itext_ichar (tempch, buf_ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5291 | if (!fastmap[*tempch]) | ~~~~~~~~~~~~~~~~~~~~~~ 5292 | goto advance; | ~~~~~~~~~~~~~ 5293 | } | ~ 5294 | #else | ~~~~~ 5295 | if (!fastmap[(unsigned char) RE_TRANSLATE (*d)]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5296 | goto advance; | ~~~~~~~~~~~~~ 5297 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 5298 | } | ~ 5299 | } | ~ 5300 | | 5301 | /* If can't match the null string, and that's all we have left, fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5302 | if (range >= 0 && startpos == total_size && fastmap | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5303 | && !bufp->can_be_null) | ~~~~~~~~~~~~~~~~~~~~~~ 5304 | { | ~ 5305 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5306 | return -1; | ~~~~~~~~~~ 5307 | } | ~ 5308 | | 5309 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5310 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5311 | { | ~ 5312 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5313 | QUIT; | ~~~~~ 5314 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5315 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5316 | } | ~ 5317 | | 5318 | #endif | ~~~~~~ 5319 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5320 | val = re_match_2_internal (bufp, string1, size1, string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5321 | startpos, regs, stop | ~~~~~~~~~~~~~~~~~~~~ 5322 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5323 | #ifndef REGEX_MALLOC | ~~~~~~~~~~~~~~~~~~~~ 5324 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5325 | #endif | ~~~~~~ 5326 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5327 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5328 | | 5329 | if (val >= 0) | ~~~~~~~~~~~~~ 5330 | { | ~ 5331 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5332 | return startpos; | ~~~~~~~~~~~~~~~~ 5333 | } | ~ 5334 | | 5335 | if (val == -2) | ~~~~~~~~~~~~~~ 5336 | { | ~ 5337 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5338 | return -2; | ~~~~~~~~~~ 5339 | } | ~ 5340 | | 5341 | RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5342 | advance: | ~~~~~~~~ 5343 | if (!range) | ~~~~~~~~~~~ 5344 | break; | ~~~~~~ 5345 | else if (range > 0) | ~~~~~~~~~~~~~~~~~~~ 5346 | { | ~ 5347 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5348 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5349 | (startpos >= size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5350 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5351 | range -= d_size; | ~~~~~~~~~~~~~~~~ 5352 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5353 | startpos += d_size; | ~~~~~~~~~~~~~~~~~~~ 5354 | } | ~ 5355 | else | ~~~~ 5356 | { | ~ 5357 | Bytecount d_size; | ~~~~~~~~~~~~~~~~~ 5358 | /* Note startpos > size1 not >=. If we are on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5359 | string1/string2 boundary, we want to backup into string1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5360 | d = ((const unsigned char *) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5361 | (startpos > size1 ? string2 - size1 : string1) + startpos); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5362 | DEC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5363 | d_size = itext_ichar_len_fmt (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5364 | range += d_size; | ~~~~~~~~~~~~~~~~ 5365 | assert (!forward_search_p || range >= 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5366 | startpos -= d_size; | ~~~~~~~~~~~~~~~~~~~ 5367 | } | ~ 5368 | } | ~ 5369 | UNBIND_REGEX_MALLOC_CHECK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5370 | return -1; | ~~~~~~~~~~ 5371 | } /* re_search_2 */ | ~~~~~~~~~~~~~~~~~~~ 5372 | | 5373 | | ~ 5374 | /* Declarations and macros for re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5375 | | 5376 | /* This converts PTR, a pointer into one of the search strings `string1' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5377 | and `string2' into an offset from the beginning of that string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5378 | #define POINTER_TO_OFFSET(ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5379 | (FIRST_STRING_P (ptr) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5380 | ? ((regoff_t) ((ptr) - string1)) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5381 | : ((regoff_t) ((ptr) - string2 + size1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5382 | | 5383 | /* Macros for dealing with the split strings in re_match_2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5384 | | 5385 | #define MATCHING_IN_FIRST_STRING (dend == end_match_1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5386 | | 5387 | /* Call before fetching a character with *d. This switches over to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5388 | string2 if necessary. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5389 | #define REGEX_PREFETCH() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5390 | while (d == dend) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5391 | { \ | ~~~~~~~~~~~ 5392 | /* End of string2 => fail. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5393 | if (dend == end_match_2) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5394 | goto fail; \ | ~~~~~~~~~~~~~~~~~~ 5395 | /* End of string1 => advance to string2. */ \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5396 | d = string2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5397 | dend = end_match_2; \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5398 | } | ~ 5399 | | 5400 | | 5401 | /* Test if at very beginning or at very end of the virtual concatenation | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5402 | of `string1' and `string2'. If only one string, it's `string2'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5403 | #define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5404 | #define AT_STRINGS_END(d) ((d) == end2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5405 | | 5406 | /* XEmacs change: | ~~~~~~~~~~~~~~~~~ 5407 | If the given position straddles the string gap, return the equivalent | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5408 | position that is before or after the gap, respectively; otherwise, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5409 | return the same position. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5410 | #define POS_BEFORE_GAP_UNSAFE(d) ((d) == string2 ? end1 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5411 | #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5412 | | 5413 | /* Test if CH is a word-constituent character. (XEmacs change) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5414 | #define WORDCHAR_P(ch) \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5415 | (SYNTAX (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), ch) == Sword) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5416 | | 5417 | /* Free everything we malloc. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5418 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5419 | #define FREE_VAR(var,type) if (var) REGEX_FREE (var, type); var = NULL | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5420 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5421 | do { \ | ~~~~~~~~~~~~~~ 5422 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5423 | REGEX_FREE_STACK (fail_stack.stack); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5424 | FREE_VAR (regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5425 | FREE_VAR (regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5426 | FREE_VAR (old_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5427 | FREE_VAR (old_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5428 | FREE_VAR (best_regstart, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5429 | FREE_VAR (best_regend, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5430 | FREE_VAR (reg_info, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5431 | FREE_VAR (reg_dummy, re_char **); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5432 | FREE_VAR (reg_info_dummy, register_info_type *); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5433 | } while (0) | ~~~~~~~~~~~ 5434 | #else /* not MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5435 | #define FREE_VARIABLES() \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5436 | do { \ | ~~~~~~~~~~~ 5437 | UNBIND_REGEX_MALLOC_CHECK (); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5438 | } while (0) | ~~~~~~~~~~~ 5439 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5440 | | 5441 | /* These values must meet several constraints. They must not be valid | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5442 | register values, which means we can use numbers larger than MAX_REGNUM. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5443 | They must differ by 1, because of NUM_FAILURE_ITEMS above. And the value | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5444 | for the lowest register must be larger than the value for the highest | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5445 | register, so we do not try to actually save any registers when none are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5446 | active. */ | ~~~~~~~~~~~ 5447 | #define NO_HIGHEST_ACTIVE_REG (MAX_REGNUM + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5448 | #define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5449 | | ~ 5450 | /* Matching routines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5451 | | 5452 | #ifndef emacs /* XEmacs never uses this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5453 | /* re_match is like re_match_2 except it takes only a single string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5454 | | 5455 | int | ~~~ 5456 | re_match (struct re_pattern_buffer *bufp, const char *string, int size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5457 | int pos, struct re_registers *regs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5458 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5459 | { | ~ 5460 | int result = re_match_2_internal (bufp, NULL, 0, (re_char *) string, size, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5461 | pos, regs, size | ~~~~~~~~~~~~~~~ 5462 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5463 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5464 | return result; | ~~~~~~~~~~~~~~ 5465 | } | ~ 5466 | #endif /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~~ 5467 | | 5468 | /* re_match_2 matches the compiled pattern in BUFP against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5469 | (virtual) concatenation of STRING1 and STRING2 (of length SIZE1 and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5470 | SIZE2, respectively). We start matching at POS, and stop matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5471 | at STOP. | ~~~~~~~~ 5472 | | 5473 | If REGS is non-null and the `no_sub' field of BUFP is nonzero, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5474 | store offsets for the substring each group matched in REGS. See the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5475 | documentation for exactly how many groups we fill. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5476 | | 5477 | We return -1 if no match, -2 if an internal error (such as the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5478 | failure stack overflowing). Otherwise, we return the length of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5479 | matched substring. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5480 | | 5481 | int | ~~~ 5482 | re_match_2 (struct re_pattern_buffer *bufp, const char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5483 | int size1, const char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5484 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5485 | RE_LISP_CONTEXT_ARGS_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5486 | { | ~ 5487 | int result; | ~~~~~~~~~~~ 5488 | | 5489 | #ifdef emacs | ~~~~~~~~~~~~ 5490 | /* Update the mirror syntax table if it's dirty now, this would otherwise | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5491 | cause a malloc() in charset_mule in re_match_2_internal() when checking | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5492 | characters' syntax. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5493 | SYNTAX_CODE (BUFFER_MIRROR_SYNTAX_TABLE (lispbuf), 'a'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5494 | scache = setup_syntax_cache (scache, lispobj, lispbuf, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5495 | offset_to_bytexpos (lispobj, pos), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5496 | 1); | ~~~ 5497 | #endif | ~~~~~~ 5498 | | 5499 | result = re_match_2_internal (bufp, (re_char *) string1, size1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5500 | (re_char *) string2, size2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5501 | pos, regs, stop | ~~~~~~~~~~~~~~~ 5502 | RE_LISP_CONTEXT_ARGS); | ~~~~~~~~~~~~~~~~~~~~~~ 5503 | | 5504 | ALLOCA_GARBAGE_COLLECT (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5505 | return result; | ~~~~~~~~~~~~~~ 5506 | } | ~ 5507 | | 5508 | /* This is a separate function so that we can force an alloca cleanup | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5509 | afterwards. */ | ~~~~~~~~~~~~~~~ 5510 | static int | ~~~~~~~~~~ 5511 | re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5512 | int size1, re_char *string2, int size2, int pos, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5513 | struct re_registers *regs, int stop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5514 | RE_LISP_CONTEXT_ARGS_MULE_DECL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5515 | { | ~ 5516 | /* General temporaries. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5517 | int mcnt; | ~~~~~~~~~ 5518 | re_char *p1; | ~~~~~~~~~~~~ 5519 | int should_succeed; /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5520 | | 5521 | /* Just past the end of the corresponding string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5522 | re_char *end1, *end2; | ~~~~~~~~~~~~~~~~~~~~~ 5523 | | 5524 | /* Pointers into string1 and string2, just past the last characters in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5525 | each to consider matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5526 | re_char *end_match_1, *end_match_2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5527 | | 5528 | /* Where we are in the data, and the end of the current string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5529 | re_char *d, *dend; | ~~~~~~~~~~~~~~~~~~ 5530 | | 5531 | /* Where we are in the pattern, and the end of the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5532 | unsigned char *p; | ~~~~~~~~~~~~~~~~~ 5533 | re_char *pstart; | ~~~~~~~~~~~~~~~~ 5534 | REGISTER re_char *pend; | ~~~~~~~~~~~~~~~~~~~~~~~ 5535 | | 5536 | /* Mark the opcode just after a start_memory, so we can test for an | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5537 | empty subpattern when we get to the stop_memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5538 | re_char *just_past_start_mem = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5539 | | 5540 | /* We use this to map every character in the string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5541 | RE_TRANSLATE_TYPE translate = bufp->translate; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5542 | | 5543 | /* Failure point stack. Each place that can handle a failure further | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5544 | down the line pushes a failure point on this stack. It consists of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5545 | restart, regend, and reg_info for all registers corresponding to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5546 | the subexpressions we're currently inside, plus the number of such | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5547 | registers, and, finally, two char *'s. The first char * is where | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5548 | to resume scanning the pattern; the second one is where to resume | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5549 | scanning the strings. If the latter is zero, the failure point is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5550 | a ``dummy''; if a failure happens and the failure point is a dummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5551 | it gets discarded and the next one is tried. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5552 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5553 | fail_stack_type fail_stack; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5554 | #endif | ~~~~~~ 5555 | #ifdef DEBUG | ~~~~~~~~~~~~ 5556 | static int failure_id; | ~~~~~~~~~~~~~~~~~~~~~~ 5557 | int nfailure_points_pushed = 0, nfailure_points_popped = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5558 | #endif | ~~~~~~ 5559 | | 5560 | #ifdef REGEX_REL_ALLOC | ~~~~~~~~~~~~~~~~~~~~~~ 5561 | /* This holds the pointer to the failure stack, when | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5562 | it is allocated relocatably. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5563 | fail_stack_elt_t *failure_stack_ptr; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5564 | #endif | ~~~~~~ 5565 | | 5566 | /* We fill all the registers internally, independent of what we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5567 | return, for use in backreferences. The number here includes | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5568 | an element for register zero. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5569 | regnum_t num_regs = bufp->re_ngroups + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5570 | | 5571 | /* The currently active registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5572 | regnum_t lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5573 | regnum_t highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5574 | | 5575 | /* Information on the contents of registers. These are pointers into | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5576 | the input strings; they record just what was matched (on this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5577 | attempt) by a subexpression part of the pattern, that is, the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5578 | regnum-th regstart pointer points to where in the pattern we began | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5579 | matching and the regnum-th regend points to right after where we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5580 | stopped matching the regnum-th subexpression. (The zeroth register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5581 | keeps track of what the whole pattern matches.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5582 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5583 | re_char **regstart, **regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5584 | #endif | ~~~~~~ 5585 | | 5586 | /* If a group that's operated upon by a repetition operator fails to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5587 | match anything, then the register for its start will need to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5588 | restored because it will have been set to wherever in the string we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5589 | are when we last see its open-group operator. Similarly for a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5590 | register's end. */ | ~~~~~~~~~~~~~~~~~~~ 5591 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5592 | re_char **old_regstart, **old_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5593 | #endif | ~~~~~~ 5594 | | 5595 | /* The is_active field of reg_info helps us keep track of which (possibly | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5596 | nested) subexpressions we are currently in. The matched_something | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5597 | field of reg_info[reg_num] helps us tell whether or not we have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5598 | matched any of the pattern so far this time through the reg_num-th | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5599 | subexpression. These two fields get reset each time through any | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5600 | loop their register is in. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5601 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5602 | register_info_type *reg_info; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5603 | #endif | ~~~~~~ 5604 | | 5605 | /* The following record the register info as found in the above | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5606 | variables when we find a match better than any we've seen before. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5607 | This happens as we backtrack through the failure points, which in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5608 | turn happens only if we have not yet matched the entire string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5609 | int best_regs_set = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5610 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5611 | re_char **best_regstart, **best_regend; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5612 | #endif | ~~~~~~ 5613 | | 5614 | /* Logically, this is `best_regend[0]'. But we don't want to have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5615 | allocate space for that if we're not allocating space for anything | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5616 | else (see below). Also, we never need info about register 0 for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5617 | any of the other register vectors, and it seems rather a kludge to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5618 | treat `best_regend' differently than the rest. So we keep track of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5619 | the end of the best match so far in a separate variable. We | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5620 | initialize this to NULL so that when we backtrack the first time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5621 | and need to test it, it's not garbage. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5622 | re_char *match_end = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5623 | | 5624 | /* This helps SET_REGS_MATCHED avoid doing redundant work. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5625 | int set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5626 | | 5627 | /* Used when we pop values we don't care about. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5628 | #ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5629 | re_char **reg_dummy; | ~~~~~~~~~~~~~~~~~~~~ 5630 | register_info_type *reg_info_dummy; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5631 | #endif | ~~~~~~ 5632 | | 5633 | #ifdef DEBUG | ~~~~~~~~~~~~ 5634 | /* Counts the total number of registers pushed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5635 | int num_regs_pushed = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~ 5636 | #endif | ~~~~~~ 5637 | | 5638 | /* 1 if this match ends in the same string (string1 or string2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5639 | as the best previous match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5640 | re_bool same_str_p; | ~~~~~~~~~~~~~~~~~~~ 5641 | | 5642 | /* 1 if this match is the best seen so far. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5643 | re_bool best_match_p; | ~~~~~~~~~~~~~~~~~~~~~ 5644 | | 5645 | #ifdef emacs | ~~~~~~~~~~~~ 5646 | Internal_Format fmt = buffer_or_other_internal_format (lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5647 | #ifdef REL_ALLOC | ~~~~~~~~~~~~~~~~ 5648 | const Ibyte *orig_buftext = | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5649 | BUFFERP (lispobj) ? | ~~~~~~~~~~~~~~~~~~~ 5650 | BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5651 | BYTE_BUF_BEG (XBUFFER (lispobj))) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5652 | 0; | ~~ 5653 | #endif | ~~~~~~ 5654 | | 5655 | #ifdef ERROR_CHECK_MALLOC | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5656 | int depth = bind_regex_malloc_disallowed (1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5657 | #endif | ~~~~~~ 5658 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 5659 | | 5660 | DEBUG_MATCH_PRINT1 ("\n\nEntering re_match_2.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5661 | | 5662 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5663 | INIT_FAIL_STACK (); | ~~~~~~~~~~~~~~~~~~~ 5664 | p = (unsigned char *) ALLOCA (bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5665 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5666 | | 5667 | /* re_match_2_internal() modifies the compiled pattern (see the succeed_n, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5668 | jump_n, set_number_at opcodes), make it re-entrant by working on a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5669 | copy. This should also give better locality of reference. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5670 | memcpy (p, bufp->buffer, bufp->used); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5671 | pstart = (re_char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~ 5672 | pend = pstart + bufp->used; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5673 | | 5674 | #ifdef MATCH_MAY_ALLOCATE | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5675 | /* Do not bother to initialize all the register variables if there are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5676 | no groups in the pattern, as it takes a fair amount of time. If | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5677 | there are groups, we include space for register 0 (the whole | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5678 | pattern), even though we never use it, since it simplifies the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5679 | array indexing. We should fix this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5680 | if (bufp->re_ngroups) | ~~~~~~~~~~~~~~~~~~~~~ 5681 | { | ~ 5682 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5683 | regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5684 | regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5685 | old_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5686 | old_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5687 | best_regstart = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5688 | best_regend = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5689 | reg_info = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5690 | reg_dummy = REGEX_TALLOC (num_regs, re_char *); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5691 | reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5692 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5693 | | 5694 | if (!(regstart && regend && old_regstart && old_regend && reg_info | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5695 | && best_regstart && best_regend && reg_dummy && reg_info_dummy)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5696 | { | ~ 5697 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5698 | return -2; | ~~~~~~~~~~ 5699 | } | ~ 5700 | } | ~ 5701 | else | ~~~~ 5702 | { | ~ 5703 | /* We must initialize all our variables to NULL, so that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5704 | `FREE_VARIABLES' doesn't try to free them. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5705 | regstart = regend = old_regstart = old_regend = best_regstart | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5706 | = best_regend = reg_dummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5707 | reg_info = reg_info_dummy = (register_info_type *) NULL; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5708 | } | ~ 5709 | #endif /* MATCH_MAY_ALLOCATE */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5710 | | 5711 | #if defined (emacs) && defined (REL_ALLOC) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5712 | { | ~ 5713 | /* If the allocations above (or the call to setup_syntax_cache() in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5714 | re_match_2) caused a rel-alloc relocation, then fix up the data | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5715 | pointers */ | ~~~~~~~~~~~ 5716 | Bytecount offset = offset_post_relocation (lispobj, orig_buftext); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5717 | if (offset) | ~~~~~~~~~~~ 5718 | { | ~ 5719 | string1 += offset; | ~~~~~~~~~~~~~~~~~~ 5720 | string2 += offset; | ~~~~~~~~~~~~~~~~~~ 5721 | } | ~ 5722 | } | ~ 5723 | #endif /* defined (emacs) && defined (REL_ALLOC) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5724 | | 5725 | /* The starting position is bogus. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5726 | if (pos < 0 || pos > size1 + size2) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5727 | { | ~ 5728 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5729 | return -1; | ~~~~~~~~~~ 5730 | } | ~ 5731 | | 5732 | /* Initialize subexpression text positions to our sentinel to mark ones that | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5733 | no start_memory/stop_memory has been seen for. Also initialize the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5734 | register information struct. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5735 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5736 | { | ~ 5737 | regstart[mcnt] = regend[mcnt] = old_regstart[mcnt] = old_regend[mcnt] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5738 | = best_regstart[mcnt] = best_regend[mcnt] = REG_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5739 | REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5740 | IS_ACTIVE (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5741 | MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5742 | EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5743 | } | ~ 5744 | /* We move `string1' into `string2' if the latter's empty -- but not if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5745 | `string1' is null. */ | ~~~~~~~~~~~~~~~~~~~~~~ 5746 | if (size2 == 0 && string1 != NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5747 | { | ~ 5748 | string2 = string1; | ~~~~~~~~~~~~~~~~~~ 5749 | size2 = size1; | ~~~~~~~~~~~~~~ 5750 | string1 = 0; | ~~~~~~~~~~~~ 5751 | size1 = 0; | ~~~~~~~~~~ 5752 | } | ~ 5753 | end1 = string1 + size1; | ~~~~~~~~~~~~~~~~~~~~~~~ 5754 | end2 = string2 + size2; | ~~~~~~~~~~~~~~~~~~~~~~~ 5755 | | 5756 | /* Compute where to stop matching, within the two strings. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5757 | if (stop <= size1) | ~~~~~~~~~~~~~~~~~~ 5758 | { | ~ 5759 | end_match_1 = string1 + stop; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5760 | end_match_2 = string2; | ~~~~~~~~~~~~~~~~~~~~~~ 5761 | } | ~ 5762 | else | ~~~~ 5763 | { | ~ 5764 | end_match_1 = end1; | ~~~~~~~~~~~~~~~~~~~ 5765 | end_match_2 = string2 + stop - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5766 | } | ~ 5767 | | 5768 | /* `p' scans through the pattern as `d' scans through the data. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5769 | `dend' is the end of the input string that `d' points within. `d' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5770 | is advanced into the following input string whenever necessary, but | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5771 | this happens before fetching; therefore, at the beginning of the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5772 | loop, `d' can be pointing at the end of a string, but it cannot | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5773 | equal `string2'. */ | ~~~~~~~~~~~~~~~~~~~~ 5774 | if (size1 > 0 && pos <= size1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5775 | { | ~ 5776 | d = string1 + pos; | ~~~~~~~~~~~~~~~~~~ 5777 | dend = end_match_1; | ~~~~~~~~~~~~~~~~~~~ 5778 | } | ~ 5779 | else | ~~~~ 5780 | { | ~ 5781 | d = string2 + pos - size1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5782 | dend = end_match_2; | ~~~~~~~~~~~~~~~~~~~ 5783 | } | ~ 5784 | | 5785 | DEBUG_MATCH_PRINT1 ("The compiled pattern is: \n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5786 | DEBUG_MATCH_PRINT_COMPILED_PATTERN (bufp, p, pend); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5787 | DEBUG_MATCH_PRINT1 ("The string to match is: `"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5788 | DEBUG_MATCH_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5789 | DEBUG_MATCH_PRINT1 ("'\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5790 | | 5791 | /* This loops over pattern commands. It exits by returning from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5792 | function if the match is complete, or it drops through if the match | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5793 | fails at this starting point in the input data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5794 | for (;;) | ~~~~~~~~ 5795 | { | ~ 5796 | DEBUG_MATCH_PRINT2 ("\n0x%zx: ", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5797 | #ifdef emacs /* XEmacs added, w/removal of immediate_quit */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5798 | if (!no_quit_in_re_search) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5799 | { | ~ 5800 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5801 | QUIT; | ~~~~~ 5802 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5803 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5804 | } | ~ 5805 | #endif | ~~~~~~ 5806 | | 5807 | if (p == pend) | ~~~~~~~~~~~~~~ 5808 | { /* End of pattern means we might have succeeded. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5809 | DEBUG_MATCH_PRINT1 ("end of pattern ... "); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5810 | | 5811 | /* If we haven't matched the entire string, and we want the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5812 | longest match, try backtracking. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5813 | if (d != end_match_2) | ~~~~~~~~~~~~~~~~~~~~~ 5814 | { | ~ 5815 | same_str_p = (FIRST_STRING_P (match_end) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5816 | == MATCHING_IN_FIRST_STRING); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5817 | | 5818 | /* AIX compiler got confused when this was combined | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5819 | with the previous declaration. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5820 | if (same_str_p) | ~~~~~~~~~~~~~~~ 5821 | best_match_p = d > match_end; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5822 | else | ~~~~ 5823 | best_match_p = !MATCHING_IN_FIRST_STRING; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5824 | | 5825 | DEBUG_MATCH_PRINT1 ("backtracking.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5826 | | 5827 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5828 | { /* More failure points to try. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5829 | | 5830 | /* If exceeds best match so far, save it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5831 | if (!best_regs_set || best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5832 | { | ~ 5833 | best_regs_set = true; | ~~~~~~~~~~~~~~~~~~~~~ 5834 | match_end = d; | ~~~~~~~~~~~~~~ 5835 | | 5836 | DEBUG_MATCH_PRINT1 ("\nSAVING match as best so far.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5837 | | 5838 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5839 | { | ~ 5840 | best_regstart[mcnt] = regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5841 | best_regend[mcnt] = regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5842 | } | ~ 5843 | } | ~ 5844 | goto fail; | ~~~~~~~~~~ 5845 | } | ~ 5846 | | 5847 | /* If no failure points, don't restore garbage. And if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5848 | last match is real best match, don't restore second | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5849 | best one. */ | ~~~~~~~~~~~~ 5850 | else if (best_regs_set && !best_match_p) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5851 | { | ~ 5852 | restore_best_regs: | ~~~~~~~~~~~~~~~~~~ 5853 | /* Restore best match. It may happen that `dend == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5854 | end_match_1' while the restored d is in string2. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5855 | For example, the pattern `x.*y.*z' against the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5856 | strings `x-' and `y-z-', if the two strings are | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5857 | not consecutive in memory. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5858 | DEBUG_MATCH_PRINT1 ("Restoring best registers.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5859 | | 5860 | d = match_end; | ~~~~~~~~~~~~~~ 5861 | dend = ((d >= string1 && d <= end1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5862 | ? end_match_1 : end_match_2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5863 | | 5864 | for (mcnt = 1; mcnt < num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5865 | { | ~ 5866 | regstart[mcnt] = best_regstart[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5867 | regend[mcnt] = best_regend[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5868 | } | ~ 5869 | } | ~ 5870 | } /* d != end_match_2 */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 5871 | | 5872 | succeed_label: | ~~~~~~~~~~~~~~ 5873 | DEBUG_MATCH_PRINT1 ("Accepting match.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5874 | | 5875 | /* If caller wants register contents data back, do it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5876 | { | ~ 5877 | int num_nonshy_regs = bufp->re_nsub + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5878 | if (regs && !bufp->no_sub) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5879 | { | ~ 5880 | /* Have the register data arrays been allocated? */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5881 | if (bufp->regs_allocated == REGS_UNALLOCATED) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5882 | { /* No. So allocate them with malloc. We need one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5883 | extra element beyond `num_regs' for the `-1' marker | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5884 | GNU code uses. */ | ~~~~~~~~~~~~~~~~~~ 5885 | regs->num_regs = MAX (RE_NREGS, num_nonshy_regs + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5886 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5887 | regs->start = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5888 | regs->end = TALLOC (regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5889 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5890 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5891 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5892 | { | ~ 5893 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5894 | return -2; | ~~~~~~~~~~ 5895 | } | ~ 5896 | bufp->regs_allocated = REGS_REALLOCATE; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5897 | } | ~ 5898 | else if (bufp->regs_allocated == REGS_REALLOCATE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5899 | { /* Yes. If we need more elements than were already | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5900 | allocated, reallocate them. If we need fewer, just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5901 | leave it alone. */ | ~~~~~~~~~~~~~~~~~~~ 5902 | if (regs->num_regs < num_nonshy_regs + 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5903 | { | ~ 5904 | regs->num_regs = num_nonshy_regs + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5905 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 5906 | RETALLOC (regs->start, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5907 | RETALLOC (regs->end, regs->num_regs, regoff_t); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5908 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 5909 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5910 | if (regs->start == NULL || regs->end == NULL) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5911 | { | ~ 5912 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5913 | return -2; | ~~~~~~~~~~ 5914 | } | ~ 5915 | } | ~ 5916 | } | ~ 5917 | else | ~~~~ 5918 | { | ~ 5919 | /* The braces fend off a "empty body in an else-statement" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5920 | warning under GCC when assert expands to nothing. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5921 | assert (bufp->regs_allocated == REGS_FIXED); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5922 | } | ~ 5923 | | 5924 | /* Convert the pointer data in `regstart' and `regend' to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5925 | indices. Register zero has to be set differently, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5926 | since we haven't kept track of any info for it. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5927 | if (regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~ 5928 | { | ~ 5929 | regs->start[0] = pos; | ~~~~~~~~~~~~~~~~~~~~~ 5930 | regs->end[0] = (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5931 | ? ((regoff_t) (d - string1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5932 | : ((regoff_t) (d - string2 + size1))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5933 | } | ~ 5934 | | 5935 | /* Map over the NUM_NONSHY_REGS non-shy internal registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5936 | Copy each into the corresponding external register. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5937 | MCNT indexes external registers. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5938 | for (mcnt = 1; mcnt < MIN (num_nonshy_regs, regs->num_regs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5939 | mcnt++) | ~~~~~~~ 5940 | { | ~ 5941 | int internal_reg = bufp->external_to_internal_register[mcnt]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5942 | if ((int)0xDEADBEEF == internal_reg | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5943 | || REG_UNSET (regstart[internal_reg]) || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5944 | REG_UNSET (regend[internal_reg])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5945 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5946 | else | ~~~~ 5947 | { | ~ 5948 | regs->start[mcnt] = | ~~~~~~~~~~~~~~~~~~~ 5949 | (regoff_t) POINTER_TO_OFFSET (regstart[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5950 | regs->end[mcnt] = | ~~~~~~~~~~~~~~~~~ 5951 | (regoff_t) POINTER_TO_OFFSET (regend[internal_reg]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5952 | } | ~ 5953 | } | ~ 5954 | } /* regs && !bufp->no_sub */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5955 | | 5956 | /* If we have regs and the regs structure has more elements than | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5957 | were in the pattern, set the extra elements starting with | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5958 | NUM_NONSHY_REGS to -1. If we (re)allocated the registers, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5959 | this is the case, because we always allocate enough to have | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5960 | at least one -1 at the end. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5961 | | 5962 | We do this even when no_sub is set because some applications | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5963 | (XEmacs) reuse register structures which may contain stale | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5964 | information, and permit attempts to access those registers. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5965 | | 5966 | It would be possible to require the caller to do this, but we'd | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5967 | have to change the API for this function to reflect that, and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5968 | audit all callers. Note: as of 2003-04-17 callers in XEmacs | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5969 | do clear the registers, but it's safer to leave this code in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5970 | because of reallocation. | ~~~~~~~~~~~~~~~~~~~~~~~~ 5971 | */ | ~~ 5972 | if (regs && regs->num_regs > 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5973 | for (mcnt = num_nonshy_regs; mcnt < regs->num_regs; mcnt++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5974 | regs->start[mcnt] = regs->end[mcnt] = -1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5975 | } | ~ 5976 | DEBUG_MATCH_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5977 | nfailure_points_pushed, nfailure_points_popped, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5978 | nfailure_points_pushed - nfailure_points_popped); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5979 | DEBUG_MATCH_PRINT2 ("%u registers pushed.\n", num_regs_pushed); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5980 | | 5981 | mcnt = d - pos - (MATCHING_IN_FIRST_STRING | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5982 | ? string1 | ~~~~~~~~~ 5983 | : string2 - size1); | ~~~~~~~~~~~~~~~~~~~ 5984 | | 5985 | DEBUG_MATCH_PRINT2 ("Returning %d from re_match_2.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5986 | | 5987 | FREE_VARIABLES (); | ~~~~~~~~~~~~~~~~~~ 5988 | return mcnt; | ~~~~~~~~~~~~ 5989 | } | ~ 5990 | | 5991 | /* Otherwise match next pattern command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5992 | switch ((re_opcode_t) *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5993 | { | ~ 5994 | /* Ignore these. Used to ignore the n of succeed_n's which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5995 | currently have n == 0. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 5996 | case no_op: | ~~~~~~~~~~~ 5997 | DEBUG_MATCH_PRINT1 ("EXECUTING no_op.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5998 | break; | ~~~~~~ 5999 | | 6000 | case succeed: | ~~~~~~~~~~~~~ 6001 | DEBUG_MATCH_PRINT1 ("EXECUTING succeed.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6002 | goto succeed_label; | ~~~~~~~~~~~~~~~~~~~ 6003 | | 6004 | /* Match exactly a string of length n in the pattern. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6005 | following byte in the pattern defines n, and the n bytes after | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6006 | that make up the string to match. (Under Mule, this will be in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6007 | the default internal format.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6008 | case exactn: | ~~~~~~~~~~~~ 6009 | mcnt = *p++; | ~~~~~~~~~~~~ 6010 | DEBUG_MATCH_PRINT2 ("EXECUTING exactn %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6011 | | 6012 | /* This is written out as an if-else so we don't waste time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6013 | testing `translate' inside the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6014 | if (TRANSLATE_P (translate)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6015 | { | ~ 6016 | do | ~~ 6017 | { | ~ 6018 | #ifdef MULE | ~~~~~~~~~~~ 6019 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6020 | | 6021 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6022 | if (RE_TRANSLATE_1 (itext_ichar_fmt (d, fmt, lispobj)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6023 | != itext_ichar (p)) | ~~~~~~~~~~~~~~~~~~~ 6024 | goto fail; | ~~~~~~~~~~ 6025 | | 6026 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6027 | p += pat_len; | ~~~~~~~~~~~~~ 6028 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6029 | | 6030 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6031 | #else /* not MULE */ | ~~~~~~~~~~~~~~~~~~~~ 6032 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6033 | if ((unsigned char) RE_TRANSLATE_1 (*d++) != *p++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6034 | goto fail; | ~~~~~~~~~~ 6035 | mcnt--; | ~~~~~~~ 6036 | #endif | ~~~~~~ 6037 | } | ~ 6038 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6039 | } | ~ 6040 | else | ~~~~ 6041 | { | ~ 6042 | #ifdef MULE | ~~~~~~~~~~~ 6043 | /* If buffer format is default, then we can shortcut and just | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6044 | compare the text directly, byte by byte. Otherwise, we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6045 | need to go character by character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6046 | if (fmt != FORMAT_DEFAULT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6047 | { | ~ 6048 | do | ~~ 6049 | { | ~ 6050 | Bytecount pat_len; | ~~~~~~~~~~~~~~~~~~ 6051 | | 6052 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6053 | if (itext_ichar_fmt (d, fmt, lispobj) != | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6054 | itext_ichar (p)) | ~~~~~~~~~~~~~~~~ 6055 | goto fail; | ~~~~~~~~~~ 6056 | | 6057 | pat_len = itext_ichar_len (p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6058 | p += pat_len; | ~~~~~~~~~~~~~ 6059 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6060 | | 6061 | mcnt -= pat_len; | ~~~~~~~~~~~~~~~~ 6062 | } | ~ 6063 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6064 | } | ~ 6065 | else | ~~~~ 6066 | #endif | ~~~~~~ 6067 | { | ~ 6068 | do | ~~ 6069 | { | ~ 6070 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6071 | if (*d++ != *p++) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6072 | mcnt--; | ~~~~~~~ 6073 | } | ~ 6074 | while (mcnt > 0); | ~~~~~~~~~~~~~~~~~ 6075 | } | ~ 6076 | } | ~ 6077 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6078 | break; | ~~~~~~ 6079 | | 6080 | | 6081 | /* Match any character except possibly a newline or a null. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6082 | case anychar: | ~~~~~~~~~~~~~ 6083 | DEBUG_MATCH_PRINT1 ("EXECUTING anychar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6084 | | 6085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6086 | | 6087 | if ((!(bufp->syntax & RE_DOT_NEWLINE) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6088 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == '\n') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6089 | || (bufp->syntax & RE_DOT_NOT_NULL && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6090 | RE_TRANSLATE (itext_ichar_fmt (d, fmt, lispobj)) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6091 | '\000')) | ~~~~~~~~ 6092 | goto fail; | ~~~~~~~~~~ 6093 | | 6094 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6095 | DEBUG_MATCH_PRINT2 (" Matched `%c'.\n", *d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6096 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6097 | break; | ~~~~~~ 6098 | | 6099 | | 6100 | case charset: | ~~~~~~~~~~~~~ 6101 | case charset_not: | ~~~~~~~~~~~~~~~~~ 6102 | { | ~ 6103 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6104 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6105 | | 6106 | DEBUG_MATCH_PRINT2 ("EXECUTING charset%s.\n", not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6107 | | 6108 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6109 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6110 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6111 | | 6112 | /* Cast to `unsigned int' instead of `unsigned char' in case the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6113 | bit list is a full 32 bytes long. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6114 | if ((unsigned int)c < (unsigned int) (*p * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6115 | && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6116 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6117 | | 6118 | p += 1 + *p; | ~~~~~~~~~~~~ 6119 | | 6120 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6121 | | 6122 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6123 | INC_IBYTEPTR_FMT (d, fmt); /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6124 | break; | ~~~~~~ 6125 | } | ~ 6126 | | 6127 | #ifdef MULE | ~~~~~~~~~~~ 6128 | case charset_mule: | ~~~~~~~~~~~~~~~~~~ 6129 | case charset_mule_not: | ~~~~~~~~~~~~~~~~~~~~~~ 6130 | { | ~ 6131 | REGISTER Ichar c; | ~~~~~~~~~~~~~~~~~ 6132 | re_bool not_p = (re_opcode_t) *(p - 1) == charset_mule_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6133 | Bitbyte class_bits = *p++; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6134 | | 6135 | DEBUG_MATCH_PRINT2 ("EXECUTING charset_mule%s.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6136 | not_p ? "_not" : ""); | ~~~~~~~~~~~~~~~~~~~~~ 6137 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6138 | c = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6139 | c = RE_TRANSLATE (c); /* The character to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6140 | | 6141 | if ((class_bits && | ~~~~~~~~~~~~~~~~~~ 6142 | ((class_bits & BIT_WORD && ISWORD (c)) /* = ALNUM */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6143 | || (class_bits & BIT_ALPHA && ISALPHA (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6144 | || (class_bits & BIT_SPACE && ISSPACE (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6145 | || (class_bits & BIT_PUNCT && ISPUNCT (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6146 | || (TRANSLATE_P (translate) ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6147 | (class_bits & (BIT_UPPER | BIT_LOWER) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6148 | && !NOCASEP (lispbuf, c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6149 | : ((class_bits & BIT_UPPER && ISUPPER (c)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6150 | || (class_bits & BIT_LOWER && ISLOWER (c)))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6151 | || EQ (Qt, unified_range_table_lookup ((void *) p, c, Qnil))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6152 | { | ~ 6153 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6154 | } | ~ 6155 | | 6156 | p += unified_range_table_bytes_used ((void *) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6157 | | 6158 | if (!not_p) goto fail; | ~~~~~~~~~~~~~~~~~~~~~~ 6159 | | 6160 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6161 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6162 | break; | ~~~~~~ 6163 | } | ~ 6164 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 6165 | | 6166 | | 6167 | /* The beginning of a group is represented by start_memory. The | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6168 | arguments are the register number in the next two bytes, and the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6169 | number of groups inner to this one in the two bytes thereafter. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6170 | The text matched within the group is recorded (in the internal | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6171 | registers data structure) under the register number. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6172 | case start_memory: | ~~~~~~~~~~~~~~~~~~ 6173 | { | ~ 6174 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6175 | | 6176 | /* Find out if this group can match the empty string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6177 | p1 = p; /* To send to group_match_null_string_p. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6178 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6179 | | 6180 | DEBUG_MATCH_PRINT3 ("EXECUTING start_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6181 | regno, extract_number (p)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6182 | | 6183 | if (REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6184 | == MATCH_NULL_UNSET_VALUE) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6185 | { | ~ 6186 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6187 | = group_match_null_string_p (&p1, pend, reg_info); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6188 | } | ~ 6189 | | 6190 | DEBUG_MATCH_PRINT2 (" group CAN%s match null string\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6191 | REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6192 | ? "NOT" : ""); | ~~~~~~~~~~~~~~ 6193 | | 6194 | /* Save the position in the string where we were the last time | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6195 | we were at this open-group operator in case the group is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6196 | operated upon by a repetition operator, e.g., with `(a*)*b' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6197 | against `ab'; then we want to ignore where we are now in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6198 | string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6199 | old_regstart[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6200 | ? REG_UNSET (regstart[regno]) ? d : regstart[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6201 | : regstart[regno]; | ~~~~~~~~~~~~~~~~~~ 6202 | DEBUG_MATCH_PRINT2 (" old_regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6203 | POINTER_TO_OFFSET (old_regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6204 | | 6205 | regstart[regno] = d; | ~~~~~~~~~~~~~~~~~~~~ 6206 | DEBUG_MATCH_PRINT2 (" regstart: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6207 | POINTER_TO_OFFSET (regstart[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6208 | | 6209 | IS_ACTIVE (reg_info[regno]) = 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6210 | MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6211 | | 6212 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6213 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6214 | | 6215 | /* This is the new highest active register. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6216 | highest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6217 | /* If nothing was active before, this is the new lowest active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6218 | register. */ | ~~~~~~~~~~~~~ 6219 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6220 | lowest_active_reg = regno; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6221 | | 6222 | /* Move past the inner group count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6223 | p += 2; | ~~~~~~~ 6224 | just_past_start_mem = p; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6225 | break; | ~~~~~~ 6226 | } | ~ 6227 | | 6228 | /* The stop_memory opcode represents the end of a group. Its | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6229 | arguments are the same as start_memory's: the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6230 | number, and the number of inner groups. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6231 | case stop_memory: | ~~~~~~~~~~~~~~~~~ 6232 | { | ~ 6233 | regnum_t regno, inner_groups; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6234 | | 6235 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6236 | EXTRACT_NONNEGATIVE_AND_INCR (inner_groups, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6237 | | 6238 | DEBUG_MATCH_PRINT3 ("EXECUTING stop_memory %d (%d):\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6239 | regno, inner_groups); | ~~~~~~~~~~~~~~~~~~~~~ 6240 | | 6241 | /* We need to save the string position the last time we were at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6242 | this close-group operator in case the group is operated | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6243 | upon by a repetition operator, e.g., with `((a*)*(b*)*)*' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6244 | against `aba'; then we want to ignore where we are now in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6245 | the string in case this attempt to match fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6246 | old_regend[regno] = REG_MATCH_NULL_STRING_P (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6247 | ? REG_UNSET (regend[regno]) ? d : regend[regno] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6248 | : regend[regno]; | ~~~~~~~~~~~~~~~~ 6249 | DEBUG_MATCH_PRINT2 (" old_regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6250 | POINTER_TO_OFFSET (old_regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6251 | regend[regno] = d; | ~~~~~~~~~~~~~~~~~~ 6252 | DEBUG_MATCH_PRINT2 (" regend: %zd\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6253 | POINTER_TO_OFFSET (regend[regno])); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6254 | | 6255 | /* This register isn't active anymore. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6256 | IS_ACTIVE (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6257 | | 6258 | /* Clear this whenever we change the register activity status. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6259 | set_regs_matched_done = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6260 | | 6261 | /* If this was the only register active, nothing is active | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6262 | anymore. */ | ~~~~~~~~~~~~ 6263 | if (lowest_active_reg == highest_active_reg) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6264 | { | ~ 6265 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6266 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6267 | } | ~ 6268 | else | ~~~~ 6269 | { | ~ 6270 | /* We must scan for the new highest active register, since it | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6271 | isn't necessarily one less than now: consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6272 | (a(b)c(d(e)f)g). When group 3 ends, after the f), the new | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6273 | highest active register is 1. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6274 | regnum_t r = regno - 1; | ~~~~~~~~~~~~~~~~~~~~~~~ 6275 | while (r > 0 && !IS_ACTIVE (reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6276 | r--; | ~~~~ 6277 | | 6278 | /* If we end up at register zero, that means that we saved | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6279 | the registers as the result of an `on_failure_jump', not | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6280 | a `start_memory', and we jumped to past the innermost | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6281 | `stop_memory'. For example, in ((.)*) we save registers | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6282 | 1 and 2 as a result of the *, but when we pop back to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6283 | second ), we are at the stop_memory 1. Thus, nothing is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6284 | active. */ | ~~~~~~~~~~~ 6285 | if (r == 0) | ~~~~~~~~~~~ 6286 | { | ~ 6287 | lowest_active_reg = NO_LOWEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6288 | highest_active_reg = NO_HIGHEST_ACTIVE_REG; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6289 | } | ~ 6290 | else | ~~~~ 6291 | { | ~ 6292 | highest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~~ 6293 | | 6294 | /* 98/9/21 jhod: We've also gotta set lowest_active_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6295 | don't we? */ | ~~~~~~~~~~~~ 6296 | r = 1; | ~~~~~~ 6297 | while (r < highest_active_reg && !IS_ACTIVE(reg_info[r])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6298 | r++; | ~~~~ 6299 | lowest_active_reg = r; | ~~~~~~~~~~~~~~~~~~~~~~ 6300 | } | ~ 6301 | } | ~ 6302 | | 6303 | /* If just failed to match something this time around with a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6304 | group that's operated on by a repetition operator, try to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6305 | force exit from the ``loop'', and restore the register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6306 | information for this group that we had before trying this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6307 | last match. */ | ~~~~~~~~~~~~~~~ 6308 | if ((!MATCHED_SOMETHING (reg_info[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6309 | || just_past_start_mem == p - 4) && p < pend) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6310 | { | ~ 6311 | re_bool is_a_jump_n = false; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6312 | | 6313 | p1 = p; | ~~~~~~~ 6314 | mcnt = 0; | ~~~~~~~~~ 6315 | switch ((re_opcode_t) *p1++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6316 | { | ~ 6317 | case jump_n: | ~~~~~~~~~~~~ 6318 | is_a_jump_n = true; | ~~~~~~~~~~~~~~~~~~~ 6319 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6320 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6321 | case jump: | ~~~~~~~~~~ 6322 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6323 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6324 | if (is_a_jump_n) | ~~~~~~~~~~~~~~~~ 6325 | p1 += 2; | ~~~~~~~~ 6326 | break; | ~~~~~~ 6327 | | 6328 | default: | ~~~~~~~~ 6329 | /* do nothing */ ; | ~~~~~~~~~~~~~~~~~~ 6330 | } | ~ 6331 | p1 += mcnt; | ~~~~~~~~~~~ 6332 | | 6333 | /* If the next operation is a jump backwards in the pattern | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6334 | to an on_failure_jump right before the start_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6335 | corresponding to this stop_memory, exit from the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6336 | by forcing a failure after pushing on the stack the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6337 | on_failure_jump's jump in the pattern, and d. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6338 | if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6339 | && (re_opcode_t) p1[3] == start_memory && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6340 | regno == extract_nonnegative (p1 + 4)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6341 | { | ~ 6342 | /* If this group ever matched anything, then restore | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6343 | what its registers were before trying this last | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6344 | failed match, e.g., with `(a*)*b' against `ab' for | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6345 | regstart[1], and, e.g., with `((a*)*(b*)*)*' against | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6346 | `aba' for regend[3]. | ~~~~~~~~~~~~~~~~~~~~ 6347 | | 6348 | Also restore the registers for inner groups for, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6349 | e.g., `((a*)(b*))*' against `aba' (register 3 would | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6350 | otherwise get trashed). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6351 | if (EVER_MATCHED_SOMETHING (reg_info[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6352 | { | ~ 6353 | int r; | ~~~~~~ 6354 | | 6355 | EVER_MATCHED_SOMETHING (reg_info[regno]) = 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6356 | | 6357 | /* Restore this and inner groups' (if any) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6358 | registers. */ | ~~~~~~~~~~~~~~ 6359 | for (r = regno; r < regno + inner_groups; r++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6360 | { | ~ 6361 | regstart[r] = old_regstart[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6362 | | 6363 | /* xx why this test? */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6364 | if (old_regend[r] >= regstart[r]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6365 | regend[r] = old_regend[r]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6366 | } | ~ 6367 | } | ~ 6368 | p1++; | ~~~~~ 6369 | EXTRACT_NUMBER_AND_INCR (mcnt, p1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6370 | PUSH_FAILURE_POINT (p1 + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6371 | | 6372 | goto fail; | ~~~~~~~~~~ 6373 | } | ~ 6374 | } | ~ 6375 | /* We used to move past the register number and inner group count | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6376 | here, when registers were just one byte; that's no longer | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6377 | necessary with EXTRACT_NUMBER_AND_INCR(), above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6378 | break; | ~~~~~~ 6379 | } | ~ 6380 | | 6381 | /* \ has been turned into a `duplicate' command which is | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6382 | followed by the numeric value of as the register number. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6383 | (Already passed through external-to-internal-register mapping, so | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6384 | it refers to the actual group number, not the non-shy-only | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6385 | numbering used in the external world.) */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6386 | case duplicate: | ~~~~~~~~~~~~~~~ 6387 | { | ~ 6388 | REGISTER re_char *d2, *dend2; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6389 | /* Get which register to match against. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6390 | regnum_t regno; | ~~~~~~~~~~~~~~~ 6391 | | 6392 | EXTRACT_NONNEGATIVE_AND_INCR (regno, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6393 | DEBUG_MATCH_PRINT2 ("EXECUTING duplicate %d.\n", regno); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6394 | | 6395 | /* Can't back reference a group which we've never matched. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6396 | if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6397 | goto fail; | ~~~~~~~~~~ 6398 | | 6399 | /* Where in input to try to start matching. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6400 | d2 = regstart[regno]; | ~~~~~~~~~~~~~~~~~~~~~ 6401 | | 6402 | /* Where to stop matching; if both the place to start and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6403 | the place to stop matching are in the same string, then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6404 | set to the place to stop, otherwise, for now have to use | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6405 | the end of the first string. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6406 | | 6407 | dend2 = ((FIRST_STRING_P (regstart[regno]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6408 | == FIRST_STRING_P (regend[regno])) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6409 | ? regend[regno] : end_match_1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6410 | for (;;) | ~~~~~~~~ 6411 | { | ~ 6412 | /* If necessary, advance to next segment in register | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6413 | contents. */ | ~~~~~~~~~~~~~ 6414 | while (d2 == dend2) | ~~~~~~~~~~~~~~~~~~~ 6415 | { | ~ 6416 | if (dend2 == end_match_2) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6417 | if (dend2 == regend[regno]) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6418 | | 6419 | /* End of string1 => advance to string2. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6420 | d2 = string2; | ~~~~~~~~~~~~~ 6421 | dend2 = regend[regno]; | ~~~~~~~~~~~~~~~~~~~~~~ 6422 | } | ~ 6423 | /* At end of register contents => success */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6424 | if (d2 == dend2) break; | ~~~~~~~~~~~~~~~~~~~~~~~ 6425 | | 6426 | /* If necessary, advance to next segment in data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6427 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 6428 | | 6429 | /* How many characters left in this segment to match. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6430 | mcnt = dend - d; | ~~~~~~~~~~~~~~~~ 6431 | | 6432 | /* Want how many consecutive characters we can match in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6433 | one shot, so, if necessary, adjust the count. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6434 | if (mcnt > dend2 - d2) | ~~~~~~~~~~~~~~~~~~~~~~ 6435 | mcnt = dend2 - d2; | ~~~~~~~~~~~~~~~~~~ 6436 | | 6437 | /* Compare that many; failure if mismatch, else move | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6438 | past them. */ | ~~~~~~~~~~~~~~ 6439 | if (TRANSLATE_P (translate) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6440 | ? bcmp_translate (d, d2, mcnt, translate | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6441 | #ifdef emacs | ~~~~~~~~~~~~ 6442 | , fmt, lispobj | ~~~~~~~~~~~~~~ 6443 | #endif | ~~~~~~ 6444 | ) | ~ 6445 | : memcmp (d, d2, mcnt)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6446 | goto fail; | ~~~~~~~~~~ 6447 | d += mcnt, d2 += mcnt; | ~~~~~~~~~~~~~~~~~~~~~~ 6448 | | 6449 | /* Do this because we've match some characters. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6450 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 6451 | } | ~ 6452 | } | ~ 6453 | break; | ~~~~~~ 6454 | | 6455 | | 6456 | /* begline matches the empty string at the beginning of the string | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6457 | (unless `not_bol' is set in `bufp'), and, if | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6458 | `newline_anchor' is set, after newlines. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6459 | case begline: | ~~~~~~~~~~~~~ 6460 | DEBUG_MATCH_PRINT1 ("EXECUTING begline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6461 | | 6462 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6463 | { | ~ 6464 | if (!bufp->not_bol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6465 | } | ~ 6466 | else | ~~~~ 6467 | { | ~ 6468 | re_char *d2 = d; | ~~~~~~~~~~~~~~~~ 6469 | DEC_IBYTEPTR (d2); | ~~~~~~~~~~~~~~~~~~ 6470 | if (itext_ichar_ascii_fmt (d2, fmt, lispobj) == '\n' && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6471 | bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~ 6472 | break; | ~~~~~~ 6473 | } | ~ 6474 | /* In all other cases, we fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6475 | goto fail; | ~~~~~~~~~~ 6476 | | 6477 | | 6478 | /* endline is the dual of begline. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6479 | case endline: | ~~~~~~~~~~~~~ 6480 | DEBUG_MATCH_PRINT1 ("EXECUTING endline.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6481 | | 6482 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6483 | { | ~ 6484 | if (!bufp->not_eol) break; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 6485 | } | ~ 6486 | | 6487 | /* We have to ``prefetch'' the next character. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6488 | else if ((d == end1 ? | ~~~~~~~~~~~~~~~~~~~~~ 6489 | itext_ichar_ascii_fmt (string2, fmt, lispobj) : | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6490 | itext_ichar_ascii_fmt (d, fmt, lispobj)) == '\n' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6491 | && bufp->newline_anchor) | ~~~~~~~~~~~~~~~~~~~~~~~~ 6492 | { | ~ 6493 | break; | ~~~~~~ 6494 | } | ~ 6495 | goto fail; | ~~~~~~~~~~ 6496 | | 6497 | | 6498 | /* Match at the very beginning of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6499 | case begbuf: | ~~~~~~~~~~~~ 6500 | DEBUG_MATCH_PRINT1 ("EXECUTING begbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6501 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6502 | break; | ~~~~~~ 6503 | goto fail; | ~~~~~~~~~~ 6504 | | 6505 | | 6506 | /* Match at the very end of the data. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6507 | case endbuf: | ~~~~~~~~~~~~ 6508 | DEBUG_MATCH_PRINT1 ("EXECUTING endbuf.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6509 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6510 | break; | ~~~~~~ 6511 | goto fail; | ~~~~~~~~~~ 6512 | | 6513 | | 6514 | /* on_failure_keep_string_jump is used to optimize `.*\n'. It | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6515 | pushes NULL as the value for the string on the stack. Then | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6516 | `pop_failure_point' will keep the current value for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6517 | string, instead of restoring it. To see why, consider | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6518 | matching `foo\nbar' against `.*\n'. The .* matches the foo; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6519 | then the . fails against the \n. But the next thing we want | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6520 | to do is match the \n against the \n; if we restored the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6521 | string value, we would be back at the foo. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6522 | | 6523 | Because this is used only in specific cases, we don't need to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6524 | check all the things that `on_failure_jump' does, to make | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6525 | sure the right things get saved on the stack. Hence we don't | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6526 | share its code. The only reason to push anything on the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6527 | stack at all is that otherwise we would have to change | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6528 | `anychar's code to do something besides goto fail in this | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6529 | case; that seems worse than this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6530 | case on_failure_keep_string_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6531 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6532 | | 6533 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6534 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx):\n", mcnt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6535 | (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~ 6536 | | 6537 | PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6538 | break; | ~~~~~~ 6539 | | 6540 | | 6541 | /* Uses of on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6542 | | 6543 | Each alternative starts with an on_failure_jump that points | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6544 | to the beginning of the next alternative. Each alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6545 | except the last ends with a jump that in effect jumps past | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6546 | the rest of the alternatives. (They really jump to the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6547 | ending jump of the following alternative, because tensioning | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6548 | these jumps is a hassle.) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6549 | | 6550 | Repeats start with an on_failure_jump that points past both | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6551 | the repetition text and either the following jump or | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6552 | pop_failure_jump back to this on_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6553 | case on_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~ 6554 | on_failure: | ~~~~~~~~~~~ 6555 | DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6556 | | 6557 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6558 | DEBUG_MATCH_PRINT3 (" %d (to 0x%zx)", mcnt, (Bytecount) (p + mcnt)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6559 | | 6560 | /* If this on_failure_jump comes right before a group (i.e., | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6561 | the original * applied to a group), save the information | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6562 | for that group and all inner ones, so that if we fail back | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6563 | to this point, the group's information will be correct. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6564 | For example, in \(a*\)*\1, we need the preceding group, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6565 | and in \(\(a*\)b*\)\2, we need the inner group. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6566 | | 6567 | /* We can't use `p' to check ahead because we push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6568 | a failure point to `p + mcnt' after we do this. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6569 | p1 = p; | ~~~~~~~ 6570 | | 6571 | /* We need to skip no_op's before we look for the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6572 | start_memory in case this on_failure_jump is happening as | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6573 | the result of a completed succeed_n, as in \(a\)\{1,3\}b\1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6574 | against aba. */ | ~~~~~~~~~~~~~~~~ 6575 | while (p1 < pend && (re_opcode_t) *p1 == no_op) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6576 | p1++; | ~~~~~ 6577 | | 6578 | if (p1 < pend && (re_opcode_t) *p1 == start_memory) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6579 | { | ~ 6580 | /* We have a new highest active register now. This will | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6581 | get reset at the start_memory we are about to get to, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6582 | but we will have saved all the registers relevant to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6583 | this repetition op, as described above. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6584 | highest_active_reg = *(p1 + 1) + *(p1 + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6585 | if (lowest_active_reg == NO_LOWEST_ACTIVE_REG) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6586 | lowest_active_reg = *(p1 + 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6587 | } | ~ 6588 | | 6589 | DEBUG_MATCH_PRINT1 (":\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6590 | PUSH_FAILURE_POINT (p + mcnt, d, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6591 | break; | ~~~~~~ 6592 | | 6593 | | 6594 | /* A smart repeat ends with `maybe_pop_jump'. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6595 | We change it to either `pop_failure_jump' or `jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6596 | case maybe_pop_jump: | ~~~~~~~~~~~~~~~~~~~~ 6597 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6598 | DEBUG_MATCH_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6599 | { | ~ 6600 | REGISTER const unsigned char *p2 = p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6601 | | 6602 | /* Compare the beginning of the repeat with what in the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6603 | pattern follows its end. If we can establish that there | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6604 | is nothing that they would both match, i.e., that we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6605 | would have to backtrack because of (as in, e.g., `a*a') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6606 | then we can change to pop_failure_jump, because we'll | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6607 | never have to backtrack. | ~~~~~~~~~~~~~~~~~~~~~~~~ 6608 | | 6609 | This is not true in the case of alternatives: in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6610 | `(a|ab)*' we do need to backtrack to the `ab' alternative | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6611 | (e.g., if the string was `ab'). But instead of trying to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6612 | detect that here, the alternative has put on a dummy | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6613 | failure point which is what we will end up popping. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6614 | | 6615 | /* Skip over open/close-group commands. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6616 | If what follows this loop is a ...+ construct, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6617 | look at what begins its body, since we will have to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6618 | match at least one of that. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6619 | while (1) | ~~~~~~~~~ 6620 | { | ~ 6621 | if (p2 + 2 < pend | ~~~~~~~~~~~~~~~~~ 6622 | && ((re_opcode_t) *p2 == stop_memory | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6623 | || (re_opcode_t) *p2 == start_memory)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6624 | p2 += 3; | ~~~~~~~~ 6625 | else if (p2 + 6 < pend | ~~~~~~~~~~~~~~~~~~~~~~ 6626 | && (re_opcode_t) *p2 == dummy_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6627 | p2 += 6; | ~~~~~~~~ 6628 | else | ~~~~ 6629 | break; | ~~~~~~ 6630 | } | ~ 6631 | | 6632 | p1 = p + mcnt; | ~~~~~~~~~~~~~~ 6633 | /* p1[0] ... p1[2] are the `on_failure_jump' corresponding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6634 | to the `maybe_finalize_jump' of this case. Examine what | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6635 | follows. */ | ~~~~~~~~~~~~ 6636 | | 6637 | /* If we're at the end of the pattern, we can change. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6638 | if (p2 == pend) | ~~~~~~~~~~~~~~~ 6639 | { | ~ 6640 | /* Consider what happens when matching ":\(.*\)" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6641 | against ":/". I don't really understand this code | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6642 | yet. */ | ~~~~~~~~ 6643 | ((unsigned char *)p)[-3] = (re_char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6644 | DEBUG_MATCH_PRINT1 | ~~~~~~~~~~~~~~~~~~ 6645 | (" End of pattern: change to `pop_failure_jump'.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6646 | } | ~ 6647 | | 6648 | else if ((re_opcode_t) *p2 == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6649 | || (bufp->newline_anchor && (re_opcode_t) *p2 == endline)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6650 | { | ~ 6651 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6652 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6653 | | 6654 | if ((re_opcode_t) p1[3] == exactn && p1[5] != c) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6655 | { | ~ 6656 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6657 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6658 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6659 | c, p1[5]); | ~~~~~~~~~~ 6660 | } | ~ 6661 | | 6662 | else if ((re_opcode_t) p1[3] == charset | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6663 | || (re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6664 | { | ~ 6665 | int not_p = (re_opcode_t) p1[3] == charset_not; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6666 | | 6667 | if (c < (unsigned char) (p1[4] * BYTEWIDTH) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6668 | && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6669 | not_p = !not_p; | ~~~~~~~~~~~~~~~ 6670 | | 6671 | /* `not_p' is equal to 1 if c would match, which means | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6672 | that we can't change to pop_failure_jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6673 | if (!not_p) | ~~~~~~~~~~~ 6674 | { | ~ 6675 | ((unsigned char *)p)[-3] | ~~~~~~~~~~~~~~~~~~~~~~~~ 6676 | = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6677 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6678 | } | ~ 6679 | } | ~ 6680 | } | ~ 6681 | else if ((re_opcode_t) *p2 == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6682 | { | ~ 6683 | #ifdef DEBUG | ~~~~~~~~~~~~ 6684 | REGISTER unsigned char c | ~~~~~~~~~~~~~~~~~~~~~~~~ 6685 | = *p2 == (unsigned char) endline ? '\n' : p2[2]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6686 | #endif | ~~~~~~ 6687 | | 6688 | if ((re_opcode_t) p1[3] == exactn | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6689 | && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6690 | && (p2[2 + p1[5] / BYTEWIDTH] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6691 | & (1 << (p1[5] % BYTEWIDTH))))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6692 | { | ~ 6693 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6694 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6695 | DEBUG_MATCH_PRINT3 (" %c != %c => pop_failure_jump.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6696 | c, p1[5]); | ~~~~~~~~~~ 6697 | } | ~ 6698 | | 6699 | else if ((re_opcode_t) p1[3] == charset_not) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6700 | { | ~ 6701 | int idx; | ~~~~~~~~ 6702 | /* We win if the charset_not inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6703 | lists every character listed in the charset after. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6704 | for (idx = 0; idx < (int) p2[1]; idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6705 | if (! (p2[2 + idx] == 0 | ~~~~~~~~~~~~~~~~~~~~~~~ 6706 | || (idx < (int) p1[4] | ~~~~~~~~~~~~~~~~~~~~~ 6707 | && ((p2[2 + idx] & ~ p1[5 + idx]) == 0)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6708 | break; | ~~~~~~ 6709 | | 6710 | if (idx == p2[1]) | ~~~~~~~~~~~~~~~~~ 6711 | { | ~ 6712 | unsigned char *p3 = (unsigned char *) p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6713 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6714 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6715 | } | ~ 6716 | } | ~ 6717 | else if ((re_opcode_t) p1[3] == charset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6718 | { | ~ 6719 | int idx; | ~~~~~~~~ 6720 | /* We win if the charset inside the loop | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6721 | has no overlap with the one after the loop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6722 | for (idx = 0; | ~~~~~~~~~~~~~ 6723 | idx < (int) p2[1] && idx < (int) p1[4]; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6724 | idx++) | ~~~~~~ 6725 | if ((p2[2 + idx] & p1[5 + idx]) != 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6726 | break; | ~~~~~~ 6727 | | 6728 | if (idx == p2[1] || idx == p1[4]) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6729 | { | ~ 6730 | unsigned char *p3 = (unsigned char *)p; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6731 | p3[-3] = (unsigned char) pop_failure_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6732 | DEBUG_MATCH_PRINT1 (" No match => pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6733 | } | ~ 6734 | } | ~ 6735 | } | ~ 6736 | } | ~ 6737 | p -= 2; /* Point at relative address again. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6738 | if ((re_opcode_t) p[-1] != pop_failure_jump) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6739 | { | ~ 6740 | p[-1] = (unsigned char) jump; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6741 | DEBUG_MATCH_PRINT1 (" Match => jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6742 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6743 | } | ~ 6744 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6745 | | 6746 | | 6747 | /* The end of a simple repeat has a pop_failure_jump back to | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6748 | its matching on_failure_jump, where the latter will push a | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6749 | failure point. The pop_failure_jump takes off failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6750 | points put on by this pop_failure_jump's matching | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6751 | on_failure_jump; we got through the pattern to here from the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6752 | matching on_failure_jump, so didn't fail. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6753 | case pop_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~ 6754 | { | ~ 6755 | /* We need to pass separate storage for the lowest and | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6756 | highest registers, even though we don't care about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6757 | actual values. Otherwise, we will restore only one | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6758 | register from the stack, since lowest will == highest in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6759 | `pop_failure_point'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~ 6760 | int dummy_low_reg, dummy_high_reg; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6761 | unsigned char *pdummy; | ~~~~~~~~~~~~~~~~~~~~~~ 6762 | re_char *sdummy = NULL; | ~~~~~~~~~~~~~~~~~~~~~~~ 6763 | | 6764 | USED (sdummy); /* Silence warning. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6765 | | 6766 | DEBUG_MATCH_PRINT1 ("EXECUTING pop_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6767 | POP_FAILURE_POINT (sdummy, pdummy, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6768 | dummy_low_reg, dummy_high_reg, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6769 | reg_dummy, reg_dummy, reg_info_dummy); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6770 | USED (pdummy); | ~~~~~~~~~~~~~~ 6771 | } | ~ 6772 | /* Note fall through. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6773 | | 6774 | | 6775 | /* Unconditionally jump (without popping any failure points). */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6776 | case jump: | ~~~~~~~~~~ 6777 | unconditional_jump: | ~~~~~~~~~~~~~~~~~~~ 6778 | EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6779 | DEBUG_MATCH_PRINT2 ("EXECUTING jump %d ", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6780 | p += mcnt; /* Do the jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6781 | DEBUG_MATCH_PRINT2 ("(to 0x%zx).\n", (Bytecount) p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6782 | break; | ~~~~~~ 6783 | | 6784 | | 6785 | /* We need this opcode so we can detect where alternatives end | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6786 | in `group_match_null_string_p' et al. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6787 | case jump_past_alt: | ~~~~~~~~~~~~~~~~~~~ 6788 | DEBUG_MATCH_PRINT1 ("EXECUTING jump_past_alt.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6789 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6790 | | 6791 | | 6792 | /* Normally, the on_failure_jump pushes a failure point, which | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6793 | then gets popped at pop_failure_jump. We will end up at | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6794 | pop_failure_jump, also, and with a pattern of, say, `a+', we | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6795 | are skipping over the on_failure_jump, so we have to push | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6796 | something meaningless for pop_failure_jump to pop. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6797 | case dummy_failure_jump: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6798 | DEBUG_MATCH_PRINT1 ("EXECUTING dummy_failure_jump.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6799 | /* It doesn't matter what we push for the string here. What | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6800 | the code at `fail' tests is the value for the pattern. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6801 | PUSH_FAILURE_POINT ((unsigned char *) 0, (unsigned char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6802 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6803 | | 6804 | | 6805 | /* At the end of an alternative, we need to push a dummy failure | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6806 | point in case we are followed by a `pop_failure_jump', because | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6807 | we don't want the failure point for the alternative to be | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6808 | popped. For example, matching `(a|ab)*' against `aab' | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6809 | requires that we match the `ab' alternative. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6810 | case push_dummy_failure: | ~~~~~~~~~~~~~~~~~~~~~~~~ 6811 | DEBUG_MATCH_PRINT1 ("EXECUTING push_dummy_failure.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6812 | /* See comments just above at `dummy_failure_jump' about the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6813 | two zeroes. */ | ~~~~~~~~~~~~~~~ 6814 | PUSH_FAILURE_POINT ((re_char *) 0, (re_char *) 0, -2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6815 | break; | ~~~~~~ 6816 | | 6817 | /* Have to succeed matching what follows at least n times. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6818 | After that, handle like `on_failure_jump'. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6819 | case succeed_n: | ~~~~~~~~~~~~~~~ 6820 | EXTRACT_NONNEGATIVE (mcnt, p + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6821 | DEBUG_MATCH_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6822 | | 6823 | /* Originally, this is how many times we HAVE to succeed. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6824 | if (mcnt) | ~~~~~~~~~ 6825 | { | ~ 6826 | mcnt--; | ~~~~~~~ 6827 | p += 2; | ~~~~~~~ 6828 | DEBUG_MATCH_PRINT3 (" Setting 0x%zx to %d.\n", (Bytecount) p, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6829 | mcnt); | ~~~~~~ 6830 | STORE_MATCH_NUMBER_AND_INCR (p, mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6831 | } | ~ 6832 | else | ~~~~ 6833 | { | ~ 6834 | DEBUG_MATCH_PRINT2 (" Setting two bytes from 0x%zx to no_op.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6835 | (Bytecount) (p+2)); | ~~~~~~~~~~~~~~~~~~~ 6836 | STORE_MATCH_NUMBER (p + 2, no_op); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6837 | goto on_failure; | ~~~~~~~~~~~~~~~~ 6838 | } | ~ 6839 | break; | ~~~~~~ 6840 | | 6841 | case jump_n: | ~~~~~~~~~~~~ 6842 | EXTRACT_NONNEGATIVE (mcnt, p + 2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6843 | DEBUG_MATCH_PRINT2 ("EXECUTING jump_n %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6844 | | 6845 | /* Originally, this is how many times we CAN jump. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6846 | if (mcnt) | ~~~~~~~~~ 6847 | { | ~ 6848 | mcnt--; | ~~~~~~~ 6849 | STORE_MATCH_NUMBER (p + 2, mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6850 | goto unconditional_jump; | ~~~~~~~~~~~~~~~~~~~~~~~~ 6851 | } | ~ 6852 | /* If don't have to jump any more, skip over the rest of command. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6853 | else | ~~~~ 6854 | p += 4; | ~~~~~~~ 6855 | break; | ~~~~~~ 6856 | | 6857 | case set_number_at: | ~~~~~~~~~~~~~~~~~~~ 6858 | { | ~ 6859 | unsigned char *p2; /* Location of the counter. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6860 | DEBUG_MATCH_PRINT1 ("EXECUTING set_number_at.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6861 | | 6862 | EXTRACT_NUMBER_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6863 | /* Discard 'const', making re_match_2_internal() | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6864 | non-reentrant. */ | ~~~~~~~~~~~~~~~~~~ 6865 | p2 = (unsigned char *) p + mcnt; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6866 | EXTRACT_NONNEGATIVE_AND_INCR (mcnt, p); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6867 | | 6868 | DEBUG_MATCH_PRINT3 (" Setting 0x%zx to %d.\n", (Bytecount) p2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6869 | mcnt); | ~~~~~~ 6870 | STORE_MATCH_NUMBER (p2, mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6871 | break; | ~~~~~~ 6872 | } | ~ 6873 | | 6874 | case wordbound: | ~~~~~~~~~~~~~~~ 6875 | DEBUG_MATCH_PRINT1 ("EXECUTING wordbound.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6876 | should_succeed = 1; | ~~~~~~~~~~~~~~~~~~~ 6877 | matchwordbound: | ~~~~~~~~~~~~~~~ 6878 | { | ~ 6879 | /* XEmacs change */ | ~~~~~~~~~~~~~~~~~~~ 6880 | /* Straightforward and (I hope) correct implementation. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6881 | /* emch1 is the character before d, syn1 is the syntax of | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6882 | emch1, emch2 is the character at d, and syn2 is the | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6883 | syntax of emch2. */ | ~~~~~~~~~~~~~~~~~~~ 6884 | Ichar emch1, emch2; | ~~~~~~~~~~~~~~~~~~~ 6885 | int syn1 = 0, | ~~~~~~~~~~~~~ 6886 | syn2 = 0; | ~~~~~~~~~ 6887 | re_char *d_before, *d_after; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6888 | int result, | ~~~~~~~~~~~ 6889 | at_beg = AT_STRINGS_BEG (d), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6890 | at_end = AT_STRINGS_END (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6891 | | 6892 | if (at_beg && at_end) | ~~~~~~~~~~~~~~~~~~~~~ 6893 | { | ~ 6894 | result = 0; | ~~~~~~~~~~~ 6895 | } | ~ 6896 | else | ~~~~ 6897 | { | ~ 6898 | if (!at_beg) | ~~~~~~~~~~~~ 6899 | { | ~ 6900 | d_before = POS_BEFORE_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6901 | DEC_IBYTEPTR_FMT (d_before, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6902 | emch1 = itext_ichar_fmt (d_before, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6903 | #ifdef emacs | ~~~~~~~~~~~~ 6904 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6905 | UPDATE_SYNTAX_CACHE (scache, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6906 | offset_to_bytexpos | ~~~~~~~~~~~~~~~~~~ 6907 | (lispobj, PTR_TO_OFFSET (d_before))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6908 | #endif | ~~~~~~ 6909 | syn1 = SYNTAX_FROM_CACHE (scache, emch1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6910 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 6911 | } | ~ 6912 | if (!at_end) | ~~~~~~~~~~~~ 6913 | { | ~ 6914 | d_after = POS_AFTER_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6915 | emch2 = itext_ichar_fmt (d_after, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6916 | #ifdef emacs | ~~~~~~~~~~~~ 6917 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6918 | UPDATE_SYNTAX_CACHE_FORWARD (scache, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6919 | offset_to_bytexpos | ~~~~~~~~~~~~~~~~~~ 6920 | (lispobj, PTR_TO_OFFSET (d))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6921 | #endif | ~~~~~~ 6922 | syn2 = SYNTAX_FROM_CACHE (scache, emch2); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6923 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 6924 | } | ~ 6925 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6926 | | 6927 | if (at_beg) | ~~~~~~~~~~~ 6928 | result = (syn2 == Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6929 | else if (at_end) | ~~~~~~~~~~~~~~~~ 6930 | result = (syn1 == Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6931 | else | ~~~~ 6932 | result = ((syn1 == Sword) != (syn2 == Sword)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6933 | } | ~ 6934 | | 6935 | if (result == should_succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6936 | break; | ~~~~~~ 6937 | goto fail; | ~~~~~~~~~~ 6938 | } | ~ 6939 | | 6940 | case notwordbound: | ~~~~~~~~~~~~~~~~~~ 6941 | DEBUG_MATCH_PRINT1 ("EXECUTING notwordbound.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6942 | should_succeed = 0; | ~~~~~~~~~~~~~~~~~~~ 6943 | goto matchwordbound; | ~~~~~~~~~~~~~~~~~~~~ 6944 | | 6945 | case wordbeg: | ~~~~~~~~~~~~~ 6946 | DEBUG_MATCH_PRINT1 ("EXECUTING wordbeg.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6947 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6948 | goto fail; | ~~~~~~~~~~ 6949 | { | ~ 6950 | /* XEmacs: this originally read: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6951 | | 6952 | if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6953 | break; | ~~~~~~ 6954 | | 6955 | */ | ~~ 6956 | re_char *dtmp = POS_AFTER_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6957 | Ichar emch = itext_ichar_fmt (dtmp, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6958 | int tempres; | ~~~~~~~~~~~~ 6959 | | 6960 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6961 | #ifdef emacs | ~~~~~~~~~~~~ 6962 | UPDATE_SYNTAX_CACHE | ~~~~~~~~~~~~~~~~~~~ 6963 | (scache, | ~~~~~~~~ 6964 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (d))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6965 | #endif | ~~~~~~ 6966 | tempres = (SYNTAX_FROM_CACHE (scache, emch) != Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6967 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 6968 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6969 | if (tempres) | ~~~~~~~~~~~~ 6970 | goto fail; | ~~~~~~~~~~ 6971 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6972 | break; | ~~~~~~ 6973 | dtmp = POS_BEFORE_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6974 | DEC_IBYTEPTR_FMT (dtmp, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6975 | emch = itext_ichar_fmt (dtmp, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6976 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 6977 | #ifdef emacs | ~~~~~~~~~~~~ 6978 | UPDATE_SYNTAX_CACHE_BACKWARD | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6979 | (scache, | ~~~~~~~~ 6980 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (dtmp))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6981 | #endif | ~~~~~~ 6982 | tempres = (SYNTAX_FROM_CACHE (scache, emch) != Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6983 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 6984 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6985 | if (tempres) | ~~~~~~~~~~~~ 6986 | break; | ~~~~~~ 6987 | goto fail; | ~~~~~~~~~~ 6988 | } | ~ 6989 | | 6990 | case wordend: | ~~~~~~~~~~~~~ 6991 | DEBUG_MATCH_PRINT1 ("EXECUTING wordend.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6992 | if (AT_STRINGS_BEG (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 6993 | goto fail; | ~~~~~~~~~~ 6994 | { | ~ 6995 | /* XEmacs: this originally read: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6996 | | 6997 | if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6998 | && (!WORDCHAR_P (d) || AT_STRINGS_END (d))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6999 | break; | ~~~~~~ 7000 | | 7001 | The or condition is incorrect (reversed). | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7002 | */ | ~~ 7003 | re_char *dtmp; | ~~~~~~~~~~~~~~ 7004 | Ichar emch; | ~~~~~~~~~~~ 7005 | int tempres; | ~~~~~~~~~~~~ 7006 | #ifdef emacs | ~~~~~~~~~~~~ 7007 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7008 | UPDATE_SYNTAX_CACHE | ~~~~~~~~~~~~~~~~~~~ 7009 | (scache, | ~~~~~~~~ 7010 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (d))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7011 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7012 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7013 | #endif | ~~~~~~ 7014 | dtmp = POS_BEFORE_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7015 | DEC_IBYTEPTR_FMT (dtmp, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7016 | emch = itext_ichar_fmt (dtmp, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7017 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7018 | tempres = (SYNTAX_FROM_CACHE (scache, emch) != Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7019 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7020 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7021 | if (tempres) | ~~~~~~~~~~~~ 7022 | goto fail; | ~~~~~~~~~~ 7023 | if (AT_STRINGS_END (d)) | ~~~~~~~~~~~~~~~~~~~~~~~ 7024 | break; | ~~~~~~ 7025 | dtmp = POS_AFTER_GAP_UNSAFE (d); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7026 | emch = itext_ichar_fmt (dtmp, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7027 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7028 | #ifdef emacs | ~~~~~~~~~~~~ 7029 | { | ~ 7030 | re_char *next = d; | ~~~~~~~~~~~~~~~~~~ 7031 | INC_IBYTEPTR_FMT (next, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7032 | UPDATE_SYNTAX_CACHE_FORWARD | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7033 | (scache, | ~~~~~~~~ 7034 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (next))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7035 | } | ~ 7036 | #endif | ~~~~~~ 7037 | tempres = (SYNTAX_FROM_CACHE (scache, emch) != Sword); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7038 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7039 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7040 | if (tempres) | ~~~~~~~~~~~~ 7041 | break; | ~~~~~~ 7042 | goto fail; | ~~~~~~~~~~ 7043 | } | ~ 7044 | | 7045 | #ifdef emacs | ~~~~~~~~~~~~ 7046 | case before_dot: | ~~~~~~~~~~~~~~~~ 7047 | DEBUG_MATCH_PRINT1 ("EXECUTING before_dot.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7048 | if (!BUFFERP (lispobj) | ~~~~~~~~~~~~~~~~~~~~~~ 7049 | || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7050 | >= BUF_PT (XBUFFER (lispobj)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7051 | goto fail; | ~~~~~~~~~~ 7052 | break; | ~~~~~~ 7053 | | 7054 | case at_dot: | ~~~~~~~~~~~~ 7055 | DEBUG_MATCH_PRINT1 ("EXECUTING at_dot.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7056 | if (!BUFFERP (lispobj) | ~~~~~~~~~~~~~~~~~~~~~~ 7057 | || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7058 | != BUF_PT (XBUFFER (lispobj)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7059 | goto fail; | ~~~~~~~~~~ 7060 | break; | ~~~~~~ 7061 | | 7062 | case after_dot: | ~~~~~~~~~~~~~~~ 7063 | DEBUG_MATCH_PRINT1 ("EXECUTING after_dot.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7064 | if (!BUFFERP (lispobj) | ~~~~~~~~~~~~~~~~~~~~~~ 7065 | || (BUF_PTR_BYTE_POS (XBUFFER (lispobj), (unsigned char *) d) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7066 | <= BUF_PT (XBUFFER (lispobj)))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7067 | goto fail; | ~~~~~~~~~~ 7068 | break; | ~~~~~~ 7069 | | 7070 | case syntaxspec: | ~~~~~~~~~~~~~~~~ 7071 | DEBUG_MATCH_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7072 | mcnt = *p++; | ~~~~~~~~~~~~ 7073 | goto matchsyntax; | ~~~~~~~~~~~~~~~~~ 7074 | | 7075 | case wordchar: | ~~~~~~~~~~~~~~ 7076 | DEBUG_MATCH_PRINT1 ("EXECUTING Emacs wordchar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7077 | mcnt = (int) Sword; | ~~~~~~~~~~~~~~~~~~~ 7078 | matchsyntax: | ~~~~~~~~~~~~ 7079 | should_succeed = 1; | ~~~~~~~~~~~~~~~~~~~ 7080 | matchornotsyntax: | ~~~~~~~~~~~~~~~~~ 7081 | { | ~ 7082 | int matches; | ~~~~~~~~~~~~ 7083 | Ichar emch; | ~~~~~~~~~~~ 7084 | | 7085 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 7086 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7087 | UPDATE_SYNTAX_CACHE | ~~~~~~~~~~~~~~~~~~~ 7088 | (scache, | ~~~~~~~~ 7089 | offset_to_bytexpos (lispobj, PTR_TO_OFFSET (d))); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7090 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7091 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7092 | | 7093 | emch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7094 | BEGIN_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7095 | matches = (SYNTAX_FROM_CACHE (scache, emch) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7096 | (enum syntaxcode) mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~ 7097 | END_REGEX_MALLOC_OK (); | ~~~~~~~~~~~~~~~~~~~~~~~ 7098 | RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7099 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 7100 | if (matches != should_succeed) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7101 | goto fail; | ~~~~~~~~~~ 7102 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 7103 | } | ~ 7104 | break; | ~~~~~~ 7105 | | 7106 | case notsyntaxspec: | ~~~~~~~~~~~~~~~~~~~ 7107 | DEBUG_MATCH_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7108 | mcnt = *p++; | ~~~~~~~~~~~~ 7109 | goto matchnotsyntax; | ~~~~~~~~~~~~~~~~~~~~ 7110 | | 7111 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 7112 | DEBUG_MATCH_PRINT1 ("EXECUTING Emacs notwordchar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7113 | mcnt = (int) Sword; | ~~~~~~~~~~~~~~~~~~~ 7114 | matchnotsyntax: | ~~~~~~~~~~~~~~~ 7115 | should_succeed = 0; | ~~~~~~~~~~~~~~~~~~~ 7116 | goto matchornotsyntax; | ~~~~~~~~~~~~~~~~~~~~~~ 7117 | | 7118 | #ifdef MULE | ~~~~~~~~~~~ 7119 | /* 97/2/17 jhod Mule category code patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7120 | case categoryspec: | ~~~~~~~~~~~~~~~~~~ 7121 | should_succeed = 1; | ~~~~~~~~~~~~~~~~~~~ 7122 | matchornotcategory: | ~~~~~~~~~~~~~~~~~~~ 7123 | { | ~ 7124 | Ichar emch; | ~~~~~~~~~~~ 7125 | | 7126 | mcnt = *p++; | ~~~~~~~~~~~~ 7127 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 7128 | emch = itext_ichar_fmt (d, fmt, lispobj); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7129 | INC_IBYTEPTR_FMT (d, fmt); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 7130 | if (check_char_in_category (emch, BUFFER_CATEGORY_TABLE (lispbuf), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7131 | mcnt, should_succeed)) | ~~~~~~~~~~~~~~~~~~~~~~ 7132 | goto fail; | ~~~~~~~~~~ 7133 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 7134 | } | ~ 7135 | break; | ~~~~~~ 7136 | | 7137 | case notcategoryspec: | ~~~~~~~~~~~~~~~~~~~~~ 7138 | should_succeed = 0; | ~~~~~~~~~~~~~~~~~~~ 7139 | goto matchornotcategory; | ~~~~~~~~~~~~~~~~~~~~~~~~ 7140 | /* end of category patch */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7141 | #endif /* MULE */ | ~~~~~~~~~~~~~~~~~ 7142 | #else /* not emacs */ | ~~~~~~~~~~~~~~~~~~~~~ 7143 | case wordchar: | ~~~~~~~~~~~~~~ 7144 | DEBUG_MATCH_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7145 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 7146 | if (!WORDCHAR_P ((int) (*d))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7147 | goto fail; | ~~~~~~~~~~ 7148 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 7149 | d++; | ~~~~ 7150 | break; | ~~~~~~ 7151 | | 7152 | case notwordchar: | ~~~~~~~~~~~~~~~~~ 7153 | DEBUG_MATCH_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7154 | REGEX_PREFETCH (); | ~~~~~~~~~~~~~~~~~~ 7155 | if (!WORDCHAR_P ((int) (*d))) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7156 | goto fail; | ~~~~~~~~~~ 7157 | SET_REGS_MATCHED (); | ~~~~~~~~~~~~~~~~~~~~ 7158 | d++; | ~~~~ 7159 | break; | ~~~~~~ 7160 | #endif /* emacs */ | ~~~~~~~~~~~~~~~~~~ 7161 | | 7162 | default: | ~~~~~~~~ 7163 | ABORT (); | ~~~~~~~~~ 7164 | } | ~ 7165 | continue; /* Successfully executed one pattern command; keep going. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7166 | | 7167 | | 7168 | /* We goto here if a matching operation fails. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7169 | fail: | ~~~~~ 7170 | if (!FAIL_STACK_EMPTY ()) | ~~~~~~~~~~~~~~~~~~~~~~~~~ 7171 | { /* A restart point is known. Restore to that state. */ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7172 | DEBUG_MATCH_PRINT1 ("\nFAIL:\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7173 | POP_FAILURE_POINT (d, p, | ~~~~~~~~~~~~~~~~~~~~~~~ regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:7173:11: note: in expansion of macro 'POP_FAILURE_POINT' 7173 | POP_FAILURE_POINT (d, p, | ^~~~~~~~~~~~~~~~~ regex.c:1905:49: note: format string is defined here 1905 | DEBUG_FAIL_PRINT2 (" Popping pattern 0x%zx: ", (Bytecount) pat); \ | ~~^ | | | unsigned int | %lx regex.c:1920:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'Bytecount' {aka 'long int'} [-Wformat=] 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~~ 1921 | * (Bytecount *) ®_info[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | Bytecount {aka long int} regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:7173:11: note: in expansion of macro 'POP_FAILURE_POINT' 7173 | POP_FAILURE_POINT (d, p, | ^~~~~~~~~~~~~~~~~ regex.c:1920:40: note: format string is defined here 1920 | DEBUG_FAIL_PRINT2 (" info: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1922:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~ 1923 | (Bytecount) regend[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:7173:11: note: in expansion of macro 'POP_FAILURE_POINT' 7173 | POP_FAILURE_POINT (d, p, | ^~~~~~~~~~~~~~~~~ regex.c:1922:39: note: format string is defined here 1922 | DEBUG_FAIL_PRINT2 (" end: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx regex.c:1924:23: warning: format '%zx' expects argument of type 'size_t', but argument 2 has type 'long int' [-Wformat=] 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ^~~~~~~~~~~~~~~~~~~~~~ 1925 | (Bytecount) regstart[this_reg]); \ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | long int regex.c:774:55: note: in definition of macro 'DEBUG_FAIL_PRINT2' 774 | if (debug_regexps & RE_DEBUG_FAILURE_POINT) printf (x1, x2) | ^~ regex.c:7173:11: note: in expansion of macro 'POP_FAILURE_POINT' 7173 | POP_FAILURE_POINT (d, p, | ^~~~~~~~~~~~~~~~~ regex.c:1924:41: note: format string is defined here 1924 | DEBUG_FAIL_PRINT2 (" start: 0x%zx\n", \ | ~~^ | | | unsigned int | %lx --- syntax.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include syntax.c --- sysdep.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include sysdep.c --- sysdll.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include sysdll.c --- terminfo.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include terminfo.c --- tests.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include tests.c --- text.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include text.c --- tls.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include tls.c --- undo.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include undo.c --- unicode.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include unicode.c unicode.c: In function 'print_precedence_array': unicode.c:1643:46: warning: format '%zd' expects argument of type 'signed size_t', but argument 3 has type 'long int' [-Wformat=] 1643 | write_fmt_string (printcharfun, " length=%zd", | ~~^ | | | int | %ld --- widget.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include widget.c --- window.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include window.c --- regex.o --- regex.c: In function 're_search_2': regex.c:1503:8: warning: 'd' may be used uninitialized in this function [-Wmaybe-uninitialized] 1503 | && (re_char *) (val) <= (re_char *) string1 + size1) \ | ^~ regex.c:5016:12: note: 'd' was declared here 5016 | re_char *d; | ^ --- dump-id.c --- ../lib-src/make-dump-id --- dump-id.o --- gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include dump-id.c --- temacs --- if test -f dump-size ; then gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include -DMAX_SIZE=`cat dump-size` /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src/dump-data.c ; else gcc -c -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -DTERMINFO -I/usr/pkg/include -I/usr/include -Demacs -I. -I/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src -DHAVE_CONFIG_H -I/usr/pkg/include -DMAX_SIZE=0 /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src/dump-data.c ; fi gcc -Wall -Wno-switch -Wundef -Wsign-compare -Wno-char-subscripts -Wpacked -Wpointer-arith -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -g -O2 -Dunix -I/usr/pkg/include -I/usr/include -Wl,-zrelro -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -Wl,-export-dynamic -o temacs abbrev.o alloc.o alloca.o array.o blocktype.o buffer.o bytecode.o callint.o casefiddle.o casetab.o chartab.o filelock.o cmdloop.o cmds.o console.o console-stream.o data.o database.o debug.o tests.o device.o dired.o doc.o doprnt.o editfns.o elhash.o emacs.o emodules.o eval.o events.o event-stream.o event-unixoid.o dumper.o inline.o linuxplay.o miscplay.o terminfo.o extents.o faces.o file-coding.o fileio.o filemode.o floatfns.o fns.o font-lock.o frame.o gc.o general.o glyphs.o glyphs-widget.o gui.o gutter.o imgproc.o indent.o insdel.o intl.o keymap.o line-number.o lread.o lstream.o macros.o marker.o md5.o minibuf.o mule-ccl.o mule-charset.o mule-coding.o number-gmp.o number.o fontcolor.o opaque.o print.o process.o process-unix.o profile.o rangetab.o realpath.o redisplay.o redisplay-output.o regex.o search.o select.o sequence.o sysdll.o signal.o sound.o specifier.o strftime.o symbols.o syntax.o sysdep.o text.o tls.o console-tty.o device-tty.o event-tty.o frame-tty.o fontcolor-tty.o redisplay-tty.o cm.o undo.o unicode.o widget.o window.o lastfile.o ralloc.o dump-id.o dump-data.o -lgmp -lgdbm -ltermcap -lossaudio -lintl -lm -lkvm -lutil --- ./NEEDTODUMP --- ./temacs -nd -no-packages -no-configured-paths -batch -l ../lisp/update-elc.el Loading ../lisp/update-elc.el... Loading find-paths.el... Loading packages.el... Loading setup-paths.el... Loading /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lisp/dumped-lisp.el... Wrote /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src/NEEDTODUMP Loading loadup-el.el... Loading loadup.el... Using load-path (/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lisp/) Using module-load-path (/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/modules) Loading dumped-lisp.el... Loading backquote.el... Loading bytecomp-runtime.el... Loading subr.el... Loading cl.el... Loading cl-extra.el... Loading cl-macs.el... Loading cl-seq.el... Loading post-gc.el... Loading version.el... Loading custom.el... Loading cus-start.el... Loading find-paths.el... Loading packages.el... Loading setup-paths.el... Loading replace.el... Loading widget.el... Loading cmdloop.el... Loading keymap.el... Loading syntax.el... Loading syntax-ppss.el... Loading device.el... Loading console.el... Loading obsolete.el... Loading specifier.el... Loading frame.el... Loading faces.el... Requiring font.el... Requiring fontconfig.el... Requiring font-mgr.el... Requiring disp-table.el... Loading glyphs.el... Loading fontcolor.el... Loading extents.el... Loading events.el... Loading hash-table.el... Loading text-props.el... Loading process.el... Loading multicast.el... Loading map-ynp.el... Loading undo-stack.el... Loading window.el... Loading window-xemacs.el... Loading resize-minibuffer.el... Loading simple.el... Loading newcomment.el... Loading keydefs.el... Loading abbrev.el... Loading derived.el... Loading minibuf.el... Loading list-mode.el... Loading modeline.el... Loading cus-file.el... Loading startup.el... Loading misc.el... Loading loadhist.el... Loading files.el... Loading lib-complete.el... Loading format.el... Loading indent.el... Loading isearch-mode.el... *** Error in XEmacs initialization (void-variable isearch-state-places) *** Backtrace really-early-error-handler((void-variable isearch-state-places)) (cons (quote list) isearch-state-places) # (catch #:isearch-make-state-object ...) (catch (quote #:isearch-make-state-object) (cons (quote list) isearch-state-places)) (block isearch-make-state-object (cons (quote list) isearch-state-places)) (lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places)))() # bind (byte-compile-macro-environment) macroexpand((isearch-make-state-object) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) (setq form (macroexpand form env)) (eq form (setq form (macroexpand form env))) (not (eq form (setq form (macroexpand form env)))) (or (not (eq form (setq form (macroexpand form env)))) (and cl-macroexpand-cmacs (not (eq form (setq form (compiler-macroexpand form)))))) (while (or (not (eq form (setq form (macroexpand form env)))) (and cl-macroexpand-cmacs (not (eq form (setq form (compiler-macroexpand form))))))) # bind (env form) cl-macroexpand-all((isearch-make-state-object) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) # bind (x) (lambda (x) (cl-macroexpand-all x env))((isearch-make-state-object)) mapcar((lambda (x) (cl-macroexpand-all x env)) ((isearch-make-state-object) isearch-cmds)) # bind (env body) cl-macroexpand-body(((isearch-make-state-object) isearch-cmds) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) (cons (car form) (cl-macroexpand-body (cdr form) env)) (cond ((not (consp form)) form) ((memq (car form) (quote (let let*))) (if (null (nth 1 form)) (cl-macroexpand-all (cons (quote progn) (cddr form)) env) (let ((letf nil) (res nil) (lets (cadr form)) (env env) shadows) (while lets (push (funcall (function (lambda (symbol valueform) (let* ((eq-hash (eq-hash symbol)) (acons (cdr (assoc* eq-hash env)))) (if (null acons) (cons symbol (cl-macroexpand-body valueform env)) (if (cadr acons) (if (eq (car form) (quote let*)) (push (backquote ((\, eq-hash))) env) (push (backquote ((\, eq-hash))) shadows)) (setq symbol (car acons)) (unless (symbolp symbol) (setq letf t))) (cons symbol (cl-macroexpand-body valueform env)))))) (if (consp (car lets)) (caar lets) (car lets)) (cdr-safe (car-safe lets))) res) (setq lets (cdr lets))) (list* (if letf (if (eq (car form) (quote let)) (quote letf) (quote letf*)) (car form)) (nreverse res) (cl-macroexpand-body (cddr form) (nconc shadows env)))))) ((eq (car form) (quote cond)) (cons (car form) (mapcar (function (lambda (x) (cl-macroexpand-body x env))) (cdr form)))) ((eq (car form) (quote condition-case)) (list* (car form) (nth 1 form) (cl-macroexpand-all (nth 2 form) env) (mapcar (function (lambda (x) (cons (car x) (cl-macroexpand-body (cdr x) env)))) (cdddr form)))) ((memq (car form) (quote (quote function))) (if (eq (car-safe (nth 1 form)) (quote lambda)) (let* ((env (reduce (function nconc) (nth 1 (nth 1 form)) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env)) (body (cl-macroexpand-body (cddadr form) env))) (if (and cl-closure-vars (eq (car form) (quote function)) (cl-expr-contains-any body cl-closure-vars)) (let* ((closed (remove* nil cl-closure-vars :key (function (lambda (y) (cl-expr-contains body y))))) (new (mapcar (quote gensym) closed)) (sub (pairlis closed new))) (put (car (last cl-closure-vars)) (quote used) t) (backquote (apply-partially (function (lambda (\, (append new (cadadr form))) (\,@ (sublis sub body)))) (\,@ closed)))) (list (car form) (list* (quote lambda) (cadadr form) body)))) (let ((found (cdr (assq (cadr form) env)))) (cond ((and (consp found) (eq (nth 1 (nth 1 found)) (quote cl-labels-args))) (cl-macroexpand-all (nth 1 (nth 2 (nth 2 found))) env)) ((and (consp found) (eq (nth 1 (nth 1 found)) (quote byte-compile-labels-args))) (unless (eq (quote function) (car form)) (byte-compile-warn "deprecated: '%s, use #'%s instead to quote it as a function" (cadr form) (cadr form))) (setq found (get (nth 1 (nth 1 (nth 3 found))) (quote byte-compile-data-placeholder))) (put found (quote byte-compile-label-calls) (1+ (get found (quote byte-compile-label-calls) 0))) (list (quote function) found)) (t form))))) ((memq (car form) (quote (defun defmacro))) (let ((env (reduce (function nconc) (nth 2 form) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env))) (list* (car form) (nth 1 form) (cl-macroexpand-body (cddr form) env)))) ((and (eq (car form) (quote progn)) (not (cddr form))) (cl-macroexpand-all (nth 1 form) env)) ((eq (car form) (quote setq)) (let* ((args (cl-macroexpand-body (cdr form) env)) (p args)) (while (and p (symbolp (car p))) (setq p (cddr p))) (if p (cl-macroexpand-all (cons (quote setf) args)) (cons (quote setq) args)))) (t (cons (car form) (cl-macroexpand-body (cdr form) env)))) # bind (env form) cl-macroexpand-all((cons (isearch-make-state-object) isearch-cmds) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) # bind (x) (lambda (x) (cl-macroexpand-all x env))((cons (isearch-make-state-object) isearch-cmds)) mapcar((lambda (x) (cl-macroexpand-all x env)) (isearch-cmds (cons (isearch-make-state-object) isearch-cmds))) # bind (env body) cl-macroexpand-body((isearch-cmds (cons (isearch-make-state-object) isearch-cmds)) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) (let* ((args (cl-macroexpand-body (cdr form) env)) (p args)) (while (and p (symbolp (car p))) (setq p (cddr p))) (if p (cl-macroexpand-all (cons (quote setf) args)) (cons (quote setq) args))) (cond ((not (consp form)) form) ((memq (car form) (quote (let let*))) (if (null (nth 1 form)) (cl-macroexpand-all (cons (quote progn) (cddr form)) env) (let ((letf nil) (res nil) (lets (cadr form)) (env env) shadows) (while lets (push (funcall (function (lambda (symbol valueform) (let* ((eq-hash (eq-hash symbol)) (acons (cdr (assoc* eq-hash env)))) (if (null acons) (cons symbol (cl-macroexpand-body valueform env)) (if (cadr acons) (if (eq (car form) (quote let*)) (push (backquote ((\, eq-hash))) env) (push (backquote ((\, eq-hash))) shadows)) (setq symbol (car acons)) (unless (symbolp symbol) (setq letf t))) (cons symbol (cl-macroexpand-body valueform env)))))) (if (consp (car lets)) (caar lets) (car lets)) (cdr-safe (car-safe lets))) res) (setq lets (cdr lets))) (list* (if letf (if (eq (car form) (quote let)) (quote letf) (quote letf*)) (car form)) (nreverse res) (cl-macroexpand-body (cddr form) (nconc shadows env)))))) ((eq (car form) (quote cond)) (cons (car form) (mapcar (function (lambda (x) (cl-macroexpand-body x env))) (cdr form)))) ((eq (car form) (quote condition-case)) (list* (car form) (nth 1 form) (cl-macroexpand-all (nth 2 form) env) (mapcar (function (lambda (x) (cons (car x) (cl-macroexpand-body (cdr x) env)))) (cdddr form)))) ((memq (car form) (quote (quote function))) (if (eq (car-safe (nth 1 form)) (quote lambda)) (let* ((env (reduce (function nconc) (nth 1 (nth 1 form)) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env)) (body (cl-macroexpand-body (cddadr form) env))) (if (and cl-closure-vars (eq (car form) (quote function)) (cl-expr-contains-any body cl-closure-vars)) (let* ((closed (remove* nil cl-closure-vars :key (function (lambda (y) (cl-expr-contains body y))))) (new (mapcar (quote gensym) closed)) (sub (pairlis closed new))) (put (car (last cl-closure-vars)) (quote used) t) (backquote (apply-partially (function (lambda (\, (append new (cadadr form))) (\,@ (sublis sub body)))) (\,@ closed)))) (list (car form) (list* (quote lambda) (cadadr form) body)))) (let ((found (cdr (assq (cadr form) env)))) (cond ((and (consp found) (eq (nth 1 (nth 1 found)) (quote cl-labels-args))) (cl-macroexpand-all (nth 1 (nth 2 (nth 2 found))) env)) ((and (consp found) (eq (nth 1 (nth 1 found)) (quote byte-compile-labels-args))) (unless (eq (quote function) (car form)) (byte-compile-warn "deprecated: '%s, use #'%s instead to quote it as a function" (cadr form) (cadr form))) (setq found (get (nth 1 (nth 1 (nth 3 found))) (quote byte-compile-data-placeholder))) (put found (quote byte-compile-label-calls) (1+ (get found (quote byte-compile-label-calls) 0))) (list (quote function) found)) (t form))))) ((memq (car form) (quote (defun defmacro))) (let ((env (reduce (function nconc) (nth 2 form) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env))) (list* (car form) (nth 1 form) (cl-macroexpand-body (cddr form) env)))) ((and (eq (car form) (quote progn)) (not (cddr form))) (cl-macroexpand-all (nth 1 form) env)) ((eq (car form) (quote setq)) (let* ((args (cl-macroexpand-body (cdr form) env)) (p args)) (while (and p (symbolp (car p))) (setq p (cddr p))) (if p (cl-macroexpand-all (cons (quote setf) args)) (cons (quote setq) args)))) (t (cons (car form) (cl-macroexpand-body (cdr form) env)))) # bind (env form) cl-macroexpand-all((push (isearch-make-state-object) isearch-cmds) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) # bind (x) (lambda (x) (cl-macroexpand-all x env))((push (isearch-make-state-object) isearch-cmds)) mapcar((lambda (x) (cl-macroexpand-all x env)) (nil (push (isearch-make-state-object) isearch-cmds))) # bind (env body) cl-macroexpand-body((nil (push (isearch-make-state-object) isearch-cmds)) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) (list* (car form) (nth 1 form) (cl-macroexpand-body (cddr form) env)) # bind (env) (let ((env (reduce (function nconc) (nth 2 form) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env))) (list* (car form) (nth 1 form) (cl-macroexpand-body (cddr form) env))) (cond ((not (consp form)) form) ((memq (car form) (quote (let let*))) (if (null (nth 1 form)) (cl-macroexpand-all (cons (quote progn) (cddr form)) env) (let ((letf nil) (res nil) (lets (cadr form)) (env env) shadows) (while lets (push (funcall (function (lambda (symbol valueform) (let* ((eq-hash (eq-hash symbol)) (acons (cdr (assoc* eq-hash env)))) (if (null acons) (cons symbol (cl-macroexpand-body valueform env)) (if (cadr acons) (if (eq (car form) (quote let*)) (push (backquote ((\, eq-hash))) env) (push (backquote ((\, eq-hash))) shadows)) (setq symbol (car acons)) (unless (symbolp symbol) (setq letf t))) (cons symbol (cl-macroexpand-body valueform env)))))) (if (consp (car lets)) (caar lets) (car lets)) (cdr-safe (car-safe lets))) res) (setq lets (cdr lets))) (list* (if letf (if (eq (car form) (quote let)) (quote letf) (quote letf*)) (car form)) (nreverse res) (cl-macroexpand-body (cddr form) (nconc shadows env)))))) ((eq (car form) (quote cond)) (cons (car form) (mapcar (function (lambda (x) (cl-macroexpand-body x env))) (cdr form)))) ((eq (car form) (quote condition-case)) (list* (car form) (nth 1 form) (cl-macroexpand-all (nth 2 form) env) (mapcar (function (lambda (x) (cons (car x) (cl-macroexpand-body (cdr x) env)))) (cdddr form)))) ((memq (car form) (quote (quote function))) (if (eq (car-safe (nth 1 form)) (quote lambda)) (let* ((env (reduce (function nconc) (nth 1 (nth 1 form)) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env)) (body (cl-macroexpand-body (cddadr form) env))) (if (and cl-closure-vars (eq (car form) (quote function)) (cl-expr-contains-any body cl-closure-vars)) (let* ((closed (remove* nil cl-closure-vars :key (function (lambda (y) (cl-expr-contains body y))))) (new (mapcar (quote gensym) closed)) (sub (pairlis closed new))) (put (car (last cl-closure-vars)) (quote used) t) (backquote (apply-partially (function (lambda (\, (append new (cadadr form))) (\,@ (sublis sub body)))) (\,@ closed)))) (list (car form) (list* (quote lambda) (cadadr form) body)))) (let ((found (cdr (assq (cadr form) env)))) (cond ((and (consp found) (eq (nth 1 (nth 1 found)) (quote cl-labels-args))) (cl-macroexpand-all (nth 1 (nth 2 (nth 2 found))) env)) ((and (consp found) (eq (nth 1 (nth 1 found)) (quote byte-compile-labels-args))) (unless (eq (quote function) (car form)) (byte-compile-warn "deprecated: '%s, use #'%s instead to quote it as a function" (cadr form) (cadr form))) (setq found (get (nth 1 (nth 1 (nth 3 found))) (quote byte-compile-data-placeholder))) (put found (quote byte-compile-label-calls) (1+ (get found (quote byte-compile-label-calls) 0))) (list (quote function) found)) (t form))))) ((memq (car form) (quote (defun defmacro))) (let ((env (reduce (function nconc) (nth 2 form) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env))) (list* (car form) (nth 1 form) (cl-macroexpand-body (cddr form) env)))) ((and (eq (car form) (quote progn)) (not (cddr form))) (cl-macroexpand-all (nth 1 form) env)) ((eq (car form) (quote setq)) (let* ((args (cl-macroexpand-body (cdr form) env)) (p args)) (while (and p (symbolp (car p))) (setq p (cddr p))) (if p (cl-macroexpand-all (cons (quote setf) args)) (cons (quote setq) args)))) (t (cons (car form) (cl-macroexpand-body (cdr form) env)))) # bind (env form) cl-macroexpand-all((defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) # bind (x) (lambda (x) (cl-macroexpand-all x env))((defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds))) mapcar((lambda (x) (cl-macroexpand-all x env)) ((defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) (defun isearch-top-state nil (isearch-setf-state-places (car isearch-cmds))))) # bind (env body) cl-macroexpand-body(((defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) (defun isearch-top-state nil (isearch-setf-state-places (car isearch-cmds)))) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) (cons (car form) (cl-macroexpand-body (cdr form) env)) (cond ((not (consp form)) form) ((memq (car form) (quote (let let*))) (if (null (nth 1 form)) (cl-macroexpand-all (cons (quote progn) (cddr form)) env) (let ((letf nil) (res nil) (lets (cadr form)) (env env) shadows) (while lets (push (funcall (function (lambda (symbol valueform) (let* ((eq-hash (eq-hash symbol)) (acons (cdr (assoc* eq-hash env)))) (if (null acons) (cons symbol (cl-macroexpand-body valueform env)) (if (cadr acons) (if (eq (car form) (quote let*)) (push (backquote ((\, eq-hash))) env) (push (backquote ((\, eq-hash))) shadows)) (setq symbol (car acons)) (unless (symbolp symbol) (setq letf t))) (cons symbol (cl-macroexpand-body valueform env)))))) (if (consp (car lets)) (caar lets) (car lets)) (cdr-safe (car-safe lets))) res) (setq lets (cdr lets))) (list* (if letf (if (eq (car form) (quote let)) (quote letf) (quote letf*)) (car form)) (nreverse res) (cl-macroexpand-body (cddr form) (nconc shadows env)))))) ((eq (car form) (quote cond)) (cons (car form) (mapcar (function (lambda (x) (cl-macroexpand-body x env))) (cdr form)))) ((eq (car form) (quote condition-case)) (list* (car form) (nth 1 form) (cl-macroexpand-all (nth 2 form) env) (mapcar (function (lambda (x) (cons (car x) (cl-macroexpand-body (cdr x) env)))) (cdddr form)))) ((memq (car form) (quote (quote function))) (if (eq (car-safe (nth 1 form)) (quote lambda)) (let* ((env (reduce (function nconc) (nth 1 (nth 1 form)) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env)) (body (cl-macroexpand-body (cddadr form) env))) (if (and cl-closure-vars (eq (car form) (quote function)) (cl-expr-contains-any body cl-closure-vars)) (let* ((closed (remove* nil cl-closure-vars :key (function (lambda (y) (cl-expr-contains body y))))) (new (mapcar (quote gensym) closed)) (sub (pairlis closed new))) (put (car (last cl-closure-vars)) (quote used) t) (backquote (apply-partially (function (lambda (\, (append new (cadadr form))) (\,@ (sublis sub body)))) (\,@ closed)))) (list (car form) (list* (quote lambda) (cadadr form) body)))) (let ((found (cdr (assq (cadr form) env)))) (cond ((and (consp found) (eq (nth 1 (nth 1 found)) (quote cl-labels-args))) (cl-macroexpand-all (nth 1 (nth 2 (nth 2 found))) env)) ((and (consp found) (eq (nth 1 (nth 1 found)) (quote byte-compile-labels-args))) (unless (eq (quote function) (car form)) (byte-compile-warn "deprecated: '%s, use #'%s instead to quote it as a function" (cadr form) (cadr form))) (setq found (get (nth 1 (nth 1 (nth 3 found))) (quote byte-compile-data-placeholder))) (put found (quote byte-compile-label-calls) (1+ (get found (quote byte-compile-label-calls) 0))) (list (quote function) found)) (t form))))) ((memq (car form) (quote (defun defmacro))) (let ((env (reduce (function nconc) (nth 2 form) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env))) (list* (car form) (nth 1 form) (cl-macroexpand-body (cddr form) env)))) ((and (eq (car form) (quote progn)) (not (cddr form))) (cl-macroexpand-all (nth 1 form) env)) ((eq (car form) (quote setq)) (let* ((args (cl-macroexpand-body (cdr form) env)) (p args)) (while (and p (symbolp (car p))) (setq p (cddr p))) (if p (cl-macroexpand-all (cons (quote setf) args)) (cons (quote setq) args)))) (t (cons (car form) (cl-macroexpand-body (cdr form) env)))) # bind (env form) cl-macroexpand-all((progn (defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) (defun isearch-top-state nil (isearch-setf-state-places (car isearch-cmds)))) ((isearch-setf-state-places lambda (cmd) (block isearch-setf-state-places (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd)))))))) (isearch-make-state-object lambda nil (block isearch-make-state-object (cons (quote list) isearch-state-places))) (-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) # (catch #:macrolet ...) (catch (quote #:macrolet) (cl-macroexpand-all (cons (quote progn) form) (nconc (catch (quote #:nil) (let* ((#:G65160 macros) (details nil) (name nil) (#:G65161 nil)) (while (consp #:G65160) (setq details (car #:G65160) name (car-safe (prog1 details (setq details (cdr details))))) (setq #:G65161 (cons (list* name (quote lambda) (cdr (cl-transform-lambda details name))) #:G65161)) (setq #:G65160 (cdr #:G65160))) (nreverse #:G65161))) env))) (block macrolet (cl-macroexpand-all (cons (quote progn) form) (nconc (loop for (name . details) in macros collect (list* name (quote lambda) (cdr (cl-transform-lambda details name)))) env))) # bind (env macros) (let* ((macros (if form (pop form) (signal (quote wrong-number-of-arguments) (list (quote macrolet) (length form))))) (env byte-compile-macro-environment)) (block macrolet (cl-macroexpand-all (cons (quote progn) form) (nconc (loop for (name . details) in macros collect (list* name (quote lambda) (cdr (cl-transform-lambda details name)))) env)))) # bind (form) (lambda (&rest form) "Make temporary macro definitions.\nThis is like `flet', but for macros instead of functions.\n\narguments: ((&rest MACROS) &body FORM &environment ENV)\n" (let* ((macros (if form (pop form) (signal (quote wrong-number-of-arguments) (list (quote macrolet) (length form))))) (env byte-compile-macro-environment)) (block macrolet (cl-macroexpand-all (cons (quote progn) form) (nconc (loop for (name . details) in macros collect (list* name (quote lambda) (cdr (cl-transform-lambda details name)))) env)))))(((isearch-setf-state-places (cmd) (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd))))))) (isearch-make-state-object nil (cons (quote list) isearch-state-places))) (defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) (defun isearch-top-state nil (isearch-setf-state-places (car isearch-cmds)))) # bind (byte-compile-macro-environment) macroexpand((macrolet ((isearch-setf-state-places (cmd) (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd))))))) (isearch-make-state-object nil (cons (quote list) isearch-state-places))) (defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) (defun isearch-top-state nil (isearch-setf-state-places (car isearch-cmds)))) ((-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) (setq form (macroexpand form env)) (eq form (setq form (macroexpand form env))) (not (eq form (setq form (macroexpand form env)))) (or (not (eq form (setq form (macroexpand form env)))) (and cl-macroexpand-cmacs (not (eq form (setq form (compiler-macroexpand form)))))) (while (or (not (eq form (setq form (macroexpand form env)))) (and cl-macroexpand-cmacs (not (eq form (setq form (compiler-macroexpand form))))))) # bind (env form) cl-macroexpand-all((macrolet ((isearch-setf-state-places (cmd) (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd))))))) (isearch-make-state-object nil (cons (quote list) isearch-state-places))) (defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) (defun isearch-top-state nil (isearch-setf-state-places (car isearch-cmds)))) ((-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) (cond ((not (consp form)) form) ((memq (car form) (quote (let let*))) (if (null (nth 1 form)) (cl-macroexpand-all (cons (quote progn) (cddr form)) env) (let ((letf nil) (res nil) (lets (cadr form)) (env env) shadows) (while lets (push (funcall (function (lambda (symbol valueform) (let* ((eq-hash (eq-hash symbol)) (acons (cdr (assoc* eq-hash env)))) (if (null acons) (cons symbol (cl-macroexpand-body valueform env)) (if (cadr acons) (if (eq (car form) (quote let*)) (push (backquote ((\, eq-hash))) env) (push (backquote ((\, eq-hash))) shadows)) (setq symbol (car acons)) (unless (symbolp symbol) (setq letf t))) (cons symbol (cl-macroexpand-body valueform env)))))) (if (consp (car lets)) (caar lets) (car lets)) (cdr-safe (car-safe lets))) res) (setq lets (cdr lets))) (list* (if letf (if (eq (car form) (quote let)) (quote letf) (quote letf*)) (car form)) (nreverse res) (cl-macroexpand-body (cddr form) (nconc shadows env)))))) ((eq (car form) (quote cond)) (cons (car form) (mapcar (function (lambda (x) (cl-macroexpand-body x env))) (cdr form)))) ((eq (car form) (quote condition-case)) (list* (car form) (nth 1 form) (cl-macroexpand-all (nth 2 form) env) (mapcar (function (lambda (x) (cons (car x) (cl-macroexpand-body (cdr x) env)))) (cdddr form)))) ((memq (car form) (quote (quote function))) (if (eq (car-safe (nth 1 form)) (quote lambda)) (let* ((env (reduce (function nconc) (nth 1 (nth 1 form)) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env)) (body (cl-macroexpand-body (cddadr form) env))) (if (and cl-closure-vars (eq (car form) (quote function)) (cl-expr-contains-any body cl-closure-vars)) (let* ((closed (remove* nil cl-closure-vars :key (function (lambda (y) (cl-expr-contains body y))))) (new (mapcar (quote gensym) closed)) (sub (pairlis closed new))) (put (car (last cl-closure-vars)) (quote used) t) (backquote (apply-partially (function (lambda (\, (append new (cadadr form))) (\,@ (sublis sub body)))) (\,@ closed)))) (list (car form) (list* (quote lambda) (cadadr form) body)))) (let ((found (cdr (assq (cadr form) env)))) (cond ((and (consp found) (eq (nth 1 (nth 1 found)) (quote cl-labels-args))) (cl-macroexpand-all (nth 1 (nth 2 (nth 2 found))) env)) ((and (consp found) (eq (nth 1 (nth 1 found)) (quote byte-compile-labels-args))) (unless (eq (quote function) (car form)) (byte-compile-warn "deprecated: '%s, use #'%s instead to quote it as a function" (cadr form) (cadr form))) (setq found (get (nth 1 (nth 1 (nth 3 found))) (quote byte-compile-data-placeholder))) (put found (quote byte-compile-label-calls) (1+ (get found (quote byte-compile-label-calls) 0))) (list (quote function) found)) (t form))))) ((memq (car form) (quote (defun defmacro))) (let ((env (reduce (function nconc) (nth 2 form) :from-end t :key (function (lambda (symbol) (when (and (not (member symbol (quote (&optional &rest)))) (cdr (assoc* (setq symbol (eq-hash symbol)) env))) (backquote (((\, symbol))))))) :initial-value env))) (list* (car form) (nth 1 form) (cl-macroexpand-body (cddr form) env)))) ((and (eq (car form) (quote progn)) (not (cddr form))) (cl-macroexpand-all (nth 1 form) env)) ((eq (car form) (quote setq)) (let* ((args (cl-macroexpand-body (cdr form) env)) (p args)) (while (and p (symbolp (car p))) (setq p (cddr p))) (if p (cl-macroexpand-all (cons (quote setf) args)) (cons (quote setq) args)))) (t (cons (car form) (cl-macroexpand-body (cdr form) env)))) # bind (env form) cl-macroexpand-all((progn (macrolet ((isearch-setf-state-places (cmd) (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd))))))) (isearch-make-state-object nil (cons (quote list) isearch-state-places))) (defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) (defun isearch-top-state nil (isearch-setf-state-places (car isearch-cmds))))) ((-100265140 (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets))))) # (catch #:symbol-macrolet ...) (catch (quote #:symbol-macrolet) (cl-macroexpand-all (cons (quote progn) body) (nconc (catch (quote #:nil) (let* ((#:G65158 symbol-macros) (shadow nil) (name nil) (expansion nil) (#:G65159 nil)) (while (consp #:G65158) (setq shadow (car #:G65158) name (car-safe (prog1 shadow (setq shadow (cdr shadow)))) expansion (car-safe (prog1 shadow (setq shadow (cdr shadow))))) (progn (while (not (symbolp name)) (setq name (signal (quote wrong-type-argument) (list (quote symbol) name (quote name))))) nil) (setq #:G65159 (cons (list* (eq-hash name) expansion shadow) #:G65159)) (setq #:G65158 (cdr #:G65158))) (nreverse #:G65159))) env))) (block symbol-macrolet (cl-macroexpand-all (cons (quote progn) body) (nconc (loop for (name expansion . shadow) in symbol-macros do (check-type name symbol) collect (list* (eq-hash name) expansion shadow)) env))) # bind (env symbol-macros) (let* ((symbol-macros (if body (pop body) (signal (quote wrong-number-of-arguments) (list (quote symbol-macrolet) (length body))))) (env byte-compile-macro-environment)) (block symbol-macrolet (cl-macroexpand-all (cons (quote progn) body) (nconc (loop for (name expansion . shadow) in symbol-macros do (check-type name symbol) collect (list* (eq-hash name) expansion shadow)) env)))) # bind (body) (lambda (&rest body) "Make temporary symbol macro definitions.\n\nElements in SYMBOL-MACROS look like (NAME EXPANSION &optional SHADOW).\nWithin BODY, a series of Lisp forms, a reference to NAME is replaced with its\nEXPANSION, and (setq NAME ...) acts like (setf EXPANSION ...).\n\nIf NAME is encountered in a lambda argument list within BODY, then the\ncorresponding symbol macro will be shadowed within the lambda body, and NAME\nwill be treated as normal.\n\nIf NAME is encountered as a symbol within the VARLIST of a `let', `let*',\n`lexical-let', or `lexical-let*' form, then the binding acts as it would with\n`letf' or `letf*', depending on the specific form encountered. This is in\ncontravention of Common Lisp, where such bindings shadow any enclosing symbol\nmacros. To specify the Common Lisp behavior for an individual symbol macro,\nsupply a non-nil third SHADOW element.\n\narguments: ((&rest SYMBOL-MACROS) &body BODY &environment ENV)\n" (let* ((symbol-macros (if body (pop body) (signal (quote wrong-number-of-arguments) (list (quote symbol-macrolet) (length body))))) (env byte-compile-macro-environment)) (block symbol-macrolet (cl-macroexpand-all (cons (quote progn) body) (nconc (loop for (name expansion . shadow) in symbol-macros do (check-type name symbol) collect (list* (eq-hash name) expansion shadow)) env)))))(((isearch-state-places (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets)))) (macrolet ((isearch-setf-state-places (cmd) (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd))))))) (isearch-make-state-object nil (cons (quote list) isearch-state-places))) (defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) (defun isearch-top-state nil (isearch-setf-state-places (car isearch-cmds))))) (symbol-macrolet ((isearch-state-places (quote (isearch-string isearch-message (point) isearch-success isearch-forward isearch-other-end isearch-word isearch-invalid-regexp isearch-wrapped isearch-barrier isearch-within-brackets)))) (macrolet ((isearch-setf-state-places (cmd) (cons (quote setf) (loop for var being each element in isearch-state-places using (index index) nconc (list var (backquote (nth (\, index) (\, cmd))))))) (isearch-make-state-object nil (cons (quote list) isearch-state-places))) (defun isearch-push-state nil (push (isearch-make-state-object) isearch-cmds)) (defun isearch-top-state nil (isearch-setf-state-places (car isearch-cmds))))) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) (load-internal "[internal]") load("/pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/lisp/isearch-mode.el") (prog1 (load full-path) (unless (memq (quote quick-build) internal-error-checking) (garbage-collect))) (if full-path (prog1 (load full-path) (unless (memq (quote quick-build) internal-error-checking) (garbage-collect))) (format-into (quote external-debugging-output) "\nLoad file %s: not found\n" file) nil) # bind (full-path) (let ((full-path (locate-file file load-path (if load-ignore-elc-files (quote (".el" "")) (quote (".elc" ".el" "")))))) (if full-path (prog1 (load full-path) (unless (memq (quote quick-build) internal-error-checking) (garbage-collect))) (format-into (quote external-debugging-output) "\nLoad file %s: not found\n" file) nil)) # bind (file) pureload("isearch-mode") (if (pureload file) nil (external-debugging-output "Fatal error during load, aborting") (kill-emacs 1)) (unless (pureload file) (external-debugging-output "Fatal error during load, aborting") (kill-emacs 1)) (while (setq file (car files)) (unless (pureload file) (external-debugging-output "Fatal error during load, aborting") (kill-emacs 1)) (setq files (cdr files))) # bind (file files) (let ((files preloaded-file-list) file) (while (setq file (car files)) (unless (pureload file) (external-debugging-output "Fatal error during load, aborting") (kill-emacs 1)) (setq files (cdr files))) (unless (featurep (quote toolbar)) (defun toolbar-button-p (obj) "No toolbar support." nil) (defun toolbar-specifier-p (obj) "No toolbar support." nil)) (fmakunbound (quote pureload))) (lambda nil (setq load-path (list source-lisp)) (setq module-load-path (list (expand-file-name "modules" build-directory))) (format-into (quote external-debugging-output) "\nUsing load-path %s" load-path) (format-into (quote external-debugging-output) "\nUsing module-load-path %s" module-load-path) (buffer-disable-undo (get-buffer "*scratch*")) (let ((temp-path (expand-file-name "." (car load-path)))) (setq load-path (nconc (mapcar (function (lambda (i) (concatenate (quote string) i "/"))) (directory-files temp-path t "^[^-.]" nil (quote dirs-only))) (cons (file-name-as-directory temp-path) load-path)))) (setq load-warn-when-source-only t) (defun pureload (file) (let ((full-path (locate-file file load-path (if load-ignore-elc-files (quote (".el" "")) (quote (".elc" ".el" "")))))) (if full-path (prog1 (load full-path) (unless (memq (quote quick-build) internal-error-checking) (garbage-collect))) (format-into (quote external-debugging-output) "\nLoad file %s: not found\n" file) nil))) (load (expand-file-name "dumped-lisp.el" source-lisp)) (let ((files preloaded-file-list) file) (while (setq file (car files)) (unless (pureload file) (external-debugging-output "Fatal error during load, aborting") (kill-emacs 1)) (setq files (cdr files))) (unless (featurep (quote toolbar)) (defun toolbar-button-p (obj) "No toolbar support." nil) (defun toolbar-specifier-p (obj) "No toolbar support." nil)) (fmakunbound (quote pureload))) (packages-load-package-dumped-lisps late-package-load-path))() # (unwind-protect ...) call-with-condition-handler(really-early-error-handler (lambda nil (setq load-path (list source-lisp)) (setq module-load-path (list (expand-file-name "modules" build-directory))) (format-into (quote external-debugging-output) "\nUsing load-path %s" load-path) (format-into (quote external-debugging-output) "\nUsing module-load-path %s" module-load-path) (buffer-disable-undo (get-buffer "*scratch*")) (let ((temp-path (expand-file-name "." (car load-path)))) (setq load-path (nconc (mapcar (function (lambda (i) (concatenate (quote string) i "/"))) (directory-files temp-path t "^[^-.]" nil (quote dirs-only))) (cons (file-name-as-directory temp-path) load-path)))) (setq load-warn-when-source-only t) (defun pureload (file) (let ((full-path (locate-file file load-path (if load-ignore-elc-files (quote (".el" "")) (quote (".elc" ".el" "")))))) (if full-path (prog1 (load full-path) (unless (memq (quote quick-build) internal-error-checking) (garbage-collect))) (format-into (quote external-debugging-output) "\nLoad file %s: not found\n" file) nil))) (load (expand-file-name "dumped-lisp.el" source-lisp)) (let ((files preloaded-file-list) file) (while (setq file (car files)) (unless (pureload file) (external-debugging-output "Fatal error during load, aborting") (kill-emacs 1)) (setq files (cdr files))) (unless (featurep (quote toolbar)) (defun toolbar-button-p (obj) "No toolbar support." nil) (defun toolbar-specifier-p (obj) "No toolbar support." nil)) (fmakunbound (quote pureload))) (packages-load-package-dumped-lisps late-package-load-path))) # bind (stack-trace-on-error) (let ((stack-trace-on-error nil)) (call-with-condition-handler (quote really-early-error-handler) (function (lambda nil (setq load-path (list source-lisp)) (setq module-load-path (list (expand-file-name "modules" build-directory))) (format-into (quote external-debugging-output) "\nUsing load-path %s" load-path) (format-into (quote external-debugging-output) "\nUsing module-load-path %s" module-load-path) (buffer-disable-undo (get-buffer "*scratch*")) (let ((temp-path (expand-file-name "." (car load-path)))) (setq load-path (nconc (mapcar (function (lambda (i) (concatenate (quote string) i "/"))) (directory-files temp-path t "^[^-.]" nil (quote dirs-only))) (cons (file-name-as-directory temp-path) load-path)))) (setq load-warn-when-source-only t) (defun pureload (file) (let ((full-path (locate-file file load-path (if load-ignore-elc-files (quote (".el" "")) (quote (".elc" ".el" "")))))) (if full-path (prog1 (load full-path) (unless (memq (quote quick-build) internal-error-checking) (garbage-collect))) (format-into (quote external-debugging-output) "\nLoad file %s: not found\n" file) nil))) (load (expand-file-name "dumped-lisp.el" source-lisp)) (let ((files preloaded-file-list) file) (while (setq file (car files)) (unless (pureload file) (external-debugging-output "Fatal error during load, aborting") (kill-emacs 1)) (setq files (cdr files))) (unless (featurep (quote toolbar)) (defun toolbar-button-p (obj) "No toolbar support." nil) (defun toolbar-specifier-p (obj) "No toolbar support." nil)) (fmakunbound (quote pureload))) (packages-load-package-dumped-lisps late-package-load-path))))) # bind (gc-cons-threshold) (let ((gc-cons-threshold (if (and purify-flag (eq (memq (quote quick-build) internal-error-checking) nil)) 30000 3000000))) (let ((stack-trace-on-error nil)) (call-with-condition-handler (quote really-early-error-handler) (function (lambda nil (setq load-path (list source-lisp)) (setq module-load-path (list (expand-file-name "modules" build-directory))) (format-into (quote external-debugging-output) "\nUsing load-path %s" load-path) (format-into (quote external-debugging-output) "\nUsing module-load-path %s" module-load-path) (buffer-disable-undo (get-buffer "*scratch*")) (let ((temp-path (expand-file-name "." (car load-path)))) (setq load-path (nconc (mapcar (function (lambda (i) (concatenate (quote string) i "/"))) (directory-files temp-path t "^[^-.]" nil (quote dirs-only))) (cons (file-name-as-directory temp-path) load-path)))) (setq load-warn-when-source-only t) (defun pureload (file) (let ((full-path (locate-file file load-path (if load-ignore-elc-files (quote (".el" "")) (quote (".elc" ".el" "")))))) (if full-path (prog1 (load full-path) (unless (memq (quote quick-build) internal-error-checking) (garbage-collect))) (format-into (quote external-debugging-output) "\nLoad file %s: not found\n" file) nil))) (load (expand-file-name "dumped-lisp.el" source-lisp)) (let ((files preloaded-file-list) file) (while (setq file (car files)) (unless (pureload file) (external-debugging-output "Fatal error during load, aborting") (kill-emacs 1)) (setq files (cdr files))) (unless (featurep (quote toolbar)) (defun toolbar-button-p (obj) "No toolbar support." nil) (defun toolbar-specifier-p (obj) "No toolbar support." nil)) (fmakunbound (quote pureload))) (packages-load-package-dumped-lisps late-package-load-path))))) (setq preloaded-file-list (mapcar (function file-name-sans-extension) preloaded-file-list)) (setq load-warn-when-source-only nil) (setq debugger (quote debug)) (when (member "no-site-file" command-line-args) (setq site-start-file nil)) (when (load "site-load" t) (garbage-collect)) (when purify-flag (message "Finding pointers to doc strings...") (Snarf-documentation "DOC") (message "Finding pointers to doc strings...done") (Verify-documentation)) (when (stringp site-start-file) (load "site-init" t)) (setq load-history (cons (nreverse current-load-list) (delete* nil (mapc (function (lambda (element) (delete* (quote defun) element :key (function car-safe)) (delete-if (function (lambda (elt) (and (symbolp elt) (get elt (quote variable-documentation))))) element))) load-history) :key (function cdr))) current-load-list nil) (setcar (car load-history) (file-truename (caar load-history))) (store-match-data (list (let ((extent (make-extent 0 6 "string"))) (set-extent-property extent (quote search) (quote discard)) extent))) (garbage-collect) (buffer-enable-undo "*scratch*")) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) (load-internal "[internal]") load("loadup.el") # bind (purify-flag load-ignore-elc-files) (let ((load-ignore-elc-files t) (purify-flag nil)) (load "loadup.el")) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) (load-internal "[internal]") load("loadup-el.el") (cond ((and (eq update-elc-files-to-compile nil) (eq need-to-rebuild-autoloads nil) (eq need-to-rebuild-mule-autoloads nil) (eq need-to-recompile-autoloads nil) (eq need-to-recompile-mule-autoloads nil))) ((eq update-elc-files-to-compile nil) (setq command-line-args (append (quote ("-l" "loadup-el.el" "run-temacs" "-batch" "-no-packages" "-no-autoloads" "-eval" "(setq stack-trace-on-error t)" "-eval" "(setq load-always-display-messages t)" "-l" "bytecomp.elc" "-l" "autoload.elc")) do-autoload-commands)) (write-sequence "\nNeed to regenerate auto-autoload files... " (quote external-debugging-output)) (let ((load-ignore-elc-files nil) (purify-flag nil)) (load "loadup.el"))) (t (let ((bc-bootstrap (mapcar (function (lambda (arg) (concatenate (quote string) (update-elc-chop-extension (locate-library arg)) ".el"))) lisp-files-needed-for-byte-compilation)) (bootstrap-other (mapcar (function (lambda (arg) (concatenate (quote string) (update-elc-chop-extension (locate-library arg)) ".el"))) lisp-files-needing-early-byte-compilation))) (setq inhibit-autoloads t) (let ((recompile-bc-bootstrap (mapcan (function (lambda (arg) (when (member arg update-elc-files-to-compile) (append (quote ("-f" "batch-byte-compile-one-file")) (list arg))))) bc-bootstrap)) (recompile-bootstrap-other (mapcan (function (lambda (arg) (when (member arg update-elc-files-to-compile) (append (quote ("-f" "batch-byte-compile-one-file")) (list arg))))) bootstrap-other))) (mapc (function (lambda (arg) (setq update-elc-files-to-compile (delete* arg update-elc-files-to-compile :test (if default-file-system-ignore-case (function equalp) (function equal)))))) (append bc-bootstrap bootstrap-other)) (setq command-line-args (append (quote ("-l" "loadup-el.el" "run-temacs" "-batch" "-no-packages" "-no-autoloads" "-eval" "(setq stack-trace-on-error t)" "-eval" "(setq load-always-display-messages t)")) (when recompile-bc-bootstrap (append (quote ("-eval" "(setq load-ignore-elc-files t)" "-l" "bytecomp")) recompile-bc-bootstrap (quote ("-eval" "(setq load-ignore-elc-files nil)")))) (quote ("-l" "bytecomp")) recompile-bootstrap-other do-autoload-commands (quote ("-eval" "(setq inhibit-autoloads nil)" "-f" "startup-load-autoloads" "-f" "batch-byte-compile")) update-elc-files-to-compile)))) (load "loadup-el.el"))) # bind (do-autoload-commands) (let ((do-autoload-commands (append (if (or need-to-rebuild-autoloads need-to-rebuild-mule-autoloads need-to-rebuild-module-autoloads) (list "-l" "autoload")) (if need-to-rebuild-autoloads (list "-f" "batch-update-directory-autoloads" "auto" source-lisp)) (if need-to-rebuild-mule-autoloads (list "-f" "batch-update-directory-autoloads" "mule" source-lisp-mule)) (if need-to-rebuild-module-autoloads (list "-eval" (concatenate (quote string) "(update-autoload-files '(" (mapconcat (function prin1-to-string) (mapcan (function (lambda (full-dir) (unless (member* (file-name-nondirectory full-dir) (quote ("." "..")) :test (function equal)) (directory-files full-dir t "\\.c$" nil t)))) (directory-files source-modules t nil t (quote subdirs))) " ") ") \"modules\" " (prin1-to-string aa-modules) ")"))) (if need-to-recompile-autoloads (list "-f" "batch-byte-compile-one-file" aa-lisp)) (if need-to-recompile-mule-autoloads (list "-f" "batch-byte-compile-one-file" aa-lisp-mule)) (if need-to-recompile-module-autoloads (list "-f" "batch-byte-compile-one-file" aa-modules))))) (cond ((and (eq update-elc-files-to-compile nil) (eq need-to-rebuild-autoloads nil) (eq need-to-rebuild-mule-autoloads nil) (eq need-to-recompile-autoloads nil) (eq need-to-recompile-mule-autoloads nil))) ((eq update-elc-files-to-compile nil) (setq command-line-args (append (quote ("-l" "loadup-el.el" "run-temacs" "-batch" "-no-packages" "-no-autoloads" "-eval" "(setq stack-trace-on-error t)" "-eval" "(setq load-always-display-messages t)" "-l" "bytecomp.elc" "-l" "autoload.elc")) do-autoload-commands)) (write-sequence "\nNeed to regenerate auto-autoload files... " (quote external-debugging-output)) (let ((load-ignore-elc-files nil) (purify-flag nil)) (load "loadup.el"))) (t (let ((bc-bootstrap (mapcar (function (lambda (arg) (concatenate (quote string) (update-elc-chop-extension (locate-library arg)) ".el"))) lisp-files-needed-for-byte-compilation)) (bootstrap-other (mapcar (function (lambda (arg) (concatenate (quote string) (update-elc-chop-extension (locate-library arg)) ".el"))) lisp-files-needing-early-byte-compilation))) (setq inhibit-autoloads t) (let ((recompile-bc-bootstrap (mapcan (function (lambda (arg) (when (member arg update-elc-files-to-compile) (append (quote ("-f" "batch-byte-compile-one-file")) (list arg))))) bc-bootstrap)) (recompile-bootstrap-other (mapcan (function (lambda (arg) (when (member arg update-elc-files-to-compile) (append (quote ("-f" "batch-byte-compile-one-file")) (list arg))))) bootstrap-other))) (mapc (function (lambda (arg) (setq update-elc-files-to-compile (delete* arg update-elc-files-to-compile :test (if default-file-system-ignore-case (function equalp) (function equal)))))) (append bc-bootstrap bootstrap-other)) (setq command-line-args (append (quote ("-l" "loadup-el.el" "run-temacs" "-batch" "-no-packages" "-no-autoloads" "-eval" "(setq stack-trace-on-error t)" "-eval" "(setq load-always-display-messages t)")) (when recompile-bc-bootstrap (append (quote ("-eval" "(setq load-ignore-elc-files t)" "-l" "bytecomp")) recompile-bc-bootstrap (quote ("-eval" "(setq load-ignore-elc-files nil)")))) (quote ("-l" "bytecomp")) recompile-bootstrap-other do-autoload-commands (quote ("-eval" "(setq inhibit-autoloads nil)" "-f" "startup-load-autoloads" "-f" "batch-byte-compile")) update-elc-files-to-compile)))) (load "loadup-el.el")))) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) # (unwind-protect ...) (load-internal "[internal]") load("../lisp/update-elc.el") # (condition-case ... . error) # (catch top-level ...) *** Killing XEmacs XEmacs exiting to debugger. Fatal error: assertion failed, file emacs.c, line 3397, ABORT() [1] Abort trap (core dumped) ./temacs -nd -no-packages -no-configured-paths... *** [./NEEDTODUMP] Error code 134 make[1]: stopped in /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src 1 error make[1]: stopped in /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35/src *** [src] Error code 2 make: stopped in /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35 1 error make: stopped in /pbulk/work/editors/xemacs-current-nox11/work/xemacs-21.5.35 *** Error code 2 Stop. make[1]: stopped in /usr/pkgsrc/editors/xemacs-current-nox11 *** Error code 1 Stop. make: stopped in /usr/pkgsrc/editors/xemacs-current-nox11