summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/Makefile.am25
-rw-r--r--sample/Makefile.in560
-rw-r--r--sample/crnl.c127
-rw-r--r--sample/encode.c298
-rw-r--r--sample/listcap.c107
-rw-r--r--sample/names.c72
-rw-r--r--sample/posix.c93
-rw-r--r--sample/simple.c56
-rw-r--r--sample/sql.c73
-rw-r--r--sample/syntax.c74
10 files changed, 1485 insertions, 0 deletions
diff --git a/sample/Makefile.am b/sample/Makefile.am
new file mode 100644
index 0000000..af33057
--- /dev/null
+++ b/sample/Makefile.am
@@ -0,0 +1,25 @@
+noinst_PROGRAMS = encode listcap names posix simple sql syntax crnl
+
+libname = $(top_builddir)/libonig.la
+LDADD = $(libname)
+INCLUDES = -I$(top_srcdir) -I$(includedir)
+
+encode_SOURCES = encode.c
+listcap_SOURCES = listcap.c
+names_SOURCES = names.c
+posix_SOURCES = posix.c
+simple_SOURCES = simple.c
+sql_SOURCES = sql.c
+syntax_SOURCES = syntax.c
+
+
+sampledir = $(top_builddir)/sample
+
+test: encode listcap names posix simple sql syntax
+ @$(sampledir)/encode
+ @$(sampledir)/listcap
+ @$(sampledir)/names
+ @$(sampledir)/posix
+ @$(sampledir)/simple
+ @$(sampledir)/sql
+ @$(sampledir)/syntax
diff --git a/sample/Makefile.in b/sample/Makefile.in
new file mode 100644
index 0000000..b780699
--- /dev/null
+++ b/sample/Makefile.in
@@ -0,0 +1,560 @@
+# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+noinst_PROGRAMS = encode$(EXEEXT) listcap$(EXEEXT) names$(EXEEXT) \
+ posix$(EXEEXT) simple$(EXEEXT) sql$(EXEEXT) syntax$(EXEEXT) \
+ crnl$(EXEEXT)
+subdir = sample
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+crnl_SOURCES = crnl.c
+crnl_OBJECTS = crnl.$(OBJEXT)
+crnl_LDADD = $(LDADD)
+crnl_DEPENDENCIES = $(libname)
+am_encode_OBJECTS = encode.$(OBJEXT)
+encode_OBJECTS = $(am_encode_OBJECTS)
+encode_LDADD = $(LDADD)
+encode_DEPENDENCIES = $(libname)
+am_listcap_OBJECTS = listcap.$(OBJEXT)
+listcap_OBJECTS = $(am_listcap_OBJECTS)
+listcap_LDADD = $(LDADD)
+listcap_DEPENDENCIES = $(libname)
+am_names_OBJECTS = names.$(OBJEXT)
+names_OBJECTS = $(am_names_OBJECTS)
+names_LDADD = $(LDADD)
+names_DEPENDENCIES = $(libname)
+am_posix_OBJECTS = posix.$(OBJEXT)
+posix_OBJECTS = $(am_posix_OBJECTS)
+posix_LDADD = $(LDADD)
+posix_DEPENDENCIES = $(libname)
+am_simple_OBJECTS = simple.$(OBJEXT)
+simple_OBJECTS = $(am_simple_OBJECTS)
+simple_LDADD = $(LDADD)
+simple_DEPENDENCIES = $(libname)
+am_sql_OBJECTS = sql.$(OBJEXT)
+sql_OBJECTS = $(am_sql_OBJECTS)
+sql_LDADD = $(LDADD)
+sql_DEPENDENCIES = $(libname)
+am_syntax_OBJECTS = syntax.$(OBJEXT)
+syntax_OBJECTS = $(am_syntax_OBJECTS)
+syntax_LDADD = $(LDADD)
+syntax_DEPENDENCIES = $(libname)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = crnl.c $(encode_SOURCES) $(listcap_SOURCES) $(names_SOURCES) \
+ $(posix_SOURCES) $(simple_SOURCES) $(sql_SOURCES) \
+ $(syntax_SOURCES)
+DIST_SOURCES = crnl.c $(encode_SOURCES) $(listcap_SOURCES) \
+ $(names_SOURCES) $(posix_SOURCES) $(simple_SOURCES) \
+ $(sql_SOURCES) $(syntax_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LTVERSION = @LTVERSION@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+RUBYDIR = @RUBYDIR@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STATISTICS = @STATISTICS@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+libname = $(top_builddir)/libonig.la
+LDADD = $(libname)
+INCLUDES = -I$(top_srcdir) -I$(includedir)
+encode_SOURCES = encode.c
+listcap_SOURCES = listcap.c
+names_SOURCES = names.c
+posix_SOURCES = posix.c
+simple_SOURCES = simple.c
+sql_SOURCES = sql.c
+syntax_SOURCES = syntax.c
+sampledir = $(top_builddir)/sample
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign sample/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign sample/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+crnl$(EXEEXT): $(crnl_OBJECTS) $(crnl_DEPENDENCIES) $(EXTRA_crnl_DEPENDENCIES)
+ @rm -f crnl$(EXEEXT)
+ $(LINK) $(crnl_OBJECTS) $(crnl_LDADD) $(LIBS)
+encode$(EXEEXT): $(encode_OBJECTS) $(encode_DEPENDENCIES) $(EXTRA_encode_DEPENDENCIES)
+ @rm -f encode$(EXEEXT)
+ $(LINK) $(encode_OBJECTS) $(encode_LDADD) $(LIBS)
+listcap$(EXEEXT): $(listcap_OBJECTS) $(listcap_DEPENDENCIES) $(EXTRA_listcap_DEPENDENCIES)
+ @rm -f listcap$(EXEEXT)
+ $(LINK) $(listcap_OBJECTS) $(listcap_LDADD) $(LIBS)
+names$(EXEEXT): $(names_OBJECTS) $(names_DEPENDENCIES) $(EXTRA_names_DEPENDENCIES)
+ @rm -f names$(EXEEXT)
+ $(LINK) $(names_OBJECTS) $(names_LDADD) $(LIBS)
+posix$(EXEEXT): $(posix_OBJECTS) $(posix_DEPENDENCIES) $(EXTRA_posix_DEPENDENCIES)
+ @rm -f posix$(EXEEXT)
+ $(LINK) $(posix_OBJECTS) $(posix_LDADD) $(LIBS)
+simple$(EXEEXT): $(simple_OBJECTS) $(simple_DEPENDENCIES) $(EXTRA_simple_DEPENDENCIES)
+ @rm -f simple$(EXEEXT)
+ $(LINK) $(simple_OBJECTS) $(simple_LDADD) $(LIBS)
+sql$(EXEEXT): $(sql_OBJECTS) $(sql_DEPENDENCIES) $(EXTRA_sql_DEPENDENCIES)
+ @rm -f sql$(EXEEXT)
+ $(LINK) $(sql_OBJECTS) $(sql_LDADD) $(LIBS)
+syntax$(EXEEXT): $(syntax_OBJECTS) $(syntax_DEPENDENCIES) $(EXTRA_syntax_DEPENDENCIES)
+ @rm -f syntax$(EXEEXT)
+ $(LINK) $(syntax_OBJECTS) $(syntax_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crnl.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encode.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/listcap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/names.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sql.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syntax.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstPROGRAMS ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+test: encode listcap names posix simple sql syntax
+ @$(sampledir)/encode
+ @$(sampledir)/listcap
+ @$(sampledir)/names
+ @$(sampledir)/posix
+ @$(sampledir)/simple
+ @$(sampledir)/sql
+ @$(sampledir)/syntax
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/sample/crnl.c b/sample/crnl.c
new file mode 100644
index 0000000..3f511e9
--- /dev/null
+++ b/sample/crnl.c
@@ -0,0 +1,127 @@
+/*
+ * crnl.c 2007/05/30 K.Kosako
+ *
+ * !!! You should enable USE_CRNL_AS_LINE_TERMINATOR. !!!
+ *
+ * USE_CRNL_AS_LINE_TERMINATOR config test program.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+static int nfail = 0;
+
+static void result(int no, int from, int to,
+ int expected_from, int expected_to)
+{
+ fprintf(stderr, "%3d: ", no);
+ if (from == expected_from && to == expected_to) {
+ fprintf(stderr, "Success\n");
+ }
+ else {
+ fprintf(stderr, "Fail: expected: (%d-%d), result: (%d-%d)\n",
+ expected_from, expected_to, from, to);
+
+ nfail++;
+ }
+}
+
+static int
+x(int no, char* pattern_arg, char* str_arg,
+ int expected_from, int expected_to)
+{
+ int r;
+ unsigned char *start, *range, *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ OnigRegion *region;
+ UChar *pattern, *str;
+
+ pattern = (UChar* )pattern_arg;
+ str = (UChar* )str_arg;
+
+ r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
+ ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo);
+ if (r != ONIG_NORMAL) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r, &einfo);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ region = onig_region_new();
+
+ end = str + strlen((char* )str);
+ start = str;
+ range = end;
+ r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ if (r >= 0 || r == ONIG_MISMATCH) {
+ result(no, region->beg[0], region->end[0], expected_from, expected_to);
+ }
+ else if (r == ONIG_MISMATCH) {
+ result(no, r, -1, expected_from, expected_to);
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ return 0;
+}
+
+static int
+f(int no, char* pattern_arg, char* str_arg)
+{
+ return x(no, pattern_arg, str_arg, -1, -1);
+}
+
+extern int main(int argc, char* argv[])
+{
+ x( 1, "", "\r\n", 0, 0);
+ x( 2, ".", "\r\n", 0, 1);
+ f( 3, "..", "\r\n");
+ x( 4, "^", "\r\n", 0, 0);
+ x( 5, "\\n^", "\r\nf", 1, 2);
+ x( 6, "\\n^a", "\r\na", 1, 3);
+ x( 7, "$", "\r\n", 0, 0);
+ x( 8, "T$", "T\r\n", 0, 1);
+ x( 9, "T$", "T\raT\r\n", 3, 4);
+ x(10, "\\z", "\r\n", 2, 2);
+ f(11, "a\\z", "a\r\n");
+ x(12, "\\Z", "\r\n", 0, 0);
+ x(13, "\\Z", "\r\na", 3, 3);
+ x(14, "\\Z", "\r\n\r\n\n", 4, 4);
+ x(15, "\\Z", "\r\n\r\nX", 5, 5);
+ x(16, "a\\Z", "a\r\n", 0, 1);
+ x(17, "aaaaaaaaaaaaaaa\\Z", "aaaaaaaaaaaaaaa\r\n", 0, 15);
+ x(18, "a|$", "b\r\n", 1, 1);
+ x(19, "$|b", "\rb", 1, 2);
+ x(20, "a$|ab$", "\r\nab\r\n", 2, 4);
+
+ x(21, "a|\\Z", "b\r\n", 1, 1);
+ x(22, "\\Z|b", "\rb", 1, 2);
+ x(23, "a\\Z|ab\\Z", "\r\nab\r\n", 2, 4);
+ x(24, "(?=a$).", "a\r\n", 0, 1);
+ f(25, "(?=a$).", "a\r");
+ x(26, "(?!a$)..", "a\r", 0, 2);
+ x(27, "(?<=a$).\\n", "a\r\n", 1, 3);
+ f(28, "(?<!a$).\\n", "a\r\n");
+ x(29, "(?=a\\Z).", "a\r\n", 0, 1);
+ f(30, "(?=a\\Z).", "a\r");
+ x(31, "(?!a\\Z)..", "a\r", 0, 2);
+
+ onig_end();
+
+ if (nfail > 0) {
+ fprintf(stderr, "\n");
+ fprintf(stderr, "!!! You have to enable USE_CRNL_AS_LINE_TERMINATOR\n");
+ fprintf(stderr, "!!! in regenc.h for this test program.\n");
+ fprintf(stderr, "\n");
+ }
+
+ return 0;
+}
diff --git a/sample/encode.c b/sample/encode.c
new file mode 100644
index 0000000..3fbd03d
--- /dev/null
+++ b/sample/encode.c
@@ -0,0 +1,298 @@
+/*
+ * encode.c
+ */
+#include <stdio.h>
+#include "oniguruma.h"
+
+static int
+search(regex_t* reg, unsigned char* str, unsigned char* end)
+{
+ int r;
+ unsigned char *start, *range;
+ OnigRegion *region;
+
+ region = onig_region_new();
+
+ start = str;
+ range = end;
+ r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ if (r >= 0) {
+ int i;
+
+ fprintf(stderr, "match at %d (%s)\n", r,
+ ONIGENC_NAME(onig_get_encoding(reg)));
+ for (i = 0; i < region->num_regs; i++) {
+ fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
+ }
+ }
+ else if (r == ONIG_MISMATCH) {
+ fprintf(stderr, "search fail (%s)\n",
+ ONIGENC_NAME(onig_get_encoding(reg)));
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r);
+ fprintf(stderr, "ERROR: %s\n", s);
+ fprintf(stderr, " (%s)\n", ONIGENC_NAME(onig_get_encoding(reg)));
+ return -1;
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ return 0;
+}
+
+static int
+exec(OnigEncoding enc, OnigOptionType options,
+ char* apattern, char* astr)
+{
+ int r;
+ unsigned char *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ UChar* pattern = (UChar* )apattern;
+ UChar* str = (UChar* )astr;
+
+ r = onig_new(&reg, pattern,
+ pattern + onigenc_str_bytelen_null(enc, pattern),
+ options, enc, ONIG_SYNTAX_DEFAULT, &einfo);
+ if (r != ONIG_NORMAL) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r, &einfo);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ end = str + onigenc_str_bytelen_null(enc, str);
+ r = search(reg, str, end);
+
+ onig_free(reg);
+ onig_end();
+ return 0;
+}
+
+static OnigCaseFoldType CF = ONIGENC_CASE_FOLD_MIN;
+
+#if 0
+static void
+set_case_fold(OnigCaseFoldType cf)
+{
+ CF = cf;
+}
+#endif
+
+static int
+exec_deluxe(OnigEncoding pattern_enc, OnigEncoding str_enc,
+ OnigOptionType options, char* apattern, char* astr)
+{
+ int r;
+ unsigned char *end;
+ regex_t* reg;
+ OnigCompileInfo ci;
+ OnigErrorInfo einfo;
+ UChar* pattern = (UChar* )apattern;
+ UChar* str = (UChar* )astr;
+
+ ci.num_of_elements = 5;
+ ci.pattern_enc = pattern_enc;
+ ci.target_enc = str_enc;
+ ci.syntax = ONIG_SYNTAX_DEFAULT;
+ ci.option = options;
+ ci.case_fold_flag = CF;
+
+ r = onig_new_deluxe(&reg, pattern,
+ pattern + onigenc_str_bytelen_null(pattern_enc, pattern),
+ &ci, &einfo);
+ if (r != ONIG_NORMAL) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r, &einfo);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ end = str + onigenc_str_bytelen_null(str_enc, str);
+ r = search(reg, str, end);
+
+ onig_free(reg);
+ onig_end();
+ return 0;
+}
+
+extern int main(int argc, char* argv[])
+{
+ int r;
+ /* ISO 8859-1 test */
+ static unsigned char str[] = { 0xc7, 0xd6, 0xfe, 0xea, 0xe0, 0xe2, 0x00 };
+ static unsigned char pattern[] = { 0xe7, 0xf6, 0xde, '\\', 'w', '+', 0x00 };
+
+ r = exec(ONIG_ENCODING_CP1251, ONIG_OPTION_IGNORECASE,
+ "aBc", " AbC");
+
+ r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE,
+ " [a-c\337z] ", " SS ");
+ r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE,
+ " [\330-\341] ", " SS ");
+
+ r = exec(ONIG_ENCODING_ISO_8859_2, ONIG_OPTION_IGNORECASE,
+ "\337 ", " Ss ");
+ r = exec(ONIG_ENCODING_ISO_8859_2, ONIG_OPTION_IGNORECASE,
+ "SS ", " \337 ");
+ r = exec(ONIG_ENCODING_ISO_8859_2, ONIG_OPTION_IGNORECASE,
+ "\\A\\S\\z", "ss");
+
+ r = exec(ONIG_ENCODING_ISO_8859_2, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+
+ r = exec(ONIG_ENCODING_ISO_8859_3, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_4, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_5, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_6, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_7, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_8, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_9, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_10, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_11, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_13, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_14, ONIG_OPTION_IGNORECASE,
+ "[ac]+", "bbbaAaCCC");
+ r = exec(ONIG_ENCODING_ISO_8859_15, ONIG_OPTION_IGNORECASE,
+ (char* )pattern, (char* )str);
+ r = exec(ONIG_ENCODING_ISO_8859_16, ONIG_OPTION_IGNORECASE,
+ (char* )pattern, (char* )str);
+
+ r = exec(ONIG_ENCODING_KOI8_R, ONIG_OPTION_NONE, "a+", "bbbaaaccc");
+ r = exec(ONIG_ENCODING_EUC_TW, ONIG_OPTION_NONE, "b*a+?c+", "bbbaaaccc");
+ r = exec(ONIG_ENCODING_EUC_KR, ONIG_OPTION_NONE, "a+", "bbbaaaccc");
+ r = exec(ONIG_ENCODING_EUC_CN, ONIG_OPTION_NONE, "c+", "bbbaaaccc");
+ r = exec(ONIG_ENCODING_BIG5, ONIG_OPTION_NONE, "a+", "bbbaaaccc");
+
+ r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE,
+ "\337", "SS");
+ r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE,
+ "SS", "\337");
+ r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE,
+ "SSb\337ssc", "a\337bSS\337cd");
+ r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE,
+ "[a\337]{0,2}", "aSS");
+ r = exec(ONIG_ENCODING_ISO_8859_1, ONIG_OPTION_IGNORECASE,
+ "is", "iss");
+
+ r = exec_deluxe(ONIG_ENCODING_ASCII, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_NONE, "a+",
+ "\000b\000a\000a\000a\000c\000c\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_ASCII, ONIG_ENCODING_UTF16_LE,
+ ONIG_OPTION_NONE, "a+",
+ "b\000a\000a\000a\000a\000c\000\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_LE,
+ ONIG_OPTION_NONE,
+ "\000b\000a\000a\000a\000c\000c\000\000",
+ "x\000b\000a\000a\000a\000c\000c\000\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ "\337", "\000S\000S\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ "SS", "\000\337\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF16_LE,
+ ONIG_OPTION_IGNORECASE,
+ "\337", "S\000S\000\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF32_BE,
+ ONIG_OPTION_IGNORECASE,
+ "SS", "\000\000\000\337\000\000\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF32_LE,
+ ONIG_OPTION_IGNORECASE,
+ "\337", "S\000\000\000S\000\000\000\000\000\000\000");
+
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_NONE,
+ "\000[\000[\000:\000a\000l\000n\000u\000m\000:\000]\000]\000+\000\000",
+ "\000#\002\120\000a\000Z\012\077\012\076\012\075\000\000");
+ /* 0x0a3d == \012\075 : is not alnum */
+ /* 0x0a3e == \012\076 : is alnum */
+
+ r = exec(ONIG_ENCODING_UTF16_BE, ONIG_OPTION_NONE,
+ "\000\\\000d\000+\000\000",
+ "\0003\0001\377\020\377\031\377\032\000\000");
+
+ r = exec(ONIG_ENCODING_GB18030, ONIG_OPTION_IGNORECASE,
+ "(Aa\\d)+", "BaA5Aa0234");
+
+ r = exec_deluxe(ONIG_ENCODING_ISO_8859_1, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_NONE,
+ "^\\P{Hiragana}\\p{^Hiragana}(\\p{Hiragana}+)$",
+ "\060\100\060\240\060\101\060\102\060\226\060\237\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ "\000[\000\337\000]\000\000", "\000S\000S\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ "\000[\000\337\000]\000\000", "\000s\000S\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ "\000^\000[\000\001\000-\377\375\000]\000$\000\000",
+ "\000s\000S\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ "\000S\000S\000\000",
+ "\000S\000T\000\337\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ "\000S\000T\000S\000S\000\000",
+ "\000S\000t\000s\000S\000\000");
+
+ {
+ UChar pat[] = { 0x1f, 0xfc, 0x00, 0x00 };
+ UChar str1[] = { 0x21, 0x26, 0x1f, 0xbe, 0x00, 0x00 };
+ UChar str2[] = { 0x1f, 0xf3, 0x00, 0x00 };
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ (char* )pat, (char* )str1);
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ (char* )pat, (char* )str2);
+ }
+
+#if 0
+ /* You should define USE_UNICODE_CASE_FOLD_TURKISH_AZERI in regenc.h. */
+
+ set_case_fold(ONIGENC_CASE_FOLD_TURKISH_AZERI);
+
+ r = exec_deluxe(ONIG_ENCODING_UTF8, ONIG_ENCODING_UTF8,
+ ONIG_OPTION_IGNORECASE,
+ "Ii", "\304\261\304\260");
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ "\000I\000i\000\000", "\001\061\001\060\000\000");
+
+ r = exec_deluxe(ONIG_ENCODING_UTF16_BE, ONIG_ENCODING_UTF16_BE,
+ ONIG_OPTION_IGNORECASE,
+ "\001\061\001\060\000\000", "\000I\000i\000\000");
+
+ set_case_fold(ONIGENC_CASE_FOLD_MIN);
+#endif
+
+ return r;
+}
diff --git a/sample/listcap.c b/sample/listcap.c
new file mode 100644
index 0000000..9a4fd9a
--- /dev/null
+++ b/sample/listcap.c
@@ -0,0 +1,107 @@
+/*
+ * listcap.c
+ *
+ * capture history (?@...) sample.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+static int
+node_callback(int group, int beg, int end, int level, int at, void* arg)
+{
+ int i;
+
+ if (at != ONIG_TRAVERSE_CALLBACK_AT_FIRST)
+ return -1; /* error */
+
+ /* indent */
+ for (i = 0; i < level * 2; i++)
+ fputc(' ', stderr);
+
+ fprintf(stderr, "%d: (%d-%d)\n", group, beg, end);
+ return 0;
+}
+
+extern int ex(unsigned char* str, unsigned char* pattern,
+ OnigSyntaxType* syntax)
+{
+ int r;
+ unsigned char *start, *range, *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ OnigRegion *region;
+
+ r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
+ ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo);
+ if (r != ONIG_NORMAL) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r, &einfo);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ fprintf(stderr, "number of captures: %d\n", onig_number_of_captures(reg));
+ fprintf(stderr, "number of capture histories: %d\n",
+ onig_number_of_capture_histories(reg));
+
+ region = onig_region_new();
+
+ end = str + strlen((char* )str);
+ start = str;
+ range = end;
+ r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ if (r >= 0) {
+ int i;
+
+ fprintf(stderr, "match at %d\n", r);
+ for (i = 0; i < region->num_regs; i++) {
+ fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
+ }
+ fprintf(stderr, "\n");
+
+ r = onig_capture_tree_traverse(region, ONIG_TRAVERSE_CALLBACK_AT_FIRST,
+ node_callback, (void* )0);
+ }
+ else if (r == ONIG_MISMATCH) {
+ fprintf(stderr, "search fail\n");
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r);
+ return -1;
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ return 0;
+}
+
+
+extern int main(int argc, char* argv[])
+{
+ int r;
+ OnigSyntaxType syn;
+
+ static UChar* str1 = (UChar* )"((())())";
+ static UChar* pattern1
+ = (UChar* )"\\g<p>(?@<p>\\(\\g<s>\\)){0}(?@<s>(?:\\g<p>)*|){0}";
+
+ static UChar* str2 = (UChar* )"x00x00x00";
+ static UChar* pattern2 = (UChar* )"(?@x(?@\\d+))+";
+
+ static UChar* str3 = (UChar* )"0123";
+ static UChar* pattern3 = (UChar* )"(?@.)(?@.)(?@.)(?@.)";
+
+ /* enable capture hostory */
+ onig_copy_syntax(&syn, ONIG_SYNTAX_DEFAULT);
+ onig_set_syntax_op2(&syn,
+ onig_get_syntax_op2(&syn) | ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY);
+
+ r = ex(str1, pattern1, &syn);
+ r = ex(str2, pattern2, &syn);
+ r = ex(str3, pattern3, &syn);
+
+ onig_end();
+ return r;
+}
diff --git a/sample/names.c b/sample/names.c
new file mode 100644
index 0000000..6667eb5
--- /dev/null
+++ b/sample/names.c
@@ -0,0 +1,72 @@
+/*
+ * names.c -- example of group name callback.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+static int
+name_callback(const UChar* name, const UChar* name_end,
+ int ngroup_num, int* group_nums,
+ regex_t* reg, void* arg)
+{
+ int i, gn, ref;
+ char* s;
+ OnigRegion *region = (OnigRegion* )arg;
+
+ for (i = 0; i < ngroup_num; i++) {
+ gn = group_nums[i];
+ ref = onig_name_to_backref_number(reg, name, name_end, region);
+ s = (ref == gn ? "*" : "");
+ fprintf(stderr, "%s (%d): ", name, gn);
+ fprintf(stderr, "(%d-%d) %s\n", region->beg[gn], region->end[gn], s);
+ }
+ return 0; /* 0: continue */
+}
+
+extern int main(int argc, char* argv[])
+{
+ int r;
+ unsigned char *start, *range, *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ OnigRegion *region;
+
+ static UChar* pattern = (UChar* )"(?<foo>a*)(?<bar>b*)(?<foo>c*)";
+ static UChar* str = (UChar* )"aaabbbbcc";
+
+ r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
+ ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo);
+ if (r != ONIG_NORMAL) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r, &einfo);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ fprintf(stderr, "number of names: %d\n", onig_number_of_names(reg));
+
+ region = onig_region_new();
+
+ end = str + strlen((char* )str);
+ start = str;
+ range = end;
+ r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ if (r >= 0) {
+ fprintf(stderr, "match at %d\n\n", r);
+ r = onig_foreach_name(reg, name_callback, (void* )region);
+ }
+ else if (r == ONIG_MISMATCH) {
+ fprintf(stderr, "search fail\n");
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r);
+ return -1;
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ onig_end();
+ return 0;
+}
diff --git a/sample/posix.c b/sample/posix.c
new file mode 100644
index 0000000..d24ee35
--- /dev/null
+++ b/sample/posix.c
@@ -0,0 +1,93 @@
+/*
+ * posix.c
+ */
+#include <stdio.h>
+#include "onigposix.h"
+
+typedef unsigned char UChar;
+
+static int x(regex_t* reg, unsigned char* pattern, unsigned char* str)
+{
+ int r, i;
+ char buf[200];
+ regmatch_t pmatch[20];
+
+ r = regexec(reg, (char* )str, reg->re_nsub + 1, pmatch, 0);
+ if (r != 0 && r != REG_NOMATCH) {
+ regerror(r, reg, buf, sizeof(buf));
+ fprintf(stderr, "ERROR: %s\n", buf);
+ return -1;
+ }
+
+ if (r == REG_NOMATCH) {
+ fprintf(stderr, "FAIL: /%s/ '%s'\n", pattern, str);
+ }
+ else {
+ fprintf(stderr, "OK: /%s/ '%s'\n", pattern, str);
+ for (i = 0; i <= (int )reg->re_nsub; i++) {
+ fprintf(stderr, "%d: %d-%d\n", i, pmatch[i].rm_so, pmatch[i].rm_eo);
+ }
+ }
+ return 0;
+}
+
+extern int main(int argc, char* argv[])
+{
+ int r;
+ char buf[200];
+ regex_t reg;
+ UChar* pattern;
+
+ /* default syntax (ONIG_SYNTAX_RUBY) */
+ pattern = (UChar* )"^a+b{2,7}[c-f]?$|uuu";
+ r = regcomp(&reg, (char* )pattern, REG_EXTENDED);
+ if (r) {
+ regerror(r, &reg, buf, sizeof(buf));
+ fprintf(stderr, "ERROR: %s\n", buf);
+ return -1;
+ }
+ x(&reg, pattern, (UChar* )"aaabbbbd");
+
+ /* POSIX Basic RE (REG_EXTENDED is not specified.) */
+ pattern = (UChar* )"^a+b{2,7}[c-f]?|uuu";
+ r = regcomp(&reg, (char* )pattern, 0);
+ if (r) {
+ regerror(r, &reg, buf, sizeof(buf));
+ fprintf(stderr, "ERROR: %s\n", buf);
+ return -1;
+ }
+ x(&reg, pattern, (UChar* )"a+b{2,7}d?|uuu");
+
+ /* POSIX Basic RE (REG_EXTENDED is not specified.) */
+ pattern = (UChar* )"^a*b\\{2,7\\}\\([c-f]\\)$";
+ r = regcomp(&reg, (char* )pattern, 0);
+ if (r) {
+ regerror(r, &reg, buf, sizeof(buf));
+ fprintf(stderr, "ERROR: %s\n", buf);
+ return -1;
+ }
+ x(&reg, pattern, (UChar* )"aaaabbbbbbd");
+
+ /* POSIX Extended RE */
+ onig_set_default_syntax(ONIG_SYNTAX_POSIX_EXTENDED);
+ pattern = (UChar* )"^a+b{2,7}[c-f]?)$|uuu";
+ r = regcomp(&reg, (char* )pattern, REG_EXTENDED);
+ if (r) {
+ regerror(r, &reg, buf, sizeof(buf));
+ fprintf(stderr, "ERROR: %s\n", buf);
+ return -1;
+ }
+ x(&reg, pattern, (UChar* )"aaabbbbd)");
+
+ pattern = (UChar* )"^b.";
+ r = regcomp(&reg, (char* )pattern, REG_EXTENDED | REG_NEWLINE);
+ if (r) {
+ regerror(r, &reg, buf, sizeof(buf));
+ fprintf(stderr, "ERROR: %s\n", buf);
+ return -1;
+ }
+ x(&reg, pattern, (UChar* )"a\nb\n");
+
+ regfree(&reg);
+ return 0;
+}
diff --git a/sample/simple.c b/sample/simple.c
new file mode 100644
index 0000000..948a542
--- /dev/null
+++ b/sample/simple.c
@@ -0,0 +1,56 @@
+/*
+ * simple.c
+ */
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+extern int main(int argc, char* argv[])
+{
+ int r;
+ unsigned char *start, *range, *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ OnigRegion *region;
+
+ static UChar* pattern = (UChar* )"a(.*)b|[e-f]+";
+ static UChar* str = (UChar* )"zzzzaffffffffb";
+
+ r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
+ ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo);
+ if (r != ONIG_NORMAL) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r, &einfo);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ region = onig_region_new();
+
+ end = str + strlen((char* )str);
+ start = str;
+ range = end;
+ r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ if (r >= 0) {
+ int i;
+
+ fprintf(stderr, "match at %d\n", r);
+ for (i = 0; i < region->num_regs; i++) {
+ fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
+ }
+ }
+ else if (r == ONIG_MISMATCH) {
+ fprintf(stderr, "search fail\n");
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ onig_end();
+ return 0;
+}
diff --git a/sample/sql.c b/sample/sql.c
new file mode 100644
index 0000000..e0ce62c
--- /dev/null
+++ b/sample/sql.c
@@ -0,0 +1,73 @@
+/*
+ * sql.c
+ */
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+extern int main(int argc, char* argv[])
+{
+ static OnigSyntaxType SQLSyntax;
+
+ int r;
+ unsigned char *start, *range, *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ OnigRegion *region;
+
+ static UChar* pattern = (UChar* )"\\_%\\\\__zz";
+ static UChar* str = (UChar* )"a_abcabcabc\\ppzz";
+
+ onig_set_syntax_op (&SQLSyntax, ONIG_SYN_OP_VARIABLE_META_CHARACTERS);
+ onig_set_syntax_op2 (&SQLSyntax, 0);
+ onig_set_syntax_behavior(&SQLSyntax, 0);
+ onig_set_syntax_options (&SQLSyntax, ONIG_OPTION_MULTILINE);
+ onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ESCAPE, (OnigCodePoint )'\\');
+ onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYCHAR, (OnigCodePoint )'_');
+ onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYTIME,
+ ONIG_INEFFECTIVE_META_CHAR);
+ onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ZERO_OR_ONE_TIME,
+ ONIG_INEFFECTIVE_META_CHAR);
+ onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ONE_OR_MORE_TIME,
+ ONIG_INEFFECTIVE_META_CHAR);
+ onig_set_meta_char(&SQLSyntax, ONIG_META_CHAR_ANYCHAR_ANYTIME,
+ (OnigCodePoint )'%');
+
+ r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
+ ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, &SQLSyntax, &einfo);
+ if (r != ONIG_NORMAL) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r, &einfo);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ region = onig_region_new();
+
+ end = str + strlen((char* )str);
+ start = str;
+ range = end;
+ r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ if (r >= 0) {
+ int i;
+
+ fprintf(stderr, "match at %d\n", r);
+ for (i = 0; i < region->num_regs; i++) {
+ fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
+ }
+ }
+ else if (r == ONIG_MISMATCH) {
+ fprintf(stderr, "search fail\n");
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ onig_end();
+ return 0;
+}
diff --git a/sample/syntax.c b/sample/syntax.c
new file mode 100644
index 0000000..7cc353f
--- /dev/null
+++ b/sample/syntax.c
@@ -0,0 +1,74 @@
+/*
+ * syntax.c
+ */
+#include <stdio.h>
+#include <string.h>
+#include "oniguruma.h"
+
+extern int exec(OnigSyntaxType* syntax,
+ char* apattern, char* astr)
+{
+ int r;
+ unsigned char *start, *range, *end;
+ regex_t* reg;
+ OnigErrorInfo einfo;
+ OnigRegion *region;
+ UChar* pattern = (UChar* )apattern;
+ UChar* str = (UChar* )astr;
+
+ r = onig_new(&reg, pattern, pattern + strlen((char* )pattern),
+ ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, syntax, &einfo);
+ if (r != ONIG_NORMAL) {
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r, &einfo);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ region = onig_region_new();
+
+ end = str + strlen((char* )str);
+ start = str;
+ range = end;
+ r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE);
+ if (r >= 0) {
+ int i;
+
+ fprintf(stderr, "match at %d\n", r);
+ for (i = 0; i < region->num_regs; i++) {
+ fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]);
+ }
+ }
+ else if (r == ONIG_MISMATCH) {
+ fprintf(stderr, "search fail\n");
+ }
+ else { /* error */
+ char s[ONIG_MAX_ERROR_MESSAGE_LEN];
+ onig_error_code_to_str(s, r);
+ fprintf(stderr, "ERROR: %s\n", s);
+ return -1;
+ }
+
+ onig_region_free(region, 1 /* 1:free self, 0:free contents only */);
+ onig_free(reg);
+ onig_end();
+ return 0;
+}
+
+extern int main(int argc, char* argv[])
+{
+ int r;
+
+ r = exec(ONIG_SYNTAX_PERL,
+ "\\p{XDigit}\\P{XDigit}\\p{^XDigit}\\P{^XDigit}\\p{XDigit}",
+ "bgh3a");
+
+ r = exec(ONIG_SYNTAX_JAVA,
+ "\\p{XDigit}\\P{XDigit}[a-c&&b-g]", "bgc");
+
+ r = exec(ONIG_SYNTAX_ASIS,
+ "abc def* e+ g?ddd[a-rvvv] (vv){3,7}hv\\dvv(?:aczui ss)\\W\\w$",
+ "abc def* e+ g?ddd[a-rvvv] (vv){3,7}hv\\dvv(?:aczui ss)\\W\\w$");
+ onig_end();
+ return r;
+}