diff options
author | Gabor Kovesdan <gabor@FreeBSD.org> | 2011-05-03 19:33:09 +0000 |
---|---|---|
committer | Gabor Kovesdan <gabor@FreeBSD.org> | 2011-05-03 19:33:09 +0000 |
commit | 7e370ebd64e43d1ac59181c51ed9065a094d39d7 (patch) | |
tree | 28a6b48ed3f1eff1d6eab2af016c684746c58035 /src |
Diffstat (limited to 'src')
-rw-r--r-- | src/.deps/agrep-agrep.Po | 1 | ||||
-rw-r--r-- | src/Makefile | 511 | ||||
-rw-r--r-- | src/Makefile.am | 15 | ||||
-rw-r--r-- | src/Makefile.in | 511 | ||||
-rw-r--r-- | src/agrep.c | 823 |
5 files changed, 1861 insertions, 0 deletions
diff --git a/src/.deps/agrep-agrep.Po b/src/.deps/agrep-agrep.Po new file mode 100644 index 0000000000000..9ce06a81ea45b --- /dev/null +++ b/src/.deps/agrep-agrep.Po @@ -0,0 +1 @@ +# dummy diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000000000..02abebc682edc --- /dev/null +++ b/src/Makefile @@ -0,0 +1,511 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# src/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 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. + + + + +pkgdatadir = $(datadir)/tre +pkglibdir = $(libdir)/tre +pkgincludedir = $(includedir)/tre +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 = x86_64-unknown-freebsd8.0 +host_triplet = x86_64-unknown-freebsd8.0 +target_triplet = x86_64-unknown-freebsd8.0 +bin_PROGRAMS = agrep$(EXEEXT) +subdir = src +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_libtool_tags.m4 \ + $(top_srcdir)/m4/ax_check_funcs_comp.m4 \ + $(top_srcdir)/m4/ax_check_sign.m4 \ + $(top_srcdir)/m4/ax_decl_wchar_max.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/vl_prog_cc_warnings.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/utils/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/lib/tre-config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am__agrep_SOURCES_DIST = agrep.c +am_agrep_OBJECTS = agrep-agrep.$(OBJEXT) +agrep_OBJECTS = $(am_agrep_OBJECTS) +am__DEPENDENCIES_1 = +agrep_DEPENDENCIES = ../lib/libtre.la \ + $(am__DEPENDENCIES_1) +agrep_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(agrep_CFLAGS) $(CFLAGS) $(agrep_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/lib +depcomp = $(SHELL) $(top_srcdir)/utils/depcomp +am__depfiles_maybe = depfiles +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 = $(agrep_SOURCES) +DIST_SOURCES = $(am__agrep_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = ${SHELL} /home/gabor/wrk/tre/tre-0.8.0/utils/missing --run aclocal-1.10 +ALLOCA = +AMTAR = ${SHELL} /home/gabor/wrk/tre/tre-0.8.0/utils/missing --run tar +AR = ar +AS = as +AUTOCONF = ${SHELL} /home/gabor/wrk/tre/tre-0.8.0/utils/missing --run autoconf +AUTOHEADER = ${SHELL} /home/gabor/wrk/tre/tre-0.8.0/utils/missing --run autoheader +AUTOMAKE = ${SHELL} /home/gabor/wrk/tre/tre-0.8.0/utils/missing --run automake-1.10 +AWK = nawk +CC = gcc +CCDEPMODE = depmode=gcc3 +CFLAGS = -g -O2 -Wall +CPP = gcc -E +CPPFLAGS = +CYGPATH_W = echo +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +DLLTOOL = dlltool +DSYMUTIL = +ECHO = echo +ECHO_C = +ECHO_N = -n +ECHO_T = +EGREP = /usr/bin/grep -E +EXEEXT = +GETTEXT_MACRO_VERSION = 0.17 +GMSGFMT = /usr/local/bin/msgfmt +GMSGFMT_015 = /usr/local/bin/msgfmt +GREP = /usr/bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +INTLLIBS = +INTL_MACOSX_LIBS = +LDFLAGS = +LIBICONV = /usr/local/lib/libiconv.so -Wl,-rpath -Wl,/usr/local/lib +LIBINTL = +LIBOBJS = +LIBS = +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LN_S = ln -s +LTLIBICONV = -L/usr/local/lib -liconv -R/usr/local/lib +LTLIBINTL = +LTLIBOBJS = +MAKEINFO = ${SHELL} /home/gabor/wrk/tre/tre-0.8.0/utils/missing --run makeinfo +MKDIR_P = ../utils/install-sh -c -d +MSGFMT = /usr/local/bin/msgfmt +MSGFMT_015 = /usr/local/bin/msgfmt +MSGMERGE = /usr/local/bin/msgmerge +NMEDIT = +OBJDUMP = objdump +OBJEXT = o +PACKAGE = tre +PACKAGE_BUGREPORT = tre-general@lists.laurikari.net +PACKAGE_NAME = TRE +PACKAGE_STRING = TRE 0.8.0 +PACKAGE_TARNAME = tre +PACKAGE_VERSION = 0.8.0 +PATH_SEPARATOR = : +POSUB = +RANLIB = ranlib +SED = /usr/local/bin/gsed +SET_MAKE = +SHELL = /bin/sh +STRIP = strip +TRE_VERSION = 0.8.0 +USE_NLS = no +VERSION = 0.8.0 +XGETTEXT = /usr/local/bin/xgettext +XGETTEXT_015 = /usr/local/bin/xgettext +XGETTEXT_EXTRA_OPTIONS = +abs_builddir = /home/gabor/wrk/tre/tre-0.8.0/src +abs_srcdir = /home/gabor/wrk/tre/tre-0.8.0/src +abs_top_builddir = /home/gabor/wrk/tre/tre-0.8.0 +abs_top_srcdir = /home/gabor/wrk/tre/tre-0.8.0 +ac_ct_CC = gcc +am__include = include +am__leading_dot = . +am__quote = +am__tar = ${AMTAR} chof - "$$tardir" +am__untar = ${AMTAR} xf - +bindir = ${exec_prefix}/bin +build = x86_64-unknown-freebsd8.0 +build_alias = +build_cpu = x86_64 +build_os = freebsd8.0 +build_vendor = unknown +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = x86_64-unknown-freebsd8.0 +host_alias = +host_cpu = x86_64 +host_os = freebsd8.0 +host_vendor = unknown +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = $(SHELL) /home/gabor/wrk/tre/tre-0.8.0/utils/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = $(datadir)/locale +localstatedir = ${prefix}/var +mandir = ${datarootdir}/man +mkdir_p = $(top_builddir)/utils/install-sh -c -d +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr/local +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target = x86_64-unknown-freebsd8.0 +target_alias = +target_cpu = x86_64 +target_os = freebsd8.0 +target_vendor = unknown +top_builddir = .. +top_srcdir = .. +INCLUDES = -I$(top_srcdir)/lib +agrep_SOURCES = agrep.c +agrep_LDADD = ../lib/libtre.la $(LTLIBINTL) +agrep_CFLAGS = -DLOCALEDIR=\"$(localedir)\" +#agrep_LDFLAGS = -static +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 \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/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 +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +agrep$(EXEEXT): $(agrep_OBJECTS) $(agrep_DEPENDENCIES) + @rm -f agrep$(EXEEXT) + $(agrep_LINK) $(agrep_OBJECTS) $(agrep_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/agrep-agrep.Po + +.c.o: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +# source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(LTCOMPILE) -c -o $@ $< + +agrep-agrep.o: agrep.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(agrep_CFLAGS) $(CFLAGS) -MT agrep-agrep.o -MD -MP -MF $(DEPDIR)/agrep-agrep.Tpo -c -o agrep-agrep.o `test -f 'agrep.c' || echo '$(srcdir)/'`agrep.c + mv -f $(DEPDIR)/agrep-agrep.Tpo $(DEPDIR)/agrep-agrep.Po +# source='agrep.c' object='agrep-agrep.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(agrep_CFLAGS) $(CFLAGS) -c -o agrep-agrep.o `test -f 'agrep.c' || echo '$(srcdir)/'`agrep.c + +agrep-agrep.obj: agrep.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(agrep_CFLAGS) $(CFLAGS) -MT agrep-agrep.obj -MD -MP -MF $(DEPDIR)/agrep-agrep.Tpo -c -o agrep-agrep.obj `if test -f 'agrep.c'; then $(CYGPATH_W) 'agrep.c'; else $(CYGPATH_W) '$(srcdir)/agrep.c'; fi` + mv -f $(DEPDIR)/agrep-agrep.Tpo $(DEPDIR)/agrep-agrep.Po +# source='agrep.c' object='agrep-agrep.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(agrep_CFLAGS) $(CFLAGS) -c -o agrep-agrep.obj `if test -f 'agrep.c'; then $(CYGPATH_W) 'agrep.c'; else $(CYGPATH_W) '$(srcdir)/agrep.c'; fi` + +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; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$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: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +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: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-binPROGRAMS clean-generic clean-libtool 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 + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: 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: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS 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 \ + uninstall-binPROGRAMS + +# 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/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000000000..9635404165cf9 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,15 @@ +## Process this file with automake to produce Makefile.in + +localedir = $(datadir)/locale +INCLUDES = -I$(top_srcdir)/lib + +if TRE_AGREP +bin_PROGRAMS = agrep + +agrep_SOURCES = agrep.c +agrep_LDADD = ../lib/libtre.la $(LTLIBINTL) +agrep_CFLAGS = -DLOCALEDIR=\"$(localedir)\" +if TRE_PROFILE +agrep_LDFLAGS = -static +endif +endif diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000000000..584db14626224 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,511 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 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@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@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@ +target_triplet = @target@ +@TRE_AGREP_TRUE@bin_PROGRAMS = agrep$(EXEEXT) +subdir = src +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_libtool_tags.m4 \ + $(top_srcdir)/m4/ax_check_funcs_comp.m4 \ + $(top_srcdir)/m4/ax_check_sign.m4 \ + $(top_srcdir)/m4/ax_decl_wchar_max.m4 \ + $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ + $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/vl_prog_cc_warnings.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/utils/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/lib/tre-config.h +CONFIG_CLEAN_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am__agrep_SOURCES_DIST = agrep.c +@TRE_AGREP_TRUE@am_agrep_OBJECTS = agrep-agrep.$(OBJEXT) +agrep_OBJECTS = $(am_agrep_OBJECTS) +am__DEPENDENCIES_1 = +@TRE_AGREP_TRUE@agrep_DEPENDENCIES = ../lib/libtre.la \ +@TRE_AGREP_TRUE@ $(am__DEPENDENCIES_1) +agrep_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(agrep_CFLAGS) $(CFLAGS) $(agrep_LDFLAGS) \ + $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/lib +depcomp = $(SHELL) $(top_srcdir)/utils/depcomp +am__depfiles_maybe = depfiles +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 = $(agrep_SOURCES) +DIST_SOURCES = $(am__agrep_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +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@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TRE_VERSION = @TRE_VERSION@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +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 = $(datadir)/locale +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 = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = -I$(top_srcdir)/lib +@TRE_AGREP_TRUE@agrep_SOURCES = agrep.c +@TRE_AGREP_TRUE@agrep_LDADD = ../lib/libtre.la $(LTLIBINTL) +@TRE_AGREP_TRUE@agrep_CFLAGS = -DLOCALEDIR=\"$(localedir)\" +@TRE_AGREP_TRUE@@TRE_PROFILE_TRUE@agrep_LDFLAGS = -static +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 \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/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 +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +agrep$(EXEEXT): $(agrep_OBJECTS) $(agrep_DEPENDENCIES) + @rm -f agrep$(EXEEXT) + $(agrep_LINK) $(agrep_OBJECTS) $(agrep_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agrep-agrep.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(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@ mv -f $(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@ mv -f $(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 $@ $< + +agrep-agrep.o: agrep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(agrep_CFLAGS) $(CFLAGS) -MT agrep-agrep.o -MD -MP -MF $(DEPDIR)/agrep-agrep.Tpo -c -o agrep-agrep.o `test -f 'agrep.c' || echo '$(srcdir)/'`agrep.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/agrep-agrep.Tpo $(DEPDIR)/agrep-agrep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='agrep.c' object='agrep-agrep.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(agrep_CFLAGS) $(CFLAGS) -c -o agrep-agrep.o `test -f 'agrep.c' || echo '$(srcdir)/'`agrep.c + +agrep-agrep.obj: agrep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(agrep_CFLAGS) $(CFLAGS) -MT agrep-agrep.obj -MD -MP -MF $(DEPDIR)/agrep-agrep.Tpo -c -o agrep-agrep.obj `if test -f 'agrep.c'; then $(CYGPATH_W) 'agrep.c'; else $(CYGPATH_W) '$(srcdir)/agrep.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/agrep-agrep.Tpo $(DEPDIR)/agrep-agrep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='agrep.c' object='agrep-agrep.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(agrep_CFLAGS) $(CFLAGS) -c -o agrep-agrep.obj `if test -f 'agrep.c'; then $(CYGPATH_W) 'agrep.c'; else $(CYGPATH_W) '$(srcdir)/agrep.c'; fi` + +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; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + 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)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && 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 $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$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: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +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: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-binPROGRAMS clean-generic clean-libtool 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 + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: 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: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS 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 \ + uninstall-binPROGRAMS + +# 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/src/agrep.c b/src/agrep.c new file mode 100644 index 0000000000000..55d2b05f0853f --- /dev/null +++ b/src/agrep.c @@ -0,0 +1,823 @@ +/* + agrep.c - Approximate grep + + This software is released under a BSD-style license. + See the file LICENSE for details and copyright. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <stdio.h> +#include <stdlib.h> +#include <locale.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <assert.h> +#include <limits.h> +#include <unistd.h> +#ifdef HAVE_GETOPT_H +#include <getopt.h> +#endif /* HAVE_GETOPT_H */ +#include "regex.h" + +#ifdef HAVE_GETTEXT +#include <libintl.h> +#else +#define gettext(s) s +#define bindtextdomain(p, d) +#define textdomain(p) +#endif + +#define _(String) gettext(String) + +#undef MAX +#undef MIN +#define MAX(a, b) (((a) >= (b)) ? (a) : (b)) +#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) + +/* Short options. */ +static char const short_options[] = +"cd:e:hiklnqsvwyBD:E:HI:MS:V0123456789-:"; + +static int show_help; +char *program_name; + +#ifdef HAVE_GETOPT_LONG +/* Long options that have no corresponding short equivalents. */ +enum { + COLOR_OPTION = CHAR_MAX + 1, + SHOW_POSITION_OPTION +}; + +/* Long option equivalences. */ +static struct option const long_options[] = +{ + {"best-match", no_argument, NULL, 'B'}, + {"color", no_argument, NULL, COLOR_OPTION}, + {"colour", no_argument, NULL, COLOR_OPTION}, + {"count", no_argument, NULL, 'c'}, + {"delete-cost", required_argument, NULL, 'D'}, + {"delimiter", no_argument, NULL, 'd'}, + {"delimiter-after", no_argument, NULL, 'M'}, + {"files-with-matches", no_argument, NULL, 'l'}, + {"help", no_argument, &show_help, 1}, + {"ignore-case", no_argument, NULL, 'i'}, + {"insert-cost", required_argument, NULL, 'I'}, + {"invert-match", no_argument, NULL, 'v'}, + {"line-number", no_argument, NULL, 'n'}, + {"literal", no_argument, NULL, 'k'}, + {"max-errors", required_argument, NULL, 'E'}, + {"no-filename", no_argument, NULL, 'h'}, + {"nothing", no_argument, NULL, 'y'}, + {"quiet", no_argument, NULL, 'q'}, + {"record-number", no_argument, NULL, 'n'}, + {"regexp", required_argument, NULL, 'e'}, + {"show-cost", no_argument, NULL, 's'}, + {"show-position", no_argument, NULL, SHOW_POSITION_OPTION}, + {"silent", no_argument, NULL, 'q'}, + {"substitute-cost", required_argument, NULL, 'S'}, + {"version", no_argument, NULL, 'V'}, + {"with-filename", no_argument, NULL, 'H'}, + {"word-regexp", no_argument, NULL, 'w'}, + {0, 0, 0, 0} +}; +#endif /* HAVE_GETOPT_LONG */ + +static void +tre_agrep_usage(int status) +{ + if (status != 0) + { + fprintf(stderr, _("Usage: %s [OPTION]... PATTERN [FILE]...\n"), + program_name); + fprintf(stderr, _("Try `%s --help' for more information.\n"), + program_name); + } + else + { + printf(_("Usage: %s [OPTION]... PATTERN [FILE]...\n"), program_name); + printf(_("\ +Searches for approximate matches of PATTERN in each FILE or standard input.\n\ +Example: `%s -2 optimize foo.txt' outputs all lines in file `foo.txt' that\n\ +match \"optimize\" within two errors. E.g. lines which contain \"optimise\",\n\ +\"optmise\", and \"opitmize\" all match.\n"), program_name); + printf("\n"); + printf(_("\ +Regexp selection and interpretation:\n\ + -e, --regexp=PATTERN use PATTERN as a regular expression\n\ + -i, --ignore-case ignore case distinctions\n\ + -k, --literal PATTERN is a literal string\n\ + -w, --word-regexp force PATTERN to match only whole words\n\ +\n\ +Approximate matching settings:\n\ + -D, --delete-cost=NUM set cost of missing characters\n\ + -I, --insert-cost=NUM set cost of extra characters\n\ + -S, --substitute-cost=NUM set cost of wrong characters\n\ + -E, --max-errors=NUM select records that have at most NUM errors\n\ + -# select records that have at most # errors (# is a\n\ + digit between 0 and 9)\n\ +\n\ +Miscellaneous:\n\ + -d, --delimiter=PATTERN set the record delimiter regular expression\n\ + -v, --invert-match select non-matching records\n\ + -V, --version print version information and exit\n\ + -y, --nothing does nothing (for compatibility with the non-free\n\ + agrep program)\n\ + --help display this help and exit\n\ +\n\ +Output control:\n\ + -B, --best-match only output records with least errors\n\ + -c, --count only print a count of matching records per FILE\n\ + -h, --no-filename suppress the prefixing filename on output\n\ + -H, --with-filename print the filename for each match\n\ + -l, --files-with-matches only print FILE names containing matches\n\ + -M, --delimiter-after print record delimiter after record if -d is used\n\ + -n, --record-number print record number with output\n\ + --line-number same as -n\n\ + -q, --quiet, --silent suppress all normal output\n\ + -s, --show-cost print match cost with output\n\ + --colour, --color use markers to distinguish the matching \ +strings\n\ + --show-position prefix each output record with start and end\n\ + position of the first match within the record\n")); + printf("\n"); + printf(_("\ +With no FILE, or when FILE is -, reads standard input. If less than two\n\ +FILEs are given, -h is assumed. Exit status is 0 if a match is found, 1 for\n\ +no match, and 2 if there were errors. If -E or -# is not specified, only\n\ +exact matches are selected.\n")); + printf("\n"); + printf(_("\ +PATTERN is a POSIX extended regular expression (ERE) with the TRE extensions.\n\ +See tre(7) for a complete description.\n")); + printf("\n"); + printf(_("Report bugs to: ")); + printf("%s.\n", PACKAGE_BUGREPORT); + } + exit(status); +} + +static regex_t preg; /* Compiled pattern to search for. */ +static regex_t delim; /* Compiled record delimiter pattern. */ + +#define INITIAL_BUF_SIZE 10240 /* Initial size of the buffer. */ +static char *buf; /* Buffer for scanning text. */ +static int buf_size; /* Current size of the buffer. */ +static int data_len; /* Amount of data in the buffer. */ +static char *record; /* Start of current record. */ +static char *next_record; /* Start of next record. */ +static int record_len; /* Length of current record. */ +static int delim_len; /* Length of delimiter before record. */ +static int next_delim_len; /* Length of delimiter after record. */ +static int delim_after = 1;/* If true, print the delimiter after the record. */ +static int at_eof; +static int have_matches; /* If true, matches have been found. */ + +static int invert_match; /* Show only non-matching records. */ +static int print_filename; /* Output filename. */ +static int print_recnum; /* Output record number. */ +static int print_cost; /* Output match cost. */ +static int count_matches; /* Count matching records. */ +static int list_files; /* List matching files. */ +static int color_option; /* Highlight matches. */ +static int print_position; /* Show start and end offsets for matches. */ + +static int best_match; /* Output only best matches. */ +static int best_cost; /* Best match cost found so far. */ +static int be_silent; /* Never output anything */ + +static regaparams_t match_params; + +/* The color string used with the --color option. If set, the + environment variable GREP_COLOR overrides this default value. */ +static const char *highlight = "01;31"; + +/* Sets `record' to the next complete record from file `fd', and `record_len' + to the length of the record. Returns 1 when there are no more records, + 0 otherwise. */ +static inline int +tre_agrep_get_next_record(int fd, const char *filename) +{ + if (at_eof) + return 1; + + while (1) + { + int errcode; + regmatch_t pmatch[1]; + + if (next_record == NULL) + { + int r; + int read_size = buf_size - data_len; + + if (read_size <= 0) + { + /* The buffer is full and no record delimiter found yet, + we need to grow the buffer. We double the size to + avoid rescanning the data too many times when the + records are very large. */ + buf_size *= 2; + buf = realloc(buf, buf_size); + if (buf == NULL) + { + fprintf(stderr, "%s: %s\n", program_name, _("Out of memory")); + exit(2); + } + read_size = buf_size - data_len; + } + + r = read(fd, buf + data_len, read_size); + if (r < 0) + { + /* Read error. */ + char *err; + if (errno == EINTR) + continue; + err = strerror(errno); + fprintf(stderr, "%s: ", program_name); + fprintf(stderr, _("Error reading from %s: %s\n"), filename, err); + return 1; + } + + if (r == 0) + { + /* End of file. Return the last record. */ + record = buf; + record_len = data_len; + at_eof = 1; + /* The empty string after a trailing delimiter is not considered + to be a record. */ + if (record_len == 0) + return 1; + return 0; + } + data_len += r; + next_record = buf; + } + + /* Find the next record delimiter. */ + errcode = tre_regnexec(&delim, next_record, data_len - (next_record - buf), + 1, pmatch, 0); + + + switch (errcode) + { + case REG_OK: + /* Record delimiter found, now we know how long the current + record is. */ + record = next_record; + record_len = pmatch[0].rm_so; + delim_len = next_delim_len; + + next_delim_len = pmatch[0].rm_eo - pmatch[0].rm_so; + next_record = next_record + pmatch[0].rm_eo; + return 0; + break; + + case REG_NOMATCH: + if (next_record == buf) + { + next_record = NULL; + continue; + } + + /* Move the data to start of the buffer and read more + data. */ + memmove(buf, next_record, buf + data_len - next_record); + data_len = buf + data_len - next_record; + next_record = NULL; + continue; + break; + + case REG_ESPACE: + fprintf(stderr, "%s: %s\n", program_name, _("Out of memory")); + exit(2); + break; + + default: + assert(0); + break; + } + } +} + + +static int +tre_agrep_handle_file(const char *filename) +{ + int fd; + int count = 0; + int recnum = 0; + + /* Allocate the initial buffer. */ + if (buf == NULL) + { + buf = malloc(INITIAL_BUF_SIZE); + if (buf == NULL) + { + fprintf(stderr, "%s: %s\n", program_name, _("Out of memory")); + exit(2); + } + buf_size = INITIAL_BUF_SIZE; + } + + /* Reset read buffer state. */ + next_record = NULL; + data_len = 0; + + if (!filename || strcmp(filename, "-") == 0) + { + if (best_match) + { + fprintf(stderr, "%s: %s\n", program_name, + _("Cannot use -B when reading from standard input.")); + return 2; + } + fd = 0; + filename = _("(standard input)"); + } + else + { + fd = open(filename, O_RDONLY); + } + + if (fd < 0) + { + fprintf(stderr, "%s: %s: %s\n", program_name, filename, strerror(errno)); + return 1; + } + + + /* Go through all records and output the matching ones, or the non-matching + ones if `invert_match' is true. */ + at_eof = 0; + while (!tre_agrep_get_next_record(fd, filename)) + { + int errcode; + regamatch_t match; + regmatch_t pmatch[1]; + recnum++; + memset(&match, 0, sizeof(match)); + if (best_match) + match_params.max_cost = best_cost; + if (color_option || print_position) + { + match.pmatch = pmatch; + match.nmatch = 1; + } + + /* Stop searching for better matches if an exact match is found. */ + if (best_match == 1 && best_cost == 0) + break; + + /* See if the record matches. */ + errcode = tre_reganexec(&preg, record, record_len, &match, match_params, 0); + if ((!invert_match && errcode == REG_OK) + || (invert_match && errcode == REG_NOMATCH)) + { + if (be_silent) + exit(0); + + count++; + have_matches = 1; + if (best_match) + { + if (best_match == 1) + { + /* First best match pass. */ + if (match.cost < best_cost) + best_cost = match.cost; + continue; + } + /* Second best match pass. */ + if (match.cost > best_cost) + continue; + } + + if (list_files) + { + printf("%s\n", filename); + break; + } + else if (!count_matches) + { + if (print_filename) + printf("%s:", filename); + if (print_recnum) + printf("%d:", recnum); + if (print_cost) + printf("%d:", match.cost); + if (print_position) + printf("%d-%d:", + invert_match ? 0 : (int)pmatch[0].rm_so, + invert_match ? record_len : (int)pmatch[0].rm_eo); + + /* Adjust record boundaries so we print the delimiter + before or after the record. */ + if (delim_after) + { + record_len += next_delim_len; + } + else + { + record -= delim_len; + record_len += delim_len; + pmatch[0].rm_so += delim_len; + pmatch[0].rm_eo += delim_len; + } + + if (color_option && !invert_match) + { + printf("%.*s", (int)pmatch[0].rm_so, record); + printf("\33[%sm", highlight); + printf("%.*s", (int)(pmatch[0].rm_eo - pmatch[0].rm_so), + record + pmatch[0].rm_so); + fputs("\33[00m", stdout); + printf("%.*s", (int)(record_len - pmatch[0].rm_eo), + record + pmatch[0].rm_eo); + } + else + { + printf("%.*s", record_len, record); + } + } + } + } + + if (count_matches && !best_match && !be_silent) + { + if (print_filename) + printf("%s:", filename); + printf("%d\n", count); + } + + if (fd) + close(fd); + + return 0; +} + + + +int +main(int argc, char **argv) +{ + int c, errcode; + int comp_flags = REG_EXTENDED; + char *tmp_str; + char *regexp = NULL; + const char *delim_regexp = "\n"; + int word_regexp = 0; + int literal_string = 0; + int max_cost_set = 0; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + /* Get the program name without the path (for error messages etc). */ + program_name = argv[0]; + if (program_name) + { + tmp_str = strrchr(program_name, '/'); + if (tmp_str) + program_name = tmp_str + 1; + } + + /* Defaults. */ + print_filename = -1; + print_cost = 0; + be_silent = 0; + tre_regaparams_default(&match_params); + match_params.max_cost = 0; + + /* Parse command line options. */ + while (1) + { +#ifdef HAVE_GETOPT_LONG + c = getopt_long(argc, argv, short_options, long_options, NULL); +#else /* !HAVE_GETOPT_LONG */ + c = getopt(argc, argv, short_options); +#endif /* !HAVE_GETOPT_LONG */ + if (c == -1) + break; + + switch (c) + { + case 'c': + /* Count number of matching records. */ + count_matches = 1; + break; + case 'd': + /* Set record delimiter regexp. */ + delim_regexp = optarg; + if (delim_after == 1) + delim_after = 0; + break; + case 'e': + /* Regexp to use. */ + regexp = optarg; + break; + case 'h': + /* Don't prefix filename on output if there are multiple files. */ + print_filename = 0; + break; + case 'i': + /* Ignore case. */ + comp_flags |= REG_ICASE; + break; + case 'k': + /* The pattern is a literal string. */ + literal_string = 1; + break; + case 'l': + /* Only print files that contain matches. */ + list_files = 1; + break; + case 'n': + /* Print record number of matching record. */ + print_recnum = 1; + break; + case 'q': + be_silent = 1; + break; + case 's': + /* Print match cost of matching record. */ + print_cost = 1; + break; + case 'v': + /* Select non-matching records. */ + invert_match = 1; + break; + case 'w': + /* Match only whole words. */ + word_regexp = 1; + break; + case 'y': + /* Compatibility option, does nothing. */ + break; + case 'B': + /* Select only the records which have the best match. */ + best_match = 1; + break; + case 'D': + /* Set the cost of a deletion. */ + match_params.cost_del = atoi(optarg); + break; + case 'E': + /* Set the maximum number of errors allowed for a record to match. */ + match_params.max_cost = atoi(optarg); + max_cost_set = 1; + break; + case 'H': + /* Always print filename prefix on output. */ + print_filename = 1; + break; + case 'I': + /* Set the cost of an insertion. */ + match_params.cost_ins = atoi(optarg); + break; + case 'M': + /* Print delimiters after matches instead of before. */ + delim_after = 2; + break; + case 'S': + /* Set the cost of a substitution. */ + match_params.cost_subst = atoi(optarg); + break; + case 'V': + { + /* Print version string and exit. */ + char *version; + tre_config(TRE_CONFIG_VERSION, &version); + printf("%s (TRE agrep) %s\n\n", program_name, version); + printf(_("\ +Copyright (c) 2001-2009 Ville Laurikari <vl@iki.fi>.\n")); + printf("\n"); + exit(0); + break; + } + case '?': + /* Ambiguous match or extraneous parameter. */ + break; + + case '-': + /* Emulate some long options on systems which don't + have getopt_long. */ + if (strcmp(optarg, "color") == 0 + || strcmp(optarg, "colour") == 0) + color_option = 1; + else if (strcmp(optarg, "show-position") == 0) + print_position = 1; + else if (strcmp(optarg, "help") == 0) + show_help = 1; + else + { + fprintf(stderr, _("%s: invalid option --%s\n"), + program_name, optarg); + exit(2); + } + break; + +#ifdef HAVE_GETOPT_LONG + case COLOR_OPTION: + color_option = 1; + break; + case SHOW_POSITION_OPTION: + print_position = 1; + break; +#endif /* HAVE_GETOPT_LONG */ + case 0: + /* Long options without corresponding short options. */ + break; + + default: + if (c >= '0' && c <= '9') + match_params.max_cost = c - '0'; + else + tre_agrep_usage(2); + max_cost_set = 1; + break; + } + } + + if (show_help) + tre_agrep_usage(0); + + if (color_option) + { + char *user_highlight = getenv("GREP_COLOR"); + if (user_highlight && *user_highlight != '\0') + highlight = user_highlight; + } + + /* Get the pattern. */ + if (regexp == NULL) + { + if (optind >= argc) + tre_agrep_usage(2); + regexp = argv[optind++]; + } + + /* If -k is specified, make the regexp literal. This uses + the \Q and \E extensions. If the string already contains + occurrences of \E, we need to handle them separately. This is a + pain, but can't really be avoided if we want to create a regexp + which works together with -w (see below). */ + if (literal_string) + { + char *next_pos = regexp; + char *new_re, *new_re_end; + int n = 0; + int len; + + next_pos = regexp; + while (next_pos) + { + next_pos = strstr(next_pos, "\\E"); + if (next_pos) + { + n++; + next_pos += 2; + } + } + + len = strlen(regexp); + new_re = malloc(len + 5 + n * 7); + if (!new_re) + { + fprintf(stderr, "%s: %s\n", program_name, _("Out of memory")); + return 2; + } + + next_pos = regexp; + new_re_end = new_re; + strcpy(new_re_end, "\\Q"); + new_re_end += 2; + while (next_pos) + { + char *start = next_pos; + next_pos = strstr(next_pos, "\\E"); + if (next_pos) + { + strncpy(new_re_end, start, next_pos - start); + new_re_end += next_pos - start; + strcpy(new_re_end, "\\E\\\\E\\Q"); + new_re_end += 7; + next_pos += 2; + } + else + { + strcpy(new_re_end, start); + new_re_end += strlen(start); + } + } + strcpy(new_re_end, "\\E"); + regexp = new_re; + } + + /* If -w is specified, prepend beginning-of-word and end-of-word + assertions to the regexp before compiling. */ + if (word_regexp) + { + char *tmp = regexp; + int len = strlen(tmp); + regexp = malloc(len + 7); + if (regexp == NULL) + { + fprintf(stderr, "%s: %s\n", program_name, _("Out of memory")); + return 2; + } + strcpy(regexp, "\\<("); + strcpy(regexp + 3, tmp); + strcpy(regexp + len + 3, ")\\>"); + } + + /* Compile the pattern. */ + errcode = tre_regcomp(&preg, regexp, comp_flags); + if (errcode) + { + char errbuf[256]; + tre_regerror(errcode, &preg, errbuf, sizeof(errbuf)); + fprintf(stderr, "%s: %s: %s\n", + program_name, _("Error in search pattern"), errbuf); + return 2; + } + + /* Compile the record delimiter pattern. */ + errcode = tre_regcomp(&delim, delim_regexp, REG_EXTENDED | REG_NEWLINE); + if (errcode) + { + char errbuf[256]; + tre_regerror(errcode, &preg, errbuf, sizeof(errbuf)); + fprintf(stderr, "%s: %s: %s\n", + program_name, _("Error in record delimiter pattern"), errbuf); + return 2; + } + + if (tre_regexec(&delim, "", 0, NULL, 0) == REG_OK) + { + fprintf(stderr, "%s: %s\n", program_name, + _("Record delimiter pattern must not match an empty string")); + return 2; + } + + /* The rest of the arguments are file(s) to match. */ + + /* If -h or -H were not specified, print filenames if there are more + than one files specified. */ + if (print_filename == -1) + { + if (argc - optind <= 1) + print_filename = 0; + else + print_filename = 1; + } + + if (optind >= argc) + { + /* There are no files specified, read from stdin. */ + tre_agrep_handle_file(NULL); + } + else if (best_match) + { + int first_ind = optind; + + /* Best match mode. Set up the limits first. */ + if (!max_cost_set) + match_params.max_cost = INT_MAX; + best_cost = INT_MAX; + + /* Scan all files once without outputting anything, searching + for the best matches. */ + while (optind < argc) + tre_agrep_handle_file(argv[optind++]); + + /* If there were no matches, bail out now. */ + if (best_cost == INT_MAX) + return 1; + + /* Otherwise, rescan the files with max_cost set to the cost + of the best match found previously, this time outputting + the matches. */ + match_params.max_cost = best_cost; + best_match = 2; + optind = first_ind; + while (optind < argc) + tre_agrep_handle_file(argv[optind++]); + } + else + { + /* Normal mode. */ + while (optind < argc) + tre_agrep_handle_file(argv[optind++]); + } + + return have_matches == 0; +} |