diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-07-10 20:45:43 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-07-10 20:49:33 +0300 |
commit | 6134242c5f804ee94856088f0258a20560c809fe (patch) | |
tree | 56f7191da2579ba57058ed3a602e7955a11b7d9f | |
parent | 9223032f5025f8bc4820dfdfb081be1c7fcd1c4e (diff) | |
download | smap-6134242c5f804ee94856088f0258a20560c809fe.tar.gz smap-6134242c5f804ee94856088f0258a20560c809fe.tar.bz2 |
Use wordsplit from a submodule
* .gitmodules (wordsplit): New module.
* configure.ac: Link lib/wordsplit/wordsplit.h to
include/smap/wordsplit.h
* include/smap/Makefile.am (pkginclude_HEADERS): Install wordsplit.h
from submodule.
* include/smap/wordsplit.h: Remove.
* lib/wordsplit.c: Remove.
* lib/Makefile.am: Access wordsplit sources from the submodule.
* modules/echo/Makefile.am (AM_CPPFLAGS): Add -I$(top_builddir)/include
* modules/guile/Makefile.am: Likewise.
* modules/ldap/Makefile.am: Likewise.
* modules/mailutils/Makefile.am: Likewise.
* modules/mysql/Makefile.am: Likewise.
* modules/postgres/Makefile.am: Likewise.
* modules/sed/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | include/smap/.gitignore | 1 | ||||
-rw-r--r-- | include/smap/Makefile.am | 2 | ||||
-rw-r--r-- | include/smap/wordsplit.h | 263 | ||||
-rw-r--r-- | lib/Makefile.am | 12 | ||||
m--------- | lib/wordsplit | 0 | ||||
-rw-r--r-- | lib/wordsplit.c | 2447 | ||||
-rw-r--r-- | modules/echo/Makefile.am | 4 | ||||
-rw-r--r-- | modules/guile/Makefile.am | 4 | ||||
-rw-r--r-- | modules/ldap/Makefile.am | 4 | ||||
-rw-r--r-- | modules/mailutils/Makefile.am | 4 | ||||
-rw-r--r-- | modules/mysql/Makefile.am | 2 | ||||
-rw-r--r-- | modules/postgres/Makefile.am | 2 | ||||
-rw-r--r-- | modules/sed/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.am | 6 |
16 files changed, 30 insertions, 2727 deletions
diff --git a/.gitmodules b/.gitmodules index 7c369d4..50664b0 100644 --- a/.gitmodules +++ b/.gitmodules | |||
@@ -3 +3,4 @@ | |||
3 | url = git://git.gnu.org.ua/gint.git | 3 | url = git://git.gnu.org.ua/gint.git |
4 | [submodule "lib/wordsplit"] | ||
5 | path = lib/wordsplit | ||
6 | url = git://git.gnu.org.ua/wordsplit.git | ||
diff --git a/configure.ac b/configure.ac index 46774b2..387a8d1 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -225,2 +225,3 @@ fi | |||
225 | 225 | ||
226 | AC_CONFIG_LINKS(include/smap/wordsplit.h:lib/wordsplit/wordsplit.h) | ||
226 | 227 | ||
diff --git a/include/smap/.gitignore b/include/smap/.gitignore new file mode 100644 index 0000000..357781f --- /dev/null +++ b/include/smap/.gitignore | |||
@@ -0,0 +1 @@ | |||
wordsplit.h | |||
diff --git a/include/smap/Makefile.am b/include/smap/Makefile.am index 040c936..672b23a 100644 --- a/include/smap/Makefile.am +++ b/include/smap/Makefile.am | |||
@@ -17,3 +17,3 @@ | |||
17 | pkginclude_HEADERS = \ | 17 | pkginclude_HEADERS = \ |
18 | wordsplit.h\ | 18 | $(top_srcdir)/lib/wordsplit/wordsplit.h\ |
19 | kwtab.h\ | 19 | kwtab.h\ |
diff --git a/include/smap/wordsplit.h b/include/smap/wordsplit.h deleted file mode 100644 index d5775d1..0000000 --- a/include/smap/wordsplit.h +++ /dev/null | |||
@@ -1,263 +0,0 @@ | |||
1 | /* wordsplit - a word splitter | ||
2 | Copyright (C) 2009-2016 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 | #ifndef __WORDSPLIT_H | ||
18 | #define __WORDSPLIT_H | ||
19 | |||
20 | #include <stddef.h> | ||
21 | |||
22 | typedef struct wordsplit wordsplit_t; | ||
23 | |||
24 | /* Structure used to direct the splitting. Members marked with [Input] | ||
25 | can be defined before calling wordsplit(), those marked with [Output] | ||
26 | provide return values when the function returns. If neither mark is | ||
27 | used, the member is internal and must not be used by the caller. | ||
28 | |||
29 | In the comments below, the | ||
30 | identifiers in parentheses indicate bits that must be set (or unset, if | ||
31 | starting with !) in the ws_flags to initialize or use the given member. | ||
32 | If not redefined explicitly, most of them are set to some reasonable | ||
33 | default value upon entry to wordsplit(). */ | ||
34 | struct wordsplit | ||
35 | { | ||
36 | size_t ws_wordc; /* [Output] Number of words in ws_wordv. */ | ||
37 | char **ws_wordv; /* [Output] Array of parsed out words. */ | ||
38 | size_t ws_offs; /* [Input] (WRDSF_DOOFFS) Number of initial | ||
39 | elements in ws_wordv to fill with NULLs. */ | ||
40 | size_t ws_wordn; /* Number of elements ws_wordv can accomodate. */ | ||
41 | int ws_flags; /* [Input] Flags passed to wordsplit. */ | ||
42 | int ws_options; /* [Input] (WRDSF_PATHEXPAND) | ||
43 | Additional options. */ | ||
44 | const char *ws_delim; /* [Input] (WRDSF_DELIM) Word delimiters. */ | ||
45 | const char *ws_comment; /* [Input] (WRDSF_COMMENT) Comment characters. */ | ||
46 | const char *ws_escape[2]; /* [Input] (WRDSF_ESCAPE) Characters to be escaped | ||
47 | with backslash. */ | ||
48 | void (*ws_alloc_die) (wordsplit_t *wsp); | ||
49 | /* [Input] (WRDSF_ALLOC_DIE) Function called when | ||
50 | out of memory. Must not return. */ | ||
51 | void (*ws_error) (const char *, ...) | ||
52 | __attribute__ ((__format__ (__printf__, 1, 2))); | ||
53 | /* [Input] (WRDSF_ERROR) Function used for error | ||
54 | reporting */ | ||
55 | void (*ws_debug) (const char *, ...) | ||
56 | __attribute__ ((__format__ (__printf__, 1, 2))); | ||
57 | /* [Input] (WRDSF_DEBUG) Function used for debug | ||
58 | output. */ | ||
59 | const char **ws_env; /* [Input] (WRDSF_ENV, !WRDSF_NOVAR) Array of | ||
60 | environment variables. */ | ||
61 | |||
62 | char **ws_envbuf; | ||
63 | size_t ws_envidx; | ||
64 | size_t ws_envsiz; | ||
65 | |||
66 | int (*ws_getvar) (char **ret, const char *var, size_t len, void *clos); | ||
67 | /* [Input] (WRDSF_GETVAR, !WRDSF_NOVAR) Looks up | ||
68 | the name VAR (LEN bytes long) in the table of | ||
69 | variables and if found returns in memory | ||
70 | location pointed to by RET the value of that | ||
71 | variable. Returns WRDSE_OK (0) on success, | ||
72 | and an error code (see WRDSE_* defines below) | ||
73 | on error. User-specific errors can be returned | ||
74 | by storing the error diagnostic string in RET | ||
75 | and returning WRDSE_USERERR. | ||
76 | Whatever is stored in RET, it must be allocated | ||
77 | using malloc(3). */ | ||
78 | void *ws_closure; /* [Input] (WRDSF_CLOSURE) Passed as the CLOS | ||
79 | argument to ws_getvar and ws_command. */ | ||
80 | int (*ws_command) (char **ret, const char *cmd, size_t len, char **argv, | ||
81 | void *clos); | ||
82 | /* [Input] (!WRDSF_NOCMD) Returns in the memory | ||
83 | location pointed to by RET the expansion of | ||
84 | the command CMD (LEN bytes nong). If WRDSF_ARGV | ||
85 | flag is set, ARGV contains CMD split out to | ||
86 | words. Otherwise ARGV is NULL. | ||
87 | |||
88 | See ws_getvar for a discussion of possible | ||
89 | return values. */ | ||
90 | |||
91 | const char *ws_input; /* Input string (the S argument to wordsplit. */ | ||
92 | size_t ws_len; /* Length of ws_input. */ | ||
93 | size_t ws_endp; /* Points past the last processed byte in | ||
94 | ws_input. */ | ||
95 | int ws_errno; /* [Output] Error code, if an error occurred. */ | ||
96 | char *ws_usererr; /* Points to textual description of | ||
97 | the error, if ws_errno is WRDSE_USERERR. Must | ||
98 | be allocated with malloc(3). */ | ||
99 | struct wordsplit_node *ws_head, *ws_tail; | ||
100 | /* Doubly-linked list of parsed out nodes. */ | ||
101 | int ws_lvl; /* Invocation nesting level. */ | ||
102 | }; | ||
103 | |||
104 | /* Initial size for ws_env, if allocated automatically */ | ||
105 | #define WORDSPLIT_ENV_INIT 16 | ||
106 | |||
107 | /* Wordsplit flags. */ | ||
108 | /* Append the words found to the array resulting from a previous | ||
109 | call. */ | ||
110 | #define WRDSF_APPEND 0x00000001 | ||
111 | /* Insert ws_offs initial NULLs in the array ws_wordv. | ||
112 | (These are not counted in the returned ws_wordc.) */ | ||
113 | #define WRDSF_DOOFFS 0x00000002 | ||
114 | /* Don't do command substitution. */ | ||
115 | #define WRDSF_NOCMD 0x00000004 | ||
116 | /* The parameter p resulted from a previous call to | ||
117 | wordsplit(), and wordsplit_free() was not called. Reuse the | ||
118 | allocated storage. */ | ||
119 | #define WRDSF_REUSE 0x00000008 | ||
120 | /* Print errors */ | ||
121 | #define WRDSF_SHOWERR 0x00000010 | ||
122 | /* Consider it an error if an undefined variable is expanded. */ | ||
123 | #define WRDSF_UNDEF 0x00000020 | ||
124 | /* Don't do variable expansion. */ | ||
125 | #define WRDSF_NOVAR 0x00000040 | ||
126 | /* Abort on ENOMEM error */ | ||
127 | #define WRDSF_ENOMEMABRT 0x00000080 | ||
128 | /* Trim off any leading and trailind whitespace */ | ||
129 | #define WRDSF_WS 0x00000100 | ||
130 | /* Handle single quotes */ | ||
131 | #define WRDSF_SQUOTE 0x00000200 | ||
132 | /* Handle double quotes */ | ||
133 | #define WRDSF_DQUOTE 0x00000400 | ||
134 | /* Handle single and double quotes */ | ||
135 | #define WRDSF_QUOTE (WRDSF_SQUOTE|WRDSF_DQUOTE) | ||
136 | /* Replace each input sequence of repeated delimiters with a single | ||
137 | delimiter */ | ||
138 | #define WRDSF_SQUEEZE_DELIMS 0x00000800 | ||
139 | /* Return delimiters */ | ||
140 | #define WRDSF_RETURN_DELIMS 0x00001000 | ||
141 | /* Treat sed expressions as words */ | ||
142 | #define WRDSF_SED_EXPR 0x00002000 | ||
143 | /* ws_delim field is initialized */ | ||
144 | #define WRDSF_DELIM 0x00004000 | ||
145 | /* ws_comment field is initialized */ | ||
146 | #define WRDSF_COMMENT 0x00008000 | ||
147 | /* ws_alloc_die field is initialized */ | ||
148 | #define WRDSF_ALLOC_DIE 0x00010000 | ||
149 | /* ws_error field is initialized */ | ||
150 | #define WRDSF_ERROR 0x00020000 | ||
151 | /* ws_debug field is initialized */ | ||
152 | #define WRDSF_DEBUG 0x00040000 | ||
153 | /* ws_env field is initialized */ | ||
154 | #define WRDSF_ENV 0x00080000 | ||
155 | /* ws_getvar field is initialized */ | ||
156 | #define WRDSF_GETVAR 0x00100000 | ||
157 | /* enable debugging */ | ||
158 | #define WRDSF_SHOWDBG 0x00200000 | ||
159 | /* Don't split input into words. Useful for side effects. */ | ||
160 | #define WRDSF_NOSPLIT 0x00400000 | ||
161 | /* Keep undefined variables in place, instead of expanding them to | ||
162 | empty strings. */ | ||
163 | #define WRDSF_KEEPUNDEF 0x00800000 | ||
164 | /* Warn about undefined variables */ | ||
165 | #define WRDSF_WARNUNDEF 0x01000000 | ||
166 | /* Handle C escapes */ | ||
167 | #define WRDSF_CESCAPES 0x02000000 | ||
168 | /* ws_closure is set */ | ||
169 | #define WRDSF_CLOSURE 0x04000000 | ||
170 | /* ws_env is a Key/Value environment, i.e. the value of a variable is | ||
171 | stored in the element that follows its name. */ | ||
172 | #define WRDSF_ENV_KV 0x08000000 | ||
173 | /* ws_escape is set */ | ||
174 | #define WRDSF_ESCAPE 0x10000000 | ||