summaryrefslogtreecommitdiffstats
path: root/gettext-tools/libgrep
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2005-01-14 12:23:28 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:12:04 +0200
commit7930a02ede8b3999f8ce59134759a02a360240ed (patch)
tree6cd5b2567ca844ab64cb0e7e3e6a7ed7ac020454 /gettext-tools/libgrep
parentb7993e288c91eb1402b3f7b679ef138fb144369c (diff)
downloadexternal_gettext-7930a02ede8b3999f8ce59134759a02a360240ed.zip
external_gettext-7930a02ede8b3999f8ce59134759a02a360240ed.tar.gz
external_gettext-7930a02ede8b3999f8ce59134759a02a360240ed.tar.bz2
grep as a library.
Diffstat (limited to 'gettext-tools/libgrep')
-rw-r--r--gettext-tools/libgrep/ChangeLog22
-rw-r--r--gettext-tools/libgrep/Makefile.am55
-rw-r--r--gettext-tools/libgrep/Makefile.msvc119
-rw-r--r--gettext-tools/libgrep/Makefile.vms89
-rw-r--r--gettext-tools/libgrep/libgrep.h48
5 files changed, 333 insertions, 0 deletions
diff --git a/gettext-tools/libgrep/ChangeLog b/gettext-tools/libgrep/ChangeLog
new file mode 100644
index 0000000..60df7f0
--- /dev/null
+++ b/gettext-tools/libgrep/ChangeLog
@@ -0,0 +1,22 @@
+2005-01-08 Bruno Haible <bruno@clisp.org>
+
+ * libgrep.h: New file.
+ * kwset.h: From grep-2.5.1 with modifications.
+ * kwset.c: From grep-2.5.1 with modifications.
+ * dfa.h: From grep-2.5.1 with modifications.
+ * dfa.c: From grep-2.5.1 with modifications.
+ * m-common.h: New file.
+ * m-common.c: New file, with code from grep-2.5.1/src/search.c.
+ * m-fgrep.c: New file, with code from grep-2.5.1/src/search.c.
+ * m-regex.c: New file, with code from grep-2.5.1/src/search.c.
+ * hard-locale.h: New file, from gnulib.
+ * hard-locale.c: New file, from gnulib.
+ * memchr.c: New file, from gnulib.
+ * regex.h: New file, from gnulib.
+ * regex.c: New file, from gnulib.
+ * strdup.h: New file, from gnulib.
+ * strdup.c: New file, from gnulib.
+ * Makefile.am: New file.
+ * Makefile.msvc: New file.
+ * Makefile.vms: New file.
+
diff --git a/gettext-tools/libgrep/Makefile.am b/gettext-tools/libgrep/Makefile.am
new file mode 100644
index 0000000..48b19c7
--- /dev/null
+++ b/gettext-tools/libgrep/Makefile.am
@@ -0,0 +1,55 @@
+## Makefile for libgrep directory in GNU gettext package.
+## Copyright (C) 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
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+## Process this file with automake to produce Makefile.in.
+
+AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
+EXTRA_DIST =
+
+
+noinst_LIBRARIES = libgrep.a
+
+# Sources that are compiled on all platforms.
+
+libgrep_a_SOURCES = \
+ libgrep.h \
+ kwset.h kwset.c \
+ dfa.h dfa.c \
+ m-common.h m-common.c m-fgrep.c m-regex.c \
+ hard-locale.h hard-locale.c
+
+# Sources that are compiled only on platforms that lack the functions.
+
+LIBADD_SOURCE = \
+ memchr.c \
+ regex.h regex.c \
+ strdup.h strdup.c
+
+# How to build libgrep.a.
+libgrep_a_LIBADD = @LIBGREPOBJS@
+
+AM_CPPFLAGS = -I.. -I../lib -I$(top_srcdir)/lib
+
+
+# VMS support.
+
+EXTRA_DIST += Makefile.vms
+
+
+# Woe32 support.
+
+EXTRA_DIST += Makefile.msvc
diff --git a/gettext-tools/libgrep/Makefile.msvc b/gettext-tools/libgrep/Makefile.msvc
new file mode 100644
index 0000000..d7790bb
--- /dev/null
+++ b/gettext-tools/libgrep/Makefile.msvc
@@ -0,0 +1,119 @@
+# -*- Makefile -*- for gettext-tools/libgrep
+
+#### Start of system configuration section. ####
+
+# Flags that can be set on the nmake command line:
+# DLL=1 for compiling a .dll with a stub .lib (default is a static .lib)
+# Note that this works only with MFLAGS=-MD.
+# MFLAGS={-ML|-MT|-MD} for defining the compilation model
+# MFLAGS=-ML (the default) Single-threaded, statically linked - libc.lib
+# MFLAGS=-MT Multi-threaded, statically linked - libcmt.lib
+# MFLAGS=-MD Multi-threaded, dynamically linked - msvcrt.lib
+# DEBUG=1 for compiling with debugging information
+!if !defined(DLL)
+DLL=0
+!endif
+!if !defined(DEBUG)
+DEBUG=0
+!endif
+!if !defined(MFLAGS)
+!if !$(DLL)
+MFLAGS=
+!else
+MFLAGS=-MD
+!endif
+!endif
+
+# Programs used by "make":
+
+CC = cl
+
+# Set to -W3 if you want to see maximum amount of warnings, including stupid
+# ones. Set to -W1 to avoid warnings about signed/unsigned combinations.
+WARN_CFLAGS = -W1
+
+!if !$(DLL)
+PICFLAGS =
+!else
+# "-GD" (msvc5) optimizes for DLL.
+# mscv4 doesn't know about this flag and ignores it.
+PICFLAGS = -GD
+!endif
+
+!if $(DEBUG)
+OPTIMFLAGS = -Od -Z7
+!else
+# Some people prefer -O2 -G6 instead of -O1, but -O2 is not reliable in MSVC5.
+OPTIMFLAGS = -D_NDEBUG -O1
+!endif
+
+CFLAGS = $(MFLAGS) $(WARN_CFLAGS) $(OPTIMFLAGS) -DHAVE_CONFIG_H
+
+INCLUDES = -I.. -I..\lib -I..\windows
+
+AR = lib
+AR_FLAGS = /out:
+
+LN = copy
+RM = -del
+
+#### End of system configuration section. ####
+
+SHELL = /bin/sh
+
+OBJECTS = \
+ kwset.obj \
+ dfa.obj \
+ m-common.obj \
+ m-fgrep.obj \
+ m-regex.obj \
+ hard-locale.obj \
+ regex.obj
+
+all : grep.lib
+
+kwset.obj : kwset.c
+ $(CC) $(INCLUDES) $(CFLAGS) -c kwset.c
+
+dfa.obj : dfa.c
+ $(CC) $(INCLUDES) $(CFLAGS) -c dfa.c
+
+m-common.obj : m-common.c
+ $(CC) $(INCLUDES) $(CFLAGS) -c m-common.c
+
+m-fgrep.obj : m-fgrep.c
+ $(CC) $(INCLUDES) $(CFLAGS) -c m-fgrep.c
+
+m-regex.obj : m-regex.c
+ $(CC) $(INCLUDES) $(CFLAGS) -c m-regex.c
+
+hard-locale.obj : hard-locale.c
+ $(CC) $(INCLUDES) $(CFLAGS) -c hard-locale.c
+
+regex.obj : regex.c
+ $(CC) $(INCLUDES) $(CFLAGS) -c regex.c
+
+grep.lib : $(OBJECTS)
+ -$(RM) grep.lib
+ $(AR) $(AR_FLAGS)grep.lib $(OBJECTS)
+
+install : all
+
+installdirs :
+
+uninstall :
+
+check :
+
+mostlyclean : clean
+
+clean : force
+ $(RM) *.obj
+ $(RM) *.lib
+ $(RM) core
+
+distclean : clean
+
+maintainer-clean : distclean
+
+force :
diff --git a/gettext-tools/libgrep/Makefile.vms b/gettext-tools/libgrep/Makefile.vms
new file mode 100644
index 0000000..6996f25
--- /dev/null
+++ b/gettext-tools/libgrep/Makefile.vms
@@ -0,0 +1,89 @@
+# -*- Makefile -*- for gettext-tools/libgrep on VMS using the MMS utility
+
+#### Start of system configuration section. ####
+
+# Programs used by "make":
+
+CC = cc
+
+# These flags affect binary compatibility. GNU gettext does not need them,
+# but other packages do, and we need to be binary compatible with them.
+ABIFLAGS = /name=(as_is,short) /float=ieee
+
+WARN_CFLAGS = /warning
+
+OPTIMFLAGS = /optimize
+
+CFLAGS = $(ABIFLAGS) $(WARN_CFLAGS) $(OPTIMFLAGS)
+DEFS = "VMS=1","HAVE_CONFIG_H=1"
+
+INCLUDES = /include=([],[-],[-.lib])
+
+AR = library
+AR_FLAGS = /create
+
+LN = copy
+RM = delete
+
+#### End of system configuration section. ####
+
+OBJECTS = \
+ kwset.obj, \
+ dfa.obj, \
+ m-common.obj, \
+ m-fgrep.obj, \
+ m-regex.obj, \
+ hard-locale.obj, \
+ regex.obj
+
+all : grep.olb
+ write sys$output "Nothing else to be done for 'all'."
+
+kwset.obj : kwset.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) kwset.c
+
+dfa.obj : dfa.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) dfa.c
+
+m-common.obj : m-common.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) m-common.c
+
+m-fgrep.obj : m-fgrep.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) m-fgrep.c
+
+m-regex.obj : m-regex.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) m-regex.c
+
+hard-locale.obj : hard-locale.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) hard-locale.c
+
+regex.obj : regex.c
+ $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) regex.c
+
+grep.olb : $(OBJECTS)
+ $(AR) $(AR_FLAGS) grep.olb $(OBJECTS)
+
+install : all
+ write sys$output "Nothing else to be done for 'install'."
+
+installdirs :
+ write sys$output "Nothing to be done for 'installdirs'."
+
+uninstall :
+ write sys$output "Nothing to be done for 'uninstall'."
+
+check :
+ write sys$output "Nothing to be done for 'check'."
+
+mostlyclean : clean
+ write sys$output "Nothing else to be done for 'mostlyclean'."
+
+clean :
+ $(RM) *.obj;*
+ $(RM) *.olb;*
+
+distclean : clean
+ write sys$output "Nothing else to be done for 'distclean'."
+
+maintainer-clean : distclean
+ write sys$output "Nothing else to be done for 'maintainer-clean'."
diff --git a/gettext-tools/libgrep/libgrep.h b/gettext-tools/libgrep/libgrep.h
new file mode 100644
index 0000000..7220e6f
--- /dev/null
+++ b/gettext-tools/libgrep/libgrep.h
@@ -0,0 +1,48 @@
+/* Search for patterns in strings or files.
+ Copyright (C) 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef _LIBGREP_H
+#define _LIBGREP_H
+
+#include <stdbool.h>
+#include <stddef.h>
+
+/* A pattern matcher. */
+typedef struct {
+
+ /* Compile a pattern and return the compiled pattern. */
+ void * (*compile) (const char *pattern, size_t pattern_size,
+ bool match_icase, bool match_words, bool match_lines,
+ char eolbyte);
+
+ /* Execute a search. */
+ size_t (*execute) (const void *compiled_pattern,
+ const char *buf, size_t buf_size,
+ size_t *match_size, bool exact);
+
+ /* Free a compiled pattern. */
+ void (*free) (void *compiled_pattern);
+
+} matcher_t;
+
+/* The built-in pattern matchers. */
+extern matcher_t matcher_grep; /* POSIX Basic Regular Expressions */
+extern matcher_t matcher_egrep; /* POSIX Extended Regular Expressions */
+extern matcher_t matcher_fgrep; /* Fixed String search */
+extern matcher_t matcher_awk; /* AWK Regular Expressions */
+
+#endif /* _LIBGREP_H */