summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-09-13 22:01:20 +0000
committerJim Meyering <jim@meyering.net>2003-09-13 22:01:20 +0000
commitdce9582d2ca06a6c50165014b21d95654541e8da (patch)
treea44364d0664dbc9f44ba1ed449b6e1fe9c1a7808 /lib
parent2be39af412edc53d4ef09097949550697c270173 (diff)
downloadcoreutils-dce9582d2ca06a6c50165014b21d95654541e8da.tar.xz
Update from gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/strcspn.c12
-rw-r--r--lib/strdup.c13
-rw-r--r--lib/strndup.c15
-rw-r--r--lib/strnlen.c16
-rw-r--r--lib/strpbrk.c7
-rw-r--r--lib/strstr.c6
-rw-r--r--lib/strtod.c21
-rw-r--r--lib/strtoimax.c16
-rw-r--r--lib/tempname.c6
-rw-r--r--lib/unicodeio.c6
-rw-r--r--lib/userspec.c15
-rw-r--r--lib/vasprintf.h28
-rw-r--r--lib/xgethostname.c2
-rw-r--r--lib/xreadlink.c4
-rw-r--r--lib/xstrdup.c13
-rw-r--r--lib/xstrndup.c26
-rw-r--r--lib/xstrndup.h24
17 files changed, 82 insertions, 148 deletions
diff --git a/lib/strcspn.c b/lib/strcspn.c
index 2bbd90664..33a662852 100644
--- a/lib/strcspn.c
+++ b/lib/strcspn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1996-1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1994, 1996-1997, 2002-2003 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
@@ -23,15 +23,7 @@
#endif
#include <stddef.h>
-
-#if defined _LIBC || HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-# ifndef strchr
-# define strchr index
-# endif
-#endif
+#include <string.h>
#undef strcspn
diff --git a/lib/strdup.c b/lib/strdup.c
index d37207199..52667e98e 100644
--- a/lib/strdup.c
+++ b/lib/strdup.c
@@ -1,4 +1,6 @@
-/* Copyright (C) 1991, 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003 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
@@ -19,13 +21,8 @@
# include <config.h>
#endif
-#if defined _LIBC || defined STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else
-char *malloc ();
-char *memcpy ();
-#endif
+#include <stdlib.h>
+#include <string.h>
#undef __strdup
#undef strdup
diff --git a/lib/strndup.c b/lib/strndup.c
index 136e51c73..f85627e87 100644
--- a/lib/strndup.c
+++ b/lib/strndup.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
@@ -21,15 +21,8 @@
# include "config.h"
#endif
-#include <stdio.h>
-#include <sys/types.h>
-
-#if defined _LIBC || defined STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else
-char *malloc ();
-#endif
+#include <stdlib.h>
+#include <string.h>
#ifndef HAVE_DECL_STRNLEN
"this configure-time declaration test was not run"
@@ -55,7 +48,7 @@ __strndup (const char *s, size_t n)
return NULL;
new[len] = '\0';
- return (char *) memcpy (new, s, len);
+ return memcpy (new, s, len);
}
#ifdef weak_alias
weak_alias (__strndup, strndup)
diff --git a/lib/strnlen.c b/lib/strnlen.c
index 617b0aa18..c9f389845 100644
--- a/lib/strnlen.c
+++ b/lib/strnlen.c
@@ -21,21 +21,7 @@
#endif
#undef strnlen
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-
-#ifndef HAVE_DECL_MEMCHR
-"this configure-time declaration test was not run"
-#endif
-#if !HAVE_DECL_MEMCHR
-char *memchr ();
-#endif
+#include <string.h>
#undef __strnlen
#undef strnlen
diff --git a/lib/strpbrk.c b/lib/strpbrk.c
index 01d8df5a8..ce4399620 100644
--- a/lib/strpbrk.c
+++ b/lib/strpbrk.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1994, 2000, 2002-2003 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
@@ -21,10 +21,7 @@
#endif
#include <stddef.h>
-
-#if defined _LIBC || HAVE_STRING_H
-# include <string.h>
-#endif
+#include <string.h>
#undef strpbrk
diff --git a/lib/strstr.c b/lib/strstr.c
index 42ffcfa8e..dd4622297 100644
--- a/lib/strstr.c
+++ b/lib/strstr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1999, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1999, 2002-2003 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
@@ -28,9 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
# include <config.h>
#endif
-#if defined _LIBC || defined HAVE_STRING_H
-# include <string.h>
-#endif
+#include <string.h>
typedef unsigned chartype;
diff --git a/lib/strtod.c b/lib/strtod.c
index 10edb5cfe..161f97a7b 100644
--- a/lib/strtod.c
+++ b/lib/strtod.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1997, 1999, 2003 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
@@ -37,22 +37,9 @@ extern int errno;
#include <math.h>
-#if HAVE_FLOAT_H
-# include <float.h>
-#else
-# define DBL_MAX 1.7976931348623159e+308
-# define DBL_MIN 2.2250738585072010e-308
-#endif
-
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else
-# define NULL 0
-# ifndef HUGE_VAL
-# define HUGE_VAL HUGE
-# endif
-#endif
+#include <float.h>
+#include <stdlib.h>
+#include <string.h>
/* Convert NPTR to a double. If ENDPTR is not NULL, a pointer to the
character after the last one used in the number is put in *ENDPTR. */
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
index 555f2d5b5..4ce741cfd 100644
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -27,20 +27,12 @@
# include <stdint.h>
#endif
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
#ifdef UNSIGNED
-# ifndef HAVE_DECL_STRTOUL
-"this configure-time declaration test was not run"
-# endif
-# if !HAVE_DECL_STRTOUL
-unsigned long strtoul (char const *, char **, int);
-# endif
# ifndef HAVE_DECL_STRTOULL
"this configure-time declaration test was not run"
# endif
@@ -50,12 +42,6 @@ unsigned long long strtoull (char const *, char **, int);
#else
-# ifndef HAVE_DECL_STRTOL
-"this configure-time declaration test was not run"
-# endif
-# if !HAVE_DECL_STRTOL
-long strtol (char const *, char **, int);
-# endif
# ifndef HAVE_DECL_STRTOLL
"this configure-time declaration test was not run"
# endif
diff --git a/lib/tempname.c b/lib/tempname.c
index 13a8204a4..b3d0874ce 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -44,12 +44,8 @@
#endif
#include <stddef.h>
-
-#if STDC_HEADERS || _LIBC
-# include <string.h>
-#endif
-
#include <stdlib.h>
+#include <string.h>
#if HAVE_FCNTL_H || _LIBC
# include <fcntl.h>
diff --git a/lib/unicodeio.c b/lib/unicodeio.c
index 7b7f6f229..4f0792bb6 100644
--- a/lib/unicodeio.c
+++ b/lib/unicodeio.c
@@ -29,11 +29,7 @@
#include "unicodeio.h"
#include <stdio.h>
-#if HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
+#include <string.h>
#include <errno.h>
#ifndef errno
diff --git a/lib/userspec.c b/lib/userspec.c
index 19443ec91..6e58b486c 100644
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -33,19 +33,8 @@
#endif
#include <limits.h>
-
-#if HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-# ifndef strchr
-# define strchr index
-# endif
-#endif
-
-#if STDC_HEADERS
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
+#include <string.h>
#if HAVE_UNISTD_H
# include <unistd.h>
diff --git a/lib/vasprintf.h b/lib/vasprintf.h
index 0ab75ccf4..fdd831f20 100644
--- a/lib/vasprintf.h
+++ b/lib/vasprintf.h
@@ -21,29 +21,29 @@
#if HAVE_VASPRINTF
/* Get asprintf(), vasprintf() declarations. */
-# include <stdio.h>
+#include <stdio.h>
#else
/* Get va_list. */
-# include <stdarg.h>
+#include <stdarg.h>
-# ifndef __attribute__
+#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
-# define __attribute__(Spec) /* empty */
-# endif
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+# define __attribute__(Spec) /* empty */
+# endif
/* The __-protected variants of `format' and `printf' attributes
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __format__ format
-# define __printf__ printf
-# endif
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define __format__ format
+# define __printf__ printf
# endif
+#endif
-# ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
-# endif
+#endif
/* Write formatted output to a string dynamically allocated with malloc().
If the memory allocation succeeds, store the address of the string in
@@ -54,9 +54,9 @@ extern int asprintf (char **result, const char *format, ...)
extern int vasprintf (char **result, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0)));
-# ifdef __cplusplus
+#ifdef __cplusplus
}
-# endif
+#endif
#endif
diff --git a/lib/xgethostname.c b/lib/xgethostname.c
index 60ee91a13..494571ee1 100644
--- a/lib/xgethostname.c
+++ b/lib/xgethostname.c
@@ -47,7 +47,7 @@ int gethostname ();
If malloc fails, exit.
Upon any other failure, return NULL. */
char *
-xgethostname ()
+xgethostname (void)
{
char *hostname;
size_t size;
diff --git a/lib/xreadlink.c b/lib/xreadlink.c
index f5cce16eb..e8c677b44 100644
--- a/lib/xreadlink.c
+++ b/lib/xreadlink.c
@@ -31,9 +31,7 @@ extern int errno;
#include <limits.h>
#include <sys/types.h>
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
diff --git a/lib/xstrdup.c b/lib/xstrdup.c
index cb1efa8c2..1182c592a 100644
--- a/lib/xstrdup.c
+++ b/lib/xstrdup.c
@@ -1,5 +1,5 @@
/* xstrdup.c -- copy a string with out of memory checking
- Copyright (C) 1990, 1996, 1998, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1990, 1996, 1998, 2001, 2003 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
@@ -19,16 +19,11 @@
# include <config.h>
#endif
-#if STDC_HEADERS || HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-
-#include <sys/types.h>
-
+/* Specification. */
#include "xalloc.h"
+#include <string.h>
+
/* Return a newly allocated copy of STRING. */
char *
diff --git a/lib/xstrndup.c b/lib/xstrndup.c
index a1e819efa..5addbf663 100644
--- a/lib/xstrndup.c
+++ b/lib/xstrndup.c
@@ -1,5 +1,5 @@
-/* A wrapper around xstrndup.
-
+/* Duplicate a bounded initial segment of a string, with out-of-memory
+ checking.
Copyright (C) 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -16,22 +16,24 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* Written by Jim Meyering. */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
+#if HAVE_CONFIG_H
+# include <config.h>
#endif
+/* Specification. */
#include "xstrndup.h"
-#include "xalloc.h"
-char *strndup (char const *, size_t);
+#include "strndup.h"
+#include "xalloc.h"
+/* Return a newly allocated copy of at most N bytes of STRING.
+ In other words, return a copy of the initial segment of length N of
+ STRING. */
char *
-xstrndup (char const *s, size_t n)
+xstrndup (const char *string, size_t n)
{
- char *new = strndup (s, n);
- if (new == NULL)
+ char *s = strndup (string, n);
+ if (! s)
xalloc_die ();
- return (char *) new;
+ return s;
}
diff --git a/lib/xstrndup.h b/lib/xstrndup.h
index 27afc401d..b09a2fc0b 100644
--- a/lib/xstrndup.h
+++ b/lib/xstrndup.h
@@ -1,2 +1,24 @@
+/* Duplicate a bounded initial segment of a string, with out-of-memory
+ checking.
+ Copyright (C) 2003 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 2, 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, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
#include <stddef.h>
-char *xstrndup (char const *s, size_t n);
+
+/* Return a newly allocated copy of at most N bytes of STRING.
+ In other words, return a copy of the initial segment of length N of
+ STRING. */
+extern char *xstrndup (const char *string, size_t n);