diff options
author | Bruno Haible <bruno@clisp.org> | 2005-01-14 12:23:28 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2009-06-23 12:12:04 +0200 |
commit | 7930a02ede8b3999f8ce59134759a02a360240ed (patch) | |
tree | 6cd5b2567ca844ab64cb0e7e3e6a7ed7ac020454 /gettext-tools | |
parent | b7993e288c91eb1402b3f7b679ef138fb144369c (diff) | |
download | external_gettext-7930a02ede8b3999f8ce59134759a02a360240ed.zip external_gettext-7930a02ede8b3999f8ce59134759a02a360240ed.tar.gz external_gettext-7930a02ede8b3999f8ce59134759a02a360240ed.tar.bz2 |
grep as a library.
Diffstat (limited to 'gettext-tools')
-rw-r--r-- | gettext-tools/libgrep/ChangeLog | 22 | ||||
-rw-r--r-- | gettext-tools/libgrep/Makefile.am | 55 | ||||
-rw-r--r-- | gettext-tools/libgrep/Makefile.msvc | 119 | ||||
-rw-r--r-- | gettext-tools/libgrep/Makefile.vms | 89 | ||||
-rw-r--r-- | gettext-tools/libgrep/libgrep.h | 48 | ||||
-rw-r--r-- | gettext-tools/m4/libgrep.m4 | 32 |
6 files changed, 365 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 */ diff --git a/gettext-tools/m4/libgrep.m4 b/gettext-tools/m4/libgrep.m4 new file mode 100644 index 0000000..e82bc63 --- /dev/null +++ b/gettext-tools/m4/libgrep.m4 @@ -0,0 +1,32 @@ +# libgrep.m4 serial 1 (gettext-0.14.2) +dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +AC_DEFUN([gt_LIBGREP], +[ + AC_REQUIRE([AM_STDBOOL_H]) + AC_REQUIRE([gl_FUNC_MBRTOWC]) + m4_pushdef([AC_LIBOBJ], m4_defn([gt_LIBGREP_OBJ])) + m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gt_LIBGREP_REPLACE_FUNCS])) + gl_HARD_LOCALE + gl_FUNC_MEMCHR + gl_FUNC_STRDUP + gl_INCLUDED_REGEX([libgrep/regex.c]) + m4_popdef([AC_REPLACE_FUNCS]) + m4_popdef([AC_LIBOBJ]) + AC_SUBST([LIBGREPOBJS]) +]) + +# Like AC_LIBOBJ, except that the module name goes into LIBGREPOBJS +# instead of into LIBOBJS. +AC_DEFUN([gt_LIBGREP_OBJ], + [LIBGREPOBJS="$LIBGREPOBJS $1.$ac_objext"]) + +# Like AC_REPLACE_FUNCS, except that the module name goes into LIBGREPOBJS +# instead of into LIBOBJS. +AC_DEFUN([gt_LIBGREP_REPLACE_FUNCS], + [AC_CHECK_FUNCS([$1], , [gt_LIBGREP_OBJ($ac_func)])]) |