summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-08-18 09:44:49 +0000
committerJim Meyering <jim@meyering.net>2003-08-18 09:44:49 +0000
commitb1b4af8047b2d6c2b2ea0d552969e25f872da675 (patch)
treeee8166cbc3f75e901def92c7c94473473d360165
parent84a9ab5a07427ab8322424cd0c401e847326e7e2 (diff)
downloadcoreutils-b1b4af8047b2d6c2b2ea0d552969e25f872da675.tar.xz
Sync with gnulib.
-rw-r--r--lib/asnprintf.c17
-rw-r--r--lib/asprintf.c17
-rw-r--r--lib/backupfile.h4
-rw-r--r--lib/canon-host.c2
-rwxr-xr-xlib/config.charset17
-rw-r--r--lib/dirname.h4
-rw-r--r--lib/euidaccess.c34
-rw-r--r--lib/exclude.c40
-rw-r--r--lib/fsusage.h3
-rw-r--r--lib/full-write.c9
-rw-r--r--lib/getndelim2.h8
-rw-r--r--lib/getopt.h2
-rw-r--r--lib/gettext.h53
-rw-r--r--lib/group-member.h18
-rw-r--r--lib/hard-locale.h18
-rw-r--r--lib/hash-pjw.c7
-rw-r--r--lib/hash.c28
-rw-r--r--lib/hash.h4
-rw-r--r--lib/localcharset.c64
-rw-r--r--lib/localcharset.h41
-rw-r--r--lib/long-options.h2
-rw-r--r--lib/makepath.h21
-rw-r--r--lib/malloc.c2
-rw-r--r--lib/mbswidth.c2
-rw-r--r--lib/mbswidth.h1
-rw-r--r--lib/md5.h2
-rw-r--r--lib/memcasecmp.c19
-rw-r--r--lib/memcasecmp.h20
-rw-r--r--lib/memcoll.h20
-rw-r--r--lib/mkstemp.c21
-rw-r--r--lib/modechange.h2
-rw-r--r--lib/mountlist.h4
-rw-r--r--lib/path-concat.h20
-rw-r--r--lib/pathmax.h4
-rw-r--r--lib/physmem.h20
-rw-r--r--lib/posixtm.h21
-rw-r--r--lib/printf-args.c17
-rw-r--r--lib/printf-args.h17
-rw-r--r--lib/printf-parse.c17
-rw-r--r--lib/printf-parse.h17
-rw-r--r--lib/putenv.c2
-rw-r--r--lib/quote.h4
-rw-r--r--lib/readlink.c48
-rw-r--r--lib/readutmp.h7
-rw-r--r--lib/ref-add.sin17
-rw-r--r--lib/ref-del.sin17
-rw-r--r--lib/safe-read.c27
-rw-r--r--lib/savedir.h20
-rw-r--r--lib/setenv.c325
-rw-r--r--lib/stdbool_.h55
-rw-r--r--lib/strnlen.c11
-rw-r--r--lib/strpbrk.c2
-rw-r--r--lib/strtoimax.c2
-rw-r--r--lib/strverscmp.h18
-rw-r--r--lib/tempname.c2
-rw-r--r--lib/unicodeio.c38
-rw-r--r--lib/unicodeio.h36
-rw-r--r--lib/unistd-safer.h20
-rw-r--r--lib/unlocked-io.h17
-rw-r--r--lib/vasnprintf.h17
-rw-r--r--lib/vasprintf.c17
-rw-r--r--lib/version-etc.h4
-rw-r--r--lib/xgethostname.c2
-rw-r--r--lib/xmemcoll.c2
-rw-r--r--lib/xstrtoimax.c2
-rw-r--r--lib/xstrtoumax.c2
66 files changed, 954 insertions, 399 deletions
diff --git a/lib/asnprintf.c b/lib/asnprintf.c
index 8fb9d3c82..4881a9238 100644
--- a/lib/asnprintf.c
+++ b/lib/asnprintf.c
@@ -1,20 +1,19 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/lib/asprintf.c b/lib/asprintf.c
index a8e1bf899..5935c53e6 100644
--- a/lib/asprintf.c
+++ b/lib/asprintf.c
@@ -1,20 +1,19 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/lib/backupfile.h b/lib/backupfile.h
index 94c878ba1..fe5e1deb3 100644
--- a/lib/backupfile.h
+++ b/lib/backupfile.h
@@ -1,5 +1,7 @@
/* backupfile.h -- declarations for making Emacs style backup file names
- Copyright (C) 1990-1992, 1997-1999 Free Software Foundation, Inc.
+
+ Copyright (C) 1990, 1991, 1992, 1997, 1998, 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
diff --git a/lib/canon-host.c b/lib/canon-host.c
index 2025a7aa8..d2d0746c7 100644
--- a/lib/canon-host.c
+++ b/lib/canon-host.c
@@ -1,6 +1,6 @@
/* Host name canonicalization
- Copyright (C) 1995, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1999, 2000, 2002 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
diff --git a/lib/config.charset b/lib/config.charset
index 32becece9..6a6e2e168 100755
--- a/lib/config.charset
+++ b/lib/config.charset
@@ -3,20 +3,19 @@
#
# Copyright (C) 2000-2003 Free Software Foundation, Inc.
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Library General Public License as published
-# by the Free Software Foundation; either version 2, or (at your option)
+# 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
-# Library General Public License for more details.
+# 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 Library 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.
+# 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.
#
# The table consists of lines of the form
# ALIAS CANONICAL
diff --git a/lib/dirname.h b/lib/dirname.h
index 718365662..62da37dc9 100644
--- a/lib/dirname.h
+++ b/lib/dirname.h
@@ -1,4 +1,6 @@
-/* Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+/* Take file names apart into directory and base names.
+
+ Copyright (C) 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
diff --git a/lib/euidaccess.c b/lib/euidaccess.c
index 138c57a2b..16026c225 100644
--- a/lib/euidaccess.c
+++ b/lib/euidaccess.c
@@ -1,22 +1,23 @@
/* euidaccess -- check if effective user id can access file
- Copyright (C) 1990, 1991, 1995, 1998, 2000, 2003 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+ Copyright (C) 1990, 1991, 1995, 1998, 2000, 2003 Free Software
+ Foundation, Inc.
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+ This file is part of the GNU C Library.
-The GNU C Library 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
-Library General Public License for more details.
+ 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.
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place -
-Suite 330, Boston, MA 02111-1307, USA. */
+ 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. */
/* Written by David MacKenzie and Torbjorn Granlund.
Adapted for GNU C library by Roland McGrath. */
@@ -25,6 +26,10 @@ Suite 330, Boston, MA 02111-1307, USA. */
# include <config.h>
#endif
+#ifndef _LIBC
+# include "euidaccess.h"
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
@@ -69,7 +74,6 @@ extern int errno;
#ifndef __set_errno
# define __set_errno(val) errno = (val)
#endif
-#include "euidaccess.h"
#if defined(EACCES) && !defined(EACCESS)
# define EACCESS EACCES
diff --git a/lib/exclude.c b/lib/exclude.c
index 75042cbd8..7c038b23e 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -26,6 +26,7 @@
#include <stdbool.h>
+#include <ctype.h>
#include <errno.h>
#ifndef errno
extern int errno;
@@ -58,6 +59,18 @@ extern int errno;
# define SIZE_MAX ((size_t) -1)
#endif
+#if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
+# define IN_CTYPE_DOMAIN(c) true
+#else
+# define IN_CTYPE_DOMAIN(c) isascii (c)
+#endif
+
+static inline bool
+is_space (unsigned char c)
+{
+ return IN_CTYPE_DOMAIN (c) && isspace (c);
+}
+
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
@@ -208,8 +221,9 @@ add_exclude (struct exclude *ex, char const *pattern, int options)
}
/* Use ADD_FUNC to append to EX the patterns in FILENAME, each with
- OPTIONS. LINE_END terminates each pattern in the file. Return -1
- on failure, 0 on success. */
+ OPTIONS. LINE_END terminates each pattern in the file. If
+ LINE_END is a space character, ignore trailing spaces and empty
+ lines in FILE. Return -1 on failure, 0 on success. */
int
add_exclude_file (void (*add_func) (struct exclude *, char const *, int),
@@ -253,12 +267,28 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int),
e = errno;
buf = xrealloc (buf, buf_count + 1);
+ buf[buf_count] = line_end;
+ lim = buf + buf_count + ! (buf_count == 0 || buf[buf_count - 1] == line_end);
+ pattern = buf;
- for (pattern = p = buf, lim = buf + buf_count; p <= lim; p++)
- if (p < lim ? *p == line_end : buf < p && p[-1])
+ for (p = buf; p < lim; p++)
+ if (*p == line_end)
{
- *p = '\0';
+ char *pattern_end = p;
+
+ if (is_space (line_end))
+ {
+ for (; ; pattern_end--)
+ if (pattern_end == pattern)
+ goto next_pattern;
+ else if (! is_space (pattern_end[-1]))
+ break;
+ }
+
+ *pattern_end = '\0';
(*add_func) (ex, pattern, options);
+
+ next_pattern:
pattern = p + 1;
}
diff --git a/lib/fsusage.h b/lib/fsusage.h
index bc1522ec0..e2cbbf127 100644
--- a/lib/fsusage.h
+++ b/lib/fsusage.h
@@ -1,5 +1,6 @@
/* fsusage.h -- declarations for filesystem space usage info
- Copyright (C) 1991, 1992, 1997 Free Software Foundation, Inc.
+
+ Copyright (C) 1991, 1992, 1997, 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
diff --git a/lib/full-write.c b/lib/full-write.c
index d0b90a43f..151370563 100644
--- a/lib/full-write.c
+++ b/lib/full-write.c
@@ -20,20 +20,25 @@
# include <config.h>
#endif
+/* Specification. */
+#ifdef FULL_READ
+# include "full-read.h"
+#else
+# include "full-write.h"
+#endif
+
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#ifdef FULL_READ
-# include "full-read.h"
# include "safe-read.h"
# define safe_rw safe_read
# define full_rw full_read
# undef const
# define const /* empty */
#else
-# include "full-write.h"
# include "safe-write.h"
# define safe_rw safe_write
# define full_rw full_write
diff --git a/lib/getndelim2.h b/lib/getndelim2.h
index d964cd681..d9bafe3b4 100644
--- a/lib/getndelim2.h
+++ b/lib/getndelim2.h
@@ -18,13 +18,13 @@
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef GETNDELIM2_H
-# define GETNDELIM2_H 1
+#define GETNDELIM2_H 1
-# include <stddef.h>
-# include <stdio.h>
+#include <stddef.h>
+#include <stdio.h>
/* Get ssize_t. */
-# include <sys/types.h>
+#include <sys/types.h>
/* Read up to (and including) a delimiter DELIM1 from STREAM into *LINEPTR
+ OFFSET (and NUL-terminate it). If DELIM2 is non-zero, then read up
diff --git a/lib/getopt.h b/lib/getopt.h
index f344e7d0d..4d6adeea0 100644
--- a/lib/getopt.h
+++ b/lib/getopt.h
@@ -77,7 +77,7 @@ extern int optopt;
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
+ optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
diff --git a/lib/gettext.h b/lib/gettext.h
index 6d2d4f8ea..835732e01 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -1,31 +1,30 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifndef _LIBGETTEXT_H
-# define _LIBGETTEXT_H 1
+#define _LIBGETTEXT_H 1
/* NLS can be disabled through the configure --disable-nls option. */
-# if ENABLE_NLS
+#if ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
-# include <libintl.h>
+# include <libintl.h>
-# else
+#else
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
chokes if dcgettext is defined as a macro. So include it now, to make
@@ -33,29 +32,29 @@
as well because people using "gettext.h" will not include <libintl.h>,
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
is OK. */
-# if defined(__sun)
-# include <locale.h>
-# endif
+#if defined(__sun)
+# include <locale.h>
+#endif
/* Disabled NLS.
The casts to 'const char *' serve the purpose of producing warnings
for invalid uses of the value returned from these functions.
On pre-ANSI systems without 'const', the config.h file is supposed to
contain "#define const". */
-# define gettext(Msgid) ((const char *) (Msgid))
-# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
-# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
-# define ngettext(Msgid1, Msgid2, N) \
+# define gettext(Msgid) ((const char *) (Msgid))
+# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
+# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
+# define ngettext(Msgid1, Msgid2, N) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-# define dngettext(Domainname, Msgid1, Msgid2, N) \
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
-# define textdomain(Domainname) ((const char *) (Domainname))
-# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
-# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
+# define textdomain(Domainname) ((const char *) (Domainname))
+# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
+# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset))
-# endif
+#endif
/* A pseudo function call that serves as a marker for the automated
extraction of messages, but does not call gettext(). The run-time
@@ -64,6 +63,6 @@
and other string expressions won't work.
The macro's expansion is not parenthesized, so that it is suitable as
initializer for static 'char[]' or 'const char[]' variables. */
-# define gettext_noop(String) String
+#define gettext_noop(String) String
#endif /* _LIBGETTEXT_H */
diff --git a/lib/group-member.h b/lib/group-member.h
index 1787b103e..cc00333e6 100644
--- a/lib/group-member.h
+++ b/lib/group-member.h
@@ -1,3 +1,21 @@
+/* Determine whether group id is in calling user's group list.
+
+ Copyright (C) 1994, 1997, 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. */
+
#ifndef GROUP_MEMBER_H_
# define GROUP_MEMBER_H_ 1
diff --git a/lib/hard-locale.h b/lib/hard-locale.h
index f15e80966..ddc15d019 100644
--- a/lib/hard-locale.h
+++ b/lib/hard-locale.h
@@ -1,3 +1,21 @@
+/* Determine whether a locale is hard.
+
+ Copyright (C) 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
+ 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. */
+
#ifndef HARD_LOCALE_H_
# define HARD_LOCALE_H_ 1
diff --git a/lib/hash-pjw.c b/lib/hash-pjw.c
index 141b08b51..0a14b3e7a 100644
--- a/lib/hash-pjw.c
+++ b/lib/hash-pjw.c
@@ -1,5 +1,5 @@
/* hash-pjw.c -- compute a hash value from a NUL-terminated string.
- Copyright 2001 Free Software Foundation, Inc.
+ Copyright 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
@@ -22,7 +22,10 @@
#include "hash-pjw.h"
/* A hash function for NUL-terminated char* strings using
- the method described in Aho, Sethi, & Ullman, p 436. */
+ the method described in Aho, Sethi, & Ullman, p 436.
+ Note that this hash function produces a lot of collisions when used
+ with short strings with very varied bit patterns.
+ See http://www.haible.de/bruno/hashfunc.html. */
unsigned int
hash_pjw (const void *x, unsigned int tablesize)
diff --git a/lib/hash.c b/lib/hash.c
index 0bbe09596..7373a011c 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -34,7 +34,6 @@
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
-#include <assert.h>
#ifndef HAVE_DECL_FREE
"this configure-time declaration test was not run"
@@ -264,7 +263,8 @@ hash_lookup (const Hash_table *table, const void *entry)
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- assert (bucket < table->bucket_limit);
+ if (! (bucket < table->bucket_limit))
+ abort ();
if (bucket->data == NULL)
return NULL;
@@ -293,12 +293,11 @@ hash_get_first (const Hash_table *table)
if (table->n_entries == 0)
return NULL;
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- if (bucket->data)
+ for (bucket = table->bucket; ; bucket++)
+ if (! (bucket < table->bucket_limit))
+ abort ();
+ else if (bucket->data)
return bucket->data;
-
- assert (0);
- return NULL;
}
/* Return the user data for the entry following ENTRY, where ENTRY has been
@@ -312,7 +311,8 @@ hash_get_next (const Hash_table *table, const void *entry)
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- assert (bucket < table->bucket_limit);
+ if (! (bucket < table->bucket_limit))
+ abort ();
/* Find next entry in the same bucket. */
for (cursor = bucket; cursor; cursor = cursor->next)
@@ -752,7 +752,9 @@ hash_find_entry (Hash_table *table, const void *entry,
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- assert (bucket < table->bucket_limit);
+ if (! (bucket < table->bucket_limit))
+ abort ();
+
*bucket_head = bucket;
/* Test for empty bucket. */
@@ -846,7 +848,9 @@ hash_rehash (Hash_table *table, unsigned candidate)
= (new_table->bucket
+ new_table->hasher (data, new_table->n_buckets));
- assert (new_bucket < new_table->bucket_limit);
+ if (! (new_bucket < new_table->bucket_limit))
+ abort ();
+
next = cursor->next;
if (new_bucket->data)
@@ -910,7 +914,9 @@ hash_insert (Hash_table *table, const void *entry)
void *data;
struct hash_entry *bucket;
- assert (entry); /* cannot insert a NULL entry */
+ /* The caller cannot insert a NULL entry. */
+ if (! entry)
+ abort ();
/* If there's a matching entry already in the table, return that. */
if ((data = hash_find_entry (table, entry, &bucket, false)) != NULL)
diff --git a/lib/hash.h b/lib/hash.h
index 9a3647bbd..77e76d085 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -1,5 +1,5 @@
/* hash - hashing table processing.
- Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2003 Free Software Foundation, Inc.
Written by Jim Meyering <meyering@ascend.com>, 1998.
This program is free software; you can redistribute it and/or modify
@@ -24,6 +24,8 @@
#ifndef HASH_H_
# define HASH_H_
+# include <stdio.h>
+
typedef unsigned (*Hash_hasher) (const void *, unsigned);
typedef bool (*Hash_comparator) (const void *, const void *);
typedef void (*Hash_data_freer) (void *);
diff --git a/lib/localcharset.c b/lib/localcharset.c
index 2b1564e2f..eb5563df4 100644
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -1,21 +1,20 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
/* Written by Bruno Haible <bruno@clisp.org>. */
@@ -23,6 +22,9 @@
# include <config.h>
#endif
+/* Specification. */
+#include "localcharset.h"
+
#if HAVE_STDDEF_H
# include <stddef.h>
#endif
@@ -64,6 +66,12 @@
# include <os2.h>
#endif
+#if ENABLE_RELOCATABLE
+# include "relocatable.h"
+#else
+# define relocate(pathname) (pathname)
+#endif
+
#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
/* Win32, OS/2, DOS */
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
@@ -82,11 +90,6 @@
# define getc getc_unlocked
#endif
-#ifdef __cplusplus
-/* When compiling with "gcc -x c++", produce a function with C linkage. */
-extern "C" const char * locale_charset (void);
-#endif
-
/* The following static variable is declared 'volatile' to avoid a
possible multithread problem in the function get_charset_aliases. If we
are running in a threaded environment, and if two threads initialize
@@ -110,9 +113,9 @@ get_charset_aliases ()
cp = charset_aliases;
if (cp == NULL)
{
-#if !defined WIN32
+#if !(defined VMS || defined WIN32)
FILE *fp;
- const char *dir = LIBDIR;
+ const char *dir = relocate (LIBDIR);
const char *base = "charset.alias";
char *file_name;
@@ -200,11 +203,36 @@ get_charset_aliases ()
#else
+# if defined VMS
+ /* To avoid the troubles of an extra file charset.alias_vms in the
+ sources of many GNU packages, simply inline the aliases here. */
+ /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
+ "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
+ section 10.7 "Handling Different Character Sets". */
+ cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
+ "ISO8859-2" "\0" "ISO-8859-2" "\0"
+ "ISO8859-5" "\0" "ISO-8859-5" "\0"
+ "ISO8859-7" "\0" "ISO-8859-7" "\0"
+ "ISO8859-8" "\0" "ISO-8859-8" "\0"
+ "ISO8859-9" "\0" "ISO-8859-9" "\0"
+ /* Japanese */
+ "eucJP" "\0" "EUC-JP" "\0"
+ "SJIS" "\0" "SHIFT_JIS" "\0"
+ "DECKANJI" "\0" "DEC-KANJI" "\0"
+ "SDECKANJI" "\0" "EUC-JP" "\0"
+ /* Chinese */
+ "eucTW" "\0" "EUC-TW" "\0"
+ "DECHANYU" "\0" "DEC-HANYU" "\0"
+ "DECHANZI" "\0" "GB2312" "\0"
+ /* Korean */
+ "DECKOREAN" "\0" "EUC-KR" "\0";
+# endif
+
+# if defined WIN32
/* To avoid the troubles of installing a separate file in the same
directory as the DLL and of retrieving the DLL's directory at
runtime, simply inline the aliases here. */
-# if defined WIN32
cp = "CP936" "\0" "GBK" "\0"
"CP1361" "\0" "JOHAB" "\0"
"CP20127" "\0" "ASCII" "\0"
diff --git a/lib/localcharset.h b/lib/localcharset.h
new file mode 100644
index 000000000..5058c8436
--- /dev/null
+++ b/lib/localcharset.h
@@ -0,0 +1,41 @@
+/* Determine a canonical name for the current locale's character encoding.
+ Copyright (C) 2000-2003 Free Software Foundation, Inc.
+ This file is part of the GNU CHARSET Library.
+
+ 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. */
+
+#ifndef _LOCALCHARSET_H
+#define _LOCALCHARSET_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Determine the current locale's character encoding, and canonicalize it
+ into one of the canonical names listed in config.charset.
+ The result must not be freed; it is statically allocated.
+ If the canonical name cannot be determined, the result is a non-canonical
+ name. */
+extern const char * locale_charset (void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _LOCALCHARSET_H */
diff --git a/lib/long-options.h b/lib/long-options.h
index 6e12882bb..e89b3512d 100644
--- a/lib/long-options.h
+++ b/lib/long-options.h
@@ -1,5 +1,5 @@
/* long-options.h -- declaration for --help- and --version-handling function.
- Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1998, 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
diff --git a/lib/makepath.h b/lib/makepath.h
index 6c66ce714..487dba615 100644
--- a/lib/makepath.h
+++ b/lib/makepath.h
@@ -1,3 +1,24 @@
+/* makepath.c -- Ensure that a directory path exists.
+
+ Copyright (C) 1994, 1995, 1996, 1997, 2000, 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. */
+
+/* Written by David MacKenzie <djm@gnu.ai.mit.edu> and Jim Meyering. */
+
int make_path (const char *_argpath,
int _mode,
int _parent_mode,
diff --git a/lib/malloc.c b/lib/malloc.c
index 5e7674bd4..bcd6b564b 100644
--- a/lib/malloc.c
+++ b/lib/malloc.c
@@ -22,7 +22,7 @@
#endif
#undef malloc
-#include <sys/types.h>
+#include <stddef.h>
char *malloc ();
diff --git a/lib/mbswidth.c b/lib/mbswidth.c
index a2ef5b3fd..c6f91db97 100644
--- a/lib/mbswidth.c
+++ b/lib/mbswidth.c
@@ -75,7 +75,7 @@ int wcwidth ();
#else
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
-/* Undefine to protect against the definition in wctype.h of solaris2.6. */
+/* Undefine to protect against the definition in wctype.h of Solaris 2.6. */
#undef ISPRINT
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#undef ISCNTRL
diff --git a/lib/mbswidth.h b/lib/mbswidth.h
index b3646ea2d..cd41c9f20 100644
--- a/lib/mbswidth.h
+++ b/lib/mbswidth.h
@@ -36,6 +36,7 @@
control characters and 1 otherwise. */
#define MBSW_REJECT_UNPRINTABLE 2
+
/* Returns the number of screen columns needed for STRING. */
#define mbswidth gnu_mbswidth /* avoid clash with UnixWare 7.1.1 function */
extern int mbswidth (const char *string, int flags);
diff --git a/lib/md5.h b/lib/md5.h
index 0d22a70a2..fda0ba4ed 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -1,6 +1,6 @@
/* md5.h - Declaration of functions and data types used for MD5 sum
computing library functions.
- Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1999, 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.
diff --git a/lib/memcasecmp.c b/lib/memcasecmp.c
index 523213113..7cb427234 100644
--- a/lib/memcasecmp.c
+++ b/lib/memcasecmp.c
@@ -23,10 +23,10 @@
#include <ctype.h>
-#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
+#if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
# define IN_CTYPE_DOMAIN(Char) 1
#else
-# define IN_CTYPE_DOMAIN(Char) isascii(Char)
+# define IN_CTYPE_DOMAIN(Char) isascii (Char)
#endif
#define ISLOWER(Char) (IN_CTYPE_DOMAIN (Char) && islower (Char))
@@ -45,15 +45,16 @@
int
memcasecmp (const void *vs1, const void *vs2, size_t n)
{
- unsigned int i;
- unsigned char const *s1 = (unsigned char const *) vs1;
- unsigned char const *s2 = (unsigned char const *) vs2;
+ size_t i;
+ char const *s1 = vs1;
+ char const *s2 = vs2;
for (i = 0; i < n; i++)
{
- unsigned char u1 = *s1++;
- unsigned char u2 = *s2++;
- if (TOUPPER (u1) != TOUPPER (u2))
- return TOUPPER (u1) - TOUPPER (u2);
+ unsigned char u1 = s1[i];
+ unsigned char u2 = s2[i];
+ int diff = TOUPPER (u1) - TOUPPER (u2);
+ if (diff)
+ return diff;
}
return 0;
}
diff --git a/lib/memcasecmp.h b/lib/memcasecmp.h
index 96eb2d9d5..ed99244c6 100644
--- a/lib/memcasecmp.h
+++ b/lib/memcasecmp.h
@@ -1,3 +1,23 @@
+/* Case-insensitive buffer comparator.
+
+ Copyright (C) 1996, 1998, 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. */
+
+/* Written by Jim Meyering. */
+
#include <stddef.h>
int memcasecmp (const void *vs1, const void *vs2, size_t n);
diff --git a/lib/memcoll.h b/lib/memcoll.h
index 33f1e4940..66b2ecb1e 100644
--- a/lib/memcoll.h
+++ b/lib/memcoll.h
@@ -1,3 +1,23 @@
+/* Locale-specific memory comparison.
+
+ Copyright (C) 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
+ 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. */
+
+/* Contributed by Paul Eggert <eggert@twinsun.com>. */
+
#ifndef MEMCOLL_H_
# define MEMCOLL_H_ 1
diff --git a/lib/mkstemp.c b/lib/mkstemp.c
index 9d6c68a99..f6312b646 100644
--- a/lib/mkstemp.c
+++ b/lib/mkstemp.c
@@ -1,20 +1,19 @@
/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
This file is derived from the one in the GNU C Library.
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ 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.
- The GNU C Library is distributed in the hope that it will be useful,
+ 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
- Library General Public License for more details.
+ 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 Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ 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 <config.h>
diff --git a/lib/modechange.h b/lib/modechange.h
index 2e2e3ed5c..be2afa45c 100644
--- a/lib/modechange.h
+++ b/lib/modechange.h
@@ -1,5 +1,5 @@
/* modechange.h -- definitions for file mode manipulation
- Copyright (C) 1989, 1990, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1989, 1990, 1997, 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
diff --git a/lib/mountlist.h b/lib/mountlist.h
index 0eb295186..71fc9c25d 100644
--- a/lib/mountlist.h
+++ b/lib/mountlist.h
@@ -1,5 +1,7 @@
/* mountlist.h -- declarations for list of mounted filesystems
- Copyright (C) 1991, 1992, 1998, 2000-2002 Free Software Foundation, Inc.
+
+ Copyright (C) 1991, 1992, 1998, 2000, 2001, 2002, 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
diff --git a/lib/path-concat.h b/lib/path-concat.h
index c028f4a08..94fc35726 100644
--- a/lib/path-concat.h
+++ b/lib/path-concat.h
@@ -1,3 +1,23 @@
+/* Concatenate two arbitrary pathnames.
+
+ Copyright (C) 1996, 1997, 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. */
+
+/* Written by Jim Meyering. */
+
#if ! defined PATH_CONCAT_H_
# define PATH_CONCAT_H_
diff --git a/lib/pathmax.h b/lib/pathmax.h
index de9313b0a..bdd756e9c 100644
--- a/lib/pathmax.h
+++ b/lib/pathmax.h
@@ -1,5 +1,5 @@
/* Define PATH_MAX somehow. Requires sys/types.h.
- Copyright (C) 1992, 1999, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1999, 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
@@ -25,7 +25,7 @@
/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define
PATH_MAX but might cause redefinition warnings when sys/param.h is
later included (as on MORE/BSD 4.3). */
-# if defined _POSIX_VERSION || (defined HAVE_LIMITS_H && !defined __GNUC__)
+# if defined _POSIX_VERSION || !defined __GNUC__
# include <limits.h>
# endif
diff --git a/lib/physmem.h b/lib/physmem.h
index e0411c58c..67f880c9a 100644
--- a/lib/physmem.h
+++ b/lib/physmem.h
@@ -1,3 +1,23 @@
+/* Calculate the size of physical memory.
+
+ Copyright (C) 2000, 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. */
+
+/* Written by Paul Eggert. */
+
#ifndef PHYSMEM_H_
# define PHYSMEM_H_ 1
diff --git a/lib/posixtm.h b/lib/posixtm.h
index 1105478b9..4e9e8992d 100644
--- a/lib/posixtm.h
+++ b/lib/posixtm.h
@@ -1,3 +1,24 @@
+/* Parse dates for touch and date.
+
+ Copyright (C) 1998, 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. */
+
+/* Yacc-based version written by Jim Kingdon and David MacKenzie.
+ Rewritten by Jim Meyering. */
+
#ifndef POSIXTM_H_
# define POSIXTM_H_
diff --git a/lib/printf-args.c b/lib/printf-args.c
index f39197402..6972cfd42 100644
--- a/lib/printf-args.c
+++ b/lib/printf-args.c
@@ -1,20 +1,19 @@
/* Decomposed printf argument list.
Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/lib/printf-args.h b/lib/printf-args.h
index 35114a8fa..c938192b7 100644
--- a/lib/printf-args.h
+++ b/lib/printf-args.h
@@ -1,20 +1,19 @@
/* Decomposed printf argument list.
Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifndef _PRINTF_ARGS_H
#define _PRINTF_ARGS_H
diff --git a/lib/printf-parse.c b/lib/printf-parse.c
index bdfe88fe8..51b08bbb0 100644
--- a/lib/printf-parse.c
+++ b/lib/printf-parse.c
@@ -1,20 +1,19 @@
/* Formatted output to strings.
Copyright (C) 1999-2000, 2002-2003 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/lib/printf-parse.h b/lib/printf-parse.h
index 97e432af1..54b429f12 100644
--- a/lib/printf-parse.h
+++ b/lib/printf-parse.h
@@ -1,20 +1,19 @@
/* Parse printf format string.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifndef _PRINTF_PARSE_H
#define _PRINTF_PARSE_H
diff --git a/lib/putenv.c b/lib/putenv.c
index c2a9aad2a..f5ce1dd88 100644
--- a/lib/putenv.c
+++ b/lib/putenv.c
@@ -33,7 +33,7 @@ extern int errno;
# define __set_errno(ev) ((errno) = (ev))
#endif
-/* Don't include stdlib.h because some (e.g., Solaris 5.7) declare putenv
+/* Don't include stdlib.h because some (e.g., Solaris 7) declare putenv
with a non-const argument. That would conflict with the declaration of
rpl_putenv below (due to the #define putenv rpl_putenv from config.h). */
diff --git a/lib/quote.h b/lib/quote.h
index 058e6b55c..682f9d1fd 100644
--- a/lib/quote.h
+++ b/lib/quote.h
@@ -1,5 +1,7 @@
/* quote.h - prototypes for quote.c
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+ Copyright (C) 1998, 1999, 2000, 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
diff --git a/lib/readlink.c b/lib/readlink.c
new file mode 100644
index 000000000..c264efd8c
--- /dev/null
+++ b/lib/readlink.c
@@ -0,0 +1,48 @@
+/* Stub for readlink().
+ 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. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if !HAVE_READLINK
+
+/* readlink() substitute for systems that don't have a readlink() function,
+ such as DJGPP 2.03 and mingw32. */
+
+/* The official POSIX return type of readlink() is ssize_t, but since here
+ we have no declaration in a public header file, we use 'int' as return
+ type. */
+
+int
+readlink (const char *path, char *buf, size_t bufsize)
+{
+ struct stat statbuf;
+
+ /* In general we should use lstat() here, not stat(). But on platforms
+ without symbolic links lstat() - if it exists - would be equivalent to
+ stat(), therefore we can use stat(). This saves us a configure check. */
+ if (stat (path, &statbuf) >= 0)
+ errno = EINVAL;
+ return -1;
+}
+
+#endif
diff --git a/lib/readutmp.h b/lib/readutmp.h
index d17860154..be59fe994 100644
--- a/lib/readutmp.h
+++ b/lib/readutmp.h
@@ -1,5 +1,7 @@
/* Declarations for GNU's read utmp module.
- Copyright (C) 1992-2002 Free Software Foundation, Inc.
+
+ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+ 2001, 2002, 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
@@ -24,7 +26,8 @@
/* AIX 4.3.3 has both utmp.h and utmpx.h, but only struct utmp
has the ut_exit member. */
-# if HAVE_UTMPX_H && HAVE_UTMP_H && HAVE_STRUCT_UTMP_UT_EXIT && ! HAVE_STRUCT_UTMPX_UT_EXIT
+# if (HAVE_UTMPX_H && HAVE_UTMP_H && HAVE_STRUCT_UTMP_UT_EXIT \
+ && ! HAVE_STRUCT_UTMPX_UT_EXIT)
# undef HAVE_UTMPX_H
# endif
diff --git a/lib/ref-add.sin b/lib/ref-add.sin
index 167374e3c..912c4af6d 100644
--- a/lib/ref-add.sin
+++ b/lib/ref-add.sin
@@ -2,20 +2,19 @@
#
# Copyright (C) 2000 Free Software Foundation, Inc.
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Library General Public License as published
-# by the Free Software Foundation; either version 2, or (at your option)
+# 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
-# Library General Public License for more details.
+# 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 Library 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.
+# 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.
#
# Written by Bruno Haible <haible@clisp.cons.org>.
#
diff --git a/lib/ref-del.sin b/lib/ref-del.sin
index 613cf37f3..5cc1577d1 100644
--- a/lib/ref-del.sin
+++ b/lib/ref-del.sin
@@ -2,20 +2,19 @@
#
# Copyright (C) 2000 Free Software Foundation, Inc.
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Library General Public License as published
-# by the Free Software Foundation; either version 2, or (at your option)
+# 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
-# Library General Public License for more details.
+# 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 Library 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.
+# 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.
#
# Written by Bruno Haible <haible@clisp.cons.org>.
#
diff --git a/lib/safe-read.c b/lib/safe-read.c
index c36f6e824..c21d1cf19 100644
--- a/lib/safe-read.c
+++ b/lib/safe-read.c
@@ -1,5 +1,5 @@
/* An interface to read and write that retries after interrupts.
- Copyright (C) 1993, 1994, 1998, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1998, 2002-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,6 +19,13 @@
# include <config.h>
#endif
+/* Specification. */
+#ifdef SAFE_WRITE
+# include "safe-write.h"
+#else
+# include "safe-read.h"
+#endif
+
/* Get ssize_t. */
#include <sys/types.h>
#if HAVE_UNISTD_H
@@ -38,28 +45,10 @@ extern int errno;
#include <limits.h>
-#ifndef CHAR_BIT
-# define CHAR_BIT 8
-#endif
-
-/* The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
-#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
-#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
-
-#ifndef INT_MAX
-# define INT_MAX TYPE_MAXIMUM (int)
-#endif
-
#ifdef SAFE_WRITE
-# include "safe-write.h"
# define safe_rw safe_write
# define rw write
#else
-# include "safe-read.h"
# define safe_rw safe_read
# define rw read
# undef const
diff --git a/lib/savedir.h b/lib/savedir.h
index c99b1a8ee..bd3308521 100644
--- a/lib/savedir.h
+++ b/lib/savedir.h
@@ -1,3 +1,23 @@
+/* Save the list of files in a directory in a string.
+
+ Copyright 1997, 1999, 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
+ 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. */
+
+/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
+
#if !defined SAVEDIR_H_
# define SAVEDIR_H_
diff --git a/lib/setenv.c b/lib/setenv.c
index 66b6a6427..04073caa0 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -1,30 +1,28 @@
-/* Copyright (C) 1992, 1995, 2000, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1992,1995-1999,2000-2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-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.
+ 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 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.
-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. */
-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. */
-
-#ifdef HAVE_CONFIG_H
+#if HAVE_CONFIG_H
# include <config.h>
#endif
+#include <alloca.h>
#include <errno.h>
#if !_LIBC
-# if !defined errno
+# if !defined errno && !defined HAVE_ERRNO_DECL
extern int errno;
# endif
# define __set_errno(ev) ((errno) = (ev))
@@ -40,8 +38,20 @@ extern int errno;
# include <unistd.h>
#endif
-#ifndef HAVE_GNU_LD
+/* For those losing systems which don't have 'alloca' we have to add
+ some additional code emulating it. */
+#if _LIBC || HAVE_ALLOCA
+# define freea(p) /* nothing */
+#else
+# define alloca(n) malloc (n)
+# define freea(p) free (p)
+#endif
+
+#if !_LIBC
# define __environ environ
+# ifndef HAVE_ENVIRON_DECL
+extern char **environ;
+# endif
#endif
#if _LIBC
@@ -55,117 +65,260 @@ __libc_lock_define_initialized (static, envlock)
# define UNLOCK
#endif
+/* In the GNU C library we must keep the namespace clean. */
+#ifdef _LIBC
+# define setenv __setenv
+# define clearenv __clearenv
+# define tfind __tfind
+# define tsearch __tsearch
+#endif
+
+/* In the GNU C library implementation we try to be more clever and
+ allow arbitrarily many changes of the environment given that the used
+ values are from a small set. Outside glibc this will eat up all
+ memory after a while. */
+#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \
+ && defined __GNUC__)
+# define USE_TSEARCH 1
+# include <search.h>
+typedef int (*compar_fn_t) (const void *, const void *);
+
+/* This is a pointer to the root of the search tree with the known
+ values. */
+static void *known_values;
+
+# define KNOWN_VALUE(Str) \
+ ({ \
+ void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \
+ value != NULL ? *(char **) value : NULL; \
+ })
+# define STORE_VALUE(Str) \
+ tsearch (Str, &known_values, (compar_fn_t) strcmp)
+
+#else
+# undef USE_TSEARCH
+
+# define KNOWN_VALUE(Str) NULL
+# define STORE_VALUE(Str) do { } while (0)
+
+#endif
+
+
+/* If this variable is not a null pointer we allocated the current
+ environment. */
+static char **last_environ;
+
+
+/* This function is used by `setenv' and `putenv'. The difference between
+ the two functions is that for the former must create a new string which
+ is then placed in the environment, while the argument of `putenv'
+ must be used directly. This is all complicated by the fact that we try
+ to reuse values once generated for a `setenv' call since we can never
+ free the strings. */
int
-setenv (name, value, replace)
- const char *name;
- const char *value;
- int replace;
+__add_to_environ (const char *name, const char *value, const char *combined,
+ int replace)
{
register char **ep;
register size_t size;
const size_t namelen = strlen (name);
- const size_t vallen = strlen (value) + 1;
+ const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
+
+ LOCK;
+
+ /* We have to get the pointer now that we have the lock and not earlier
+ since another thread might have created a new environment. */
+ ep = __environ;
size = 0;
- for (ep = __environ; *ep != NULL; ++ep)
- if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
- break;
- else
- ++size;
+ if (ep != NULL)
+ {
+ for (; *ep != NULL; ++ep)
+ if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
+ break;
+ else
+ ++size;
+ }
- if (*ep == NULL)
+ if (ep == NULL || *ep == NULL)
{
- static char **last_environ;
char **new_environ;
- if (__environ == last_environ)
- /* We allocated this space; we can extend it. */
- new_environ = (char **) realloc (last_environ,
- (size + 2) * sizeof (char *));
- else
- new_environ = (char **) malloc ((size + 2) * sizeof (char *));
+#ifdef USE_TSEARCH
+ char *new_value;
+#endif
+ /* We allocated this space; we can extend it. */
+ new_environ =
+ (char **) (last_environ == NULL
+ ? malloc ((size + 2) * sizeof (char *))
+ : realloc (last_environ, (size + 2) * sizeof (char *)));
if (new_environ == NULL)
- return -1;
-
- new_environ[size] = malloc (namelen + 1 + vallen);
- if (new_environ[size] == NULL)
{
- free (new_environ);
- errno = ENOMEM;
+ UNLOCK;
return -1;
}
+ /* If the whole entry is given add it. */
+ if (combined != NULL)
+ /* We must not add the string to the search tree since it belongs
+ to the user. */
+ new_environ[size] = (char *) combined;
+ else
+ {
+ /* See whether the value is already known. */
+#ifdef USE_TSEARCH
+ new_value = (char *) alloca (namelen + 1 + vallen);
+# ifdef _LIBC
+ __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
+ value, vallen);
+# else
+ memcpy (new_value, name, namelen);
+ new_value[namelen] = '=';
+ memcpy (&new_value[namelen + 1], value, vallen);
+# endif
+
+ new_environ[size] = KNOWN_VALUE (new_value);
+ if (new_environ[size] == NULL)
+#endif
+ {
+ new_environ[size] = (char *) malloc (namelen + 1 + vallen);
+ if (new_environ[size] == NULL)
+ {
+#ifdef USE_TSEARCH
+ freea (new_value);
+#endif
+ __set_errno (ENOMEM);
+ UNLOCK;
+ return -1;
+ }
+
+#ifdef USE_TSEARCH
+ memcpy (new_environ[size], new_value, namelen + 1 + vallen);
+#else
+ memcpy (new_environ[size], name, namelen);
+ new_environ[size][namelen] = '=';
+ memcpy (&new_environ[size][namelen + 1], value, vallen);
+#endif
+ /* And save the value now. We cannot do this when we remove
+ the string since then we cannot decide whether it is a
+ user string or not. */
+ STORE_VALUE (new_environ[size]);
+ }
+#ifdef USE_TSEARCH
+ freea (new_value);
+#endif
+ }
+
if (__environ != last_environ)
memcpy ((char *) new_environ, (char *) __environ,
size * sizeof (char *));
- memcpy (new_environ[size], name, namelen);
- new_environ[size][namelen] = '=';
- memcpy (&new_environ[size][namelen + 1], value, vallen);
-
new_environ[size + 1] = NULL;
last_environ = __environ = new_environ;
}
else if (replace)
{
- size_t len = strlen (*ep);
- if (len + 1 < namelen + 1 + vallen)
+ char *np;
+
+ /* Use the user string if given. */
+ if (combined != NULL)
+ np = (char *) combined;
+ else
{
- /* The existing string is too short; malloc a new one. */
- char *new = malloc (namelen + 1 + vallen);
- if (new == NULL)
- return -1;
- *ep = new;
+#ifdef USE_TSEARCH
+ char *new_value = alloca (namelen + 1 + vallen);
+# ifdef _LIBC
+ __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
+ value, vallen);
+# else
+ memcpy (new_value, name, namelen);
+ new_value[namelen] = '=';
+ memcpy (&new_value[namelen + 1], value, vallen);
+# endif
+
+ np = KNOWN_VALUE (new_value);
+ if (np == NULL)
+#endif
+ {
+ np = malloc (namelen + 1 + vallen);
+ if (np == NULL)
+ {
+#ifdef USE_TSEARCH
+ freea (new_value);
+#endif
+ UNLOCK;
+ return -1;
+ }
+
+#ifdef USE_TSEARCH
+ memcpy (np, new_value, namelen + 1 + vallen);
+#else
+ memcpy (np, name, namelen);
+ np[namelen] = '=';
+ memcpy (&np[namelen + 1], value, vallen);
+#endif
+ /* And remember the value. */
+ STORE_VALUE (np);
+ }
+#ifdef USE_TSEARCH
+ freea (new_value);
+#endif
}
- memcpy (*ep, name, namelen);
- (*ep)[namelen] = '=';
- memcpy (&(*ep)[namelen + 1], value, vallen);
+
+ *ep = np;
}
+ UNLOCK;
+
return 0;
}
-/* WARNING: This function is not used by setenv-related code.
- But it *is* used by putenv.c, so elide the code below.
- Instead, use the static copy of the function that's in putenv.c. */
-#if 0
+int
+setenv (const char *name, const char *value, int replace)
+{
+ return __add_to_environ (name, value, NULL, replace);
+}
+/* The `clearenv' was planned to be added to POSIX.1 but probably
+ never made it. Nevertheless the POSIX.9 standard (POSIX bindings
+ for Fortran 77) requires this function. */
int
-unsetenv (name)
- const char *name;
+clearenv ()
{
- size_t len;
- char **ep;
+ LOCK;
- if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
+ if (__environ == last_environ && __environ != NULL)
{
- __set_errno (EINVAL);
- return -1;
+ /* We allocated this environment so we can free it. */
+ free (__environ);
+ last_environ = NULL;
}
- len = strlen (name);
-
- LOCK;
-
- ep = __environ;
- while (*ep != NULL)
- if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
- {
- /* Found it. Remove this pointer by moving later ones back. */
- char **dp = ep;
-
- do
- dp[0] = dp[1];
- while (*dp++);
- /* Continue the loop in case NAME appears again. */
- }
- else
- ++ep;
+ /* Clear the environment pointer removes the whole environment. */
+ __environ = NULL;
UNLOCK;
return 0;
}
+#ifdef _LIBC
+static void
+free_mem (void)
+{
+ /* Remove all traces. */
+ clearenv ();
+
+ /* Now remove the search tree. */
+ __tdestroy (known_values, free);
+ known_values = NULL;
+}
+text_set_element (__libc_subfreeres, free_mem);
+
+
+# undef setenv
+# undef clearenv
+weak_alias (__setenv, setenv)
+weak_alias (__clearenv, clearenv)
#endif
diff --git a/lib/stdbool_.h b/lib/stdbool_.h
index c29958d4a..3dbb51b24 100644
--- a/lib/stdbool_.h
+++ b/lib/stdbool_.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2003 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
@@ -20,6 +20,37 @@
/* ISO C 99 <stdbool.h> for platforms that lack it. */
+/* Usage suggestions:
+
+ Programs that use <stdbool.h> should be aware of some limitations
+ and standards compliance issues.
+
+ Standards compliance:
+
+ - <stdbool.h> must be #included before 'bool', 'false', 'true'
+ can be used.
+
+ - You cannot assume that sizeof (bool) == 1.
+
+ - Programs should not undefine the macros bool, true, and false,
+ as C99 lists that as an "obsolescent feature".
+
+ Limitations of this substitute, when used in a C89 environment:
+
+ - <stdbool.h> must be #included before the '_Bool' type can be used.
+
+ - You cannot assume that _Bool is a typedef; it might be a macro.
+
+ - In C99, casts and automatic conversions to '_Bool' or 'bool' are
+ performed in such a way that every nonzero value gets converted
+ to 'true', and zero gets converted to 'false'. This doesn't work
+ with this substitute. With this substitute, only the values 0 and 1
+ give the expected result when converted to _Bool' or 'bool'.
+
+ Also, it is suggested that programs use 'bool' rather than '_Bool';
+ this isn't required, but 'bool' is more common. */
+
+
/* 7.16. Boolean type and values */
/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
@@ -29,16 +60,24 @@
# undef true
#endif
-/* For the sake of symbolic names in gdb, define true and false as
- enum constants. However, do not define _Bool as the enum type,
- since the enum type might be compatible with unsigned int, whereas
- _Bool must promote to int. Also, make _Bool a macro rather than a
- typedef, to suppress warnings by the Sun Forte Developer 7 C
- compiler that _Bool is a keyword in ISO C99. */
+/* For the sake of symbolic names in gdb, we define true and false as
+ enum constants, not only as macros.
+ It is tempting to write
+ typedef enum { false = 0, true = 1 } _Bool;
+ so that gdb prints values of type 'bool' symbolically. But if we do
+ this, values of type '_Bool' may promote to 'int' or 'unsigned int'
+ (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
+ (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
+ enum; this ensures that '_Bool' promotes to 'int'. */
#ifndef __cplusplus
# if !@HAVE__BOOL@
+# if defined __SUNPRO_C && (__SUNPRO_C < 0x550 || __STDC__ == 1)
+ /* Avoid stupid "warning: _Bool is a keyword in ISO C99". */
+# define _Bool signed char
enum { false = 0, true = 1 };
-# define _Bool signed char
+# else
+typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
+# endif
# endif
#else
typedef bool _Bool;
diff --git a/lib/strnlen.c b/lib/strnlen.c
index f4a5b454f..617b0aa18 100644
--- a/lib/strnlen.c
+++ b/lib/strnlen.c
@@ -1,5 +1,5 @@
/* Find the length of STRING, but scan at most MAXLEN characters.
- Copyright (C) 1996, 1997, 1998, 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 2000-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,16 +19,13 @@
#if HAVE_CONFIG_H
# include <config.h>
#endif
+#undef strnlen
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
# include <memory.h>
# endif
-/* Temporarily redefine strnlen so that an inconsistent prototype
- (on at least AIX4.3.2.0 w/gcc-2.95.3) doesn't cause trouble. */
-# define strnlen system_strnlen
# include <string.h>
-# undef strnlen
#else
# include <strings.h>
#endif
@@ -43,6 +40,10 @@ char *memchr ();
#undef __strnlen
#undef strnlen
+#ifndef _LIBC
+# define strnlen rpl_strnlen
+#endif
+
#ifndef weak_alias
# define __strnlen strnlen
#endif
diff --git a/lib/strpbrk.c b/lib/strpbrk.c
index 84e4a0273..01d8df5a8 100644
--- a/lib/strpbrk.c
+++ b/lib/strpbrk.c
@@ -16,7 +16,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
index 6b0ba7be0..555f2d5b5 100644
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -1,5 +1,5 @@
/* Convert string representation of a number into an intmax_t value.
- Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2001, 2002, 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
diff --git a/lib/strverscmp.h b/lib/strverscmp.h
index fc01989db..717a057c1 100644
--- a/lib/strverscmp.h
+++ b/lib/strverscmp.h
@@ -1,4 +1,20 @@
-/* strverscmp.h -- compare strings holding indices/version numbers */
+/* Compare strings while treating digits characters numerically.
+
+ Copyright (C) 1997, 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. */
#ifndef STRVERSCMP_H_
# define STRVERSCMP_H_
diff --git a/lib/tempname.c b/lib/tempname.c
index 7e319ff7f..13a8204a4 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -1,6 +1,6 @@
/* tempname.c - generate the name of a temporary file.
- Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2003,
+ Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/unicodeio.c b/lib/unicodeio.c
index 5b1868062..7b7f6f229 100644
--- a/lib/unicodeio.c
+++ b/lib/unicodeio.c
@@ -1,21 +1,20 @@
/* Unicode character output to streams with locale dependent encoding.
- Copyright (C) 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
/* Written by Bruno Haible <haible@clisp.cons.org>. */
@@ -26,9 +25,8 @@
# include <config.h>
#endif
-#if HAVE_STDDEF_H
-# include <stddef.h>
-#endif
+/* Specification. */
+#include "unicodeio.h"
#include <stdio.h>
#if HAVE_STRING_H
@@ -52,8 +50,7 @@ extern int errno;
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-/* Specification. */
-#include "unicodeio.h"
+#include "localcharset.h"
/* When we pass a Unicode character to iconv(), we must pass it in a
suitable encoding. The standardized Unicode encodings are
@@ -114,10 +111,10 @@ utf8_wctomb (unsigned char *r, unsigned int wc)
Assumes that the locale doesn't change between two calls. */
long
unicode_to_mb (unsigned int code,
- long (*success) PARAMS ((const char *buf, size_t buflen,
- void *callback_arg)),
- long (*failure) PARAMS ((unsigned int code, const char *msg,
- void *callback_arg)),
+ long (*success) (const char *buf, size_t buflen,
+ void *callback_arg),
+ long (*failure) (unsigned int code, const char *msg,
+ void *callback_arg),
void *callback_arg)
{
static int initialized;
@@ -131,7 +128,6 @@ unicode_to_mb (unsigned int code,
if (!initialized)
{
- extern const char *locale_charset PARAMS ((void));
const char *charset = locale_charset ();
is_utf8 = !strcmp (charset, UTF8_NAME);
@@ -190,7 +186,7 @@ unicode_to_mb (unsigned int code,
)
return failure (code, NULL, callback_arg);
- /* Avoid glibc-2.1 bug and Solaris 5.7 bug. */
+ /* Avoid glibc-2.1 bug and Solaris 7 bug. */
# if defined _LIBICONV_VERSION \
|| !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
diff --git a/lib/unicodeio.h b/lib/unicodeio.h
index fb2b75242..9e16a9039 100644
--- a/lib/unicodeio.h
+++ b/lib/unicodeio.h
@@ -1,44 +1,36 @@
/* Unicode character output to streams with locale dependent encoding.
- Copyright (C) 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifndef UNICODEIO_H
# define UNICODEIO_H
+# include <stddef.h>
# include <stdio.h>
-# ifndef PARAMS
-# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
-# define PARAMS(Args) Args
-# else
-# define PARAMS(Args) ()
-# endif
-# endif
-
/* Outputs the Unicode character CODE to the output stream STREAM.
Upon failure, exit if exit_on_error is true, otherwise output a fallback
notation. */
-extern void print_unicode_char PARAMS ((FILE *stream, unsigned int code,
- int exit_on_error));
+extern void print_unicode_char (FILE *stream, unsigned int code,
+ int exit_on_error);
/* Simple success callback that outputs the converted string.
The STREAM is passed as callback_arg. */
-extern long fwrite_success_callback PARAMS ((const char *buf, size_t buflen,
- void *callback_arg));
+extern long fwrite_success_callback (const char *buf, size_t buflen,
+ void *callback_arg);
#endif
diff --git a/lib/unistd-safer.h b/lib/unistd-safer.h
index b39ffc821..2976e9d0d 100644
--- a/lib/unistd-safer.h
+++ b/lib/unistd-safer.h
@@ -1 +1,21 @@
+/* Invoke unistd functions, but avoid some glitches.
+
+ Copyright (C) 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
+ 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. */
+
+/* Written by Paul Eggert. */
+
int dup_safer (int);
diff --git a/lib/unlocked-io.h b/lib/unlocked-io.h
index a7240fb91..3fe5fe105 100644
--- a/lib/unlocked-io.h
+++ b/lib/unlocked-io.h
@@ -2,20 +2,19 @@
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
/* Written by Jim Meyering. */
diff --git a/lib/vasnprintf.h b/lib/vasnprintf.h
index 65f1bc13d..4edb95d65 100644
--- a/lib/vasnprintf.h
+++ b/lib/vasnprintf.h
@@ -1,20 +1,19 @@
/* vsprintf with automatic memory allocation.
Copyright (C) 2002-2003 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifndef _VASNPRINTF_H
#define _VASNPRINTF_H
diff --git a/lib/vasprintf.c b/lib/vasprintf.c
index 925d2fb81..7c8f212d7 100644
--- a/lib/vasprintf.c
+++ b/lib/vasprintf.c
@@ -1,20 +1,19 @@
/* Formatted output to strings.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published
- by the Free Software Foundation; either version 2, or (at your option)
+ 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
- Library General Public License for more details.
+ 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 Library 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. */
+ 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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/lib/version-etc.h b/lib/version-etc.h
index de1a76f8f..e2ef98185 100644
--- a/lib/version-etc.h
+++ b/lib/version-etc.h
@@ -1,5 +1,5 @@
/* Utility to help print --version output in a consistent format.
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 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
@@ -20,6 +20,8 @@
#ifndef VERSION_ETC_H
# define VERSION_ETC_H 1
+# include <stdio.h>
+
extern char *version_etc_copyright;
void version_etc (FILE *stream,
diff --git a/lib/xgethostname.c b/lib/xgethostname.c
index ec00373fb..5178784ba 100644
--- a/lib/xgethostname.c
+++ b/lib/xgethostname.c
@@ -72,7 +72,9 @@ xgethostname ()
break;
else if (err < 0 && errno != ENAMETOOLONG && errno != 0)
{
+ int saved_errno = errno;
free (hostname);
+ errno = saved_errno;
return NULL;
}
size *= 2;
diff --git a/lib/xmemcoll.c b/lib/xmemcoll.c
index 58c41b0f5..0e30aef15 100644
--- a/lib/xmemcoll.c
+++ b/lib/xmemcoll.c
@@ -1,5 +1,5 @@
/* Locale-specific memory comparison.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 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
diff --git a/lib/xstrtoimax.c b/lib/xstrtoimax.c
index f60a8bbab..94c657786 100644
--- a/lib/xstrtoimax.c
+++ b/lib/xstrtoimax.c
@@ -1,5 +1,5 @@
/* xstrtoimax.c -- A more useful interface to strtoimax.
- Copyright 2001 Free Software Foundation, Inc.
+ Copyright (C) 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
diff --git a/lib/xstrtoumax.c b/lib/xstrtoumax.c
index 8e1c5b807..59d6ecf5c 100644
--- a/lib/xstrtoumax.c
+++ b/lib/xstrtoumax.c
@@ -1,5 +1,5 @@
/* xstrtoumax.c -- A more useful interface to strtoumax.
- Copyright 1999 Free Software Foundation, Inc.
+ Copyright (C) 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