[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8089] XS gnulib import strndup
From: |
gavinsmith0123 |
Subject: |
[8089] XS gnulib import strndup |
Date: |
Thu, 16 Aug 2018 05:26:11 -0400 (EDT) |
Revision: 8089
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8089
Author: gavin
Date: 2018-08-16 05:26:10 -0400 (Thu, 16 Aug 2018)
Log Message:
-----------
XS gnulib import strndup
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/XS/gnulib/lib/Makefile.am
trunk/tp/Texinfo/XS/gnulib/m4/gnulib-cache.m4
trunk/tp/Texinfo/XS/gnulib/m4/gnulib-comp.m4
Added Paths:
-----------
trunk/tp/Texinfo/XS/gnulib/lib/strndup.c
trunk/tp/Texinfo/XS/gnulib/lib/strnlen.c
trunk/tp/Texinfo/XS/gnulib/m4/strndup.m4
trunk/tp/Texinfo/XS/gnulib/m4/strnlen.m4
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2018-08-15 20:24:18 UTC (rev 8088)
+++ trunk/ChangeLog 2018-08-16 09:26:10 UTC (rev 8089)
@@ -1,3 +1,7 @@
+2018-08-16 Gavin Smith <address@hidden>
+
+ * tp/Texinfo/XS: Run "gnulib --add-import strndup".
+
2018-08-15 Gavin Smith <address@hidden>
* tp/Texinfo/XS: Run "gnulib --add-import iconv".
Modified: trunk/tp/Texinfo/XS/gnulib/lib/Makefile.am
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib/Makefile.am 2018-08-15 20:24:18 UTC (rev
8088)
+++ trunk/tp/Texinfo/XS/gnulib/lib/Makefile.am 2018-08-16 09:26:10 UTC (rev
8089)
@@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=gnulib/lib
--m4-base=gnulib/m4 --doc-base=doc --tests-base=tests --aux-dir=.
--no-conditional-dependencies --libtool --macro-prefix=gl getline iconv
strchrnul vasprintf
+# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=gnulib/lib
--m4-base=gnulib/m4 --doc-base=doc --tests-base=tests --aux-dir=.
--no-conditional-dependencies --libtool --macro-prefix=gl getline iconv
strchrnul strndup vasprintf
AUTOMAKE_OPTIONS = 1.9.6 gnits
@@ -582,6 +582,24 @@
## end gnulib module string
+## begin gnulib module strndup
+
+
+EXTRA_DIST += strndup.c
+
+EXTRA_libgnu_la_SOURCES += strndup.c
+
+## end gnulib module strndup
+
+## begin gnulib module strnlen
+
+
+EXTRA_DIST += strnlen.c
+
+EXTRA_libgnu_la_SOURCES += strnlen.c
+
+## end gnulib module strnlen
+
## begin gnulib module sys_types
BUILT_SOURCES += sys/types.h
Added: trunk/tp/Texinfo/XS/gnulib/lib/strndup.c
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib/strndup.c (rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/lib/strndup.c 2018-08-16 09:26:10 UTC (rev
8089)
@@ -0,0 +1,36 @@
+/* A replacement function, for systems that lack strndup.
+
+ Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2017 Free Software
+ Foundation, Inc.
+
+ 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, 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 <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <stdlib.h>
+
+char *
+strndup (char const *s, size_t n)
+{
+ size_t len = strnlen (s, n);
+ char *new = malloc (len + 1);
+
+ if (new == NULL)
+ return NULL;
+
+ new[len] = '\0';
+ return memcpy (new, s, len);
+}
Added: trunk/tp/Texinfo/XS/gnulib/lib/strnlen.c
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/lib/strnlen.c (rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/lib/strnlen.c 2018-08-16 09:26:10 UTC (rev
8089)
@@ -0,0 +1,30 @@
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ Copyright (C) 2005-2007, 2009-2017 Free Software Foundation, Inc.
+ Written by Simon Josefsson.
+
+ 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, 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 <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <string.h>
+
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ If no '\0' terminator is found in that many characters, return MAXLEN. */
+
+size_t
+strnlen (const char *string, size_t maxlen)
+{
+ const char *end = memchr (string, '\0', maxlen);
+ return end ? (size_t) (end - string) : maxlen;
+}
Modified: trunk/tp/Texinfo/XS/gnulib/m4/gnulib-cache.m4
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/m4/gnulib-cache.m4 2018-08-15 20:24:18 UTC
(rev 8088)
+++ trunk/tp/Texinfo/XS/gnulib/m4/gnulib-cache.m4 2018-08-16 09:26:10 UTC
(rev 8089)
@@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --lib=libgnu --source-base=gnulib/lib
--m4-base=gnulib/m4 --doc-base=doc --tests-base=tests --aux-dir=.
--no-conditional-dependencies --libtool --macro-prefix=gl getline iconv
strchrnul vasprintf
+# gnulib-tool --import --lib=libgnu --source-base=gnulib/lib
--m4-base=gnulib/m4 --doc-base=doc --tests-base=tests --aux-dir=.
--no-conditional-dependencies --libtool --macro-prefix=gl getline iconv
strchrnul strndup vasprintf
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@@ -35,6 +35,7 @@
getline
iconv
strchrnul
+ strndup
vasprintf
])
gl_AVOID([])
Modified: trunk/tp/Texinfo/XS/gnulib/m4/gnulib-comp.m4
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/m4/gnulib-comp.m4 2018-08-15 20:24:18 UTC
(rev 8088)
+++ trunk/tp/Texinfo/XS/gnulib/m4/gnulib-comp.m4 2018-08-16 09:26:10 UTC
(rev 8089)
@@ -67,6 +67,8 @@
# Code from module stdio:
# Code from module strchrnul:
# Code from module string:
+ # Code from module strndup:
+ # Code from module strnlen:
# Code from module sys_types:
# Code from module vasnprintf:
# Code from module vasprintf:
@@ -140,6 +142,17 @@
fi
gl_STRING_MODULE_INDICATOR([strchrnul])
gl_HEADER_STRING_H
+ gl_FUNC_STRNDUP
+ if test $HAVE_STRNDUP = 0 || test $REPLACE_STRNDUP = 1; then
+ AC_LIBOBJ([strndup])
+ fi
+ gl_STRING_MODULE_INDICATOR([strndup])
+ gl_FUNC_STRNLEN
+ if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
+ AC_LIBOBJ([strnlen])
+ gl_PREREQ_STRNLEN
+ fi
+ gl_STRING_MODULE_INDICATOR([strnlen])
gl_SYS_TYPES_H
AC_PROG_MKDIR_P
gl_FUNC_VASNPRINTF
@@ -315,6 +328,8 @@
lib/strchrnul.c
lib/strchrnul.valgrind
lib/string.in.h
+ lib/strndup.c
+ lib/strnlen.c
lib/sys_types.in.h
lib/vasnprintf.c
lib/vasnprintf.h
@@ -360,6 +375,8 @@
m4/stdio_h.m4
m4/strchrnul.m4
m4/string_h.m4
+ m4/strndup.m4
+ m4/strnlen.m4
m4/sys_types_h.m4
m4/vasnprintf.m4
m4/vasprintf.m4
Added: trunk/tp/Texinfo/XS/gnulib/m4/strndup.m4
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/m4/strndup.m4 (rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/m4/strndup.m4 2018-08-16 09:26:10 UTC (rev
8089)
@@ -0,0 +1,58 @@
+# strndup.m4 serial 22
+dnl Copyright (C) 2002-2003, 2005-2017 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STRNDUP],
+[
+ dnl Persuade glibc <string.h> to declare strndup().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_CHECK_DECLS_ONCE([strndup])
+ AC_CHECK_FUNCS_ONCE([strndup])
+ if test $ac_cv_have_decl_strndup = no; then
+ HAVE_DECL_STRNDUP=0
+ fi
+
+ if test $ac_cv_func_strndup = yes; then
+ HAVE_STRNDUP=1
+ # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating
'\0'.
+ AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works],
+ [AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([[#include <string.h>
+ #include <stdlib.h>]], [[
+#if !HAVE_DECL_STRNDUP
+ extern
+ #ifdef __cplusplus
+ "C"
+ #endif
+ char *strndup (const char *, size_t);
+#endif
+ int result;
+ char *s;
+ s = strndup ("some longer string", 15);
+ free (s);
+ s = strndup ("shorter string", 13);
+ result = s[13] != '\0';
+ free (s);
+ return result;]])],
+ [gl_cv_func_strndup_works=yes],
+ [gl_cv_func_strndup_works=no],
+ [
+changequote(,)dnl
+ case $host_os in
+ aix | aix[3-6]*) gl_cv_func_strndup_works="guessing no";;
+ *) gl_cv_func_strndup_works="guessing yes";;
+ esac
+changequote([,])dnl
+ ])])
+ case $gl_cv_func_strndup_works in
+ *no) REPLACE_STRNDUP=1 ;;
+ esac
+ else
+ HAVE_STRNDUP=0
+ fi
+])
Added: trunk/tp/Texinfo/XS/gnulib/m4/strnlen.m4
===================================================================
--- trunk/tp/Texinfo/XS/gnulib/m4/strnlen.m4 (rev 0)
+++ trunk/tp/Texinfo/XS/gnulib/m4/strnlen.m4 2018-08-16 09:26:10 UTC (rev
8089)
@@ -0,0 +1,30 @@
+# strnlen.m4 serial 13
+dnl Copyright (C) 2002-2003, 2005-2007, 2009-2017 Free Software Foundation,
+dnl Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_STRNLEN],
+[
+ AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+
+ dnl Persuade glibc <string.h> to declare strnlen().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_DECLS_ONCE([strnlen])
+ if test $ac_cv_have_decl_strnlen = no; then
+ HAVE_DECL_STRNLEN=0
+ else
+ m4_pushdef([AC_LIBOBJ], [:])
+ dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]).
+ AC_FUNC_STRNLEN
+ m4_popdef([AC_LIBOBJ])
+ if test $ac_cv_func_strnlen_working = no; then
+ REPLACE_STRNLEN=1
+ fi
+ fi
+])
+
+# Prerequisites of lib/strnlen.c.
+AC_DEFUN([gl_PREREQ_STRNLEN], [:])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8089] XS gnulib import strndup,
gavinsmith0123 <=