Mercurial > hg > octave-lyh > gnulib-hg
changeset 4910:de285d9e7c4d
Merge from coreutils.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 16 Jan 2004 07:55:43 +0000 |
parents | b3f5a7efff1a |
children | 3d5366ba43ec |
files | ChangeLog lib/ChangeLog lib/md5.h lib/posixver.c lib/same.c lib/version-etc.c lib/xreadlink.c lib/xstrtod.c lib/xstrtod.h m4/ChangeLog m4/clock_time.m4 m4/jm-macros.m4 m4/lib-check.m4 m4/nanosleep.m4 m4/posixver.m4 m4/prereq.m4 m4/same.m4 modules/same |
diffstat | 18 files changed, 210 insertions(+), 68 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ Prefer "$@" to "poll.h" in rule for building poll.h. All this is for consistency with alloca and fnmatch. + * modules/same: Depend on stdbool. + 2003-12-03 Bruno Haible <bruno@clisp.org> Upgrade from gettext-0.13.
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,37 @@ +2004-01-15 Jim Meyering <jim@meyering.net> + + Merge from coreutils. + + * md5.h (rol) [__GNUC__ && __i386__]: Don't use `asm' code. These + days, gcc-3.x does better all by itself. Patch from Dean Gaudet: + http://mail.gnu.org/archive/html/bug-coreutils/2003-11/msg00144.html + + * posixver.c (DEFAULT_POSIX2_VERSION): Use definition of new, + optional configure-time default. + + * version-etc.c (version_etc_copyright): Update copyright date. + + * xreadlink.c (xreadlink): Correct outdated comment. + +2004-01-15 Paul Eggert <eggert@twinsun.com> + + Merge from coreutils. + + * posixver.c: Include posixver.h. + + * same.c: Include <stdbool.h>, <limits.h>. + (_POSIX_NAME_MAX): Define if not defined. + (MIN): New macro. + (same_name): If file names are silently truncated, report + that the file names are the same if they are the same after + the silent truncation. + + * xstrtod.h (xstrtod): Accept an extra arg, specifying the + conversion function. + * xstrtod.c (xstrtod): Likewise. All callers changed to + include c-strtod.h and use c_strtod. Don't include stdlib.h; no + longer needed. + 2004-01-14 Paul Eggert <eggert@twinsun.com> * fnmatch_loop.c (ALLOCA_LIMIT): Remove macro, which collided
--- a/lib/md5.h +++ b/lib/md5.h @@ -124,19 +124,6 @@ digest. */ extern void *md5_buffer (const char *buffer, size_t len, void *resblock); -/* The following is from gnupg-1.0.2's cipher/bithelp.h. */ -/* Rotate a 32 bit integer by n bytes */ -#if defined __GNUC__ && defined __i386__ -static inline md5_uint32 -rol(md5_uint32 x, int n) -{ - __asm__("roll %%cl,%0" - :"=r" (x) - :"0" (x),"c" (n)); - return x; -} -#else -# define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) -#endif +#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) #endif
--- a/lib/posixver.c +++ b/lib/posixver.c @@ -1,6 +1,6 @@ /* Which POSIX version to conform to, for utilities. - Copyright (C) 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004 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,6 +22,8 @@ # include <config.h> #endif +#include "posixver.h" + #include <limits.h> #include <stdlib.h> @@ -32,13 +34,17 @@ # define _POSIX2_VERSION 0 #endif +#ifndef DEFAULT_POSIX2_VERSION +# define DEFAULT_POSIX2_VERSION _POSIX2_VERSION +#endif + /* The POSIX version that utilities should conform to. The default is specified by the system. */ int posix2_version (void) { - long int v = _POSIX2_VERSION; + long int v = DEFAULT_POSIX2_VERSION; char const *s = getenv ("_POSIX2_VERSION"); if (s && *s)
--- a/lib/same.c +++ b/lib/same.c @@ -21,6 +21,7 @@ # include <config.h> #endif +#include <stdbool.h> #include <stdio.h> #ifdef HAVE_UNISTD_H # include <unistd.h> @@ -36,11 +37,18 @@ #include <string.h> +#include <limits.h> +#ifndef _POSIX_NAME_MAX +# define _POSIX_NAME_MAX 14 +#endif + #include "same.h" #include "dirname.h" #include "error.h" #include "xalloc.h" +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + #define SAME_INODE(Stat_buf_1, Stat_buf_2) \ ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \ && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev) @@ -56,9 +64,24 @@ char const *dest_basename = base_name (dest); size_t source_baselen = base_len (source_basename); size_t dest_baselen = base_len (dest_basename); + bool identical_basenames = + (source_baselen == dest_baselen + && memcmp (source_basename, dest_basename, dest_baselen) == 0); + bool compare_dirs = identical_basenames; + bool same = false; - if (source_baselen == dest_baselen - && memcmp (source_basename, dest_basename, dest_baselen) == 0) +#if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX + /* This implementation silently truncates pathname components. If + the base names might be truncated, check whether the truncated + base names are the same, while checking the directories. */ + size_t slen_max = HAVE_LONG_FILE_NAMES ? 255 : _POSIX_NAME_MAX; + size_t min_baselen = MIN (source_baselen, dest_baselen); + if (slen_max <= min_baselen + && memcmp (source_basename, dest_basename, slen_max) == 0) + compare_dirs = true; +#endif + + if (compare_dirs) { struct stat source_dir_stats; struct stat dest_dir_stats; @@ -80,12 +103,30 @@ error (1, errno, "%s", dest_dirname); } + same = SAME_INODE (source_dir_stats, dest_dir_stats); + +#if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX + if (same && ! identical_basenames) + { + long name_max = (errno = 0, pathconf (dest_dirname, _PC_NAME_MAX)); + if (name_max < 0) + { + if (errno) + { + /* Shouldn't happen. */ + error (1, errno, "%s", dest_dirname); + } + same = false; + } + else + same = (name_max <= min_baselen + && memcmp (source_basename, dest_basename, name_max) == 0); + } +#endif + free (source_dirname); free (dest_dirname); - - if (SAME_INODE (source_dir_stats, dest_dir_stats)) - return 1; } - return 0; + return same; }
--- a/lib/version-etc.c +++ b/lib/version-etc.c @@ -1,5 +1,5 @@ /* Utility to help print --version output in a consistent format. - Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999-2004 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 @@ -36,7 +36,7 @@ const char* version_etc_copyright = /* Do *not* mark this string for translation. */ - "Copyright (C) 2003 Free Software Foundation, Inc."; + "Copyright (C) 2004 Free Software Foundation, Inc."; /* Like version_etc, below, but with the NULL-terminated author list
--- a/lib/xreadlink.c +++ b/lib/xreadlink.c @@ -36,9 +36,6 @@ # include <unistd.h> #endif -#include "xalloc.h" -#include "xreadlink.h" - #ifndef SIZE_MAX # define SIZE_MAX ((size_t) -1) #endif @@ -46,10 +43,13 @@ # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) #endif +#include "xalloc.h" +#include "xreadlink.h" + /* Call readlink to get the symbolic link value of FILENAME. Return a pointer to that NUL-terminated string in malloc'd storage. If readlink fails, return NULL (caller may use errno to diagnose). - If realloc fails, or if the link value is longer than SIZE_MAX :-), + If malloc fails, or if the link value is longer than SSIZE_MAX :-), give a diagnostic and exit. */ char *
--- a/lib/xstrtod.c +++ b/lib/xstrtod.c @@ -1,4 +1,4 @@ -/* xstrtod.c - error-checking interface to strtod +/* error-checking interface to strtod-like functions Copyright (C) 1996, 1999, 2000, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -26,7 +26,6 @@ #include <errno.h> #include <limits.h> #include <stdio.h> -#include <stdlib.h> /* Tell the compiler that non-default rounding modes are used. */ #if 199901 <= __STDC_VERSION__ @@ -36,10 +35,12 @@ /* An interface to strtod that encapsulates all the error checking one should usually perform. Like strtod, but upon successful conversion put the result in *RESULT and return zero. Return - non-zero and don't modify *RESULT upon any failure. */ + non-zero and don't modify *RESULT upon any failure. CONVERT + specifies the conversion function, e.g., strtod itself. */ int -xstrtod (char const *str, char const **ptr, double *result) +xstrtod (char const *str, char const **ptr, double *result, + double (*convert) (char const *, char **)) { double val; char *terminator; @@ -47,7 +48,7 @@ fail = 0; errno = 0; - val = strtod (str, &terminator); + val = convert (str, &terminator); /* Having a non-zero terminator is an error only when PTR is NULL. */ if (terminator == str || (ptr == NULL && *terminator != '\0'))
--- a/lib/xstrtod.h +++ b/lib/xstrtod.h @@ -1,4 +1,4 @@ -/* Error-checking interface to strtod. +/* Error-checking interface to strtod-like functions. Copyright (C) 1996, 1998, 2003 Free Software Foundation, Inc. @@ -21,6 +21,7 @@ #ifndef XSTRTOD_H # define XSTRTOD_H 1 -int xstrtod (const char *str, const char **ptr, double *result); +int xstrtod (const char *str, const char **ptr, double *result, + double (*convert) (char const *, char **)); #endif /* not XSTRTOD_H */
--- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,43 @@ +2004-01-15 Paul Eggert <eggert@twinsun.com> + + Merge from coreutils. + + * jm-macros.m4 (jm_CHECK_ALL_TYPES): Check for uintptr_t. + * posixver.m4 (gl_POSIXVER): Require gl_DEFAULT_POSIX2_VERSION. + (gl_DEFAULT_POSIX2_VERSION): Move + the documentation from 'configure' into 'config.hin', + so that 'configure --help' isn't burdened by it and + we don't have to worry about its formatting there. + Reword the documentation so that it's more succinct + and can be run together into a single paragraph. + * same.m4 (gl_SAME): Check for pathconf. + +2004-01-15 Jim Meyering <jim@meyering.net> + + Merge from coreutils. + + * clock_time.m4 (gl_CLOCK_TIME): Don't set LIB_CLOCK_GETTIME + if no library is required. + * jm-macros.m4: Don't require UTILS_SYS_OPEN_MAX. + * jm-macros.m4 (jm_MACROS): Require gl_FUNC_FREE. + * jm-macros.m4 (jm_MACROS): Require autoconf-2.58. + (AC_LANG_SOURCE): Remove definition, now that we require autoconf-2.58. + * jm-macros.m4 (jm_MACROS): Don't require AC_FUNC_FTW. + * lib-check.m4 (jm_LIB_CHECK): Do not set LIB_CRYPT to the + value, $ac_cv_search_crypt, if it's "none required". + * posixver.m4 (gl_DEFAULT_POSIX2_VERSION): New macro. + * prereq.m4 (jm_PREREQ): Require AC_FUNC_GETLOADAVG, + not gl_FUNC_GETLOADAVG. + * prereq.m4 (jm_PREREQ): Require gl_READTOKENS, gl_MD5, gl_MAKEPATH, + gl_LONG_OPTIONS, and gl_IDCACHE, gl_GETUGROUPS. + +2004-01-15 Alexandre Duret-Lutz <adl@gnu.org> + + Merge from coreutils. + + * nanosleep.m4 (jm_FUNC_NANOSLEEP): Do not set LIB_NANOSLEEP to the + value, $ac_cv_search_nanosleep, if it's "none required". + 2003-12-03 Bruno Haible <bruno@clisp.org> * gettext.m4: Upgrade from gettext-0.13.
--- a/m4/clock_time.m4 +++ b/m4/clock_time.m4 @@ -1,4 +1,4 @@ -# clock_time.m4 serial 2 +# clock_time.m4 serial 3 dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General @@ -17,7 +17,8 @@ # library, inducing unnecessary run-time overhead. fetish_saved_libs=$LIBS AC_SEARCH_LIBS(clock_gettime, [rt posix4], - [LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime]) + [test "$ac_cv_search_clock_gettime" = "none required" || + LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime]) AC_SUBST(LIB_CLOCK_GETTIME) AC_CHECK_FUNCS(clock_gettime clock_settime) LIBS=$fetish_saved_libs
--- a/m4/jm-macros.m4 +++ b/m4/jm-macros.m4 @@ -1,28 +1,10 @@ -#serial 68 -*- autoconf -*- - -m4_undefine([AC_LANG_SOURCE(C)]) -dnl The following is identical to the definition in c.m4 -dnl from the autoconf cvs repository on 2003-03-07. -dnl FIXME: remove this code once we upgrade to autoconf-2.58. - -# We can't use '#line $LINENO "configure"' here, since -# Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09) -# rejects $LINENO greater than 32767, and some configure scripts -# are longer than 32767 lines. -m4_define([AC_LANG_SOURCE(C)], -[/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$1]) - +#serial 70 -*- autoconf -*- dnl Misc type-related macros for fileutils, sh-utils, textutils. AC_DEFUN([jm_MACROS], [ - AC_PREREQ(2.57) + AC_PREREQ(2.58) GNU_PACKAGE="GNU $PACKAGE" AC_DEFINE_UNQUOTED(GNU_PACKAGE, "$GNU_PACKAGE", @@ -50,7 +32,6 @@ AC_REQUIRE([UTILS_FUNC_DIRFD]) AC_REQUIRE([AC_FUNC_ACL]) - AC_REQUIRE([AC_FUNC_FTW]) AC_REQUIRE([jm_FUNC_LCHOWN]) AC_REQUIRE([fetish_FUNC_RMDIR_NOTEMPTY]) AC_REQUIRE([jm_FUNC_CHOWN]) @@ -127,7 +108,6 @@ AC_CHECK_FUNCS(setreuid setregid) AC_FUNC_STRTOD - AC_REQUIRE([UTILS_SYS_OPEN_MAX]) AC_REQUIRE([GL_FUNC_GETCWD_PATH_MAX]) AC_REQUIRE([GL_FUNC_READDIR]) @@ -167,6 +147,8 @@ # use the corresponding stub. AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)]) AC_CHECK_FUNC([fchown], , [AC_LIBOBJ(fchown-stub)]) + + AC_REQUIRE([gl_FUNC_FREE]) ]) # These tests must be run before any use of AC_CHECK_TYPE, @@ -257,7 +239,8 @@ AC_REQUIRE([AC_TYPE_SIGNAL]) AC_REQUIRE([AC_TYPE_SIZE_T]) AC_REQUIRE([AC_TYPE_UID_T]) - AC_CHECK_TYPE(ino_t, unsigned long) + AC_CHECK_TYPE(ino_t, unsigned long int) + AC_CHECK_TYPE(uintptr_t, size_t) gt_TYPE_SSIZE_T
--- a/m4/lib-check.m4 +++ b/m4/lib-check.m4 @@ -1,4 +1,4 @@ -#serial 5 +#serial 6 dnl Misc lib-related macros for fileutils, sh-utils, textutils. @@ -57,7 +57,9 @@ # SCO-ODT-3.0 is reported to need -lufc for crypt. # NetBSD needs -lcrypt for crypt. ac_su_saved_lib="$LIBS" - AC_SEARCH_LIBS(crypt, [ufc crypt], [LIB_CRYPT="$ac_cv_search_crypt"]) + AC_SEARCH_LIBS(crypt, [ufc crypt], + [test "$ac_cv_search_crypt" = "none required" || + LIB_CRYPT="$ac_cv_search_crypt"]) LIBS="$ac_su_saved_lib" AC_SUBST(LIB_CRYPT) ])
--- a/m4/nanosleep.m4 +++ b/m4/nanosleep.m4 @@ -11,8 +11,10 @@ # Solaris 2.5.1 needs -lposix4 to get the nanosleep function. # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. - AC_SEARCH_LIBS(nanosleep, [rt posix4], [LIB_NANOSLEEP=$ac_cv_search_nanosleep]) - AC_SUBST(LIB_NANOSLEEP) + AC_SEARCH_LIBS([nanosleep], [rt posix4], + [test "$ac_cv_search_nanosleep" = "none required" || + LIB_NANOSLEEP=$ac_cv_search_nanosleep]) + AC_SUBST([LIB_NANOSLEEP]) AC_CACHE_CHECK([whether nanosleep works], jm_cv_func_nanosleep_works,
--- a/m4/posixver.m4 +++ b/m4/posixver.m4 @@ -1,5 +1,5 @@ -# posixver.m4 serial 2 -dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. +# posixver.m4 serial 4 +dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General dnl Public License, this file may be distributed as part of a program @@ -9,4 +9,38 @@ AC_DEFUN([gl_POSIXVER], [ AC_CHECK_HEADERS_ONCE(unistd.h) + AC_REQUIRE([gl_DEFAULT_POSIX2_VERSION]) ]) + +# Set the default level of POSIX conformance at configure-time. +# Build with `./configure DEFAULT_POSIX2_VERSION=199209 ...' to +# support the older version, thus preserving portability with +# scripts that use sort +1, tail +32, head -1, etc. +# Note however, that this breaks tools that might run commands +# like `sort +some-file' that conform with the newer standard. +AC_DEFUN([gl_DEFAULT_POSIX2_VERSION], +[ + AC_MSG_CHECKING([for desired default level of POSIX conformance]) + gl_default_posix2_version=none-specified + if test -n "$ac_cv_env_DEFAULT_POSIX2_VERSION_set"; then + gl_default_posix2_version=$ac_cv_env_DEFAULT_POSIX2_VERSION_value + AC_DEFINE_UNQUOTED(DEFAULT_POSIX2_VERSION, + $gl_default_posix2_version, + [Define the default level of POSIX conformance. The value is of + the form YYYYMM, specifying the year and month the standard was + adopted. If not defined here, it defaults to the value of + _POSIX2_VERSION in <unistd.h>. Define to 199209 to default to + POSIX 1003.2-1992, which makes standard programs like `head', + `tail', and `sort' accept obsolete options like `+10' and + `-10'. Define to 200112 to default to POSIX 1003.1-2001, which + makes these standard programs treat leading-`+' operands as + file names and require modern usages like `-n 10' instead of + `-10'. Whether defined here or not, the default can be + overridden at run time via the _POSIX2_VERSION environment + variable.]) + fi + AC_MSG_RESULT($gl_default_posix2_version) + AC_ARG_VAR( + [DEFAULT_POSIX2_VERSION], + [POSIX version to default to; see 'config.hin'.]) +])
--- a/m4/prereq.m4 +++ b/m4/prereq.m4 @@ -1,4 +1,4 @@ -#serial 36 +#serial 37 dnl We use jm_ for non Autoconf macros. m4_pattern_forbid([^jm_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl @@ -33,7 +33,7 @@ AC_REQUIRE([gl_FUNC_EUIDACCESS]) AC_REQUIRE([gl_FUNC_FNMATCH_GNU]) AC_REQUIRE([gl_FUNC_GETHOSTNAME]) - AC_REQUIRE([gl_FUNC_GETLOADAVG]) + AC_REQUIRE([AC_FUNC_GETLOADAVG]) AC_REQUIRE([gl_FUNC_GETPASS]) AC_REQUIRE([gl_FUNC_GETUSERSHELL]) AC_REQUIRE([gl_FUNC_MEMCHR]) @@ -67,10 +67,15 @@ AC_REQUIRE([gl_GETNDELIM2]) AC_REQUIRE([gl_GETOPT]) AC_REQUIRE([gl_GETPAGESIZE]) + AC_REQUIRE([gl_GETUGROUPS]) AC_REQUIRE([gl_HARD_LOCALE]) AC_REQUIRE([gl_HASH]) AC_REQUIRE([gl_HUMAN]) + AC_REQUIRE([gl_IDCACHE]) + AC_REQUIRE([gl_LONG_OPTIONS]) + AC_REQUIRE([gl_MAKEPATH]) AC_REQUIRE([gl_MBSWIDTH]) + AC_REQUIRE([gl_MD5]) AC_REQUIRE([gl_MEMCOLL]) AC_REQUIRE([gl_MODECHANGE]) AC_REQUIRE([gl_MOUNTLIST]) @@ -82,6 +87,7 @@ AC_REQUIRE([gl_POSIXVER]) AC_REQUIRE([gl_QUOTEARG]) AC_REQUIRE([gl_QUOTE]) + AC_REQUIRE([gl_READTOKENS]) AC_REQUIRE([gl_READUTMP]) AC_REQUIRE([gl_REGEX]) AC_REQUIRE([gl_SAFE_READ])