mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Merge from gnulib
* doc/misc/texinfo.tex: Update from gnulib. * lib/getdtablesize.c, lib/getopt.c, lib/signal.in.h, lib/tempname.c: * lib/tempname.h, m4/dup2.m4, m4/fcntl.m4, m4/getdtablesize.m4: Update from gnulib, incorporating: 2015-02-20 getdtablesize: port better for Android 2015-02-19 fcntl: Fix cross compiling 2015-02-18 dup2, fcntl: cross-compile better for Android 2015-02-18 getopt: don't crash on memory exhaustion 2015-02-17 tempname: allow compilation with C++ (trivial) 2015-02-17 dup2, fcntl: port to AIX 2015-02-16 getdtablesize, dup2, fcntl: port to Android 2015-02-11 getdtablesize, signal_h: Fix Android build 2015-02-11 maint: various whitespace cleanups in tempname
This commit is contained in:
parent
43fb42da8b
commit
066b17df68
11 changed files with 282 additions and 157 deletions
16
ChangeLog
16
ChangeLog
|
|
@ -1,3 +1,19 @@
|
||||||
|
2015-02-21 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
Merge from gnulib
|
||||||
|
* lib/getdtablesize.c, lib/getopt.c, lib/signal.in.h, lib/tempname.c:
|
||||||
|
* lib/tempname.h, m4/dup2.m4, m4/fcntl.m4, m4/getdtablesize.m4:
|
||||||
|
Update from gnulib, incorporating:
|
||||||
|
2015-02-20 getdtablesize: port better for Android
|
||||||
|
2015-02-19 fcntl: Fix cross compiling
|
||||||
|
2015-02-18 dup2, fcntl: cross-compile better for Android
|
||||||
|
2015-02-18 getopt: don't crash on memory exhaustion
|
||||||
|
2015-02-17 tempname: allow compilation with C++ (trivial)
|
||||||
|
2015-02-17 dup2, fcntl: port to AIX
|
||||||
|
2015-02-16 getdtablesize, dup2, fcntl: port to Android
|
||||||
|
2015-02-11 getdtablesize, signal_h: Fix Android build
|
||||||
|
2015-02-11 maint: various whitespace cleanups in tempname
|
||||||
|
|
||||||
2015-02-13 Jan Djärv <jan.h.d@swipnet.se>
|
2015-02-13 Jan Djärv <jan.h.d@swipnet.se>
|
||||||
|
|
||||||
* configure.ac: Set locallisppath to empty for NS self contained,
|
* configure.ac: Set locallisppath to empty for NS self contained,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
2015-02-21 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
* texinfo.tex: Update from gnulib.
|
||||||
|
|
||||||
2015-02-10 Lars Ingebrigtsen <larsi@gnus.org>
|
2015-02-10 Lars Ingebrigtsen <larsi@gnus.org>
|
||||||
|
|
||||||
* eww.texi (Basics): Mention eww-toggle-fonts.
|
* eww.texi (Basics): Mention eww-toggle-fonts.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
% Load plain if necessary, i.e., if running under initex.
|
% Load plain if necessary, i.e., if running under initex.
|
||||||
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
|
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
|
||||||
%
|
%
|
||||||
\def\texinfoversion{2015-01-31.10}
|
\def\texinfoversion{2015-02-05.16}
|
||||||
%
|
%
|
||||||
% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
|
% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
|
||||||
% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||||
|
|
@ -4489,7 +4489,6 @@ end
|
||||||
% Called from \indexdummies and \atdummies.
|
% Called from \indexdummies and \atdummies.
|
||||||
%
|
%
|
||||||
\def\commondummies{%
|
\def\commondummies{%
|
||||||
%
|
|
||||||
% \definedummyword defines \#1 as \string\#1\space, thus effectively
|
% \definedummyword defines \#1 as \string\#1\space, thus effectively
|
||||||
% preventing its expansion. This is used only for control words,
|
% preventing its expansion. This is used only for control words,
|
||||||
% not control letters, because the \space would be incorrect for
|
% not control letters, because the \space would be incorrect for
|
||||||
|
|
@ -4566,6 +4565,7 @@ end
|
||||||
\definedummyword\guilsinglright
|
\definedummyword\guilsinglright
|
||||||
\definedummyword\lbracechar
|
\definedummyword\lbracechar
|
||||||
\definedummyword\leq
|
\definedummyword\leq
|
||||||
|
\definedummyword\mathopsup
|
||||||
\definedummyword\minus
|
\definedummyword\minus
|
||||||
\definedummyword\ogonek
|
\definedummyword\ogonek
|
||||||
\definedummyword\pounds
|
\definedummyword\pounds
|
||||||
|
|
@ -4579,6 +4579,8 @@ end
|
||||||
\definedummyword\quotesinglbase
|
\definedummyword\quotesinglbase
|
||||||
\definedummyword\rbracechar
|
\definedummyword\rbracechar
|
||||||
\definedummyword\result
|
\definedummyword\result
|
||||||
|
\definedummyword\sub
|
||||||
|
\definedummyword\sup
|
||||||
\definedummyword\textdegree
|
\definedummyword\textdegree
|
||||||
%
|
%
|
||||||
% We want to disable all macros so that they are not expanded by \write.
|
% We want to disable all macros so that they are not expanded by \write.
|
||||||
|
|
@ -4653,6 +4655,7 @@ end
|
||||||
\definedummyword\samp
|
\definedummyword\samp
|
||||||
\definedummyword\strong
|
\definedummyword\strong
|
||||||
\definedummyword\tie
|
\definedummyword\tie
|
||||||
|
\definedummyword\U
|
||||||
\definedummyword\uref
|
\definedummyword\uref
|
||||||
\definedummyword\url
|
\definedummyword\url
|
||||||
\definedummyword\var
|
\definedummyword\var
|
||||||
|
|
@ -8335,14 +8338,7 @@ end
|
||||||
\catcode`\\=\other
|
\catcode`\\=\other
|
||||||
%
|
%
|
||||||
% Make the characters 128-255 be printing characters.
|
% Make the characters 128-255 be printing characters.
|
||||||
{%
|
{\setnonasciicharscatcodenonglobal\other}%
|
||||||
\count1=128
|
|
||||||
\def\loop{%
|
|
||||||
\catcode\count1=\other
|
|
||||||
\advance\count1 by 1
|
|
||||||
\ifnum \count1<256 \loop \fi
|
|
||||||
}%
|
|
||||||
}%
|
|
||||||
%
|
%
|
||||||
% @ is our escape character in .aux files, and we need braces.
|
% @ is our escape character in .aux files, and we need braces.
|
||||||
\catcode`\{=1
|
\catcode`\{=1
|
||||||
|
|
@ -9831,15 +9827,51 @@ directory should work if nowhere else does.}
|
||||||
\DeclareUnicodeCharacter{2261}{\equiv}
|
\DeclareUnicodeCharacter{2261}{\equiv}
|
||||||
}% end of \utfeightchardefs
|
}% end of \utfeightchardefs
|
||||||
|
|
||||||
|
|
||||||
% US-ASCII character definitions.
|
% US-ASCII character definitions.
|
||||||
\def\asciichardefs{% nothing need be done
|
\def\asciichardefs{% nothing need be done
|
||||||
\relax
|
\relax
|
||||||
}
|
}
|
||||||
|
|
||||||
|
% Latin1 (ISO-8859-1) character definitions.
|
||||||
|
\def\nonasciistringdefs{%
|
||||||
|
\setnonasciicharscatcode\active
|
||||||
|
\def\defstringchar##1{\def##1{\string##1}}%
|
||||||
|
\defstringchar^^a0\defstringchar^^a1\defstringchar^^a2\defstringchar^^a3%
|
||||||
|
\defstringchar^^a4\defstringchar^^a5\defstringchar^^a6\defstringchar^^a7%
|
||||||
|
\defstringchar^^a8\defstringchar^^a9\defstringchar^^aa\defstringchar^^ab%
|
||||||
|
\defstringchar^^ac\defstringchar^^ad\defstringchar^^ae\defstringchar^^af%
|
||||||
|
%
|
||||||
|
\defstringchar^^b0\defstringchar^^b1\defstringchar^^b2\defstringchar^^b3%
|
||||||
|
\defstringchar^^b4\defstringchar^^b5\defstringchar^^b6\defstringchar^^b7%
|
||||||
|
\defstringchar^^b8\defstringchar^^b9\defstringchar^^ba\defstringchar^^bb%
|
||||||
|
\defstringchar^^bc\defstringchar^^bd\defstringchar^^be\defstringchar^^bf%
|
||||||
|
%
|
||||||
|
\defstringchar^^c0\defstringchar^^c1\defstringchar^^c2\defstringchar^^c3%
|
||||||
|
\defstringchar^^c4\defstringchar^^c5\defstringchar^^c6\defstringchar^^c7%
|
||||||
|
\defstringchar^^c8\defstringchar^^c9\defstringchar^^ca\defstringchar^^cb%
|
||||||
|
\defstringchar^^cc\defstringchar^^cd\defstringchar^^ce\defstringchar^^cf%
|
||||||
|
%
|
||||||
|
\defstringchar^^d0\defstringchar^^d1\defstringchar^^d2\defstringchar^^d3%
|
||||||
|
\defstringchar^^d4\defstringchar^^d5\defstringchar^^d6\defstringchar^^d7%
|
||||||
|
\defstringchar^^d8\defstringchar^^d9\defstringchar^^da\defstringchar^^db%
|
||||||
|
\defstringchar^^dc\defstringchar^^dd\defstringchar^^de\defstringchar^^df%
|
||||||
|
%
|
||||||
|
\defstringchar^^e0\defstringchar^^e1\defstringchar^^e2\defstringchar^^e3%
|
||||||
|
\defstringchar^^e4\defstringchar^^e5\defstringchar^^e6\defstringchar^^e7%
|
||||||
|
\defstringchar^^e8\defstringchar^^e9\defstringchar^^ea\defstringchar^^eb%
|
||||||
|
\defstringchar^^ec\defstringchar^^ed\defstringchar^^ee\defstringchar^^ef%
|
||||||
|
%
|
||||||
|
\defstringchar^^f0\defstringchar^^f1\defstringchar^^f2\defstringchar^^f3%
|
||||||
|
\defstringchar^^f4\defstringchar^^f5\defstringchar^^f6\defstringchar^^f7%
|
||||||
|
\defstringchar^^f8\defstringchar^^f9\defstringchar^^fa\defstringchar^^fb%
|
||||||
|
\defstringchar^^fc\defstringchar^^fd\defstringchar^^fe\defstringchar^^ff%
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
% define all the unicode characters we know about, for the sake of @U.
|
% define all the unicode characters we know about, for the sake of @U.
|
||||||
\utfeightchardefs
|
\utfeightchardefs
|
||||||
|
|
||||||
|
|
||||||
% Make non-ASCII characters printable again for compatibility with
|
% Make non-ASCII characters printable again for compatibility with
|
||||||
% existing Texinfo documents that may use them, even without declaring a
|
% existing Texinfo documents that may use them, even without declaring a
|
||||||
% document encoding.
|
% document encoding.
|
||||||
|
|
@ -10193,6 +10225,7 @@ directory should work if nowhere else does.}
|
||||||
%
|
%
|
||||||
{@catcode`- = @active
|
{@catcode`- = @active
|
||||||
@gdef@normalturnoffactive{%
|
@gdef@normalturnoffactive{%
|
||||||
|
@nonasciistringdefs
|
||||||
@let-=@normaldash
|
@let-=@normaldash
|
||||||
@let"=@normaldoublequote
|
@let"=@normaldoublequote
|
||||||
@let$=@normaldollar %$ font-lock fix
|
@let$=@normaldollar %$ font-lock fix
|
||||||
|
|
|
||||||
|
|
@ -84,32 +84,31 @@ getdtablesize (void)
|
||||||
return dtablesize;
|
return dtablesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif HAVE_GETDTABLESIZE
|
#else
|
||||||
|
|
||||||
|
# include <limits.h>
|
||||||
# include <sys/resource.h>
|
# include <sys/resource.h>
|
||||||
# undef getdtablesize
|
|
||||||
|
|
||||||
int
|
# ifdef __CYGWIN__
|
||||||
rpl_getdtablesize(void)
|
/* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it
|
||||||
{
|
hits the compile-time constant hard limit of 3200. We might as
|
||||||
/* To date, this replacement is only compiled for Cygwin 1.7.25,
|
well just report the hard limit. */
|
||||||
which auto-increased the RLIMIT_NOFILE soft limit until it
|
# define rlim_cur rlim_max
|
||||||
hits the compile-time constant hard limit of 3200. Although
|
# endif
|
||||||
that version of cygwin supported a child process inheriting
|
|
||||||
a smaller soft limit, the smaller limit is not enforced, so
|
|
||||||
we might as well just report the hard limit. */
|
|
||||||
struct rlimit lim;
|
|
||||||
if (!getrlimit (RLIMIT_NOFILE, &lim) && lim.rlim_max != RLIM_INFINITY)
|
|
||||||
return lim.rlim_max;
|
|
||||||
return getdtablesize ();
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined _SC_OPEN_MAX
|
|
||||||
|
|
||||||
int
|
int
|
||||||
getdtablesize (void)
|
getdtablesize (void)
|
||||||
{
|
{
|
||||||
return sysconf (_SC_OPEN_MAX);
|
struct rlimit lim;
|
||||||
|
|
||||||
|
if (getrlimit (RLIMIT_NOFILE, &lim) == 0
|
||||||
|
&& 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX
|
||||||
|
&& lim.rlim_cur != RLIM_INFINITY
|
||||||
|
&& lim.rlim_cur != RLIM_SAVED_CUR
|
||||||
|
&& lim.rlim_cur != RLIM_SAVED_MAX)
|
||||||
|
return lim.rlim_cur;
|
||||||
|
|
||||||
|
return INT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
52
lib/getopt.c
52
lib/getopt.c
|
|
@ -487,7 +487,20 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
const struct option *p;
|
const struct option *p;
|
||||||
struct option_list *next;
|
struct option_list *next;
|
||||||
} *ambig_list = NULL;
|
} *ambig_list = NULL;
|
||||||
|
#ifdef _LIBC
|
||||||
|
/* malloc() not used for _LIBC to simplify failure messages. */
|
||||||
|
# define free_option_list(l)
|
||||||
|
#else
|
||||||
|
# define free_option_list(l) \
|
||||||
|
while (l != NULL) \
|
||||||
|
{ \
|
||||||
|
struct option_list *pn = l->next; \
|
||||||
|
free (l); \
|
||||||
|
l = pn; \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
int exact = 0;
|
int exact = 0;
|
||||||
|
int ambig = 0;
|
||||||
int indfound = -1;
|
int indfound = -1;
|
||||||
int option_index;
|
int option_index;
|
||||||
|
|
||||||
|
|
@ -514,22 +527,37 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
pfound = p;
|
pfound = p;
|
||||||
indfound = option_index;
|
indfound = option_index;
|
||||||
}
|
}
|
||||||
|
else if (ambig)
|
||||||
|
; /* Taking simpler path to handling ambiguities. */
|
||||||
else if (long_only
|
else if (long_only
|
||||||
|| pfound->has_arg != p->has_arg
|
|| pfound->has_arg != p->has_arg
|
||||||
|| pfound->flag != p->flag
|
|| pfound->flag != p->flag
|
||||||
|| pfound->val != p->val)
|
|| pfound->val != p->val)
|
||||||
{
|
{
|
||||||
/* Second or later nonexact match found. */
|
/* Second or later nonexact match found. */
|
||||||
|
#ifdef _LIBC
|
||||||
|
struct option_list *newp = alloca (sizeof (*newp));
|
||||||
|
#else
|
||||||
struct option_list *newp = malloc (sizeof (*newp));
|
struct option_list *newp = malloc (sizeof (*newp));
|
||||||
newp->p = p;
|
if (newp == NULL)
|
||||||
newp->next = ambig_list;
|
{
|
||||||
ambig_list = newp;
|
free_option_list (ambig_list);
|
||||||
|
ambig_list = NULL;
|
||||||
|
ambig = 1; /* Use simpler fallback message. */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
newp->p = p;
|
||||||
|
newp->next = ambig_list;
|
||||||
|
ambig_list = newp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambig_list != NULL && !exact)
|
if ((ambig || ambig_list) && !exact)
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors && ambig_list)
|
||||||
{
|
{
|
||||||
struct option_list first;
|
struct option_list first;
|
||||||
first.p = pfound;
|
first.p = pfound;
|
||||||
|
|
@ -585,18 +613,20 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
fputc ('\n', stderr);
|
fputc ('\n', stderr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
else if (print_errors && ambig)
|
||||||
|
{
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: option '%s' is ambiguous\n"),
|
||||||
|
argv[0], argv[d->optind]);
|
||||||
|
}
|
||||||
d->__nextchar += strlen (d->__nextchar);
|
d->__nextchar += strlen (d->__nextchar);
|
||||||
d->optind++;
|
d->optind++;
|
||||||
d->optopt = 0;
|
d->optopt = 0;
|
||||||
|
free_option_list (ambig_list);
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ambig_list != NULL)
|
free_option_list (ambig_list);
|
||||||
{
|
|
||||||
struct option_list *pn = ambig_list->next;
|
|
||||||
free (ambig_list);
|
|
||||||
ambig_list = pn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pfound != NULL)
|
if (pfound != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,13 @@
|
||||||
#ifndef _@GUARD_PREFIX@_SIGNAL_H
|
#ifndef _@GUARD_PREFIX@_SIGNAL_H
|
||||||
#define _@GUARD_PREFIX@_SIGNAL_H
|
#define _@GUARD_PREFIX@_SIGNAL_H
|
||||||
|
|
||||||
/* Mac OS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6 declare
|
/* Mac OS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6, Android
|
||||||
pthread_sigmask in <pthread.h>, not in <signal.h>.
|
declare pthread_sigmask in <pthread.h>, not in <signal.h>.
|
||||||
But avoid namespace pollution on glibc systems.*/
|
But avoid namespace pollution on glibc systems.*/
|
||||||
#if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
|
#if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \
|
||||||
&& ((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ || defined __sun) \
|
&& ((defined __APPLE__ && defined __MACH__) \
|
||||||
|
|| defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ \
|
||||||
|
|| defined __sun || defined __ANDROID__) \
|
||||||
&& ! defined __GLIBC__
|
&& ! defined __GLIBC__
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
118
lib/tempname.c
118
lib/tempname.c
|
|
@ -62,6 +62,7 @@
|
||||||
# define struct_stat64 struct stat64
|
# define struct_stat64 struct stat64
|
||||||
#else
|
#else
|
||||||
# define struct_stat64 struct stat
|
# define struct_stat64 struct stat
|
||||||
|
# define __try_tempname try_tempname
|
||||||
# define __gen_tempname gen_tempname
|
# define __gen_tempname gen_tempname
|
||||||
# define __getpid getpid
|
# define __getpid getpid
|
||||||
# define __gettimeofday gettimeofday
|
# define __gettimeofday gettimeofday
|
||||||
|
|
@ -176,21 +177,9 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
|
||||||
static const char letters[] =
|
static const char letters[] =
|
||||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
|
|
||||||
/* Generate a temporary file name based on TMPL. TMPL must match the
|
|
||||||
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
|
|
||||||
The name constructed does not exist at the time of the call to
|
|
||||||
__gen_tempname. TMPL is overwritten with the result.
|
|
||||||
|
|
||||||
KIND may be one of:
|
|
||||||
__GT_NOCREATE: simply verify that the name does not exist
|
|
||||||
at the time of the call.
|
|
||||||
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
|
|
||||||
and return a read-write fd. The file is mode 0600.
|
|
||||||
__GT_DIR: create a directory, which will be mode 0700.
|
|
||||||
|
|
||||||
We use a clever algorithm to get hard-to-predict names. */
|
|
||||||
int
|
int
|
||||||
__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
__try_tempname (char *tmpl, int suffixlen, void *args,
|
||||||
|
int (*tryfunc) (char *, void *))
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *XXXXXX;
|
char *XXXXXX;
|
||||||
|
|
@ -199,7 +188,6 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int save_errno = errno;
|
int save_errno = errno;
|
||||||
struct_stat64 st;
|
|
||||||
|
|
||||||
/* A lower bound on the number of temporary files to attempt to
|
/* A lower bound on the number of temporary files to attempt to
|
||||||
generate. The maximum total number of temporary file names that
|
generate. The maximum total number of temporary file names that
|
||||||
|
|
@ -256,41 +244,7 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||||
v /= 62;
|
v /= 62;
|
||||||
XXXXXX[5] = letters[v % 62];
|
XXXXXX[5] = letters[v % 62];
|
||||||
|
|
||||||
switch (kind)
|
fd = tryfunc (tmpl, args);
|
||||||
{
|
|
||||||
case __GT_FILE:
|
|
||||||
fd = __open (tmpl,
|
|
||||||
(flags & ~O_ACCMODE)
|
|
||||||
| O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case __GT_DIR:
|
|
||||||
fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case __GT_NOCREATE:
|
|
||||||
/* This case is backward from the other three. __gen_tempname
|
|
||||||
succeeds if __xstat fails because the name does not exist.
|
|
||||||
Note the continue to bypass the common logic at the bottom
|
|
||||||
of the loop. */
|
|
||||||
if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
|
|
||||||
{
|
|
||||||
if (errno == ENOENT)
|
|
||||||
{
|
|
||||||
__set_errno (save_errno);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* Give up now. */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
|
|
||||||
default:
|
|
||||||
assert (! "invalid KIND in __gen_tempname");
|
|
||||||
abort ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
__set_errno (save_errno);
|
__set_errno (save_errno);
|
||||||
|
|
@ -304,3 +258,67 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||||
__set_errno (EEXIST);
|
__set_errno (EEXIST);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
try_file (char *tmpl, void *flags)
|
||||||
|
{
|
||||||
|
int *openflags = flags;
|
||||||
|
return __open (tmpl,
|
||||||
|
(*openflags & ~O_ACCMODE)
|
||||||
|
| O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
try_dir (char *tmpl, void *flags)
|
||||||
|
{
|
||||||
|
return __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
try_nocreate (char *tmpl, void *flags)
|
||||||
|
{
|
||||||
|
struct_stat64 st;
|
||||||
|
|
||||||
|
if (__lxstat64 (_STAT_VER, tmpl, &st) == 0)
|
||||||
|
__set_errno (EEXIST);
|
||||||
|
return errno == ENOENT ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generate a temporary file name based on TMPL. TMPL must match the
|
||||||
|
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
|
||||||
|
The name constructed does not exist at the time of the call to
|
||||||
|
__gen_tempname. TMPL is overwritten with the result.
|
||||||
|
|
||||||
|
KIND may be one of:
|
||||||
|
__GT_NOCREATE: simply verify that the name does not exist
|
||||||
|
at the time of the call.
|
||||||
|
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
|
||||||
|
and return a read-write fd. The file is mode 0600.
|
||||||
|
__GT_DIR: create a directory, which will be mode 0700.
|
||||||
|
|
||||||
|
We use a clever algorithm to get hard-to-predict names. */
|
||||||
|
int
|
||||||
|
__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||||
|
{
|
||||||
|
int (*tryfunc) (char *, void *);
|
||||||
|
|
||||||
|
switch (kind)
|
||||||
|
{
|
||||||
|
case __GT_FILE:
|
||||||
|
tryfunc = try_file;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case __GT_DIR:
|
||||||
|
tryfunc = try_dir;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case __GT_NOCREATE:
|
||||||
|
tryfunc = try_nocreate;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert (! "invalid KIND in __gen_tempname");
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
return __try_tempname (tmpl, suffixlen, &flags, tryfunc);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,10 @@
|
||||||
# define GT_NOCREATE 2
|
# define GT_NOCREATE 2
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Generate a temporary file name based on TMPL. TMPL must match the
|
/* Generate a temporary file name based on TMPL. TMPL must match the
|
||||||
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
|
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
|
||||||
The name constructed does not exist at the time of the call to
|
The name constructed does not exist at the time of the call to
|
||||||
|
|
@ -47,4 +51,15 @@
|
||||||
We use a clever algorithm to get hard-to-predict names. */
|
We use a clever algorithm to get hard-to-predict names. */
|
||||||
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
|
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
|
||||||
|
|
||||||
|
/* Similar to gen_tempname, but TRYFUNC is called for each temporary
|
||||||
|
name to try. If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
|
||||||
|
returns with this value. Otherwise, if errno is set to EEXIST, another
|
||||||
|
name is tried, or else TRY_GEN_TEMPNAME returns -1. */
|
||||||
|
extern int try_tempname (char *tmpl, int suffixlen, void *args,
|
||||||
|
int (*tryfunc) (char *, void *));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* GL_TEMPNAME_H */
|
#endif /* GL_TEMPNAME_H */
|
||||||
|
|
|
||||||
76
m4/dup2.m4
76
m4/dup2.m4
|
|
@ -1,4 +1,4 @@
|
||||||
#serial 20
|
#serial 22
|
||||||
dnl Copyright (C) 2002, 2005, 2007, 2009-2015 Free Software Foundation, Inc.
|
dnl Copyright (C) 2002, 2005, 2007, 2009-2015 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
|
|
@ -8,7 +8,6 @@ AC_DEFUN([gl_FUNC_DUP2],
|
||||||
[
|
[
|
||||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||||
AC_CHECK_FUNCS_ONCE([getdtablesize])
|
|
||||||
m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [
|
m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [
|
||||||
AC_CHECK_FUNCS_ONCE([dup2])
|
AC_CHECK_FUNCS_ONCE([dup2])
|
||||||
if test $ac_cv_func_dup2 = no; then
|
if test $ac_cv_func_dup2 = no; then
|
||||||
|
|
@ -20,38 +19,44 @@ AC_DEFUN([gl_FUNC_DUP2],
|
||||||
if test $HAVE_DUP2 = 1; then
|
if test $HAVE_DUP2 = 1; then
|
||||||
AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
|
AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
|
||||||
[AC_RUN_IFELSE([
|
[AC_RUN_IFELSE([
|
||||||
AC_LANG_PROGRAM([[#include <unistd.h>
|
AC_LANG_PROGRAM(
|
||||||
#include <fcntl.h>
|
[[#include <errno.h>
|
||||||
#include <errno.h>]],
|
#include <fcntl.h>
|
||||||
[int result = 0;
|
#include <limits.h>
|
||||||
#ifdef HAVE_GETDTABLESIZE
|
#include <sys/resource.h>
|
||||||
int bad_fd = getdtablesize ();
|
#include <unistd.h>
|
||||||
#else
|
]],
|
||||||
int bad_fd = 1000000;
|
[[int result = 0;
|
||||||
#endif
|
int bad_fd = INT_MAX;
|
||||||
#ifdef FD_CLOEXEC
|
struct rlimit rlim;
|
||||||
if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
|
if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
|
||||||
result |= 1;
|
&& 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
|
||||||
#endif
|
&& rlim.rlim_cur != RLIM_INFINITY
|
||||||
if (dup2 (1, 1) == 0)
|
&& rlim.rlim_cur != RLIM_SAVED_MAX
|
||||||
result |= 2;
|
&& rlim.rlim_cur != RLIM_SAVED_CUR)
|
||||||
#ifdef FD_CLOEXEC
|
bad_fd = rlim.rlim_cur;
|
||||||
if (fcntl (1, F_GETFD) != FD_CLOEXEC)
|
#ifdef FD_CLOEXEC
|
||||||
result |= 4;
|
if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
|
||||||
#endif
|
result |= 1;
|
||||||
close (0);
|
#endif
|
||||||
if (dup2 (0, 0) != -1)
|
if (dup2 (1, 1) == 0)
|
||||||
result |= 8;
|
result |= 2;
|
||||||
/* Many gnulib modules require POSIX conformance of EBADF. */
|
#ifdef FD_CLOEXEC
|
||||||
if (dup2 (2, bad_fd) == -1 && errno != EBADF)
|
if (fcntl (1, F_GETFD) != FD_CLOEXEC)
|
||||||
result |= 16;
|
result |= 4;
|
||||||
/* Flush out some cygwin core dumps. */
|
#endif
|
||||||
if (dup2 (2, -1) != -1 || errno != EBADF)
|
close (0);
|
||||||
result |= 32;
|
if (dup2 (0, 0) != -1)
|
||||||
dup2 (2, 255);
|
result |= 8;
|
||||||
dup2 (2, 256);
|
/* Many gnulib modules require POSIX conformance of EBADF. */
|
||||||
return result;
|
if (dup2 (2, bad_fd) == -1 && errno != EBADF)
|
||||||
])
|
result |= 16;
|
||||||
|
/* Flush out some cygwin core dumps. */
|
||||||
|
if (dup2 (2, -1) != -1 || errno != EBADF)
|
||||||
|
result |= 32;
|
||||||
|
dup2 (2, 255);
|
||||||
|
dup2 (2, 256);
|
||||||
|
return result;]])
|
||||||
],
|
],
|
||||||
[gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
|
[gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
|
||||||
[case "$host_os" in
|
[case "$host_os" in
|
||||||
|
|
@ -59,9 +64,6 @@ AC_DEFUN([gl_FUNC_DUP2],
|
||||||
gl_cv_func_dup2_works="guessing no" ;;
|
gl_cv_func_dup2_works="guessing no" ;;
|
||||||
cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
|
cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
|
||||||
gl_cv_func_dup2_works="guessing no" ;;
|
gl_cv_func_dup2_works="guessing no" ;;
|
||||||
linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
|
|
||||||
# closed fd may yield -EBADF instead of -1 / errno=EBADF.
|
|
||||||
gl_cv_func_dup2_works="guessing no" ;;
|
|
||||||
aix* | freebsd*)
|
aix* | freebsd*)
|
||||||
# on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
|
# on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
|
||||||
# not EBADF.
|
# not EBADF.
|
||||||
|
|
|
||||||
52
m4/fcntl.m4
52
m4/fcntl.m4
|
|
@ -1,4 +1,4 @@
|
||||||
# fcntl.m4 serial 5
|
# fcntl.m4 serial 7
|
||||||
dnl Copyright (C) 2009-2015 Free Software Foundation, Inc.
|
dnl Copyright (C) 2009-2015 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
|
|
@ -19,7 +19,7 @@ AC_DEFUN([gl_FUNC_FCNTL],
|
||||||
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
||||||
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
|
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||||
AC_CHECK_FUNCS_ONCE([fcntl getdtablesize])
|
AC_CHECK_FUNCS_ONCE([fcntl])
|
||||||
if test $ac_cv_func_fcntl = no; then
|
if test $ac_cv_func_fcntl = no; then
|
||||||
gl_REPLACE_FCNTL
|
gl_REPLACE_FCNTL
|
||||||
else
|
else
|
||||||
|
|
@ -27,30 +27,34 @@ AC_DEFUN([gl_FUNC_FCNTL],
|
||||||
dnl haiku alpha 2 F_DUPFD has wrong errno
|
dnl haiku alpha 2 F_DUPFD has wrong errno
|
||||||
AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
|
AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
|
||||||
[gl_cv_func_fcntl_f_dupfd_works],
|
[gl_cv_func_fcntl_f_dupfd_works],
|
||||||
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
[AC_RUN_IFELSE(
|
||||||
#ifdef HAVE_GETDTABLESIZE
|
[AC_LANG_PROGRAM(
|
||||||
# include <unistd.h>
|
[[#include <errno.h>
|
||||||
#endif
|
#include <fcntl.h>
|
||||||
#include <fcntl.h>
|
#include <limits.h>
|
||||||
#include <errno.h>
|
#include <sys/resource.h>
|
||||||
]], [[int result = 0;
|
#include <unistd.h>
|
||||||
#ifdef HAVE_GETDTABLESIZE
|
]],
|
||||||
int bad_fd = getdtablesize ();
|
[[int result = 0;
|
||||||
#else
|
int bad_fd = INT_MAX;
|
||||||
int bad_fd = 1000000;
|
struct rlimit rlim;
|
||||||
#endif
|
if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
|
||||||
if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
|
&& 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
|
||||||
if (errno != EINVAL) result |= 2;
|
&& rlim.rlim_cur != RLIM_INFINITY
|
||||||
if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4;
|
&& rlim.rlim_cur != RLIM_SAVED_MAX
|
||||||
if (errno != EINVAL) result |= 8;
|
&& rlim.rlim_cur != RLIM_SAVED_CUR)
|
||||||
return result;
|
bad_fd = rlim.rlim_cur;
|
||||||
]])],
|
if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
|
||||||
|
if (errno != EINVAL) result |= 2;
|
||||||
|
if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4;
|
||||||
|
if (errno != EINVAL) result |= 8;
|
||||||
|
return result;]])],
|
||||||
[gl_cv_func_fcntl_f_dupfd_works=yes],
|
[gl_cv_func_fcntl_f_dupfd_works=yes],
|
||||||
[gl_cv_func_fcntl_f_dupfd_works=no],
|
[gl_cv_func_fcntl_f_dupfd_works=no],
|
||||||
[# Guess that it works on glibc systems
|
[case $host_os in
|
||||||
case $host_os in #((
|
aix* | cygwin* | haiku*)
|
||||||
*-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
|
gl_cv_func_fcntl_f_dupfd_works="guessing no" ;;
|
||||||
*) gl_cv_func_fcntl_f_dupfd_works="guessing no";;
|
*) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;;
|
||||||
esac])])
|
esac])])
|
||||||
case $gl_cv_func_fcntl_f_dupfd_works in
|
case $gl_cv_func_fcntl_f_dupfd_works in
|
||||||
*yes) ;;
|
*yes) ;;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# getdtablesize.m4 serial 5
|
# getdtablesize.m4 serial 6
|
||||||
dnl Copyright (C) 2008-2015 Free Software Foundation, Inc.
|
dnl Copyright (C) 2008-2015 Free Software Foundation, Inc.
|
||||||
dnl This file is free software; the Free Software Foundation
|
dnl This file is free software; the Free Software Foundation
|
||||||
dnl gives unlimited permission to copy and/or distribute it,
|
dnl gives unlimited permission to copy and/or distribute it,
|
||||||
|
|
@ -9,7 +9,9 @@ AC_DEFUN([gl_FUNC_GETDTABLESIZE],
|
||||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||||
AC_CHECK_FUNCS_ONCE([getdtablesize])
|
AC_CHECK_FUNCS_ONCE([getdtablesize])
|
||||||
if test $ac_cv_func_getdtablesize = yes; then
|
AC_CHECK_DECLS_ONCE([getdtablesize])
|
||||||
|
if test $ac_cv_func_getdtablesize = yes &&
|
||||||
|
test $ac_cv_have_decl_getdtablesize = yes; then
|
||||||
# Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft limit
|
# Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft limit
|
||||||
# up to an unchangeable hard limit; all other platforms correctly
|
# up to an unchangeable hard limit; all other platforms correctly
|
||||||
# require setrlimit before getdtablesize() can report a larger value.
|
# require setrlimit before getdtablesize() can report a larger value.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue