summaryrefslogtreecommitdiff
path: root/kwset.h
diff options
context:
space:
mode:
authorFredrik Kuivinen <frekui@gmail.com>2011-08-20 22:41:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-08-21 05:30:46 (GMT)
commit05f3dbba67ac15952e1bf005ee9fd8be3428831f (patch)
tree89d6830ba2ce3ce31c3a4942fd8ddd60d425aea0 /kwset.h
parente831171d67469f3942c56433e3cd3c98fca15e72 (diff)
downloadgit-05f3dbba67ac15952e1bf005ee9fd8be3428831f.zip
git-05f3dbba67ac15952e1bf005ee9fd8be3428831f.tar.gz
git-05f3dbba67ac15952e1bf005ee9fd8be3428831f.tar.bz2
Add string search routines from GNU grep
kwset.c and kwset.h have been copied unmodified from commit e7ac713d^ in the GNU grep git repository (this is the last commit in the repository licensed under GPLv2). Signed-off-by: Fredrik Kuivinen <frekui@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'kwset.h')
-rw-r--r--kwset.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/kwset.h b/kwset.h
new file mode 100644
index 0000000..ab530b3
--- /dev/null
+++ b/kwset.h
@@ -0,0 +1,56 @@
+/* kwset.h - header declaring the keyword set library.
+ Copyright (C) 1989, 1998, 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., 51 Franklin Street - Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+/* Written August 1989 by Mike Haertel.
+ The author may be reached (Email) at the address mike@ai.mit.edu,
+ or (US mail) as Mike Haertel c/o Free Software Foundation. */
+
+struct kwsmatch
+{
+ int index; /* Index number of matching keyword. */
+ size_t offset[1]; /* Offset of each submatch. */
+ size_t size[1]; /* Length of each submatch. */
+};
+
+typedef ptr_t kwset_t;
+
+/* Return an opaque pointer to a newly allocated keyword set, or NULL
+ if enough memory cannot be obtained. The argument if non-NULL
+ specifies a table of character translations to be applied to all
+ pattern and search text. */
+extern kwset_t kwsalloc PARAMS((char const *));
+
+/* Incrementally extend the keyword set to include the given string.
+ Return NULL for success, or an error message. Remember an index
+ number for each keyword included in the set. */
+extern const char *kwsincr PARAMS((kwset_t, char const *, size_t));
+
+/* When the keyword set has been completely built, prepare it for
+ use. Return NULL for success, or an error message. */
+extern const char *kwsprep PARAMS((kwset_t));
+
+/* Search through the given buffer for a member of the keyword set.
+ Return a pointer to the leftmost longest match found, or NULL if
+ no match is found. If foundlen is non-NULL, store the length of
+ the matching substring in the integer it points to. Similarly,
+ if foundindex is non-NULL, store the index of the particular
+ keyword found therein. */
+extern size_t kwsexec PARAMS((kwset_t, char const *, size_t, struct kwsmatch *));
+
+/* Deallocate the given keyword set and all its associated storage. */
+extern void kwsfree PARAMS((kwset_t));