* Improved detection of the locale on MacOS X.
* The gettext autoconf macros now require autoconf 2.50 or newer.
+* msggrep is much faster now.
\f
Version 0.14 - January 2004
+2005-01-08 Bruno Haible <bruno@clisp.org>
+
+ * libgrep: New subdirectory.
+ * configure.ac: Invoke gt_LIBGREP. Declare libgrep/Makefile.am.
+ * Makefile.am (SUBDIRS): Add libgrep.
+ (config.h_vms, config.h.msvc): Define HAVE_DECL_STRDUP, HAVE_MEMCHR,
+ restrict.
+ * Makefile.msvc: Recurse into libgrep as well.
+ * Makefile.vms: Likewise.
+
2005-01-06 Bruno Haible <bruno@clisp.org>
* configure.ac: Invoke gl_STRCASE. Don't test for strcasecmp and
AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies
ACLOCAL_AMFLAGS = -I m4 -I ../gettext-runtime/m4 -I ../autoconf-lib-link/m4 -I ../config/m4
-SUBDIRS = doc intl lib libuniname src po projects misc man m4 tests examples
+SUBDIRS = doc intl lib libgrep libuniname src po projects misc man m4 tests examples
EXTRA_DIST = misc/DISCLAIM
-e 's/#undef HAVE_BTOWC$$/#define HAVE_BTOWC 1/' \
-e 's/#undef HAVE_CHOWN$$/#define HAVE_CHOWN 1/' \
-e 's/#undef HAVE_DECL_GETENV$$/#define HAVE_DECL_GETENV 1/' \
+ -e 's/#undef HAVE_DECL_STRDUP$$/#define HAVE_DECL_STRDUP 1/' \
-e 's/#undef HAVE_DECL_WCWIDTH$$/#define HAVE_DECL_WCWIDTH 1/' \
-e 's/#undef HAVE_DIRENT_H$$/#define HAVE_DIRENT_H 1/' \
-e 's/#undef HAVE_DLFCN_H$$/#define HAVE_DLFCN_H 1/' \
-e 's/#undef HAVE_MBRTOWC$$/#define HAVE_MBRTOWC 1/' \
-e 's/#undef HAVE_MBSINIT$$/#define HAVE_MBSINIT 1/' \
-e 's/#undef HAVE_MBSTATE_T$$/#define HAVE_MBSTATE_T 1/' \
+ -e 's/#undef HAVE_MEMCHR$$/#define HAVE_MEMCHR 1/' \
-e 's/#undef HAVE_MEMMOVE$$/#define HAVE_MEMMOVE 1/' \
-e 's/#undef HAVE_MEMORY_H$$/#define HAVE_MEMORY_H 1/' \
-e 's/#undef HAVE_MEMSET$$/#define HAVE_MEMSET 1/' \
-e 's/#undef fnmatch$$/#define fnmatch rpl_fnmatch/' \
-e 's/#undef getline$$/#define getline rpl_getline/' \
-e 's/#undef realpath$$/#define realpath rpl_realpath/' \
+ -e 's/#undef restrict$$/#define restrict/' \
-e 's/#undef uintmax_t$$/#define uintmax_t unsigned long long/' \
-e 's/#undef PACKAGE$$/#define PACKAGE "gettext-tools"/' \
-e 's/#undef VERSION$$/#define VERSION "$(VERSION)"/' \
-e 's/#undef HAVE_ALLOCA$$/#define HAVE_ALLOCA 1/' \
-e 's/#undef HAVE_BTOWC$$/#define HAVE_BTOWC 1/' \
-e 's/#undef HAVE_DECL_GETENV$$/#define HAVE_DECL_GETENV 1/' \
+ -e 's/#undef HAVE_DECL_STRDUP$$/#define HAVE_DECL_STRDUP 1/' \
-e 's/#undef HAVE_DECL_STRERROR$$/#define HAVE_DECL_STRERROR 1/' \
-e 's/#undef HAVE_DECL_WCWIDTH$$/#define HAVE_DECL_WCWIDTH 0/' \
-e 's/#undef HAVE_DECL__SNPRINTF$$/#define HAVE_DECL__SNPRINTF 1/' \
-e 's/#undef HAVE_LIMITS_H$$/#define HAVE_LIMITS_H 1/' \
-e 's/#undef HAVE_LOCALE_H$$/#define HAVE_LOCALE_H 1/' \
-e 's/#undef HAVE_LONG_FILE_NAMES$$/#define HAVE_LONG_FILE_NAMES 1/' \
+ -e 's/#undef HAVE_MEMCHR$$/#define HAVE_MEMCHR 1/' \
-e 's/#undef HAVE_MEMMOVE$$/#define HAVE_MEMMOVE 1/' \
-e 's/#undef HAVE_MEMSET$$/#define HAVE_MEMSET 1/' \
-e 's/#undef HAVE_PTRDIFF_T$$/#define HAVE_PTRDIFF_T 1/' \
-e 's/#undef inline$$/#define inline __inline/' \
-e 's/#undef mode_t$$/#define mode_t int/' \
-e 's/#undef pid_t$$/#define pid_t int/' \
+ -e 's/#undef restrict$$/#define restrict/' \
-e 's/#undef ssize_t$$/#define ssize_t int/' \
-e 's/#undef uintmax_t$$/#define uintmax_t unsigned long/' \
-e 's/#undef PACKAGE$$/#define PACKAGE "gettext-tools"/' \
cd lib
$(MAKE) -f Makefile.msvc all
cd ..
+ cd libgrep
+ $(MAKE) -f Makefile.msvc all
+ cd ..
cd libuniname
$(MAKE) -f Makefile.msvc all
cd ..
cd lib
$(MAKE) -f Makefile.msvc install
cd ..
+ cd libgrep
+ $(MAKE) -f Makefile.msvc install
+ cd ..
cd libuniname
$(MAKE) -f Makefile.msvc install
cd ..
cd lib
$(MAKE) -f Makefile.msvc installdirs
cd ..
+ cd libgrep
+ $(MAKE) -f Makefile.msvc installdirs
+ cd ..
cd libuniname
$(MAKE) -f Makefile.msvc installdirs
cd ..
cd lib
$(MAKE) -f Makefile.msvc uninstall
cd ..
+ cd libgrep
+ $(MAKE) -f Makefile.msvc uninstall
+ cd ..
cd libuniname
$(MAKE) -f Makefile.msvc uninstall
cd ..
cd lib
$(MAKE) -f Makefile.msvc check
cd ..
+ cd libgrep
+ $(MAKE) -f Makefile.msvc check
+ cd ..
cd libuniname
$(MAKE) -f Makefile.msvc check
cd ..
cd lib
$(MAKE) -f Makefile.msvc mostlyclean
cd ..
+ cd libgrep
+ $(MAKE) -f Makefile.msvc mostlyclean
+ cd ..
cd libuniname
$(MAKE) -f Makefile.msvc mostlyclean
cd ..
cd lib
$(MAKE) -f Makefile.msvc clean
cd ..
+ cd libgrep
+ $(MAKE) -f Makefile.msvc clean
+ cd ..
cd libuniname
$(MAKE) -f Makefile.msvc clean
cd ..
cd lib
$(MAKE) -f Makefile.msvc distclean
cd ..
+ cd libgrep
+ $(MAKE) -f Makefile.msvc distclean
+ cd ..
cd libuniname
$(MAKE) -f Makefile.msvc distclean
cd ..
cd lib
$(MAKE) -f Makefile.msvc maintainer-clean
cd ..
+ cd libgrep
+ $(MAKE) -f Makefile.msvc maintainer-clean
+ cd ..
cd libuniname
$(MAKE) -f Makefile.msvc maintainer-clean
cd ..
set default [.lib]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms all
set default [-]
+ set default [.libgrep]
+ $(MMS) $(MMSQUALIFIERS) /description=Makefile.vms all
+ set default [-]
set default [.libuniname]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms all
set default [-]
set default [.lib]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms install
set default [-]
+ set default [.libgrep]
+ $(MMS) $(MMSQUALIFIERS) /description=Makefile.vms install
+ set default [-]
set default [.libuniname]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms install
set default [-]
set default [.lib]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms installdirs
set default [-]
+ set default [.libgrep]
+ $(MMS) $(MMSQUALIFIERS) /description=Makefile.vms installdirs
+ set default [-]
set default [.libuniname]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms installdirs
set default [-]
set default [.lib]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms uninstall
set default [-]
+ set default [.libgrep]
+ $(MMS) $(MMSQUALIFIERS) /description=Makefile.vms uninstall
+ set default [-]
set default [.libuniname]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms uninstall
set default [-]
set default [.lib]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms check
set default [-]
+ set default [.libgrep]
+ $(MMS) $(MMSQUALIFIERS) /description=Makefile.vms check
+ set default [-]
set default [.libuniname]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms check
set default [-]
set default [.lib]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms mostlyclean
set default [-]
+ set default [.libgrep]
+ $(MMS) $(MMSQUALIFIERS) /description=Makefile.vms mostlyclean
+ set default [-]
set default [.libuniname]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms mostlyclean
set default [-]
set default [.lib]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms clean
set default [-]
+ set default [.libgrep]
+ $(MMS) $(MMSQUALIFIERS) /description=Makefile.vms clean
+ set default [-]
set default [.libuniname]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms clean
set default [-]
set default [.lib]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms distclean
set default [-]
+ set default [.libgrep]
+ $(MMS) $(MMSQUALIFIERS) /description=Makefile.vms distclean
+ set default [-]
set default [.libuniname]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms distclean
set default [-]
set default [.lib]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms maintainer-clean
set default [-]
+ set default [.libgrep]
+ $(MMS) $(MMSQUALIFIERS) /description=Makefile.vms maintainer-clean
+ set default [-]
set default [.libuniname]
$(MMS) $(MMSQUALIFIERS) /description=Makefile.vms maintainer-clean
set default [-]
gl_CANONICALIZE
gt_SETLOCALE
gl_XSIZE
+gt_LIBGREP
gt_PREREQ_HOSTNAME
AC_CONFIG_FILES([lib/javacomp.sh lib/javaexec.sh])
AC_CONFIG_FILES([lib/csharpcomp.sh lib/csharpexec.sh])
+AC_CONFIG_FILES([libgrep/Makefile],
+ [FIX_MAKEFILE_COMPILE])
+
AC_CONFIG_FILES([libuniname/Makefile],
[FIX_MAKEFILE_COMPILE])
+2005-01-08 Bruno Haible <bruno@clisp.org>
+
+ * libgrep.m4: New file.
+ * hard-locale.m4: New file, from gnulib.
+ * memchr.m4: New file, from gnulib.
+ * regex.m4: New file, from gnulib.
+ * restrict.m4: New file, from gnulib.
+ * strdup.m4: New file, from gnulib.
+
2005-01-06 Bruno Haible <bruno@clisp.org>
* strcase.m4: New file, from gnulib.
getline.m4 \
getndelim2.m4 \
getopt.m4 \
+hard-locale.m4 \
hostname.m4 \
javacomp.m4 \
javaexec.m4 \
mbrtowc.m4 \
mbstate_t.m4 \
mbswidth.m4 \
+memchr.m4 \
mkdtemp.m4 \
onceonly.m4 \
pathmax.m4 \
quote.m4 \
quotearg.m4 \
readlink.m4 \
+regex.m4 \
relocatable.m4 \
+restrict.m4 \
setenv.m4 \
setlocale.m4 \
sig_atomic_t.m4 \
stdbool.m4 \
stpncpy.m4 \
strcase.m4 \
+strdup.m4 \
strerror.m4 \
strerror_r.m4 \
tmpdir.m4 \
+2005-01-08 Bruno Haible <bruno@clisp.org>
+
+ * msggrep.c (grep_args, grep_path, grep_argv): Remove variables.
+ (struct grep_task): New type.
+ (grep_task): New variable.
+ (main): Initialize grep_task instead of grep_args. Change processing
+ of options 'E', 'F' to set a matcher, of 'e', 'f' to append to the
+ pattern string, and of 'i' to set a boolean. Compile the patterns.
+ (is_string_selected): Execute a compiled pattern instead of calling
+ the grep program.
+ (is_message_selected): Update.
+ * Makefile.am (AM_CPPFLAGS): Add -I option for libgrep.
+ (LIBGREP): New variable.
+ (msggrep_LDADD): Add $(LIBGREP).
+ * Makefile.msvc (INCLUDES): Add libgrep directory.
+ (msggrep.exe): Link with libgrep.
+ * Makefile.vms (INCLUDES): Add libgrep directory.
+ (msggrep.exe): Link with libgrep.
+
2005-01-09 Bruno Haible <bruno@clisp.org>
* msgl-ascii.h (is_ascii_msgdomain_list): New declaration.
## Makefile for the gettext-tools/src subdirectory of GNU gettext
-## Copyright (C) 1995-1998, 2000-2004 Free Software Foundation, Inc.
+## Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
AM_CPPFLAGS = \
-I. -I$(srcdir) \
-I.. \
+ -I$(top_srcdir)/libgrep \
-I$(top_srcdir)/libuniname \
-I../lib -I$(top_srcdir)/lib \
-I../intl -I$(top_srcdir)/../gettext-runtime/intl
LTV_REVISION=0
LTV_AGE=1
+# msggrep needs pattern matching.
+LIBGREP = ../libgrep/libgrep.a
+
# x-python needs table of Unicode character names.
LIBUNINAME = ../libuniname/libuniname.a
msgen_LDADD = libgettextsrc.la
msgexec_LDADD = libgettextsrc.la
msgfilter_LDADD = libgettextsrc.la
-msggrep_LDADD = libgettextsrc.la
+msggrep_LDADD = $(LIBGREP) libgettextsrc.la
msginit_LDADD = ../intl/localename.@INTL_LIBTOOL_SUFFIX_PREFIX@o \
@INTL_MACOSX_LDFLAGS@ libgettextsrc.la
msguniq_LDADD = libgettextsrc.la
CFLAGS = $(MFLAGS) $(WARN_CFLAGS) $(OPTIMFLAGS) -DHAVE_CONFIG_H -DLOCALEDIR=\"$(IIlocaledir)\" -DLOCALE_ALIAS_PATH=\"$(IIaliaspath)\" -DGETTEXTJAR=\"$(IIjardir)\\gettext.jar\" -DLIBDIR=\"$(IIlibdir)\" -DGETTEXTDATADIR=\"$(IIpkgdatadir)\" -DPROJECTSDIR=\"$(IIprojectsdir)\"
-INCLUDES = -I. -I.. -I..\libuniname -I..\lib -I..\intl -I..\..\gettext-runtime\intl -I..\windows -I$(includedir)
+INCLUDES = -I. -I.. -I..\libgrep -I..\libuniname -I..\lib -I..\intl -I..\..\gettext-runtime\intl -I..\windows -I$(includedir)
AR = lib
AR_FLAGS = /out:
$(CC) $(MFLAGS) $(DEBUGFLAGS) $(msgfilter_OBJECTS) gettextsrc.lib ..\lib\gettextlib.lib ..\intl\intl.lib $(libdir)\iconv.lib $(LDADD) -Femsgfilter.exe
msggrep.exe : $(msggrep_OBJECTS)
- $(CC) $(MFLAGS) $(DEBUGFLAGS) $(msggrep_OBJECTS) gettextsrc.lib ..\lib\gettextlib.lib ..\intl\intl.lib $(libdir)\iconv.lib $(LDADD) -Femsggrep.exe
+ $(CC) $(MFLAGS) $(DEBUGFLAGS) $(msggrep_OBJECTS) ..\libgrep\grep.lib gettextsrc.lib ..\lib\gettextlib.lib ..\intl\intl.lib $(libdir)\iconv.lib $(LDADD) -Femsggrep.exe
msginit.exe : $(msginit_OBJECTS)
$(CC) $(MFLAGS) $(DEBUGFLAGS) $(msginit_OBJECTS) ..\intl\localename.obj gettextsrc.lib ..\lib\gettextlib.lib ..\intl\intl.lib $(libdir)\iconv.lib $(LDADD) -Femsginit.exe
CFLAGS = $(ABIFLAGS) $(WARN_CFLAGS) $(OPTIMFLAGS)
DEFS = "VMS=1","HAVE_CONFIG_H=1","LOCALEDIR=""$(localedir)]""","GETTEXTJAR=""$(jardir)]gettext.jar""","LIBDIR=""$(libdir)]""","GETTEXTDATADIR=""$(pkgdatadir)]""","PROJECTSDIR=""$(projectsdir)"""
-INCLUDES = /include=([],[-],[-.libuniname],[-.lib],[-.intl],[-.-.gettext-runtime.intl])
+INCLUDES = /include=([],[-],[-.libgrep],[-.libuniname],[-.lib],[-.intl],[-.-.gettext-runtime.intl])
LDADD = libiconv.opt/opt,[-.-.vms]link_options.opt
LDADD_EXPAT = sys$library:expat/lib
link /executable=msgfilter.exe $(msgfilter_OBJECTS),gettextsrc.olb/lib,[-.lib]gettextlib.olb/lib,[-.intl]intl.olb/lib,$(LDADD)
msggrep.exe : $(msggrep_OBJECTS),libiconv.opt
- link /executable=msggrep.exe $(msggrep_OBJECTS),gettextsrc.olb/lib,[-.lib]gettextlib.olb/lib,[-.intl]intl.olb/lib,$(LDADD)
+ link /executable=msggrep.exe $(msggrep_OBJECTS),[-.libgrep]grep.olb/lib,gettextsrc.olb/lib,[-.lib]gettextlib.olb/lib,[-.intl]intl.olb/lib,$(LDADD)
msginit.exe : $(msginit_OBJECTS),libiconv.opt
link /executable=msginit.exe $(msginit_OBJECTS),[-.intl]localename.obj,gettextsrc.olb/lib,[-.lib]gettextlib.olb/lib,[-.intl]intl.olb/lib,$(LDADD)
#endif
#include <alloca.h>
+#include <assert.h>
#include <errno.h>
#include <getopt.h>
#include <limits.h>
#include "xalloc.h"
#include "xallocsa.h"
#include "exit.h"
-#include "full-write.h"
-#include "findprog.h"
-#include "pipe.h"
-#include "wait-process.h"
+#include "libgrep.h"
#include "gettext.h"
#define _(str) gettext (str)
/* Selected domain names. */
static string_list_ty *domain_names;
-/* Arguments to be passed to the grep subprocesses. */
-static string_list_ty *grep_args[3];
-
-/* Pathname of the grep program. */
-static const char *grep_path;
-
-/* Argument lists for the grep program. */
-static char **grep_argv[3];
+/* Task for each grep pass. */
+struct grep_task {
+ matcher_t *matcher;
+ size_t pattern_count;
+ char *patterns;
+ size_t patterns_size;
+ bool case_insensitive;
+ void *compiled_patterns;
+};
+static struct grep_task grep_task[3];
/* Long options. */
static const struct option long_options[] =
msgdomain_list_ty *result;
bool sort_by_filepos = false;
bool sort_by_msgid = false;
+ size_t i;
/* Set program name for messages. */
set_program_name (argv[0]);
grep_pass = -1;
location_files = string_list_alloc ();
domain_names = string_list_alloc ();
- grep_args[0] = string_list_alloc ();
- grep_args[1] = string_list_alloc ();
- grep_args[2] = string_list_alloc ();
+
+ for (i = 0; i < 3; i++)
+ {
+ struct grep_task *gt = &grep_task[i];
+
+ gt->matcher = &matcher_grep;
+ gt->pattern_count = 0;
+ gt->patterns = NULL;
+ gt->patterns_size = 0;
+ gt->case_insensitive = false;
+ }
while ((opt = getopt_long (argc, argv, "CD:e:Ef:FhiKM:N:o:pPTVw:",
long_options, NULL))
case 'e':
if (grep_pass < 0)
no_pass (opt);
- string_list_append (grep_args[grep_pass], "-e");
- string_list_append (grep_args[grep_pass], optarg);
+ {
+ struct grep_task *gt = &grep_task[grep_pass];
+ /* Append optarg and a newline to gt->patterns. */
+ size_t len = strlen (optarg);
+ gt->patterns =
+ (char *) xrealloc (gt->patterns, gt->patterns_size + len + 1);
+ memcpy (gt->patterns + gt->patterns_size, optarg, len);
+ gt->patterns_size += len;
+ *(gt->patterns + gt->patterns_size) = '\n';
+ gt->patterns_size += 1;
+ gt->pattern_count++;
+ }
break;
case 'E':
if (grep_pass < 0)
no_pass (opt);
- string_list_append (grep_args[grep_pass], "-E");
+ grep_task[grep_pass].matcher = &matcher_egrep;
break;
case 'f':
if (grep_pass < 0)
no_pass (opt);
- string_list_append (grep_args[grep_pass], "-f");
- string_list_append (grep_args[grep_pass], optarg);
+ {
+ struct grep_task *gt = &grep_task[grep_pass];
+ /* Append the contents of the specified file to gt->patterns. */
+ FILE *fp = fopen (optarg, "r");
+
+ if (fp == NULL)
+ error (EXIT_FAILURE, errno, _("\
+error while opening \"%s\" for reading"), optarg);
+
+ while (!feof (fp))
+ {
+ char buf[4096];
+ size_t count = fread (buf, 1, sizeof buf, fp);
+
+ if (count == 0)
+ {
+ if (ferror (fp))
+ error (EXIT_FAILURE, errno, _("\
+error while reading \"%s\""), optarg);
+ /* EOF reached. */
+ break;
+ }
+
+ gt->patterns =
+ (char *) xrealloc (gt->patterns, gt->patterns_size + count);
+ memcpy (gt->patterns + gt->patterns_size, buf, count);
+ gt->patterns_size += count;
+ }
+
+ /* Append a final newline if file ended in a non-newline. */
+ if (gt->patterns_size > 0
+ && *(gt->patterns + gt->patterns_size - 1) != '\n')
+ {
+ gt->patterns =
+ (char *) xrealloc (gt->patterns, gt->patterns_size + 1);
+ *(gt->patterns + gt->patterns_size) = '\n';
+ gt->patterns_size += 1;
+ }
+
+ fclose (fp);
+ gt->pattern_count++;
+ }
break;
case 'F':
if (grep_pass < 0)
no_pass (opt);
- string_list_append (grep_args[grep_pass], "-F");
+ grep_task[grep_pass].matcher = &matcher_fgrep;
break;
case 'h':
case 'i':
if (grep_pass < 0)
no_pass (opt);
- string_list_append (grep_args[grep_pass], "-i");
+ grep_task[grep_pass].case_insensitive = true;
break;
case 'K':
error (EXIT_FAILURE, 0, _("%s and %s are mutually exclusive"),
"--sort-output", "--sort-by-file");
+ /* Compile the patterns. */
+ for (grep_pass = 0; grep_pass < 3; grep_pass++)
+ {
+ struct grep_task *gt = &grep_task[grep_pass];
+
+ if (gt->pattern_count > 0)
+ {
+ if (gt->patterns_size > 0)
+ {
+ /* Strip trailing newline. */
+ assert (gt->patterns[gt->patterns_size - 1] == '\n');
+ gt->patterns_size--;
+ }
+ gt->compiled_patterns =
+ gt->matcher->compile (gt->patterns, gt->patterns_size,
+ gt->case_insensitive, false, false, '\n');
+ }
+ }
+
/* Read input file. */
result = read_po_file (input_file);
- if (grep_args[0]->nitems > 0
- || grep_args[1]->nitems > 0
- || grep_args[2]->nitems > 0)
+ if (grep_task[0].pattern_count > 0
+ || grep_task[1].pattern_count > 0
+ || grep_task[2].pattern_count > 0)
{
/* Warn if the current locale is not suitable for this PO file. */
compare_po_locale_charsets (result);
-
- /* Attempt to locate the 'grep' program.
- This is an optimization, to avoid that spawn/exec searches the PATH
- on every call. */
- grep_path = find_in_path ("grep");
-
- /* On Solaris, we need to use /usr/xpg4/bin/grep instead of
- /usr/bin/grep, because /usr/bin/grep doesn't understand the options
- -q and -e. */
-#if (defined (sun) || defined (__sun)) && defined (__SVR4)
- if ((strcmp (grep_path, "/usr/bin/grep") == 0
- || strcmp (grep_path, "/bin/grep") == 0)
- && access ("/usr/xpg4/bin/grep", X_OK) == 0)
- grep_path = "/usr/xpg4/bin/grep";
-#endif
}
- /* Build argument lists for the 'grep' program. */
- for (grep_pass = 0; grep_pass < 3; grep_pass++)
- if (grep_args[grep_pass]->nitems > 0)
- {
- string_list_ty *args = grep_args[grep_pass];
- size_t option_q;
- size_t i, j;
-
- /* We use "grep -q" because it is slightly more efficient than
- "grep". We pipe grep's output to /dev/null anyway. But
- SunOS4's grep program doesn't understand the -q option. */
-#if (defined (sun) || defined (__sun)) && !defined (__SVR4)
- option_q = 0;
-#else
- option_q = 1;
-#endif
-
- grep_argv[grep_pass] =
- (char **) xmalloc ((1 + option_q + args->nitems + 1)
- * sizeof (char *));
- grep_argv[grep_pass][0] = (char *) grep_path;
- j = 1;
- if (option_q)
- grep_argv[grep_pass][j++] = "-q";
- for (i = 0; i < args->nitems; i++)
- grep_argv[grep_pass][j++] = (char *) args->item[i];
- grep_argv[grep_pass][j] = NULL;
- }
-
/* Select the messages. */
result = process_msgdomain_list (result);
static bool
is_string_selected (int grep_pass, const char *str, size_t len)
{
- if (grep_args[grep_pass]->nitems > 0)
- {
- pid_t child;
- int fd[1];
- int exitstatus;
+ const struct grep_task *gt = &grep_task[grep_pass];
- /* Open a pipe to a grep subprocess. */
- child = create_pipe_out ("grep", grep_path, grep_argv[grep_pass],
- DEV_NULL, false, true, true, fd);
-
- if (full_write (fd[0], str, len) < len)
- error (EXIT_FAILURE, errno,
- _("write to grep subprocess failed"));
-
- close (fd[0]);
+ if (gt->pattern_count > 0)
+ {
+ size_t match_size;
+ size_t match_offset;
- /* Remove zombie process from process list, and retrieve exit status. */
- exitstatus = wait_subprocess (child, "grep", false, false, true, true);
- return (exitstatus == 0);
+ match_offset =
+ gt->matcher->execute (gt->compiled_patterns, str, len,
+ &match_size, false);
+ return (match_offset != (size_t) -1);
}
else
return 0;
}
/* Test translator comments using the --comment arguments. */
- if (grep_args[2]->nitems > 0
+ if (grep_task[2].pattern_count > 0
&& mp->comment != NULL && mp->comment->nitems > 0)
{
size_t length;
+2005-01-08 Bruno Haible <bruno@clisp.org>
+
+ * msggrep-4: Remove unportability notes.
+
2005-01-09 Bruno Haible <bruno@clisp.org>
* xgettext-8: New file.
# Test multiple -e and multiple -f options.
-# Note: This test fails on AIX 3 because grep, when called with both -e and
-# -f arguments, ignores the -e arguments. It is fixed on AIX 4.
-
-# Note: This test fails on SunOS 4 because grep doesn't have a -f option.
-
tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15