projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reformat: delete trailing whitespace
[idzebra-moved-to-github.git]
/
dfa
/
grepper.c
diff --git
a/dfa/grepper.c
b/dfa/grepper.c
index
d8830a1
..
d078430
100644
(file)
--- a/
dfa/grepper.c
+++ b/
dfa/grepper.c
@@
-1,8
+1,5
@@
-/* $Id: grepper.c,v 1.10 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
- Index Data Aps
-
-This file is part of the Zebra server.
+/* This file is part of the Zebra server.
+ Copyright (C) 1994-2011 Index Data
Zebra 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
Zebra 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
@@
-15,19
+12,23
@@
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
for more details.
You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
*/
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
+#include <yaz/yaz-util.h>
#include <dfa.h>
#include "imalloc.h"
#include <dfa.h>
#include "imalloc.h"
@@
-45,7
+46,7
@@
typedef struct {
#define INFBUF_SIZE 16384
#define INFBUF_SIZE 16384
-#define INLINE
+#define INLINE
static INLINE void set_bit (MatchContext *mc, MatchWord *m, int ch, int state)
{
static INLINE void set_bit (MatchContext *mc, MatchWord *m, int ch, int state)
{
@@
-81,7
+82,7
@@
static MatchContext *mk_MatchContext (struct DFA *dfa, int range)
mc->n = (dfa->no_states+WORD_BITS) / WORD_BITS;
mc->range = range;
mc->Sc = icalloc (sizeof(*mc->Sc) * 256 * mc->n);
mc->n = (dfa->no_states+WORD_BITS) / WORD_BITS;
mc->range = range;
mc->Sc = icalloc (sizeof(*mc->Sc) * 256 * mc->n);
-
+
for (i=0; i<dfa->no_states; i++)
{
int j;
for (i=0; i<dfa->no_states; i++)
{
int j;
@@
-93,7
+94,7
@@
static MatchContext *mk_MatchContext (struct DFA *dfa, int range)
int ch0 = state->trans[j].ch[0];
int ch1 = state->trans[j].ch[1];
assert (ch0 >= 0 && ch1 >= 0);
int ch0 = state->trans[j].ch[0];
int ch1 = state->trans[j].ch[1];
assert (ch0 >= 0 && ch1 >= 0);
-
+
for (ch = ch0; ch <= ch1; ch++)
set_bit (mc, mc->Sc, ch, i);
}
for (ch = ch0; ch <= ch1; ch++)
set_bit (mc, mc->Sc, ch, i);
}
@@
-259,7
+260,7
@@
static int go (MatchContext *mc, struct DFA *dfa, FILE *inf)
while ((ch = getc (inf)) != EOF)
{
MatchWord *Rj_t;
while ((ch = getc (inf)) != EOF)
{
MatchWord *Rj_t;
-
+
infbuf[inf_ptr] = ch;
if (ch == '\n')
{
infbuf[inf_ptr] = ch;
if (ch == '\n')
{
@@
-329,13
+330,13
@@
static int grep_file (struct DFA *dfa, const char *fname, int range)
inf = fopen (fname, "r");
if (!inf)
{
inf = fopen (fname, "r");
if (!inf)
{
- logf (LOG_FATAL|LOG_ERRNO, "cannot open `%s'", fname);
+ yaz_log (YLOG_FATAL|YLOG_ERRNO, "cannot open `%s'", fname);
exit (1);
}
}
else
inf = stdin;
exit (1);
}
}
else
inf = stdin;
-
+
mc = mk_MatchContext (dfa, range);
go (mc, dfa, inf);
mc = mk_MatchContext (dfa, range);
go (mc, dfa, inf);
@@
-401,7
+402,7
@@
int main (int argc, char **argv)
}
else
{
}
else
{
- logf (LOG_FATAL, "Unknown option '-%s'", arg);
+ yaz_log (YLOG_FATAL, "Unknown option '-%s'", arg);
exit (1);
}
}
exit (1);
}
}
@@
-418,3
+419,12
@@
int main (int argc, char **argv)
dfa_delete (&dfa);
return 0;
}
dfa_delete (&dfa);
return 0;
}
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+