summaryrefslogtreecommitdiff
path: root/gl
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2006-02-23 16:26:18 +0000
committerSimon Josefsson <simon@josefsson.org>2006-02-23 16:26:18 +0000
commitd05cf5b2ba8553c9b6ac1df8a921573ca51a3adc (patch)
tree85b641bcdf39fc0fb69e62fd1d247b29a6d77822 /gl
parent31ae396a75896727326da261aa05de4223870515 (diff)
downloadlibtasn1-d05cf5b2ba8553c9b6ac1df8a921573ca51a3adc.tar.gz
libtasn1-d05cf5b2ba8553c9b6ac1df8a921573ca51a3adc.tar.bz2
libtasn1-d05cf5b2ba8553c9b6ac1df8a921573ca51a3adc.zip
Add strdup.
Diffstat (limited to 'gl')
-rw-r--r--gl/Makefile.am2
-rw-r--r--gl/m4/gnulib-cache.m44
-rw-r--r--gl/m4/gnulib-comp.m44
-rw-r--r--gl/m4/strdup.m417
-rw-r--r--gl/strdup.c56
-rw-r--r--gl/strdup.h29
6 files changed, 109 insertions, 3 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 0263eda..c99dcc6 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -8,7 +8,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --lgpl --libtool --macro-prefix=gl maintainer-makefile memmove
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --lgpl --libtool --macro-prefix=gl maintainer-makefile memmove strdup
AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index b9600e4..064bf72 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -14,10 +14,10 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --lgpl --libtool --macro-prefix=gl maintainer-makefile memmove
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --aux-dir=. --lgpl --libtool --macro-prefix=gl maintainer-makefile memmove strdup
# Specification in the form of a few gnulib-tool.m4 macro invocations:
-gl_MODULES([maintainer-makefile memmove])
+gl_MODULES([maintainer-makefile memmove strdup])
gl_AVOID([])
gl_SOURCE_BASE([gl])
gl_M4_BASE([gl/m4])
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 3927778..268baf4 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -27,6 +27,7 @@ AC_DEFUN([gl_INIT],
[
AM_CONDITIONAL([GL_COND_LIBTOOL], [true])
gl_FUNC_MEMMOVE
+ gl_FUNC_STRDUP
])
# This macro records the list of files which have been installed by
@@ -36,6 +37,9 @@ AC_DEFUN([gl_FILE_LIST], [
build-aux/maint.mk
lib/dummy.c
lib/memmove.c
+ lib/strdup.c
+ lib/strdup.h
m4/memmove.m4
m4/onceonly_2_57.m4
+ m4/strdup.m4
])
diff --git a/gl/m4/strdup.m4 b/gl/m4/strdup.m4
new file mode 100644
index 0000000..42325ab
--- /dev/null
+++ b/gl/m4/strdup.m4
@@ -0,0 +1,17 @@
+# strdup.m4 serial 6
+dnl Copyright (C) 2002, 2003, 2004, 2005 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_STRDUP],
+[
+ AC_LIBSOURCES([strdup.c, strdup.h])
+
+ AC_REPLACE_FUNCS(strdup)
+ AC_CHECK_DECLS_ONCE(strdup)
+ gl_PREREQ_STRDUP
+])
+
+# Prerequisites of lib/strdup.c.
+AC_DEFUN([gl_PREREQ_STRDUP], [:])
diff --git a/gl/strdup.c b/gl/strdup.c
new file mode 100644
index 0000000..84df5b8
--- /dev/null
+++ b/gl/strdup.c
@@ -0,0 +1,56 @@
+/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004 Free Software
+ Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License along
+ with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifndef _LIBC
+/* Get specification. */
+# include "strdup.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#undef __strdup
+#undef strdup
+
+#ifndef weak_alias
+# define __strdup strdup
+#endif
+
+/* Duplicate S, returning an identical malloc'd string. */
+char *
+__strdup (const char *s)
+{
+ size_t len = strlen (s) + 1;
+ void *new = malloc (len);
+
+ if (new == NULL)
+ return NULL;
+
+ return (char *) memcpy (new, s, len);
+}
+#ifdef libc_hidden_def
+libc_hidden_def (__strdup)
+#endif
+#ifdef weak_alias
+weak_alias (__strdup, strdup)
+#endif
diff --git a/gl/strdup.h b/gl/strdup.h
new file mode 100644
index 0000000..bbf2f49
--- /dev/null
+++ b/gl/strdup.h
@@ -0,0 +1,29 @@
+/* strdup.h -- duplicate a string
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifndef STRDUP_H_
+#define STRDUP_H_
+
+/* Get strdup declaration, if available. */
+#include <string.h>
+
+#if defined HAVE_DECL_STRDUP && !HAVE_DECL_STRDUP && !defined strdup
+/* Duplicate S, returning an identical malloc'd string. */
+extern char *strdup (const char *s);
+#endif
+
+#endif /* STRDUP_H_ */