diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-07-10 10:09:45 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-07-10 10:09:45 +0300 |
commit | d73567ebdf054eb6de6dea72250ef164e4c50eec (patch) | |
tree | c8d48504b02786e13215923b3e2654fe42275f0d /src | |
parent | ee35adccec058a5a8cc62f5030b9a925168236d6 (diff) | |
download | grecs-d73567ebdf054eb6de6dea72250ef164e4c50eec.tar.gz grecs-d73567ebdf054eb6de6dea72250ef164e4c50eec.tar.bz2 |
Import wordsplit as a submodule
* .gitmodules: New module: wordsplit
* Makefile.am: Distribute wordsplit files.
* am/grecs.m4 (GRECS_INCLUDES): Add wordsplit directory
* doc/Makefile.am (dist_man_MANS): Distribute wordsplit/wordsplit.3
* doc/wordsplit.3: Remove.
* include/Makefile.am (GRECS_HDR): Add wordsplit/wordsplit.
* include/wordsplit.h: Remove.
* src/Make-inst.am: Define nodist_libgrecs_la_SOURCES.
* src/Make-shared.am: Likewise.
* src/Make-static.am: Define nodist_libgrecs_a_SOURCES.
* src/Make.am (GRECS_SRC): Remove wordsplit.c
(NODIST_GRECS_SRC): Define to wordsplit.c
(VPATH): Add the wordsplit directory.
* src/wordsplit.c: Remove.
* tests/wordsplit.at: Remove.
* tests/wsp.c: Remove.
* tests/Makefile.am: Build separate testsuite for wordsplit. Use VPATH
to build wsp.
* tests/.gitignore: Update.
Diffstat (limited to 'src')
-rw-r--r-- | src/Make-inst.am | 4 | ||||
-rw-r--r-- | src/Make-shared.am | 3 | ||||
-rw-r--r-- | src/Make-static.am | 3 | ||||
-rw-r--r-- | src/Make.am | 6 | ||||
-rw-r--r-- | src/wordsplit.c | 2892 |
5 files changed, 11 insertions, 2897 deletions
diff --git a/src/Make-inst.am b/src/Make-inst.am index a4b6aea..1eb04bb 100644 --- a/src/Make-inst.am +++ b/src/Make-inst.am | |||
@@ -1,8 +1,8 @@ | |||
1 | # This file is part of grecs - Gray's Extensible Configuration System | 1 | # This file is part of grecs - Gray's Extensible Configuration System |
2 | # Copyright (C) 2007-2016 Sergey Poznyakoff | 2 | # Copyright (C) 2007-2019 Sergey Poznyakoff |
3 | # | 3 | # |
4 | # Grecs is free software; you can redistribute it and/or modify | 4 | # Grecs is free software; you can redistribute it and/or modify |
5 | # it under the terms of the GNU General Public License as published by | 5 | # it under the terms of the GNU General Public License as published by |
6 | # the Free Software Foundation; either version 3, or (at your option) | 6 | # the Free Software Foundation; either version 3, or (at your option) |
7 | # any later version. | 7 | # any later version. |
8 | # | 8 | # |
@@ -16,6 +16,8 @@ | |||
16 | 16 | ||
17 | include Make.am | 17 | include Make.am |
18 | lib_LTLIBRARIES=libgrecs.la | 18 | lib_LTLIBRARIES=libgrecs.la |
19 | libgrecs_la_SOURCES = $(GRECS_SRC) | 19 | libgrecs_la_SOURCES = $(GRECS_SRC) |
20 | m4datadir = $(datadir)/aclocal | 20 | m4datadir = $(datadir)/aclocal |
21 | dist_m4data_DATA = libgrecs.m4 | 21 | dist_m4data_DATA = libgrecs.m4 |
22 | nodist_libgrecs_la_SOURCES = $(NODIST_GRECS_SRC) | ||
23 | |||
diff --git a/src/Make-shared.am b/src/Make-shared.am index 9a762a4..f080e46 100644 --- a/src/Make-shared.am +++ b/src/Make-shared.am | |||
@@ -1,8 +1,8 @@ | |||
1 | # This file is part of grecs - Gray's Extensible Configuration System | 1 | # This file is part of grecs - Gray's Extensible Configuration System |
2 | # Copyright (C) 2007-2016 Sergey Poznyakoff | 2 | # Copyright (C) 2007-2019 Sergey Poznyakoff |
3 | # | 3 | # |
4 | # Grecs is free software; you can redistribute it and/or modify | 4 | # Grecs is free software; you can redistribute it and/or modify |
5 | # it under the terms of the GNU General Public License as published by | 5 | # it under the terms of the GNU General Public License as published by |
6 | # the Free Software Foundation; either version 3, or (at your option) | 6 | # the Free Software Foundation; either version 3, or (at your option) |
7 | # any later version. | 7 | # any later version. |
8 | # | 8 | # |
@@ -13,7 +13,8 @@ | |||
13 | # | 13 | # |
14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
15 | # along with Grecs. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Grecs. If not, see <http://www.gnu.org/licenses/>. |
16 | include Make.am | 16 | include Make.am |
17 | noinst_LTLIBRARIES=libgrecs.la | 17 | noinst_LTLIBRARIES=libgrecs.la |
18 | libgrecs_la_SOURCES = $(GRECS_SRC) | 18 | libgrecs_la_SOURCES = $(GRECS_SRC) |
19 | nodist_libgrecs_la_SOURCES = $(NODIST_GRECS_SRC) | ||
19 | 20 | ||
diff --git a/src/Make-static.am b/src/Make-static.am index 2688b40..1f4cd3e 100644 --- a/src/Make-static.am +++ b/src/Make-static.am | |||
@@ -1,8 +1,8 @@ | |||
1 | # This file is part of grecs - Gray's Extensible Configuration System | 1 | # This file is part of grecs - Gray's Extensible Configuration System |
2 | # Copyright (C) 2007-2016 Sergey Poznyakoff | 2 | # Copyright (C) 2007-2019 Sergey Poznyakoff |
3 | # | 3 | # |
4 | # Grecs is free software; you can redistribute it and/or modify | 4 | # Grecs is free software; you can redistribute it and/or modify |
5 | # it under the terms of the GNU General Public License as published by | 5 | # it under the terms of the GNU General Public License as published by |
6 | # the Free Software Foundation; either version 3, or (at your option) | 6 | # the Free Software Foundation; either version 3, or (at your option) |
7 | # any later version. | 7 | # any later version. |
8 | # | 8 | # |
@@ -13,8 +13,9 @@ | |||
13 | # | 13 | # |
14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
15 | # along with Grecs. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with Grecs. If not, see <http://www.gnu.org/licenses/>. |
16 | include Make.am | 16 | include Make.am |
17 | noinst_LIBRARIES=libgrecs.a | 17 | noinst_LIBRARIES=libgrecs.a |
18 | libgrecs_a_SOURCES = $(GRECS_SRC) | 18 | libgrecs_a_SOURCES = $(GRECS_SRC) |
19 | nodist_libgrecs_a_SOURCES = $(NODIST_GRECS_SRC) | ||
19 | 20 | ||
20 | 21 | ||
diff --git a/src/Make.am b/src/Make.am index 9fa7688..5199991 100644 --- a/src/Make.am +++ b/src/Make.am | |||
@@ -1,8 +1,8 @@ | |||
1 | # This file is part of grecs - Gray's Extensible Configuration System | 1 | # This file is part of grecs - Gray's Extensible Configuration System |
2 | # Copyright (C) 2007-2016 Sergey Poznyakoff | 2 | # Copyright (C) 2007-2019 Sergey Poznyakoff |
3 | # | 3 | # |
4 | # Grecs is free software; you can redistribute it and/or modify | 4 | # Grecs is free software; you can redistribute it and/or modify |
5 | # it under the terms of the GNU General Public License as published by | 5 | # it under the terms of the GNU General Public License as published by |
6 | # the Free Software Foundation; either version 3, or (at your option) | 6 | # the Free Software Foundation; either version 3, or (at your option) |
7 | # any later version. | 7 | # any later version. |
8 | # | 8 | # |
@@ -66,19 +66,21 @@ GRECS_SRC = \ | |||
66 | sort.c\ | 66 | sort.c\ |
67 | symtab.c\ | 67 | symtab.c\ |
68 | text.c\ | 68 | text.c\ |
69 | tree.c\ | 69 | tree.c\ |
70 | txtacc.c\ | 70 | txtacc.c\ |
71 | version.c\ | 71 | version.c\ |
72 | wordsplit.c\ | ||
73 | $(GRECS_JSON)\ | 72 | $(GRECS_JSON)\ |
74 | $(GRECS_PARSER_BIND)\ | 73 | $(GRECS_PARSER_BIND)\ |
75 | $(GRECS_PARSER_DHCPD)\ | 74 | $(GRECS_PARSER_DHCPD)\ |
76 | $(GRECS_PARSER_GIT)\ | 75 | $(GRECS_PARSER_GIT)\ |
77 | $(GRECS_PARSER_META1) | 76 | $(GRECS_PARSER_META1) |
78 | 77 | ||
78 | VPATH += $(top_srcdir)/@GRECS_SUBDIR@/wordsplit | ||
79 | NODIST_GRECS_SRC = wordsplit.c | ||
80 | |||
79 | if GRECS_COND_SOCKADDR_LIST | 81 | if GRECS_COND_SOCKADDR_LIST |
80 | GRECS_SRC += sockaddr.c | 82 | GRECS_SRC += sockaddr.c |
81 | endif | 83 | endif |
82 | 84 | ||
83 | EXTRA_DIST=\ | 85 | EXTRA_DIST=\ |
84 | grecs-gram.h\ | 86 | grecs-gram.h\ |
diff --git a/src/wordsplit.c b/src/wordsplit.c deleted file mode 100644 index 9179a87..0000000 --- a/src/wordsplit.c +++ /dev/null | |||
@@ -1,2892 +0,0 @@ | |||
1 | /* wordsplit - a word splitter | ||
2 | Copyright (C) 2009-2019 Sergey Poznyakoff | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU General Public License as published by the | ||
6 | Free Software Foundation; either version 3 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #ifdef HAVE_CONFIG_H | ||
18 | # include <config.h> | ||
19 | #endif | ||
20 | |||
21 | #include <errno.h> | ||
22 | #include <ctype.h> | ||
23 | #include <unistd.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <string.h> | ||
26 | #include <stdio.h> | ||
27 | #include <stdarg.h> | ||
28 | #include <pwd.h> | ||
29 | #include <glob.h> | ||
30 | #include <limits.h> | ||
31 | |||
32 | #if ENABLE_NLS | ||
33 | # include <gettext.h> | ||
34 | #else | ||
35 | # define gettext(msgid) msgid | ||
36 | #endif | ||
37 | #define _(msgid) gettext (msgid) | ||
38 | #define N_(msgid) msgid | ||
39 | |||
40 | #include <wordsplit.h> | ||
41 | |||
42 | #define ISWS(c) ((c)==' '||(c)=='\t'||(c)=='\n') | ||
43 | #define ISDELIM(ws,c) \ | ||
44 | (strchr ((ws)->ws_delim, (c)) != NULL) | ||
45 | #define ISPUNCT(c) (strchr("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",(c))!=NULL) | ||
46 | #define ISUPPER(c) ('A' <= ((unsigned) (c)) && ((unsigned) (c)) <= 'Z') | ||
47 | #define ISLOWER(c) ('a' <= ((unsigned) (c)) && ((unsigned) (c)) <= 'z') | ||
48 | #define ISALPHA(c) (ISUPPER(c) || ISLOWER(c)) | ||
49 | #define ISDIGIT(c) ('0' <= ((unsigned) (c)) && ((unsigned) (c)) <= '9') | ||
50 | #define ISXDIGIT(c) (strchr("abcdefABCDEF", c)!=NULL) | ||
51 | #define ISALNUM(c) (ISALPHA(c) || ISDIGIT(c)) | ||
52 | #define ISPRINT(c) (' ' <= ((unsigned) (c)) && ((unsigned) (c)) <= 127) | ||
53 | |||
54 | #define ISVARBEG(c) (ISALPHA(c) || c == '_') | ||
55 | #define ISVARCHR(c) (ISALNUM(c) || c == '_') | ||
56 | |||
57 | #define WSP_RETURN_DELIMS(wsp) \ | ||
58 | ((wsp)->ws_flags & WRDSF_RETURN_DELIMS || ((wsp)->ws_options & WRDSO_MAXWORDS)) | ||
59 | |||
60 | #define to_num(c) \ | ||
61 | (ISDIGIT(c) ? c - '0' : (ISXDIGIT(c) ? toupper(c) - 'A' + 10 : 255 )) | ||
62 | |||
63 | #define ALLOC_INIT 128 | ||
64 | #define ALLOC_INCR 128 | ||
65 | |||
66 | static void | ||
67 | _wsplt_alloc_die (struct wordsplit *wsp) | ||
68 | { | ||
69 | wsp->ws_error ("%s", _("memory exhausted")); | ||
70 | abort (); | ||
71 | } | ||
72 | |||
73 | static void | ||
74 | _wsplt_error (const char *fmt, ...) | ||
75 | { | ||
76 | va_list ap; | ||
77 | |||
78 | va_start (ap, fmt); | ||
79 | vfprintf (stderr, fmt, ap); | ||
80 | va_end (ap); | ||
81 | fputc ('\n', stderr); | ||
82 | } | ||
83 | |||
84 | static void wordsplit_free_nodes (struct wordsplit *); | ||
85 | |||
86 | static int | ||
87 | _wsplt_seterr (struct wordsplit *wsp, int ec) | ||
88 | { | ||
89 | wsp->ws_errno = ec; | ||
90 | if (wsp->ws_flags & WRDSF_SHOWERR) | ||
91 | wordsplit_perror (wsp); | ||
92 | return ec; | ||
93 | } | ||
94 | |||
95 | static int | ||
96 | _wsplt_nomem (struct wordsplit *wsp) | ||
97 | { | ||
98 | errno = ENOMEM; | ||
99 | wsp->ws_errno = WRDSE_NOSPACE; | ||
100 | if (wsp->ws_flags & WRDSF_ENOMEMABRT) | ||
101 | wsp->ws_alloc_die (wsp); | ||
102 | if (wsp->ws_flags & WRDSF_SHOWERR) | ||
103 | wordsplit_perror (wsp); | ||
104 | if (!(wsp->ws_flags & WRDSF_REUSE)) | ||
105 | wordsplit_free (wsp); | ||