diff options
Diffstat (limited to 'gl')
-rw-r--r-- | gl/Makefile.am | 11 | ||||
-rw-r--r-- | gl/m4/gnulib-cache.m4 | 3 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 6 | ||||
-rw-r--r-- | gl/m4/strsep.m4 | 25 | ||||
-rw-r--r-- | gl/strsep.c | 58 |
5 files changed, 101 insertions, 2 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index 7954b034..2f5f9c43 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am | |||
@@ -9,7 +9,7 @@ | |||
9 | # the same distribution terms as the rest of that program. | 9 | # the same distribution terms as the rest of that program. |
10 | # | 10 | # |
11 | # Generated by gnulib-tool. | 11 | # Generated by gnulib-tool. |
12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex timegm vasprintf vsnprintf | 12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex strsep timegm vasprintf vsnprintf |
13 | 13 | ||
14 | AUTOMAKE_OPTIONS = 1.5 gnits | 14 | AUTOMAKE_OPTIONS = 1.5 gnits |
15 | 15 | ||
@@ -1367,6 +1367,15 @@ EXTRA_libgnu_a_SOURCES += strnlen.c | |||
1367 | 1367 | ||
1368 | ## end gnulib module strnlen | 1368 | ## end gnulib module strnlen |
1369 | 1369 | ||
1370 | ## begin gnulib module strsep | ||
1371 | |||
1372 | |||
1373 | EXTRA_DIST += strsep.c | ||
1374 | |||
1375 | EXTRA_libgnu_a_SOURCES += strsep.c | ||
1376 | |||
1377 | ## end gnulib module strsep | ||
1378 | |||
1370 | ## begin gnulib module strstr-simple | 1379 | ## begin gnulib module strstr-simple |
1371 | 1380 | ||
1372 | 1381 | ||
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index 97b1849b..f23cb519 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | 16 | ||
17 | # Specification in the form of a command-line invocation: | 17 | # Specification in the form of a command-line invocation: |
18 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex timegm vasprintf vsnprintf | 18 | # gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex strsep timegm vasprintf vsnprintf |
19 | 19 | ||
20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: | 20 | # Specification in the form of a few gnulib-tool.m4 macro invocations: |
21 | gl_LOCAL_DIR([]) | 21 | gl_LOCAL_DIR([]) |
@@ -32,6 +32,7 @@ gl_MODULES([ | |||
32 | gettext | 32 | gettext |
33 | mountlist | 33 | mountlist |
34 | regex | 34 | regex |
35 | strsep | ||
35 | timegm | 36 | timegm |
36 | vasprintf | 37 | vasprintf |
37 | vsnprintf | 38 | vsnprintf |
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index f4031cc7..73e63654 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 | |||
@@ -106,6 +106,7 @@ AC_DEFUN([gl_EARLY], | |||
106 | # Code from module string: | 106 | # Code from module string: |
107 | # Code from module strndup: | 107 | # Code from module strndup: |
108 | # Code from module strnlen: | 108 | # Code from module strnlen: |
109 | # Code from module strsep: | ||
109 | # Code from module strstr-simple: | 110 | # Code from module strstr-simple: |
110 | # Code from module sys_socket: | 111 | # Code from module sys_socket: |
111 | # Code from module sys_stat: | 112 | # Code from module sys_stat: |
@@ -327,6 +328,9 @@ AC_DEFUN([gl_INIT], | |||
327 | # Code from module strnlen: | 328 | # Code from module strnlen: |
328 | gl_FUNC_STRNLEN | 329 | gl_FUNC_STRNLEN |
329 | gl_STRING_MODULE_INDICATOR([strnlen]) | 330 | gl_STRING_MODULE_INDICATOR([strnlen]) |
331 | # Code from module strsep: | ||
332 | gl_FUNC_STRSEP | ||
333 | gl_STRING_MODULE_INDICATOR([strsep]) | ||
330 | # Code from module strstr-simple: | 334 | # Code from module strstr-simple: |
331 | gl_FUNC_STRSTR_SIMPLE | 335 | gl_FUNC_STRSTR_SIMPLE |
332 | gl_STRING_MODULE_INDICATOR([strstr]) | 336 | gl_STRING_MODULE_INDICATOR([strstr]) |
@@ -634,6 +638,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
634 | lib/stripslash.c | 638 | lib/stripslash.c |
635 | lib/strndup.c | 639 | lib/strndup.c |
636 | lib/strnlen.c | 640 | lib/strnlen.c |
641 | lib/strsep.c | ||
637 | lib/strstr.c | 642 | lib/strstr.c |
638 | lib/sys_socket.in.h | 643 | lib/sys_socket.in.h |
639 | lib/sys_stat.in.h | 644 | lib/sys_stat.in.h |
@@ -762,6 +767,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
762 | m4/string_h.m4 | 767 | m4/string_h.m4 |
763 | m4/strndup.m4 | 768 | m4/strndup.m4 |
764 | m4/strnlen.m4 | 769 | m4/strnlen.m4 |
770 | m4/strsep.m4 | ||
765 | m4/strstr.m4 | 771 | m4/strstr.m4 |
766 | m4/sys_socket_h.m4 | 772 | m4/sys_socket_h.m4 |
767 | m4/sys_stat_h.m4 | 773 | m4/sys_stat_h.m4 |
diff --git a/gl/m4/strsep.m4 b/gl/m4/strsep.m4 new file mode 100644 index 00000000..fb4d396b --- /dev/null +++ b/gl/m4/strsep.m4 | |||
@@ -0,0 +1,25 @@ | |||
1 | # strsep.m4 serial 9 | ||
2 | dnl Copyright (C) 2002, 2003, 2004, 2007, 2009, 2010 Free Software Foundation, | ||
3 | dnl Inc. | ||
4 | dnl This file is free software; the Free Software Foundation | ||
5 | dnl gives unlimited permission to copy and/or distribute it, | ||
6 | dnl with or without modifications, as long as this notice is preserved. | ||
7 | |||
8 | AC_DEFUN([gl_FUNC_STRSEP], | ||
9 | [ | ||
10 | dnl Persuade glibc <string.h> to declare strsep(). | ||
11 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | ||
12 | |||
13 | dnl The strsep() declaration in lib/string.in.h uses 'restrict'. | ||
14 | AC_REQUIRE([AC_C_RESTRICT]) | ||
15 | |||
16 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) | ||
17 | AC_REPLACE_FUNCS([strsep]) | ||
18 | if test $ac_cv_func_strsep = no; then | ||
19 | HAVE_STRSEP=0 | ||
20 | gl_PREREQ_STRSEP | ||
21 | fi | ||
22 | ]) | ||
23 | |||
24 | # Prerequisites of lib/strsep.c. | ||
25 | AC_DEFUN([gl_PREREQ_STRSEP], [:]) | ||
diff --git a/gl/strsep.c b/gl/strsep.c new file mode 100644 index 00000000..a2a3ffa3 --- /dev/null +++ b/gl/strsep.c | |||
@@ -0,0 +1,58 @@ | |||
1 | /* Copyright (C) 2004, 2007, 2009, 2010 Free Software Foundation, Inc. | ||
2 | |||
3 | Written by Yoann Vandoorselaere <yoann@prelude-ids.org>. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 3, or (at your option) | ||
8 | any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software Foundation, | ||
17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | /* Specification. */ | ||
24 | #include <string.h> | ||
25 | |||
26 | char * | ||
27 | strsep (char **stringp, const char *delim) | ||
28 | { | ||
29 | char *start = *stringp; | ||
30 | char *ptr; | ||
31 | |||
32 | if (start == NULL) | ||
33 | return NULL; | ||
34 | |||
35 | /* Optimize the case of no delimiters. */ | ||
36 | if (delim[0] == '\0') | ||
37 | { | ||
38 | *stringp = NULL; | ||
39 | return start; | ||
40 | } | ||
41 | |||
42 | /* Optimize the case of one delimiter. */ | ||
43 | if (delim[1] == '\0') | ||
44 | ptr = strchr (start, delim[0]); | ||
45 | else | ||
46 | /* The general case. */ | ||
47 | ptr = strpbrk (start, delim); | ||
48 | if (ptr == NULL) | ||
49 | { | ||
50 | *stringp = NULL; | ||
51 | return start; | ||
52 | } | ||
53 | |||
54 | *ptr = '\0'; | ||
55 | *stringp = ptr + 1; | ||
56 | |||
57 | return start; | ||
58 | } | ||