Update from gnulib.
authorJim Meyering <jim@meyering.net>
Sat, 13 Sep 2003 22:01:20 +0000 (22:01 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 13 Sep 2003 22:01:20 +0000 (22:01 +0000)
17 files changed:
lib/strcspn.c
lib/strdup.c
lib/strndup.c
lib/strnlen.c
lib/strpbrk.c
lib/strstr.c
lib/strtod.c
lib/strtoimax.c
lib/tempname.c
lib/unicodeio.c
lib/userspec.c
lib/vasprintf.h
lib/xgethostname.c
lib/xreadlink.c
lib/xstrdup.c
lib/xstrndup.c
lib/xstrndup.h

index 2bbd906..33a6628 100644 (file)
@@ -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.
 #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
 
index d372071..52667e9 100644 (file)
@@ -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
 # 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
index 136e51c..f85627e 100644 (file)
@@ -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.
 # 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)
index 617b0aa..c9f3898 100644 (file)
 #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
index 01d8df5..ce43996 100644 (file)
@@ -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.
 
 #endif
 
 #include <stddef.h>
-
-#if defined _LIBC || HAVE_STRING_H
-# include <string.h>
-#endif
+#include <string.h>
 
 #undef strpbrk
 
index 42ffcfa..dd46222 100644 (file)
@@ -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;
 
index 10edb5c..161f97a 100644 (file)
@@ -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.  */
index 555f2d5..4ce741c 100644 (file)
 # 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
index 13a8204..b3d0874 100644 (file)
 #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>
index 7b7f6f2..4f0792b 100644 (file)
 #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
index 19443ec..6e58b48 100644 (file)
 #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>
index 0ab75cc..fdd831f 100644 (file)
 #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
 
index 60ee91a..494571e 100644 (file)
@@ -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;
index f5cce16..e8c677b 100644 (file)
@@ -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
index cb1efa8..1182c59 100644 (file)
@@ -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
 # 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 *
index a1e819e..5addbf6 100644 (file)
@@ -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
    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;
 }
index 27afc40..b09a2fc 100644 (file)
@@ -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);