From ab6db76c77ea6480b307e43107bf570eb90d95eb Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 15 Jul 2019 11:51:50 +0300 Subject: Switch to grecs eb66a000 --- bootstrap | 3 +- grecs | 2 +- src/Makefile.am | 2 +- src/config.c | 1 + src/timer.c | 2 +- src/triplet.c | 6 +-- tests/.gitignore | 2 - tests/Makefile.am | 7 ++- tests/testsuite.at | 1 - tests/wordsplit.at | 24 --------- tests/wsbatch.c | 148 ----------------------------------------------------- tests/wstest.c | 141 -------------------------------------------------- 12 files changed, 11 insertions(+), 328 deletions(-) delete mode 100644 tests/wordsplit.at delete mode 100644 tests/wsbatch.c delete mode 100644 tests/wstest.c diff --git a/bootstrap b/bootstrap index 6c39c56..0df7e43 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,5 @@ #! /bin/sh set -e -git submodule init -git submodule update +git submodule update --init --recursive test -d m4 || mkdir m4 autoreconf -f -i -s diff --git a/grecs b/grecs index d51e136..eb66a00 160000 --- a/grecs +++ b/grecs @@ -1 +1 @@ -Subproject commit d51e1365118ce87016a39bd94437e31b35b8d307 +Subproject commit eb66a000db9b2726411c8c0f132c0278bd18c1a3 diff --git a/src/Makefile.am b/src/Makefile.am index 7188dcd..b20d563 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -71,7 +71,7 @@ inc_DATA = $(PP_SETUP_FILE) LDADD=@GRECS_LDADD@ @SQLLIB@ @GPGMELIB@ @LIBLTDL@ AM_CPPFLAGS= \ -I$(top_srcdir)/include\ - -I$(top_srcdir)/grecs/src/ @MAILUTILS_INCLUDES@\ + @GRECS_INCLUDES@ @MAILUTILS_INCLUDES@\ -DSYSCONFDIR=\"$(sysconfdir)\"\ -DLOCALSTATEDIR=\"$(localstatedir)\"\ -DWYDAWCA_MODDIR=\"$(WYDAWCA_MODDIR)\"\ diff --git a/src/config.c b/src/config.c index 346203a..8e94b8e 100644 --- a/src/config.c +++ b/src/config.c @@ -1399,6 +1399,7 @@ config_init() DEFAULT_INCLUDE_DIR, NULL); grecs_preprocessor = DEFAULT_PREPROCESSOR; grecs_log_to_stderr = 1; + grecs_parser_options = GRECS_OPTION_QUOTED_STRING_CONCAT; serv = getservbyname(PACKAGE, "tcp"); if (serv != NULL) diff --git a/src/timer.c b/src/timer.c index 4da3639..866e993 100644 --- a/src/timer.c +++ b/src/timer.c @@ -230,7 +230,7 @@ timer_fill_meta(struct wy_metadef *def, size_t num) return; td.def = def; td.num = num; - grecs_symtab_enumerate(timer_table, _fill_meta, &td); + grecs_symtab_foreach(timer_table, _fill_meta, &td); } void diff --git a/src/triplet.c b/src/triplet.c index 0b919ef..0ab597d 100644 --- a/src/triplet.c +++ b/src/triplet.c @@ -406,7 +406,7 @@ spool_commit_triplets(struct spool *spool, struct wy_triplet *tplist) tplist = next; } } else if (triplet_table) { - grecs_symtab_enumerate(triplet_table, triplet_processor, NULL); + grecs_symtab_foreach(triplet_table, triplet_processor, NULL); grecs_symtab_clear(triplet_table); } } @@ -414,7 +414,7 @@ spool_commit_triplets(struct spool *spool, struct wy_triplet *tplist) size_t count_collected_triplets() { - return triplet_table ? grecs_symtab_count_entries(triplet_table) : 0; + return triplet_table ? grecs_symtab_count(triplet_table) : 0; } struct count_closure { @@ -464,7 +464,7 @@ link_processable_triplets() clos.tp = NULL; if (triplet_table) - grecs_symtab_enumerate(triplet_table, triplet_linker, &clos); + grecs_symtab_foreach(triplet_table, triplet_linker, &clos); return clos.tp; } diff --git a/tests/.gitignore b/tests/.gitignore index 461469e..0c7f201 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -6,8 +6,6 @@ testsuite.dir testsuite.log source dest -wstest -wsbatch pushck bkupname nullmail diff --git a/tests/Makefile.am b/tests/Makefile.am index dcb3f65..d258768 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -57,8 +57,7 @@ TESTSUITE_AT = \ upl11.at\ upl12f.at\ upl12t.at\ - version.at\ - wordsplit.at + version.at TESTSUITE = $(srcdir)/testsuite M4=m4 @@ -81,9 +80,9 @@ check-local: atconfig atlocal $(TESTSUITE) #installcheck-local: # $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin -check_PROGRAMS = wstest wsbatch pushck bkupname +check_PROGRAMS = pushck bkupname AM_CPPFLAGS = \ - -I$(top_srcdir)/grecs/src\ + @GRECS_INCLUDES@ \ -I$(top_srcdir)/include\ -I$(top_srcdir)/src LDADD=@GRECS_LDADD@ diff --git a/tests/testsuite.at b/tests/testsuite.at index 5ffb503..9c298b6 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -28,7 +28,6 @@ m4_define([AT_MAILUTILS_PREREQ],[test "$WY_MAILUTILS" = yes || AT_SKIP_TEST]) AT_INIT AT_TESTED([wydawca]) m4_include([version.at]) -m4_include([wordsplit.at]) m4_include([pushdir.at]) m4_include([backup00.at]) m4_include([backup01.at]) diff --git a/tests/wordsplit.at b/tests/wordsplit.at deleted file mode 100644 index 1012c57..0000000 --- a/tests/wordsplit.at +++ /dev/null @@ -1,24 +0,0 @@ -# Check for wworking word splitter -*- Autotest -*- -# Copyright (C) 2009, 2010, 2011, 2017, 2019 Sergey Poznyakoff -# -# Wydawca 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 3, or (at your option) -# any later version. -# -# Wydawca 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 Wydawca. If not, see . - -AT_SETUP([wordsplit]) - -AT_CHECK([wsbatch], - [0], - [Tests: 13 -]) - -AT_CLEANUP diff --git a/tests/wsbatch.c b/tests/wsbatch.c deleted file mode 100644 index aeb8920..0000000 --- a/tests/wsbatch.c +++ /dev/null @@ -1,148 +0,0 @@ -/* wordsplit - a word splitter - Copyright (C) 2009, 2010, 2011, 2017, 2019 Sergey Poznyakoff - - 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 3 of the License, 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, see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include - -size_t errors = 0; -size_t count = 0; - -void -runtest (const char **input, struct wordsplit *wsinit, int flags) -{ - int i; - - for (i = 0; input[i]; i++) - { - size_t j; - const char *text = input[i]; - struct wordsplit ws = *wsinit; - i++; - for (j = 0; input[i+j]; j++); - - count++; - if (wordsplit (text, &ws, flags)) - { - fprintf (stderr, "E: %s: parse failed\n", text); - errors++; - } - else if (ws.ws_wordc != j) - { - fprintf (stderr, "E: %s: wrong number of fields (%lu/%lu)\n", - text, - (unsigned long) ws.ws_wordc, (unsigned long) j); - errors++; - } - else - { - size_t k; - - for (k = 0; k < ws.ws_wordc; k++) - if (strcmp (ws.ws_wordv[k], input[i + k])) - { - fprintf (stderr, "E: %s: word %lu mismatch: %s/%s\n", - text, (unsigned long) k, - ws.ws_wordv[k], input[i + k]); - errors++; - break; - } - } - i += j; - } -} - -const char *testv[] = { - "a bcd", "a", "bcd", NULL, - "a bcd \tef 13 456", "a", "bcd", "ef", "13", "456", NULL, - "a \"s p a c e\" b", "a", "s p a c e", "b", NULL, - "a \"s p \\\" a \\\\ c e\" b", "a", "s p \" a \\ c e", "b", NULL, - "a\\tb \"a\\tb\" 'a\\tb'", "a\tb", "a\tb", "a\\tb", NULL, - "\\\\\\a\\b\\f\\n\\r\\t\\v", "\\\a\b\f\n\r\t\v", NULL, - "a w13ord #comment", "a", "w13ord", "#comment", NULL, - NULL -}; - -const char *testcmt[] = { - "a bcd", "a", "bcd", NULL, - "a w13ord #comment", "a", "w13ord", NULL, - "#comment", NULL, - NULL -}; - -const char *testcol[] = { - "gray:x:1000:100:Sergey Poznyakoff:/home/gray:/bin/bash", - "gray", - "x", - "1000", - "100", - "Sergey Poznyakoff", - "/home/gray", - "/bin/bash", - NULL, - - "mail::8:12:\"mail pseudo user\":/:\n", - "mail", - "", - "8", - "12", - "\"mail pseudo user\"", - "/", - "", - NULL, - - NULL -}; - -const char *testcol2[] = { - "set x=foo,y=bar", - "set", " ", - "x", "=", - "foo", ",", - "y", "=", "bar", - NULL, - - NULL -}; - -int -main () -{ - struct wordsplit ws; - - runtest (testv, &ws, WRDSF_DEFFLAGS); - - ws.ws_comment = "#"; - runtest (testcmt, &ws, WRDSF_DEFFLAGS|WRDSF_COMMENT); - - ws.ws_delim = ":\n"; - runtest (testcol, &ws, WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_DELIM); - - ws.ws_delim = " =,"; - runtest (testcol2, &ws, - WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_DELIM | WRDSF_RETURN_DELIMS); - - printf ("Tests: %lu\n", (unsigned long) count); - if (errors) - printf ("Failures: %lu\n", (unsigned long) errors); - return errors ? 1 : 0; -} - diff --git a/tests/wstest.c b/tests/wstest.c deleted file mode 100644 index 9f02b0e..0000000 --- a/tests/wstest.c +++ /dev/null @@ -1,141 +0,0 @@ -/* wordsplit - a word splitter - Copyright (C) 2009, 2010, 2011, 2017, 2019 Sergey Poznyakoff - - 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 3 of the License, 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, see . */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include - -struct flgtab -{ - char *name; - int flag; -}; - -struct flgtab flgtab[] = { -#define FLG(n) { #n, n } - FLG(WRDSF_SHOWERR), - FLG(WRDSF_ENOMEMABRT), - FLG(WRDSF_WS), - FLG(WRDSF_QUOTE), - FLG(WRDSF_SQUEEZE_DELIMS), - FLG(WRDSF_RETURN_DELIMS), - FLG(WRDSF_SED_EXPR), - FLG(WRDSF_DEFFLAGS), - { NULL } -#undef FLG -}; - -int -str2flag (const char *opt) -{ - struct flgtab *f; - for (f = flgtab; f->name; f++) - if (strcmp (f->name, opt) == 0) - return f->flag; - return 0; -} - -int -main (int argc, char **argv) -{ - struct wordsplit ws; - int flags = 0; - int f; - size_t i; - char *text; - - char *progname = argv[0]; - - while (--argc) - { - char *opt = *++argv; - if (strncmp (opt, "delim=", 6) == 0) - { - ws.ws_delim = opt + 6; - flags |= WRDSF_DELIM; - } - else if (strncmp (opt, "comment=", 8) == 0) - { - ws.ws_comment = opt + 8; - flags |= WRDSF_COMMENT; - } - else if ((opt[0] == '!' || opt[0] == '~') - && strncmp (opt+1, "WRDSF_", 6) == 0) - { - f = str2flag (opt + 1); - if (!f) - { - fprintf (stderr, "%s: unknown flag: %s\n", progname, opt+1); - exit (1); - } - flags &= ~f; - } - else if (strncmp (opt, "WRDSF_", 6) == 0) - { - f = str2flag (opt); - if (!f) - { - fprintf (stderr, "%s: unknown flag: %s\n", progname, opt); - exit (1); - } - flags |= f; - } - else if (strcmp (opt, "--") == 0) - break; - else - break; - } - - if (!flags) - flags = WRDSF_DEFFLAGS; - - if (argc == 0) - { - fprintf (stderr, "%s: not enough arguments\n", progname); - return 1; - } - text = *argv++; - argc--; - - if (wordsplit (text, &ws, flags)) - { - fprintf (stderr, "%s: parse error\n", progname); - return 1; - } - - if (ws.ws_wordc != argc) - { - fprintf (stderr, "%s: wrong number of fields (%lu/%d)\n", - progname, (unsigned long) ws.ws_wordc, argc); - return 1; - } - - for (i = 0; i < ws.ws_wordc; i++) - if (strcmp (ws.ws_wordv[i], argv[i])) - { - fprintf (stderr, "%s: word %lu mismatch (got %s)\n", - progname, (unsigned long) i, ws.ws_wordv[i]); - return 1; - } - - wordsplit_free (&ws); - return 0; -} -- cgit v1.2.1