mirror of
https://github.com/coreutils/coreutils.git
synced 2025-01-21 07:33:30 +08:00
Sync from gnulib.
This commit is contained in:
parent
14f5062c30
commit
55fbe6686a
24
config/config.guess
vendored
24
config/config.guess
vendored
@ -3,7 +3,7 @@
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2004-07-19'
|
||||
timestamp='2004-09-07'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@ -203,9 +203,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
amiga:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
cats:OpenBSD:*:*)
|
||||
echo arm-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@ -230,18 +227,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
mvmeppc:OpenBSD:*:*)
|
||||
echo powerpc-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
pmax:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sgi:OpenBSD:*:*)
|
||||
echo mipseb-unknown-openbsd${UNAME_RELEASE}
|
||||
echo mips64-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
wgrisc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:OpenBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@ -833,6 +824,12 @@ EOF
|
||||
cris:Linux:*:*)
|
||||
echo cris-axis-linux-gnu
|
||||
exit 0 ;;
|
||||
crisv32:Linux:*:*)
|
||||
echo crisv32-axis-linux-gnu
|
||||
exit 0 ;;
|
||||
frv:Linux:*:*)
|
||||
echo frv-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
ia64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
@ -1179,9 +1176,10 @@ EOF
|
||||
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:Darwin:*:*)
|
||||
case `uname -p` in
|
||||
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
|
||||
case $UNAME_PROCESSOR in
|
||||
*86) UNAME_PROCESSOR=i686 ;;
|
||||
powerpc) UNAME_PROCESSOR=powerpc ;;
|
||||
unknown) UNAME_PROCESSOR=powerpc ;;
|
||||
esac
|
||||
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
|
5
config/config.sub
vendored
5
config/config.sub
vendored
@ -3,7 +3,7 @@
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2004-06-24'
|
||||
timestamp='2004-08-29'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
@ -457,6 +457,9 @@ case $basic_machine in
|
||||
crds | unos)
|
||||
basic_machine=m68k-crds
|
||||
;;
|
||||
crisv32 | crisv32-* | etraxfs*)
|
||||
basic_machine=crisv32-axis
|
||||
;;
|
||||
cris | cris-* | etrax*)
|
||||
basic_machine=cris-axis
|
||||
;;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2004-07-05.00
|
||||
scriptversion=2004-09-10.20
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
@ -260,7 +260,7 @@ do
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
|
@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2003-09-02.23
|
||||
scriptversion=2004-09-07.08
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
|
||||
# Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
@ -60,11 +60,6 @@ case "$1" in
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case "$1" in
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
@ -92,10 +87,12 @@ Supported PROGRAM values:
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit 0
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
-*)
|
||||
@ -104,12 +101,42 @@ Send bug reports to <bug-automake@gnu.org>."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
aclocal*)
|
||||
esac
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program).
|
||||
case "$1" in
|
||||
lex|yacc)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
tar)
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
# Could not run --version or --help. This is probably someone
|
||||
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case "$1" in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||
@ -119,11 +146,6 @@ WARNING: \`$1' is $msg. You should only need it if
|
||||
;;
|
||||
|
||||
autoconf)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
@ -133,11 +155,6 @@ WARNING: \`$1' is $msg. You should only need it if
|
||||
;;
|
||||
|
||||
autoheader)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
@ -157,11 +174,6 @@ WARNING: \`$1' is $msg. You should only need it if
|
||||
;;
|
||||
|
||||
automake*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||
@ -173,11 +185,6 @@ WARNING: \`$1' is $msg. You should only need it if
|
||||
;;
|
||||
|
||||
autom4te)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
@ -254,11 +261,6 @@ WARNING: \`$1' is $msg. You should only need it if
|
||||
;;
|
||||
|
||||
help2man)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
@ -279,11 +281,6 @@ WARNING: \`$1' is $msg. You should only need it if
|
||||
;;
|
||||
|
||||
makeinfo)
|
||||
if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
|
||||
# We have makeinfo, but it failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
@ -301,10 +298,6 @@ WARNING: \`$1' is $msg. You should only need it if
|
||||
|
||||
tar)
|
||||
shift
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# We have already tried tar in the generic part.
|
||||
# Look for gnutar/gtar before invocation to avoid ugly error
|
||||
|
@ -3,7 +3,7 @@
|
||||
% Load plain if necessary, i.e., if running under initex.
|
||||
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
|
||||
%
|
||||
\def\texinfoversion{2004-07-31.11}
|
||||
\def\texinfoversion{2004-09-06.16}
|
||||
%
|
||||
% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
|
||||
% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
|
||||
@ -2633,7 +2633,10 @@ where each line of input produces a line of output.}
|
||||
\startsavinginserts
|
||||
%
|
||||
% @item within a multitable starts a normal row.
|
||||
\let\item\crcr
|
||||
% We use \def instead of \let so that if one of the multitable entries
|
||||
% contains an @itemize, we don't choke on the \item (seen as \crcr aka
|
||||
% \endtemplate) expanding \doitemize.
|
||||
\def\item{\crcr}%
|
||||
%
|
||||
\tolerance=9500
|
||||
\hbadness=9500
|
||||
@ -3530,7 +3533,10 @@ width0pt\relax} \fi
|
||||
\removelastskip
|
||||
%
|
||||
% We like breaks before the index initials, so insert a bonus.
|
||||
\penalty -300
|
||||
\nobreak
|
||||
\vskip 0pt plus 3\baselineskip
|
||||
\penalty 0
|
||||
\vskip 0pt plus -3\baselineskip
|
||||
%
|
||||
% Typeset the initial. Making this add up to a whole number of
|
||||
% baselineskips increases the chance of the dots lining up from column
|
||||
@ -3540,10 +3546,9 @@ width0pt\relax} \fi
|
||||
% No shrink because it confuses \balancecolumns.
|
||||
\vskip 1.67\baselineskip plus .5\baselineskip
|
||||
\leftline{\secbf #1}%
|
||||
\vskip .33\baselineskip plus .1\baselineskip
|
||||
%
|
||||
% Do our best not to break after the initial.
|
||||
\nobreak
|
||||
\vskip .33\baselineskip plus .1\baselineskip
|
||||
}}
|
||||
|
||||
% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
|
||||
@ -5453,7 +5458,11 @@ width0pt\relax} \fi
|
||||
\newlinechar`\^^M
|
||||
\let\xeatspaces\eatspaces
|
||||
% Undo catcode changes of \startcontents and \doprintindex
|
||||
\catcode`\@=0 \catcode`\\=\other \escapechar=`\@
|
||||
% When called from @insertcopying or (short)caption, we need active
|
||||
% backslash to get it printed correctly. Previously, we had
|
||||
% \catcode`\\=\other instead. We'll see whether a problem appears
|
||||
% with macro expansion. --kasal, 19aug04
|
||||
\catcode`\@=0 \catcode`\\=\active \escapechar=`\@
|
||||
% ... and \example
|
||||
\spaceisspace
|
||||
%
|
||||
@ -5477,13 +5486,15 @@ width0pt\relax} \fi
|
||||
% \do\macro1\do\macro2...
|
||||
|
||||
% Utility routines.
|
||||
% This does \let #1 = #2, except with \csnames.
|
||||
% This does \let #1 = #2, with \csnames; that is,
|
||||
% \let \csname#1\endcsname = \csname#2\endcsname
|
||||
% (except of course we have to play expansion games).
|
||||
%
|
||||
\def\cslet#1#2{%
|
||||
\expandafter\expandafter
|
||||
\expandafter\let
|
||||
\expandafter\expandafter
|
||||
\csname#1\endcsname
|
||||
\csname#2\endcsname}
|
||||
\expandafter\let
|
||||
\csname#1\expandafter\endcsname
|
||||
\csname#2\endcsname
|
||||
}
|
||||
|
||||
% Trim leading and trailing spaces off a string.
|
||||
% Concepts from aro-bend problem 15 (see CTAN).
|
||||
@ -5511,14 +5522,15 @@ width0pt\relax} \fi
|
||||
% body, and then making it the \newlinechar in \scanmacro.
|
||||
|
||||
\def\scanctxt{%
|
||||
\catcode`\~=\other
|
||||
\catcode`\"=\other
|
||||
\catcode`\+=\other
|
||||
\catcode`\<=\other
|
||||
\catcode`\>=\other
|
||||
\catcode`\@=\other
|
||||
\catcode`\^=\other
|
||||
\catcode`\_=\other
|
||||
\catcode`\|=\other
|
||||
\catcode`\<=\other
|
||||
\catcode`\>=\other
|
||||
\catcode`\+=\other
|
||||
\catcode`\@=\other
|
||||
\catcode`\~=\other
|
||||
}
|
||||
|
||||
\def\scanargctxt{%
|
||||
@ -6468,6 +6480,9 @@ width0pt\relax} \fi
|
||||
\ifx\captionline\empty \else
|
||||
\vskip.5\parskip
|
||||
\captionline
|
||||
%
|
||||
% Space below caption.
|
||||
\vskip\parskip
|
||||
\fi
|
||||
%
|
||||
% If have an xref label, write the list of floats info. Do this
|
||||
@ -6478,19 +6493,22 @@ width0pt\relax} \fi
|
||||
% caption if specified, else the full caption if specified, else nothing.
|
||||
{%
|
||||
\atdummies \turnoffactive \otherbackslash
|
||||
\immediate\write\auxfile{@xrdef{\floatlabel-lof}{%
|
||||
\floatident
|
||||
\ifx\thisshortcaption\empty
|
||||
\ifx\thiscaption\empty \else : \thiscaption \fi
|
||||
\else
|
||||
: \thisshortcaption
|
||||
\fi
|
||||
}}%
|
||||
% since we read the caption text in the macro world, where ^^M
|
||||
% is turned into a normal character, we have to scan it back, so
|
||||
% we don't write the literal three characters "^^M" into the aux file.
|
||||
\scanexp{%
|
||||
\xdef\noexpand\gtemp{%
|
||||
\ifx\thisshortcaption\empty
|
||||
\thiscaption
|
||||
\else
|
||||
\thisshortcaption
|
||||
\fi
|
||||
}%
|
||||
}%
|
||||
\immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
|
||||
\ifx\gtemp\empty \else : \gtemp \fi}}%
|
||||
}%
|
||||
\fi
|
||||
%
|
||||
% Space below caption, if we printed anything.
|
||||
\ifx\printedsomething\empty \else \vskip\parskip \fi
|
||||
\egroup % end of \vtop
|
||||
%
|
||||
% place the captured inserts
|
||||
|
19
lib/dirfd.h
19
lib/dirfd.h
@ -1,3 +1,22 @@
|
||||
/* Declare dirfd, if necessary.
|
||||
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 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 HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
@ -1,4 +1,20 @@
|
||||
/* Emulate getpagesize on systems that lack it. */
|
||||
/* Emulate getpagesize on systems that lack it.
|
||||
Copyright (C) 1999, 2000 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 HAVE_GETPAGESIZE
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
|
||||
#include <string.h> /* memcpy(), strlen() */
|
||||
#include <errno.h> /* errno */
|
||||
#include <limits.h> /* CHAR_BIT */
|
||||
#include <limits.h> /* CHAR_BIT, INT_MAX */
|
||||
#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
|
||||
#if WIDE_CHAR_VERSION
|
||||
# include "wprintf-parse.h"
|
||||
@ -875,8 +875,19 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
|
||||
free (buf_malloced);
|
||||
CLEANUP ();
|
||||
*lengthp = length;
|
||||
if (length > INT_MAX)
|
||||
goto length_overflow;
|
||||
return result;
|
||||
|
||||
length_overflow:
|
||||
/* We could produce such a big string, but its length doesn't fit into
|
||||
an 'int'. POSIX says that snprintf() fails with errno = EOVERFLOW in
|
||||
this case. */
|
||||
if (result != resultbuf)
|
||||
free (result);
|
||||
errno = EOVERFLOW;
|
||||
return NULL;
|
||||
|
||||
out_of_memory:
|
||||
if (!(result == resultbuf || result == NULL))
|
||||
free (result);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* vsprintf with automatic memory allocation.
|
||||
Copyright (C) 2002-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-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
|
||||
@ -47,7 +47,24 @@ extern "C" {
|
||||
If successful, return the address of the string (this may be = RESULTBUF
|
||||
if no dynamic memory allocation was necessary) and set *LENGTHP to the
|
||||
number of resulting bytes, excluding the trailing NUL. Upon error, set
|
||||
errno and return NULL. */
|
||||
errno and return NULL.
|
||||
|
||||
When dynamic memory allocation occurs, the preallocated buffer is left
|
||||
alone (with possibly modified contents). This makes it possible to use
|
||||
a statically allocated or stack-allocated buffer, like this:
|
||||
|
||||
char buf[100];
|
||||
size_t len = sizeof (buf);
|
||||
char *output = vasnprintf (buf, &len, format, args);
|
||||
if (output == NULL)
|
||||
... error handling ...;
|
||||
else
|
||||
{
|
||||
... use the output string ...;
|
||||
if (output != buf)
|
||||
free (output);
|
||||
}
|
||||
*/
|
||||
extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Formatted output to strings.
|
||||
Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2002-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,7 +22,6 @@
|
||||
/* Specification. */
|
||||
#include "vasprintf.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "vasnprintf.h"
|
||||
@ -34,15 +33,10 @@ vasprintf (char **resultp, const char *format, va_list args)
|
||||
char *result = vasnprintf (NULL, &length, format, args);
|
||||
if (result == NULL)
|
||||
return -1;
|
||||
if (length > INT_MAX)
|
||||
{
|
||||
/* We could produce such a big string, but can't return its length
|
||||
as an 'int'. */
|
||||
free (result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*resultp = result;
|
||||
/* Return the number of resulting bytes, excluding the trailing NUL. */
|
||||
/* Return the number of resulting bytes, excluding the trailing NUL.
|
||||
If it wouldn't fit in an 'int', vasnprintf() would have returned NULL
|
||||
and set errno to EOVERFLOW. */
|
||||
return length;
|
||||
}
|
||||
|
66
m4/eoverflow.m4
Normal file
66
m4/eoverflow.m4
Normal file
@ -0,0 +1,66 @@
|
||||
# eoverflow.m4 serial 1
|
||||
dnl Copyright (C) 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
|
||||
dnl that contains a configuration script generated by Autoconf, under
|
||||
dnl the same distribution terms as the rest of that program.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
|
||||
# POSIX. But some systems (like AIX 3) don't define it, and some systems
|
||||
# (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
|
||||
|
||||
# Define EOVERFLOW as a C macro and as a substituted macro in such a way that
|
||||
# 1. on all systems, after inclusion of <errno.h>, EOVERFLOW is usable,
|
||||
# 2. on systems where EOVERFLOW is defined elsewhere, we use the same numeric
|
||||
# value.
|
||||
|
||||
AC_DEFUN([gl_EOVERFLOW],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])dnl
|
||||
|
||||
AC_CACHE_CHECK([for EOVERFLOW], ac_cv_decl_EOVERFLOW, [
|
||||
AC_EGREP_CPP(yes,[
|
||||
#include <errno.h>
|
||||
#ifdef EOVERFLOW
|
||||
yes
|
||||
#endif
|
||||
], have_eoverflow=1)
|
||||
if test -n "$have_eoverflow"; then
|
||||
dnl EOVERFLOW exists in <errno.h>. Don't need to define EOVERFLOW ourselves.
|
||||
ac_cv_decl_EOVERFLOW=yes
|
||||
else
|
||||
AC_EGREP_CPP(yes,[
|
||||
#define _XOPEN_SOURCE_EXTENDED 1
|
||||
#include <errno.h>
|
||||
#ifdef EOVERFLOW
|
||||
yes
|
||||
#endif
|
||||
], have_eoverflow=1)
|
||||
if test -n "$have_eoverflow"; then
|
||||
dnl EOVERFLOW exists but is hidden.
|
||||
dnl Define it to the same value.
|
||||
_AC_COMPUTE_INT([EOVERFLOW], ac_cv_decl_EOVERFLOW, [
|
||||
#define _XOPEN_SOURCE_EXTENDED 1
|
||||
#include <errno.h>
|
||||
/* The following two lines are a workaround against an autoconf-2.52 bug. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
])
|
||||
else
|
||||
dnl EOVERFLOW isn't defined by the system. Define EOVERFLOW ourselves, but
|
||||
dnl don't define it as EINVAL, because snprintf() callers want to
|
||||
dnl distinguish EINVAL and EOVERFLOW.
|
||||
ac_cv_decl_EOVERFLOW=E2BIG
|
||||
fi
|
||||
fi
|
||||
])
|
||||
if test "$ac_cv_decl_EOVERFLOW" != yes; then
|
||||
AC_DEFINE_UNQUOTED([EOVERFLOW], [$ac_cv_decl_EOVERFLOW],
|
||||
[Define as good substitute value for EOVERFLOW.])
|
||||
EOVERFLOW="$ac_cv_decl_EOVERFLOW"
|
||||
AC_SUBST(EOVERFLOW)
|
||||
fi
|
||||
])
|
@ -1,4 +1,10 @@
|
||||
#serial 11
|
||||
# mbswidth.m4 serial 11
|
||||
dnl Copyright (C) 2000-2002, 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
|
||||
dnl that contains a configuration script generated by Autoconf, under
|
||||
dnl the same distribution terms as the rest of that program.
|
||||
|
||||
dnl autoconf tests required for use of mbswidth.c
|
||||
dnl From Bruno Haible.
|
||||
|
@ -1,4 +1,4 @@
|
||||
# vasnprintf.m4 serial 4
|
||||
# vasnprintf.m4 serial 5
|
||||
dnl Copyright (C) 2002-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
|
||||
@ -8,6 +8,7 @@ dnl the same distribution terms as the rest of that program.
|
||||
|
||||
AC_DEFUN([gl_FUNC_VASNPRINTF],
|
||||
[
|
||||
AC_REQUIRE([gl_EOVERFLOW])
|
||||
AC_REPLACE_FUNCS(vasnprintf)
|
||||
if test $ac_cv_func_vasnprintf = no; then
|
||||
AC_LIBOBJ(printf-args)
|
||||
|
Loading…
Reference in New Issue
Block a user