Imported Upstream version 1.4.15
This commit is contained in:
parent
882cdeecca
commit
047baae1ca
386 changed files with 60019 additions and 38317 deletions
840
gl/Makefile.am
840
gl/Makefile.am
File diff suppressed because it is too large
Load diff
1068
gl/Makefile.in
1068
gl/Makefile.in
File diff suppressed because it is too large
Load diff
34
gl/alignof.h
34
gl/alignof.h
|
|
@ -1,5 +1,5 @@
|
|||
/* Determine alignment of types.
|
||||
Copyright (C) 2003-2004, 2006, 2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2004, 2006, 2009-2010 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,14 +20,34 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Determine the alignment of a type at compile time. */
|
||||
#if defined __GNUC__
|
||||
# define alignof __alignof__
|
||||
#elif defined __cplusplus
|
||||
/* Determine the alignment of a structure slot (field) of a given type,
|
||||
at compile time. Note that the result depends on the ABI.
|
||||
Note: The result cannot be used as a value for an 'enum' constant,
|
||||
due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */
|
||||
#if defined __cplusplus
|
||||
template <class type> struct alignof_helper { char __slot1; type __slot2; };
|
||||
# define alignof(type) offsetof (alignof_helper<type>, __slot2)
|
||||
# define alignof_slot(type) offsetof (alignof_helper<type>, __slot2)
|
||||
#else
|
||||
# define alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
|
||||
# define alignof_slot(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
|
||||
#endif
|
||||
|
||||
/* Determine the good alignment of a object of the given type at compile time.
|
||||
Note that this is not necessarily the same as alignof_slot(type).
|
||||
For example, with GNU C on x86 platforms: alignof_type(double) = 8, but
|
||||
- when -malign-double is not specified: alignof_slot(double) = 4,
|
||||
- when -malign-double is specified: alignof_slot(double) = 8.
|
||||
Note: The result cannot be used as a value for an 'enum' constant,
|
||||
due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */
|
||||
#if defined __GNUC__
|
||||
# define alignof_type __alignof__
|
||||
#else
|
||||
# define alignof_type alignof_slot
|
||||
#endif
|
||||
|
||||
/* alignof is an alias for alignof_slot semantics, since that's what most
|
||||
callers need.
|
||||
Note: The result cannot be used as a value for an 'enum' constant,
|
||||
due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */
|
||||
#define alignof alignof_slot
|
||||
|
||||
#endif /* _ALIGNOF_H */
|
||||
|
|
|
|||
489
gl/alloca.c
489
gl/alloca.c
|
|
@ -1,489 +0,0 @@
|
|||
/* alloca.c -- allocate automatically reclaimed memory
|
||||
(Mostly) portable public-domain implementation -- D A Gwyn
|
||||
|
||||
This implementation of the PWB library alloca function,
|
||||
which is used to allocate space off the run-time stack so
|
||||
that it is automatically reclaimed upon procedure exit,
|
||||
was inspired by discussions with J. Q. Johnson of Cornell.
|
||||
J.Otto Tennant <jot@cray.com> contributed the Cray support.
|
||||
|
||||
There are some preprocessor constants that can
|
||||
be defined when compiling for your specific system, for
|
||||
improved efficiency; however, the defaults should be okay.
|
||||
|
||||
The general concept of this implementation is to keep
|
||||
track of all alloca-allocated blocks, and reclaim any
|
||||
that are found to be deeper in the stack than the current
|
||||
invocation. This heuristic does not reclaim storage as
|
||||
soon as it becomes invalid, but it will do so eventually.
|
||||
|
||||
As a special case, alloca(0) reclaims storage without
|
||||
allocating any. It is a good idea to use alloca(0) in
|
||||
your main control loop, etc. to force garbage collection. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef emacs
|
||||
# include "lisp.h"
|
||||
# include "blockinput.h"
|
||||
# ifdef EMACS_FREE
|
||||
# undef free
|
||||
# define free EMACS_FREE
|
||||
# endif
|
||||
#else
|
||||
# define memory_full() abort ()
|
||||
#endif
|
||||
|
||||
/* If compiling with GCC 2, this file's not needed. */
|
||||
#if !defined (__GNUC__) || __GNUC__ < 2
|
||||
|
||||
/* If someone has defined alloca as a macro,
|
||||
there must be some other way alloca is supposed to work. */
|
||||
# ifndef alloca
|
||||
|
||||
# ifdef emacs
|
||||
# ifdef static
|
||||
/* actually, only want this if static is defined as ""
|
||||
-- this is for usg, in which emacs must undefine static
|
||||
in order to make unexec workable
|
||||
*/
|
||||
# ifndef STACK_DIRECTION
|
||||
you
|
||||
lose
|
||||
-- must know STACK_DIRECTION at compile-time
|
||||
/* Using #error here is not wise since this file should work for
|
||||
old and obscure compilers. */
|
||||
# endif /* STACK_DIRECTION undefined */
|
||||
# endif /* static */
|
||||
# endif /* emacs */
|
||||
|
||||
/* If your stack is a linked list of frames, you have to
|
||||
provide an "address metric" ADDRESS_FUNCTION macro. */
|
||||
|
||||
# if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
long i00afunc ();
|
||||
# define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
|
||||
# else
|
||||
# define ADDRESS_FUNCTION(arg) &(arg)
|
||||
# endif
|
||||
|
||||
/* Define STACK_DIRECTION if you know the direction of stack
|
||||
growth for your system; otherwise it will be automatically
|
||||
deduced at run-time.
|
||||
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
|
||||
# ifndef STACK_DIRECTION
|
||||
# define STACK_DIRECTION 0 /* Direction unknown. */
|
||||
# endif
|
||||
|
||||
# if STACK_DIRECTION != 0
|
||||
|
||||
# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
|
||||
|
||||
# else /* STACK_DIRECTION == 0; need run-time code. */
|
||||
|
||||
static int stack_dir; /* 1 or -1 once known. */
|
||||
# define STACK_DIR stack_dir
|
||||
|
||||
static void
|
||||
find_stack_direction (void)
|
||||
{
|
||||
static char *addr = NULL; /* Address of first `dummy', once known. */
|
||||
auto char dummy; /* To get stack address. */
|
||||
|
||||
if (addr == NULL)
|
||||
{ /* Initial entry. */
|
||||
addr = ADDRESS_FUNCTION (dummy);
|
||||
|
||||
find_stack_direction (); /* Recurse once. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Second entry. */
|
||||
if (ADDRESS_FUNCTION (dummy) > addr)
|
||||
stack_dir = 1; /* Stack grew upward. */
|
||||
else
|
||||
stack_dir = -1; /* Stack grew downward. */
|
||||
}
|
||||
}
|
||||
|
||||
# endif /* STACK_DIRECTION == 0 */
|
||||
|
||||
/* An "alloca header" is used to:
|
||||
(a) chain together all alloca'ed blocks;
|
||||
(b) keep track of stack depth.
|
||||
|
||||
It is very important that sizeof(header) agree with malloc
|
||||
alignment chunk size. The following default should work okay. */
|
||||
|
||||
# ifndef ALIGN_SIZE
|
||||
# define ALIGN_SIZE sizeof(double)
|
||||
# endif
|
||||
|
||||
typedef union hdr
|
||||
{
|
||||
char align[ALIGN_SIZE]; /* To force sizeof(header). */
|
||||
struct
|
||||
{
|
||||
union hdr *next; /* For chaining headers. */
|
||||
char *deep; /* For stack depth measure. */
|
||||
} h;
|
||||
} header;
|
||||
|
||||
static header *last_alloca_header = NULL; /* -> last alloca header. */
|
||||
|
||||
/* Return a pointer to at least SIZE bytes of storage,
|
||||
which will be automatically reclaimed upon exit from
|
||||
the procedure that called alloca. Originally, this space
|
||||
was supposed to be taken from the current stack frame of the
|
||||
caller, but that method cannot be made to work for some
|
||||
implementations of C, for example under Gould's UTX/32. */
|
||||
|
||||
void *
|
||||
alloca (size_t size)
|
||||
{
|
||||
auto char probe; /* Probes stack depth: */
|
||||
register char *depth = ADDRESS_FUNCTION (probe);
|
||||
|
||||
# if STACK_DIRECTION == 0
|
||||
if (STACK_DIR == 0) /* Unknown growth direction. */
|
||||
find_stack_direction ();
|
||||
# endif
|
||||
|
||||
/* Reclaim garbage, defined as all alloca'd storage that
|
||||
was allocated from deeper in the stack than currently. */
|
||||
|
||||
{
|
||||
register header *hp; /* Traverses linked list. */
|
||||
|
||||
# ifdef emacs
|
||||
BLOCK_INPUT;
|
||||
# endif
|
||||
|
||||
for (hp = last_alloca_header; hp != NULL;)
|
||||
if ((STACK_DIR > 0 && hp->h.deep > depth)
|
||||
|| (STACK_DIR < 0 && hp->h.deep < depth))
|
||||
{
|
||||
register header *np = hp->h.next;
|
||||
|
||||
free (hp); /* Collect garbage. */
|
||||
|
||||
hp = np; /* -> next header. */
|
||||
}
|
||||
else
|
||||
break; /* Rest are not deeper. */
|
||||
|
||||
last_alloca_header = hp; /* -> last valid storage. */
|
||||
|
||||
# ifdef emacs
|
||||
UNBLOCK_INPUT;
|
||||
# endif
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
return NULL; /* No allocation required. */
|
||||
|
||||
/* Allocate combined header + user data storage. */
|
||||
|
||||
{
|
||||
/* Address of header. */
|
||||
register header *new;
|
||||
|
||||
size_t combined_size = sizeof (header) + size;
|
||||
if (combined_size < sizeof (header))
|
||||
memory_full ();
|
||||
|
||||
new = malloc (combined_size);
|
||||
|
||||
if (! new)
|
||||
memory_full ();
|
||||
|
||||
new->h.next = last_alloca_header;
|
||||
new->h.deep = depth;
|
||||
|
||||
last_alloca_header = new;
|
||||
|
||||
/* User storage begins just after header. */
|
||||
|
||||
return (void *) (new + 1);
|
||||
}
|
||||
}
|
||||
|
||||
# if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
|
||||
# ifndef CRAY_STACK
|
||||
# define CRAY_STACK
|
||||
# ifndef CRAY2
|
||||
/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
|
||||
struct stack_control_header
|
||||
{
|
||||
long shgrow:32; /* Number of times stack has grown. */
|
||||
long shaseg:32; /* Size of increments to stack. */
|
||||
long shhwm:32; /* High water mark of stack. */
|
||||
long shsize:32; /* Current size of stack (all segments). */
|
||||
};
|
||||
|
||||
/* The stack segment linkage control information occurs at
|
||||
the high-address end of a stack segment. (The stack
|
||||
grows from low addresses to high addresses.) The initial
|
||||
part of the stack segment linkage control information is
|
||||
0200 (octal) words. This provides for register storage
|
||||
for the routine which overflows the stack. */
|
||||
|
||||
struct stack_segment_linkage
|
||||
{
|
||||
long ss[0200]; /* 0200 overflow words. */
|
||||
long sssize:32; /* Number of words in this segment. */
|
||||
long ssbase:32; /* Offset to stack base. */
|
||||
long:32;
|
||||
long sspseg:32; /* Offset to linkage control of previous
|
||||
segment of stack. */
|
||||
long:32;
|
||||
long sstcpt:32; /* Pointer to task common address block. */
|
||||
long sscsnm; /* Private control structure number for
|
||||
microtasking. */
|
||||
long ssusr1; /* Reserved for user. */
|
||||
long ssusr2; /* Reserved for user. */
|
||||
long sstpid; /* Process ID for pid based multi-tasking. */
|
||||
long ssgvup; /* Pointer to multitasking thread giveup. */
|
||||
long sscray[7]; /* Reserved for Cray Research. */
|
||||
long ssa0;
|
||||
long ssa1;
|
||||
long ssa2;
|
||||
long ssa3;
|
||||
long ssa4;
|
||||
long ssa5;
|
||||
long ssa6;
|
||||
long ssa7;
|
||||
long sss0;
|
||||
long sss1;
|
||||
long sss2;
|
||||
long sss3;
|
||||
long sss4;
|
||||
long sss5;
|
||||
long sss6;
|
||||
long sss7;
|
||||
};
|
||||
|
||||
# else /* CRAY2 */
|
||||
/* The following structure defines the vector of words
|
||||
returned by the STKSTAT library routine. */
|
||||
struct stk_stat
|
||||
{
|
||||
long now; /* Current total stack size. */
|
||||
long maxc; /* Amount of contiguous space which would
|
||||
be required to satisfy the maximum
|
||||
stack demand to date. */
|
||||
long high_water; /* Stack high-water mark. */
|
||||
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
|
||||
long hits; /* Number of internal buffer hits. */
|
||||
long extends; /* Number of block extensions. */
|
||||
long stko_mallocs; /* Block allocations by $STKOFEN. */
|
||||
long underflows; /* Number of stack underflow calls ($STKRETN). */
|
||||
long stko_free; /* Number of deallocations by $STKRETN. */
|
||||
long stkm_free; /* Number of deallocations by $STKMRET. */
|
||||
long segments; /* Current number of stack segments. */
|
||||
long maxs; /* Maximum number of stack segments so far. */
|
||||
long pad_size; /* Stack pad size. */
|
||||
long current_address; /* Current stack segment address. */
|
||||
long current_size; /* Current stack segment size. This
|
||||
number is actually corrupted by STKSTAT to
|
||||
include the fifteen word trailer area. */
|
||||
long initial_address; /* Address of initial segment. */
|
||||
long initial_size; /* Size of initial segment. */
|
||||
};
|
||||
|
||||
/* The following structure describes the data structure which trails
|
||||
any stack segment. I think that the description in 'asdef' is
|
||||
out of date. I only describe the parts that I am sure about. */
|
||||
|
||||
struct stk_trailer
|
||||
{
|
||||
long this_address; /* Address of this block. */
|
||||
long this_size; /* Size of this block (does not include
|
||||
this trailer). */
|
||||
long unknown2;
|
||||
long unknown3;
|
||||
long link; /* Address of trailer block of previous
|
||||
segment. */
|
||||
long unknown5;
|
||||
long unknown6;
|
||||
long unknown7;
|
||||
long unknown8;
|
||||
long unknown9;
|
||||
long unknown10;
|
||||
long unknown11;
|
||||
long unknown12;
|
||||
long unknown13;
|
||||
long unknown14;
|
||||
};
|
||||
|
||||
# endif /* CRAY2 */
|
||||
# endif /* not CRAY_STACK */
|
||||
|
||||
# ifdef CRAY2
|
||||
/* Determine a "stack measure" for an arbitrary ADDRESS.
|
||||
I doubt that "lint" will like this much. */
|
||||
|
||||
static long
|
||||
i00afunc (long *address)
|
||||
{
|
||||
struct stk_stat status;
|
||||
struct stk_trailer *trailer;
|
||||
long *block, size;
|
||||
long result = 0;
|
||||
|
||||
/* We want to iterate through all of the segments. The first
|
||||
step is to get the stack status structure. We could do this
|
||||
more quickly and more directly, perhaps, by referencing the
|
||||
$LM00 common block, but I know that this works. */
|
||||
|
||||
STKSTAT (&status);
|
||||
|
||||
/* Set up the iteration. */
|
||||
|
||||
trailer = (struct stk_trailer *) (status.current_address
|
||||
+ status.current_size
|
||||
- 15);
|
||||
|
||||
/* There must be at least one stack segment. Therefore it is
|
||||
a fatal error if "trailer" is null. */
|
||||
|
||||
if (trailer == 0)
|
||||
abort ();
|
||||
|
||||
/* Discard segments that do not contain our argument address. */
|
||||
|
||||
while (trailer != 0)
|
||||
{
|
||||
block = (long *) trailer->this_address;
|
||||
size = trailer->this_size;
|
||||
if (block == 0 || size == 0)
|
||||
abort ();
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
if ((block <= address) && (address < (block + size)))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the result to the offset in this segment and add the sizes
|
||||
of all predecessor segments. */
|
||||
|
||||
result = address - block;
|
||||
|
||||
if (trailer == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (trailer->this_size <= 0)
|
||||
abort ();
|
||||
result += trailer->this_size;
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
}
|
||||
while (trailer != 0);
|
||||
|
||||
/* We are done. Note that if you present a bogus address (one
|
||||
not in any segment), you will get a different number back, formed
|
||||
from subtracting the address of the first block. This is probably
|
||||
not what you want. */
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
# else /* not CRAY2 */
|
||||
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
|
||||
Determine the number of the cell within the stack,
|
||||
given the address of the cell. The purpose of this
|
||||
routine is to linearize, in some sense, stack addresses
|
||||
for alloca. */
|
||||
|
||||
static long
|
||||
i00afunc (long address)
|
||||
{
|
||||
long stkl = 0;
|
||||
|
||||
long size, pseg, this_segment, stack;
|
||||
long result = 0;
|
||||
|
||||
struct stack_segment_linkage *ssptr;
|
||||
|
||||
/* Register B67 contains the address of the end of the
|
||||
current stack segment. If you (as a subprogram) store
|
||||
your registers on the stack and find that you are past
|
||||
the contents of B67, you have overflowed the segment.
|
||||
|
||||
B67 also points to the stack segment linkage control
|
||||
area, which is what we are really interested in. */
|
||||
|
||||
stkl = CRAY_STACKSEG_END ();
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
|
||||
/* If one subtracts 'size' from the end of the segment,
|
||||
one has the address of the first word of the segment.
|
||||
|
||||
If this is not the first segment, 'pseg' will be
|
||||
nonzero. */
|
||||
|
||||
pseg = ssptr->sspseg;
|
||||
size = ssptr->sssize;
|
||||
|
||||
this_segment = stkl - size;
|
||||
|
||||
/* It is possible that calling this routine itself caused
|
||||
a stack overflow. Discard stack segments which do not
|
||||
contain the target address. */
|
||||
|
||||
while (!(this_segment <= address && address <= stkl))
|
||||
{
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
|
||||
# endif
|
||||
if (pseg == 0)
|
||||
break;
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
this_segment = stkl - size;
|
||||
}
|
||||
|
||||
result = address - this_segment;
|
||||
|
||||
/* If you subtract pseg from the current end of the stack,
|
||||
you get the address of the previous stack segment's end.
|
||||
This seems a little convoluted to me, but I'll bet you save
|
||||
a cycle somewhere. */
|
||||
|
||||
while (pseg != 0)
|
||||
{
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o\n", pseg, size);
|
||||
# endif
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
result += size;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
# endif /* not CRAY2 */
|
||||
# endif /* CRAY */
|
||||
|
||||
# endif /* no alloca */
|
||||
#endif /* not GCC version 3 */
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* Memory allocation on the stack.
|
||||
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
|
||||
Foundation, Inc.
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2010 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* A GNU-like <arpa/inet.h>.
|
||||
|
||||
Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2006, 2008-2010 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
|
||||
|
|
@ -18,16 +18,19 @@
|
|||
|
||||
#ifndef _GL_ARPA_INET_H
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
|
||||
/* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
|
||||
under MinGW. */
|
||||
#include <sys/socket.h>
|
||||
under MinGW.
|
||||
But avoid namespace pollution on glibc systems. */
|
||||
#ifndef __GLIBC__
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#if @HAVE_ARPA_INET_H@
|
||||
|
||||
# if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
# endif
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
# @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
|
||||
|
||||
|
|
@ -36,7 +39,9 @@
|
|||
#ifndef _GL_ARPA_INET_H
|
||||
#define _GL_ARPA_INET_H
|
||||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -60,26 +65,28 @@ extern "C" {
|
|||
For more details, see the POSIX:2001 specification
|
||||
<http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
|
||||
extern const char *inet_ntop (int af, const void *restrict src,
|
||||
char *restrict dst, socklen_t cnt);
|
||||
char *restrict dst, socklen_t cnt)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef inet_ntop
|
||||
# define inet_ntop(af,src,dst,cnt) \
|
||||
(GL_LINK_WARNING ("inet_ntop is unportable - " \
|
||||
"use gnulib module inet_ntop for portability"), \
|
||||
inet_ntop (af, src, dst, cnt))
|
||||
# if HAVE_RAW_DECL_INET_NTOP
|
||||
_GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
|
||||
"use gnulib module inet_ntop for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_INET_PTON@
|
||||
# if !@HAVE_DECL_INET_PTON@
|
||||
extern int inet_pton (int af, const char *restrict src, void *restrict dst);
|
||||
extern int inet_pton (int af, const char *restrict src, void *restrict dst)
|
||||
_GL_ARG_NONNULL ((2, 3));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef inet_pton
|
||||
# define inet_pton(af,src,dst) \
|
||||
(GL_LINK_WARNING ("inet_pton is unportable - " \
|
||||
"use gnulib module inet_pton for portability"), \
|
||||
inet_pton (af, src, dst))
|
||||
# if HAVE_RAW_DECL_INET_PTON
|
||||
_GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
|
||||
"use gnulib module inet_pton for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Formatted output to strings.
|
||||
Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2002, 2006, 2009, 2010 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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/* Formatted output to strings.
|
||||
Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999, 2002, 2006-2007, 2009-2010 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
|
||||
|
|
|
|||
328
gl/base64.c
328
gl/base64.c
|
|
@ -1,5 +1,5 @@
|
|||
/* base64.c -- Encode binary data using printable characters.
|
||||
Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006 Free Software
|
||||
Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006, 2009, 2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -67,7 +67,7 @@ to_uchar (char ch)
|
|||
terminate the output buffer. */
|
||||
void
|
||||
base64_encode (const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t outlen)
|
||||
char *restrict out, size_t outlen)
|
||||
{
|
||||
static const char b64str[64] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
|
@ -76,27 +76,27 @@ base64_encode (const char *restrict in, size_t inlen,
|
|||
{
|
||||
*out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f];
|
||||
if (!--outlen)
|
||||
break;
|
||||
break;
|
||||
*out++ = b64str[((to_uchar (in[0]) << 4)
|
||||
+ (--inlen ? to_uchar (in[1]) >> 4 : 0))
|
||||
& 0x3f];
|
||||
+ (--inlen ? to_uchar (in[1]) >> 4 : 0))
|
||||
& 0x3f];
|
||||
if (!--outlen)
|
||||
break;
|
||||
break;
|
||||
*out++ =
|
||||
(inlen
|
||||
? b64str[((to_uchar (in[1]) << 2)
|
||||
+ (--inlen ? to_uchar (in[2]) >> 6 : 0))
|
||||
& 0x3f]
|
||||
: '=');
|
||||
(inlen
|
||||
? b64str[((to_uchar (in[1]) << 2)
|
||||
+ (--inlen ? to_uchar (in[2]) >> 6 : 0))
|
||||
& 0x3f]
|
||||
: '=');
|
||||
if (!--outlen)
|
||||
break;
|
||||
break;
|
||||
*out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '=';
|
||||
if (!--outlen)
|
||||
break;
|
||||
break;
|
||||
if (inlen)
|
||||
inlen--;
|
||||
inlen--;
|
||||
if (inlen)
|
||||
in += 3;
|
||||
in += 3;
|
||||
}
|
||||
|
||||
if (outlen)
|
||||
|
|
@ -153,71 +153,71 @@ base64_encode_alloc (const char *in, size_t inlen, char **out)
|
|||
|
||||
IBM C V6 for AIX mishandles "#define B64(x) ...'x'...", so use "_"
|
||||
as the formal parameter rather than "x". */
|
||||
#define B64(_) \
|
||||
((_) == 'A' ? 0 \
|
||||
: (_) == 'B' ? 1 \
|
||||
: (_) == 'C' ? 2 \
|
||||
: (_) == 'D' ? 3 \
|
||||
: (_) == 'E' ? 4 \
|
||||
: (_) == 'F' ? 5 \
|
||||
: (_) == 'G' ? 6 \
|
||||
: (_) == 'H' ? 7 \
|
||||
: (_) == 'I' ? 8 \
|
||||
: (_) == 'J' ? 9 \
|
||||
: (_) == 'K' ? 10 \
|
||||
: (_) == 'L' ? 11 \
|
||||
: (_) == 'M' ? 12 \
|
||||
: (_) == 'N' ? 13 \
|
||||
: (_) == 'O' ? 14 \
|
||||
: (_) == 'P' ? 15 \
|
||||
: (_) == 'Q' ? 16 \
|
||||
: (_) == 'R' ? 17 \
|
||||
: (_) == 'S' ? 18 \
|
||||
: (_) == 'T' ? 19 \
|
||||
: (_) == 'U' ? 20 \
|
||||
: (_) == 'V' ? 21 \
|
||||
: (_) == 'W' ? 22 \
|
||||
: (_) == 'X' ? 23 \
|
||||
: (_) == 'Y' ? 24 \
|
||||
: (_) == 'Z' ? 25 \
|
||||
: (_) == 'a' ? 26 \
|
||||
: (_) == 'b' ? 27 \
|
||||
: (_) == 'c' ? 28 \
|
||||
: (_) == 'd' ? 29 \
|
||||
: (_) == 'e' ? 30 \
|
||||
: (_) == 'f' ? 31 \
|
||||
: (_) == 'g' ? 32 \
|
||||
: (_) == 'h' ? 33 \
|
||||
: (_) == 'i' ? 34 \
|
||||
: (_) == 'j' ? 35 \
|
||||
: (_) == 'k' ? 36 \
|
||||
: (_) == 'l' ? 37 \
|
||||
: (_) == 'm' ? 38 \
|
||||
: (_) == 'n' ? 39 \
|
||||
: (_) == 'o' ? 40 \
|
||||
: (_) == 'p' ? 41 \
|
||||
: (_) == 'q' ? 42 \
|
||||
: (_) == 'r' ? 43 \
|
||||
: (_) == 's' ? 44 \
|
||||
: (_) == 't' ? 45 \
|
||||
: (_) == 'u' ? 46 \
|
||||
: (_) == 'v' ? 47 \
|
||||
: (_) == 'w' ? 48 \
|
||||
: (_) == 'x' ? 49 \
|
||||
: (_) == 'y' ? 50 \
|
||||
: (_) == 'z' ? 51 \
|
||||
: (_) == '0' ? 52 \
|
||||
: (_) == '1' ? 53 \
|
||||
: (_) == '2' ? 54 \
|
||||
: (_) == '3' ? 55 \
|
||||
: (_) == '4' ? 56 \
|
||||
: (_) == '5' ? 57 \
|
||||
: (_) == '6' ? 58 \
|
||||
: (_) == '7' ? 59 \
|
||||
: (_) == '8' ? 60 \
|
||||
: (_) == '9' ? 61 \
|
||||
: (_) == '+' ? 62 \
|
||||
: (_) == '/' ? 63 \
|
||||
#define B64(_) \
|
||||
((_) == 'A' ? 0 \
|
||||
: (_) == 'B' ? 1 \
|
||||
: (_) == 'C' ? 2 \
|
||||
: (_) == 'D' ? 3 \
|
||||
: (_) == 'E' ? 4 \
|
||||
: (_) == 'F' ? 5 \
|
||||
: (_) == 'G' ? 6 \
|
||||
: (_) == 'H' ? 7 \
|
||||
: (_) == 'I' ? 8 \
|
||||
: (_) == 'J' ? 9 \
|
||||
: (_) == 'K' ? 10 \
|
||||
: (_) == 'L' ? 11 \
|
||||
: (_) == 'M' ? 12 \
|
||||
: (_) == 'N' ? 13 \
|
||||
: (_) == 'O' ? 14 \
|
||||
: (_) == 'P' ? 15 \
|
||||
: (_) == 'Q' ? 16 \
|
||||
: (_) == 'R' ? 17 \
|
||||
: (_) == 'S' ? 18 \
|
||||
: (_) == 'T' ? 19 \
|
||||
: (_) == 'U' ? 20 \
|
||||
: (_) == 'V' ? 21 \
|
||||
: (_) == 'W' ? 22 \
|
||||
: (_) == 'X' ? 23 \
|
||||
: (_) == 'Y' ? 24 \
|
||||
: (_) == 'Z' ? 25 \
|
||||
: (_) == 'a' ? 26 \
|
||||
: (_) == 'b' ? 27 \
|
||||
: (_) == 'c' ? 28 \
|
||||
: (_) == 'd' ? 29 \
|
||||
: (_) == 'e' ? 30 \
|
||||
: (_) == 'f' ? 31 \
|
||||
: (_) == 'g' ? 32 \
|
||||
: (_) == 'h' ? 33 \
|
||||
: (_) == 'i' ? 34 \
|
||||
: (_) == 'j' ? 35 \
|
||||
: (_) == 'k' ? 36 \
|
||||
: (_) == 'l' ? 37 \
|
||||
: (_) == 'm' ? 38 \
|
||||
: (_) == 'n' ? 39 \
|
||||
: (_) == 'o' ? 40 \
|
||||
: (_) == 'p' ? 41 \
|
||||
: (_) == 'q' ? 42 \
|
||||
: (_) == 'r' ? 43 \
|
||||
: (_) == 's' ? 44 \
|
||||
: (_) == 't' ? 45 \
|
||||
: (_) == 'u' ? 46 \
|
||||
: (_) == 'v' ? 47 \
|
||||
: (_) == 'w' ? 48 \
|
||||
: (_) == 'x' ? 49 \
|
||||
: (_) == 'y' ? 50 \
|
||||
: (_) == 'z' ? 51 \
|
||||
: (_) == '0' ? 52 \
|
||||
: (_) == '1' ? 53 \
|
||||
: (_) == '2' ? 54 \
|
||||
: (_) == '3' ? 55 \
|
||||
: (_) == '4' ? 56 \
|
||||
: (_) == '5' ? 57 \
|
||||
: (_) == '6' ? 58 \
|
||||
: (_) == '7' ? 59 \
|
||||
: (_) == '8' ? 60 \
|
||||
: (_) == '9' ? 61 \
|
||||
: (_) == '+' ? 62 \
|
||||
: (_) == '/' ? 63 \
|
||||
: -1)
|
||||
|
||||
static const signed char b64[0x100] = {
|
||||
|
|
@ -328,12 +328,12 @@ get_4 (struct base64_decode_context *ctx,
|
|||
{
|
||||
char const *t = *in;
|
||||
if (4 <= in_end - *in && memchr (t, '\n', 4) == NULL)
|
||||
{
|
||||
/* This is the common case: no newline. */
|
||||
*in += 4;
|
||||
*n_non_newline = 4;
|
||||
return (char *) t;
|
||||
}
|
||||
{
|
||||
/* This is the common case: no newline. */
|
||||
*in += 4;
|
||||
*n_non_newline = 4;
|
||||
return (char *) t;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -341,13 +341,13 @@ get_4 (struct base64_decode_context *ctx,
|
|||
char const *p = *in;
|
||||
while (p < in_end)
|
||||
{
|
||||
char c = *p++;
|
||||
if (c != '\n')
|
||||
{
|
||||
ctx->buf[ctx->i++] = c;
|
||||
if (ctx->i == 4)
|
||||
break;
|
||||
}
|
||||
char c = *p++;
|
||||
if (c != '\n')
|
||||
{
|
||||
ctx->buf[ctx->i++] = c;
|
||||
if (ctx->i == 4)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*in = p;
|
||||
|
|
@ -356,12 +356,12 @@ get_4 (struct base64_decode_context *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
#define return_false \
|
||||
do \
|
||||
{ \
|
||||
*outp = out; \
|
||||
return false; \
|
||||
} \
|
||||
#define return_false \
|
||||
do \
|
||||
{ \
|
||||
*outp = out; \
|
||||
return false; \
|
||||
} \
|
||||
while (false)
|
||||
|
||||
/* Decode up to four bytes of base64-encoded data, IN, of length INLEN
|
||||
|
|
@ -372,7 +372,7 @@ get_4 (struct base64_decode_context *ctx,
|
|||
*OUTLEN to reflect the number of bytes remaining in *OUT. */
|
||||
static inline bool
|
||||
decode_4 (char const *restrict in, size_t inlen,
|
||||
char *restrict *outp, size_t *outleft)
|
||||
char *restrict *outp, size_t *outleft)
|
||||
{
|
||||
char *out = *outp;
|
||||
if (inlen < 2)
|
||||
|
|
@ -384,7 +384,7 @@ decode_4 (char const *restrict in, size_t inlen,
|
|||
if (*outleft)
|
||||
{
|
||||
*out++ = ((b64[to_uchar (in[0])] << 2)
|
||||
| (b64[to_uchar (in[1])] >> 4));
|
||||
| (b64[to_uchar (in[1])] >> 4));
|
||||
--*outleft;
|
||||
}
|
||||
|
||||
|
|
@ -394,43 +394,43 @@ decode_4 (char const *restrict in, size_t inlen,
|
|||
if (in[2] == '=')
|
||||
{
|
||||
if (inlen != 4)
|
||||
return_false;
|
||||
return_false;
|
||||
|
||||
if (in[3] != '=')
|
||||
return_false;
|
||||
return_false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isbase64 (in[2]))
|
||||
return_false;
|
||||
return_false;
|
||||
|
||||
if (*outleft)
|
||||
{
|
||||
*out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0)
|
||||
| (b64[to_uchar (in[2])] >> 2));
|
||||
--*outleft;
|
||||
}
|
||||
{
|
||||
*out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0)
|
||||
| (b64[to_uchar (in[2])] >> 2));
|
||||
--*outleft;
|
||||
}
|
||||
|
||||
if (inlen == 3)
|
||||
return_false;
|
||||
return_false;
|
||||
|
||||
if (in[3] == '=')
|
||||
{
|
||||
if (inlen != 4)
|
||||
return_false;
|
||||
}
|
||||
{
|
||||
if (inlen != 4)
|
||||
return_false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isbase64 (in[3]))
|
||||
return_false;
|
||||
{
|
||||
if (!isbase64 (in[3]))
|
||||
return_false;
|
||||
|
||||
if (*outleft)
|
||||
{
|
||||
*out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0)
|
||||
| b64[to_uchar (in[3])]);
|
||||
--*outleft;
|
||||
}
|
||||
}
|
||||
if (*outleft)
|
||||
{
|
||||
*out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0)
|
||||
| b64[to_uchar (in[3])]);
|
||||
--*outleft;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*outp = out;
|
||||
|
|
@ -457,8 +457,8 @@ decode_4 (char const *restrict in, size_t inlen,
|
|||
|
||||
bool
|
||||
base64_decode_ctx (struct base64_decode_context *ctx,
|
||||
const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t *outlen)
|
||||
const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t *outlen)
|
||||
{
|
||||
size_t outleft = *outlen;
|
||||
bool ignore_newlines = ctx != NULL;
|
||||
|
|
@ -476,57 +476,57 @@ base64_decode_ctx (struct base64_decode_context *ctx,
|
|||
{
|
||||
size_t outleft_save = outleft;
|
||||
if (ctx_i == 0 && !flush_ctx)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
/* Save a copy of outleft, in case we need to re-parse this
|
||||
block of four bytes. */
|
||||
outleft_save = outleft;
|
||||
if (!decode_4 (in, inlen, &out, &outleft))
|
||||
break;
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
/* Save a copy of outleft, in case we need to re-parse this
|
||||
block of four bytes. */
|
||||
outleft_save = outleft;
|
||||
if (!decode_4 (in, inlen, &out, &outleft))
|
||||
break;
|
||||
|
||||
in += 4;
|
||||
inlen -= 4;
|
||||
}
|
||||
}
|
||||
in += 4;
|
||||
inlen -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (inlen == 0 && !flush_ctx)
|
||||
break;
|
||||
break;
|
||||
|
||||
/* Handle the common case of 72-byte wrapped lines.
|
||||
This also handles any other multiple-of-4-byte wrapping. */
|
||||
This also handles any other multiple-of-4-byte wrapping. */
|
||||
if (inlen && *in == '\n' && ignore_newlines)
|
||||
{
|
||||
++in;
|
||||
--inlen;
|
||||
continue;
|
||||
}
|
||||
{
|
||||
++in;
|
||||
--inlen;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Restore OUT and OUTLEFT. */
|
||||
out -= outleft_save - outleft;
|
||||
outleft = outleft_save;
|
||||
|
||||
{
|
||||
char const *in_end = in + inlen;
|
||||
char const *non_nl;
|
||||
char const *in_end = in + inlen;
|
||||
char const *non_nl;
|
||||
|
||||
if (ignore_newlines)
|
||||
non_nl = get_4 (ctx, &in, in_end, &inlen);
|
||||
else
|
||||
non_nl = in; /* Might have nl in this case. */
|
||||
if (ignore_newlines)
|
||||
non_nl = get_4 (ctx, &in, in_end, &inlen);
|
||||
else
|
||||
non_nl = in; /* Might have nl in this case. */
|
||||
|
||||
/* If the input is empty or consists solely of newlines (0 non-newlines),
|
||||
then we're done. Likewise if there are fewer than 4 bytes when not
|
||||
flushing context and not treating newlines as garbage. */
|
||||
if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines))
|
||||
{
|
||||
inlen = 0;
|
||||
break;
|
||||
}
|
||||
if (!decode_4 (non_nl, inlen, &out, &outleft))
|
||||
break;
|
||||
/* If the input is empty or consists solely of newlines (0 non-newlines),
|
||||
then we're done. Likewise if there are fewer than 4 bytes when not
|
||||
flushing context and not treating newlines as garbage. */
|
||||
if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines))
|
||||
{
|
||||
inlen = 0;
|
||||
break;
|
||||
}
|
||||
if (!decode_4 (non_nl, inlen, &out, &outleft))
|
||||
break;
|
||||
|
||||
inlen = in_end - in;
|
||||
inlen = in_end - in;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -548,8 +548,8 @@ base64_decode_ctx (struct base64_decode_context *ctx,
|
|||
undefined. */
|
||||
bool
|
||||
base64_decode_alloc_ctx (struct base64_decode_context *ctx,
|
||||
const char *in, size_t inlen, char **out,
|
||||
size_t *outlen)
|
||||
const char *in, size_t inlen, char **out,
|
||||
size_t *outlen)
|
||||
{
|
||||
/* This may allocate a few bytes too many, depending on input,
|
||||
but it's not worth the extra CPU time to compute the exact size.
|
||||
|
|
|
|||
16
gl/base64.h
16
gl/base64.h
|
|
@ -1,5 +1,5 @@
|
|||
/* base64.h -- Encode binary data using printable characters.
|
||||
Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
|
||||
Written by Simon Josefsson.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -38,24 +38,24 @@ struct base64_decode_context
|
|||
extern bool isbase64 (char ch);
|
||||
|
||||
extern void base64_encode (const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t outlen);
|
||||
char *restrict out, size_t outlen);
|
||||
|
||||
extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
|
||||
|
||||
extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
|
||||
|
||||
extern bool base64_decode_ctx (struct base64_decode_context *ctx,
|
||||
const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t *outlen);
|
||||
const char *restrict in, size_t inlen,
|
||||
char *restrict out, size_t *outlen);
|
||||
|
||||
extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
|
||||
const char *in, size_t inlen,
|
||||
char **out, size_t *outlen);
|
||||
const char *in, size_t inlen,
|
||||
char **out, size_t *outlen);
|
||||
|
||||
#define base64_decode(in, inlen, out, outlen) \
|
||||
base64_decode_ctx (NULL, in, inlen, out, outlen)
|
||||
base64_decode_ctx (NULL, in, inlen, out, outlen)
|
||||
|
||||
#define base64_decode_alloc(in, inlen, out, outlen) \
|
||||
base64_decode_alloc_ctx (NULL, in, inlen, out, outlen)
|
||||
base64_decode_alloc_ctx (NULL, in, inlen, out, outlen)
|
||||
|
||||
#endif /* BASE64_H */
|
||||
|
|
|
|||
75
gl/basename-lgpl.c
Normal file
75
gl/basename-lgpl.c
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/* basename.c -- return the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Return the address of the last file name component of NAME. If
|
||||
NAME has no relative file name components because it is a file
|
||||
system root, return the empty string. */
|
||||
|
||||
char *
|
||||
last_component (char const *name)
|
||||
{
|
||||
char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
|
||||
char const *p;
|
||||
bool saw_slash = false;
|
||||
|
||||
while (ISSLASH (*base))
|
||||
base++;
|
||||
|
||||
for (p = base; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
saw_slash = true;
|
||||
else if (saw_slash)
|
||||
{
|
||||
base = p;
|
||||
saw_slash = false;
|
||||
}
|
||||
}
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
/* Return the length of the basename NAME. Typically NAME is the
|
||||
value returned by base_name or last_component. Act like strlen
|
||||
(NAME), except omit all trailing slashes. */
|
||||
|
||||
size_t
|
||||
base_len (char const *name)
|
||||
{
|
||||
size_t len;
|
||||
size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
|
||||
|
||||
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
|
||||
continue;
|
||||
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1
|
||||
&& ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
|
||||
return 2;
|
||||
|
||||
if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
|
||||
&& len == prefix_len && ISSLASH (name[prefix_len]))
|
||||
return prefix_len + 1;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/* basename.c -- return the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free
|
||||
Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 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,52 +24,6 @@
|
|||
#include "xalloc.h"
|
||||
#include "xstrndup.h"
|
||||
|
||||
/* Return the address of the last file name component of NAME. If
|
||||
NAME has no relative file name components because it is a file
|
||||
system root, return the empty string. */
|
||||
|
||||
char *
|
||||
last_component (char const *name)
|
||||
{
|
||||
char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
|
||||
char const *p;
|
||||
bool saw_slash = false;
|
||||
|
||||
while (ISSLASH (*base))
|
||||
base++;
|
||||
|
||||
for (p = base; *p; p++)
|
||||
{
|
||||
if (ISSLASH (*p))
|
||||
saw_slash = true;
|
||||
else if (saw_slash)
|
||||
{
|
||||
base = p;
|
||||
saw_slash = false;
|
||||
}
|
||||
}
|
||||
|
||||
return (char *) base;
|
||||
}
|
||||
|
||||
|
||||
/* In general, we can't use the builtin `basename' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `basename' modifies its argument.
|
||||
|
||||
Return the last file name component of NAME, allocated with
|
||||
xmalloc. On systems with drive letters, a leading "./"
|
||||
distinguishes relative names that would otherwise look like a drive
|
||||
letter. Unlike POSIX basename(), NAME cannot be NULL,
|
||||
base_name("") returns "", and the first trailing slash is not
|
||||
stripped.
|
||||
|
||||
If lstat (NAME) would succeed, then { chdir (dir_name (NAME));
|
||||
lstat (base_name (NAME)); } will access the same file. Likewise,
|
||||
if the sequence { chdir (dir_name (NAME));
|
||||
rename (base_name (NAME), "foo"); } succeeds, you have renamed NAME
|
||||
to "foo" in the same directory NAME was in. */
|
||||
|
||||
char *
|
||||
base_name (char const *name)
|
||||
{
|
||||
|
|
@ -102,27 +56,3 @@ base_name (char const *name)
|
|||
/* Finally, copy the basename. */
|
||||
return xstrndup (base, length);
|
||||
}
|
||||
|
||||
/* Return the length of the basename NAME. Typically NAME is the
|
||||
value returned by base_name or last_component. Act like strlen
|
||||
(NAME), except omit all trailing slashes. */
|
||||
|
||||
size_t
|
||||
base_len (char const *name)
|
||||
{
|
||||
size_t len;
|
||||
size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
|
||||
|
||||
for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
|
||||
continue;
|
||||
|
||||
if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1
|
||||
&& ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
|
||||
return 2;
|
||||
|
||||
if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
|
||||
&& len == prefix_len && ISSLASH (name[prefix_len]))
|
||||
return prefix_len + 1;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Convert unibyte character to wide character.
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008, 2010 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
#include <wchar.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
wint_t
|
||||
btowc (int c)
|
||||
|
|
@ -32,7 +33,7 @@ btowc (int c)
|
|||
|
||||
buf[0] = c;
|
||||
if (mbtowc (&wc, buf, 1) >= 0)
|
||||
return wc;
|
||||
return wc;
|
||||
}
|
||||
return WEOF;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Convert string to double, using the C locale.
|
||||
|
||||
Copyright (C) 2003, 2004, 2006, 2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2004, 2006, 2009-2010 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
|
||||
|
|
@ -73,7 +73,7 @@ C_STRTOD (char const *nptr, char **endptr)
|
|||
if (!locale)
|
||||
{
|
||||
if (endptr)
|
||||
*endptr = (char *) nptr;
|
||||
*endptr = (char *) nptr;
|
||||
return 0; /* errno is set here */
|
||||
}
|
||||
|
||||
|
|
@ -87,11 +87,11 @@ C_STRTOD (char const *nptr, char **endptr)
|
|||
{
|
||||
saved_locale = strdup (saved_locale);
|
||||
if (saved_locale == NULL)
|
||||
{
|
||||
if (endptr)
|
||||
*endptr = (char *) nptr;
|
||||
return 0; /* errno is set here */
|
||||
}
|
||||
{
|
||||
if (endptr)
|
||||
*endptr = (char *) nptr;
|
||||
return 0; /* errno is set here */
|
||||
}
|
||||
setlocale (LC_NUMERIC, "C");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Convert string to double, using the C locale.
|
||||
|
||||
Copyright (C) 2003-2004, 2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003-2004, 2009-2010 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
|
||||
|
|
|
|||
51
gl/cloexec.c
51
gl/cloexec.c
|
|
@ -1,6 +1,6 @@
|
|||
/* closexec.c - set or clear the close-on-exec descriptor flag
|
||||
|
||||
Copyright (C) 1991, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 2004-2006, 2009-2010 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
|
||||
|
|
@ -21,21 +21,24 @@
|
|||
|
||||
#include "cloexec.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifndef FD_CLOEXEC
|
||||
# define FD_CLOEXEC 1
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
/* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
|
||||
or clear the flag if VALUE is false.
|
||||
Return 0 on success, or -1 on error with `errno' set. */
|
||||
Return 0 on success, or -1 on error with `errno' set.
|
||||
|
||||
Note that on MingW, this function does NOT protect DESC from being
|
||||
inherited into spawned children. Instead, either use dup_cloexec
|
||||
followed by closing the original DESC, or use interfaces such as
|
||||
open or pipe2 that accept flags like O_CLOEXEC to create DESC
|
||||
non-inheritable in the first place. */
|
||||
|
||||
int
|
||||
set_cloexec_flag (int desc, bool value)
|
||||
{
|
||||
#if defined F_GETFD && defined F_SETFD
|
||||
#ifdef F_SETFD
|
||||
|
||||
int flags = fcntl (desc, F_GETFD, 0);
|
||||
|
||||
|
|
@ -44,15 +47,37 @@ set_cloexec_flag (int desc, bool value)
|
|||
int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
|
||||
|
||||
if (flags == newflags
|
||||
|| fcntl (desc, F_SETFD, newflags) != -1)
|
||||
return 0;
|
||||
|| fcntl (desc, F_SETFD, newflags) != -1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
#else
|
||||
#else /* !F_SETFD */
|
||||
|
||||
/* Use dup2 to reject invalid file descriptors; the cloexec flag
|
||||
will be unaffected. */
|
||||
if (desc < 0)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
if (dup2 (desc, desc) < 0)
|
||||
/* errno is EBADF here. */
|
||||
return -1;
|
||||
|
||||
/* There is nothing we can do on this kind of platform. Punt. */
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
#endif /* !F_SETFD */
|
||||
}
|
||||
|
||||
|
||||
/* Duplicates a file handle FD, while marking the copy to be closed
|
||||
prior to exec or spawn. Returns -1 and sets errno if FD could not
|
||||
be duplicated. */
|
||||
|
||||
int
|
||||
dup_cloexec (int fd)
|
||||
{
|
||||
return fcntl (fd, F_DUPFD_CLOEXEC, 0);
|
||||
}
|
||||
|
|
|
|||
36
gl/cloexec.h
36
gl/cloexec.h
|
|
@ -1,2 +1,38 @@
|
|||
/* closexec.c - set or clear the close-on-exec descriptor flag
|
||||
|
||||
Copyright (C) 2004, 2009-2010 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
|
||||
or clear the flag if VALUE is false.
|
||||
Return 0 on success, or -1 on error with `errno' set.
|
||||
|
||||
Note that on MingW, this function does NOT protect DESC from being
|
||||
inherited into spawned children. Instead, either use dup_cloexec
|
||||
followed by closing the original DESC, or use interfaces such as
|
||||
open or pipe2 that accept flags like O_CLOEXEC to create DESC
|
||||
non-inheritable in the first place. */
|
||||
|
||||
int set_cloexec_flag (int desc, bool value);
|
||||
|
||||
/* Duplicates a file handle FD, while marking the copy to be closed
|
||||
prior to exec or spawn. Returns -1 and sets errno if FD could not
|
||||
be duplicated. */
|
||||
|
||||
int dup_cloexec (int fd);
|
||||
|
|
|
|||
91
gl/close-hook.c
Normal file
91
gl/close-hook.c
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/* Hook for making the close() function extensible.
|
||||
Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2009.
|
||||
|
||||
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 3 of the License, 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "close-hook.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#undef close
|
||||
|
||||
|
||||
/* Currently, this entire code is only needed for the handling of sockets
|
||||
on native Windows platforms. */
|
||||
#if WINDOWS_SOCKETS
|
||||
|
||||
/* The first and last link in the doubly linked list.
|
||||
Initially the list is empty. */
|
||||
static struct close_hook anchor = { &anchor, &anchor, NULL };
|
||||
|
||||
int
|
||||
execute_close_hooks (int fd, const struct close_hook *remaining_list)
|
||||
{
|
||||
if (remaining_list == &anchor)
|
||||
/* End of list reached. */
|
||||
return close (fd);
|
||||
else
|
||||
return remaining_list->private_fn (fd, remaining_list->private_next);
|
||||
}
|
||||
|
||||
int
|
||||
execute_all_close_hooks (int fd)
|
||||
{
|
||||
return execute_close_hooks (fd, anchor.private_next);
|
||||
}
|
||||
|
||||
void
|
||||
register_close_hook (close_hook_fn hook, struct close_hook *link)
|
||||
{
|
||||
if (link->private_next == NULL && link->private_prev == NULL)
|
||||
{
|
||||
/* Add the link to the doubly linked list. */
|
||||
link->private_next = anchor.private_next;
|
||||
link->private_prev = &anchor;
|
||||
link->private_fn = hook;
|
||||
anchor.private_next->private_prev = link;
|
||||
anchor.private_next = link;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The link is already in use. */
|
||||
if (link->private_fn != hook)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
unregister_close_hook (struct close_hook *link)
|
||||
{
|
||||
struct close_hook *next = link->private_next;
|
||||
struct close_hook *prev = link->private_prev;
|
||||
|
||||
if (next != NULL && prev != NULL)
|
||||
{
|
||||
/* The link is in use. Remove it from the doubly linked list. */
|
||||
prev->private_next = next;
|
||||
next->private_prev = prev;
|
||||
/* Clear the link, to mark it unused. */
|
||||
link->private_next = NULL;
|
||||
link->private_prev = NULL;
|
||||
link->private_fn = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
72
gl/close-hook.h
Normal file
72
gl/close-hook.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/* Hook for making the close() function extensible.
|
||||
Copyright (C) 2009, 2010 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 3 of the License, 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
#ifndef CLOSE_HOOK_H
|
||||
#define CLOSE_HOOK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Currently, this entire code is only needed for the handling of sockets
|
||||
on native Windows platforms. */
|
||||
#if WINDOWS_SOCKETS
|
||||
|
||||
|
||||
/* An element of the list of close hooks.
|
||||
The fields of this structure are considered private. */
|
||||
struct close_hook
|
||||
{
|
||||
/* Doubly linked list. */
|
||||
struct close_hook *private_next;
|
||||
struct close_hook *private_prev;
|
||||
/* Function that treats the types of FD that it knows about and calls
|
||||
execute_close_hooks (FD, REMAINING_LIST) as a fallback. */
|
||||
int (*private_fn) (int fd, const struct close_hook *remaining_list);
|
||||
};
|
||||
|
||||
/* This type of function closes FD, applying special knowledge for the FD
|
||||
types it knows about, and calls execute_close_hooks (FD, REMAINING_LIST)
|
||||
for the other FD types. */
|
||||
typedef int (*close_hook_fn) (int fd, const struct close_hook *remaining_list);
|
||||
|
||||
/* Execute the close hooks in REMAINING_LIST.
|
||||
Return 0 or -1, like close() would do. */
|
||||
extern int execute_close_hooks (int fd, const struct close_hook *remaining_list);
|
||||
|
||||
/* Execute all close hooks.
|
||||
Return 0 or -1, like close() would do. */
|
||||
extern int execute_all_close_hooks (int fd);
|
||||
|
||||
/* Add a function to the list of close hooks.
|
||||
The LINK variable points to a piece of memory which is guaranteed to be
|
||||
accessible until the corresponding call to unregister_close_hook. */
|
||||
extern void register_close_hook (close_hook_fn hook, struct close_hook *link);
|
||||
|
||||
/* Removes a function from the list of close hooks. */
|
||||
extern void unregister_close_hook (struct close_hook *link);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CLOSE_HOOK_H */
|
||||
1158
gl/config.charset
Executable file → Normal file
1158
gl/config.charset
Executable file → Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
/* Invoke creat, but avoid some glitches.
|
||||
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2006, 2009-2010 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
|
||||
|
|
|
|||
86
gl/dirname-lgpl.c
Normal file
86
gl/dirname-lgpl.c
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/* dirname.c -- return all but the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "dirname.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Return the length of the prefix of FILE that will be used by
|
||||
dir_name. If FILE is in the working directory, this returns zero
|
||||
even though `dir_name (FILE)' will return ".". Works properly even
|
||||
if there are trailing slashes (by effectively ignoring them). */
|
||||
|
||||
size_t
|
||||
dir_len (char const *file)
|
||||
{
|
||||
size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
|
||||
size_t length;
|
||||
|
||||
/* Advance prefix_length beyond important leading slashes. */
|
||||
prefix_length += (prefix_length != 0
|
||||
? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
&& ISSLASH (file[prefix_length]))
|
||||
: (ISSLASH (file[0])
|
||||
? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||
&& ISSLASH (file[1]) && ! ISSLASH (file[2])
|
||||
? 2 : 1))
|
||||
: 0));
|
||||
|
||||
/* Strip the basename and any redundant slashes before it. */
|
||||
for (length = last_component (file) - file;
|
||||
prefix_length < length; length--)
|
||||
if (! ISSLASH (file[length - 1]))
|
||||
break;
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
/* In general, we can't use the builtin `dirname' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `dirname' modifies its argument.
|
||||
|
||||
Return the leading directories part of FILE, allocated with malloc.
|
||||
Works properly even if there are trailing slashes (by effectively
|
||||
ignoring them). Return NULL on failure.
|
||||
|
||||
If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
|
||||
lstat (base_name (FILE)); } will access the same file. Likewise,
|
||||
if the sequence { chdir (dir_name (FILE));
|
||||
rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
|
||||
to "foo" in the same directory FILE was in. */
|
||||
|
||||
char *
|
||||
mdir_name (char const *file)
|
||||
{
|
||||
size_t length = dir_len (file);
|
||||
bool append_dot = (length == 0
|
||||
|| (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
&& length == FILE_SYSTEM_PREFIX_LEN (file)
|
||||
&& file[2] != '\0' && ! ISSLASH (file[2])));
|
||||
char *dir = malloc (length + append_dot + 1);
|
||||
if (!dir)
|
||||
return NULL;
|
||||
memcpy (dir, file, length);
|
||||
if (append_dot)
|
||||
dir[length++] = '.';
|
||||
dir[length] = '\0';
|
||||
return dir;
|
||||
}
|
||||
64
gl/dirname.c
64
gl/dirname.c
|
|
@ -1,6 +1,6 @@
|
|||
/* dirname.c -- return all but the last element in a file name
|
||||
|
||||
Copyright (C) 1990, 1998, 2000, 2001, 2003, 2004, 2005, 2006 Free Software
|
||||
Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -20,65 +20,19 @@
|
|||
|
||||
#include "dirname.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "xalloc.h"
|
||||
|
||||
/* Return the length of the prefix of FILE that will be used by
|
||||
dir_name. If FILE is in the working directory, this returns zero
|
||||
even though `dir_name (FILE)' will return ".". Works properly even
|
||||
if there are trailing slashes (by effectively ignoring them). */
|
||||
|
||||
size_t
|
||||
dir_len (char const *file)
|
||||
{
|
||||
size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
|
||||
size_t length;
|
||||
|
||||
/* Advance prefix_length beyond important leading slashes. */
|
||||
prefix_length += (prefix_length != 0
|
||||
? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
&& ISSLASH (file[prefix_length]))
|
||||
: (ISSLASH (file[0])
|
||||
? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
|
||||
&& ISSLASH (file[1]) && ! ISSLASH (file[2])
|
||||
? 2 : 1))
|
||||
: 0));
|
||||
|
||||
/* Strip the basename and any redundant slashes before it. */
|
||||
for (length = last_component (file) - file;
|
||||
prefix_length < length; length--)
|
||||
if (! ISSLASH (file[length - 1]))
|
||||
break;
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
/* In general, we can't use the builtin `dirname' function if available,
|
||||
since it has different meanings in different environments.
|
||||
In some environments the builtin `dirname' modifies its argument.
|
||||
|
||||
Return the leading directories part of FILE, allocated with xmalloc.
|
||||
Works properly even if there are trailing slashes (by effectively
|
||||
ignoring them). Unlike POSIX dirname(), FILE cannot be NULL.
|
||||
|
||||
If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
|
||||
lstat (base_name (FILE)); } will access the same file. Likewise,
|
||||
if the sequence { chdir (dir_name (FILE));
|
||||
rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
|
||||
to "foo" in the same directory FILE was in. */
|
||||
/* Just like mdir_name (dirname-lgpl.c), except, rather than
|
||||
returning NULL upon malloc failure, here, we report the
|
||||
"memory exhausted" condition and exit. */
|
||||
|
||||
char *
|
||||
dir_name (char const *file)
|
||||
{
|
||||
size_t length = dir_len (file);
|
||||
bool append_dot = (length == 0
|
||||
|| (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
|
||||
&& length == FILE_SYSTEM_PREFIX_LEN (file)
|
||||
&& file[2] != '\0' && ! ISSLASH (file[2])));
|
||||
char *dir = xmalloc (length + append_dot + 1);
|
||||
memcpy (dir, file, length);
|
||||
if (append_dot)
|
||||
dir[length++] = '.';
|
||||
dir[length] = '\0';
|
||||
return dir;
|
||||
char *result = mdir_name (file);
|
||||
if (!result)
|
||||
xalloc_die ();
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
13
gl/dirname.h
13
gl/dirname.h
|
|
@ -1,6 +1,7 @@
|
|||
/* Take file names apart into directory and base names.
|
||||
|
||||
Copyright (C) 1998, 2001, 2003-2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 2001, 2003-2006, 2009-2010 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
|
||||
|
|
@ -34,9 +35,9 @@
|
|||
/* This internal macro assumes ASCII, but all hosts that support drive
|
||||
letters use ASCII. */
|
||||
# define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
|
||||
<= 'z' - 'a')
|
||||
<= 'z' - 'a')
|
||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) \
|
||||
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
|
||||
(_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
|
||||
# else
|
||||
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
|
||||
# endif
|
||||
|
|
@ -54,12 +55,16 @@
|
|||
# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
|
||||
# else
|
||||
# define IS_ABSOLUTE_FILE_NAME(F) \
|
||||
(ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
|
||||
(ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
|
||||
# endif
|
||||
# define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
|
||||
|
||||
# if GNULIB_DIRNAME
|
||||
char *base_name (char const *file);
|
||||
char *dir_name (char const *file);
|
||||
# endif
|
||||
|
||||
char *mdir_name (char const *file);
|
||||
size_t base_len (char const *file);
|
||||
size_t dir_len (char const *file);
|
||||
char *last_component (char const *file);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/* Invoke dup, but avoid some glitches.
|
||||
|
||||
Copyright (C) 2001, 2004, 2005, 2006, 2009 Free Software
|
||||
Foundation, Inc.
|
||||
Copyright (C) 2001, 2004-2006, 2009-2010 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
|
||||
|
|
@ -23,7 +22,6 @@
|
|||
#include "unistd-safer.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or
|
||||
|
|
@ -32,11 +30,5 @@
|
|||
int
|
||||
dup_safer (int fd)
|
||||
{
|
||||
#if defined F_DUPFD && !defined FCHDIR_REPLACEMENT
|
||||
return fcntl (fd, F_DUPFD, STDERR_FILENO + 1);
|
||||
#else
|
||||
/* fd_safer calls us back, but eventually the recursion unwinds and
|
||||
does the right thing. */
|
||||
return fd_safer (dup (fd));
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
128
gl/dup2.c
Normal file
128
gl/dup2.c
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
/* Duplicate an open file descriptor to a specified file descriptor.
|
||||
|
||||
Copyright (C) 1999, 2004-2007, 2009-2010 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Paul Eggert */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <unistd.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
/* Get declarations of the Win32 API functions. */
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_DUP2
|
||||
|
||||
# undef dup2
|
||||
|
||||
int
|
||||
rpl_dup2 (int fd, int desired_fd)
|
||||
{
|
||||
int result;
|
||||
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
/* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open,
|
||||
dup2 (fd, fd) returns 0, but all further attempts to use fd in
|
||||
future dup2 calls will hang. */
|
||||
if (fd == desired_fd)
|
||||
{
|
||||
if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
/* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
|
||||
http://bugs.winehq.org/show_bug.cgi?id=21289 */
|
||||
if (desired_fd < 0)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
# endif
|
||||
result = dup2 (fd, desired_fd);
|
||||
# ifdef __linux__
|
||||
/* Correct a Linux return value.
|
||||
<http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.30.y.git;a=commitdiff;h=2b79bc4f7ebbd5af3c8b867968f9f15602d5f802>
|
||||
*/
|
||||
if (fd == desired_fd && result == (unsigned int) -EBADF)
|
||||
{
|
||||
errno = EBADF;
|
||||
result = -1;
|
||||
}
|
||||
# endif
|
||||
if (result == 0)
|
||||
result = desired_fd;
|
||||
/* Correct a cygwin 1.5.x errno value. */
|
||||
else if (result == -1 && errno == EMFILE)
|
||||
errno = EBADF;
|
||||
# if REPLACE_FCHDIR
|
||||
if (fd != desired_fd && result != -1)
|
||||
result = _gl_register_dup (fd, result);
|
||||
# endif
|
||||
return result;
|
||||
}
|
||||
|
||||
#else /* !HAVE_DUP2 */
|
||||
|
||||
/* On older platforms, dup2 did not exist. */
|
||||
|
||||
# ifndef F_DUPFD
|
||||
static int
|
||||
dupfd (int fd, int desired_fd)
|
||||
{
|
||||
int duplicated_fd = dup (fd);
|
||||
if (duplicated_fd < 0 || duplicated_fd == desired_fd)
|
||||
return duplicated_fd;
|
||||
else
|
||||
{
|
||||
int r = dupfd (fd, desired_fd);
|
||||
int e = errno;
|
||||
close (duplicated_fd);
|
||||
errno = e;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
int
|
||||
dup2 (int fd, int desired_fd)
|
||||
{
|
||||
int result = fcntl (fd, F_GETFL) < 0 ? -1 : fd;
|
||||
if (result == -1 || fd == desired_fd)
|
||||
return result;
|
||||
close (desired_fd);
|
||||
# ifdef F_DUPFD
|
||||
result = fcntl (fd, F_DUPFD, desired_fd);
|
||||
# if REPLACE_FCHDIR
|
||||
if (0 <= result)
|
||||
result = _gl_register_dup (fd, result);
|
||||
# endif
|
||||
# else
|
||||
result = dupfd (fd, desired_fd);
|
||||
# endif
|
||||
if (result == -1 && (errno == EMFILE || errno == EINVAL))
|
||||
errno = EBADF;
|
||||
return result;
|
||||
}
|
||||
#endif /* !HAVE_DUP2 */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* A POSIX-like <errno.h>.
|
||||
|
||||
Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2008-2010 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
|
||||
|
|
@ -145,6 +145,11 @@
|
|||
# define GNULIB_defined_ENOTSUP 1
|
||||
# endif
|
||||
|
||||
# ifndef ESTALE
|
||||
# define ESTALE 2009
|
||||
# define GNULIB_defined_ESTALE 1
|
||||
# endif
|
||||
|
||||
# ifndef ECANCELED
|
||||
# define ECANCELED 2008
|
||||
# define GNULIB_defined_ECANCELED 1
|
||||
|
|
|
|||
170
gl/error.c
170
gl/error.c
|
|
@ -1,5 +1,5 @@
|
|||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-1998, 2000-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990-1998, 2000-2007, 2009-2010 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
|
||||
|
|
@ -70,8 +70,8 @@ unsigned int error_message_count;
|
|||
extern void __error (int status, int errnum, const char *message, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message,
|
||||
...)
|
||||
unsigned int line_number, const char *message,
|
||||
...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));;
|
||||
# define error __error
|
||||
# define error_at_line __error_at_line
|
||||
|
|
@ -85,6 +85,18 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
|
|||
|
||||
#else /* not _LIBC */
|
||||
|
||||
# include <fcntl.h>
|
||||
# include <unistd.h>
|
||||
|
||||
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
/* Get declarations of the Win32 API functions. */
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
# endif
|
||||
|
||||
/* The gnulib override of fcntl is not needed in this file. */
|
||||
# undef fcntl
|
||||
|
||||
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||
# ifndef HAVE_DECL_STRERROR_R
|
||||
"this configure-time declaration test was not run"
|
||||
|
|
@ -98,8 +110,52 @@ extern char *program_name;
|
|||
|
||||
# if HAVE_STRERROR_R || defined strerror_r
|
||||
# define __strerror_r strerror_r
|
||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||
#endif /* not _LIBC */
|
||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||
#endif /* not _LIBC */
|
||||
|
||||
#if !_LIBC
|
||||
/* Return non-zero if FD is open. */
|
||||
static inline int
|
||||
is_open (int fd)
|
||||
{
|
||||
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
/* On Win32: The initial state of unassigned standard file descriptors is
|
||||
that they are open but point to an INVALID_HANDLE_VALUE. There is no
|
||||
fcntl, and the gnulib replacement fcntl does not support F_GETFL. */
|
||||
return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
|
||||
# else
|
||||
# ifndef F_GETFL
|
||||
# error Please port fcntl to your platform
|
||||
# endif
|
||||
return 0 <= fcntl (fd, F_GETFL);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
flush_stdout (void)
|
||||
{
|
||||
#if !_LIBC
|
||||
int stdout_fd;
|
||||
|
||||
# if GNULIB_FREOPEN_SAFER
|
||||
/* Use of gnulib's freopen-safer module normally ensures that
|
||||
fileno (stdout) == 1
|
||||
whenever stdout is open. */
|
||||
stdout_fd = STDOUT_FILENO;
|
||||
# else
|
||||
/* POSIX states that fileno (stdout) after fclose is unspecified. But in
|
||||
practice it is not a problem, because stdout is statically allocated and
|
||||
the fd of a FILE stream is stored as a field in its allocated memory. */
|
||||
stdout_fd = fileno (stdout);
|
||||
# endif
|
||||
/* POSIX states that fflush (stdout) after fclose is unspecified; it
|
||||
is safe in glibc, but not on all other platforms. fflush (NULL)
|
||||
is always defined, but too draconian. */
|
||||
if (0 <= stdout_fd && is_open (stdout_fd))
|
||||
#endif
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
static void
|
||||
print_errno_message (int errnum)
|
||||
|
|
@ -147,58 +203,58 @@ error_tail (int status, int errnum, const char *message, va_list args)
|
|||
bool use_malloc = false;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (__libc_use_alloca (len * sizeof (wchar_t)))
|
||||
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||
else
|
||||
{
|
||||
if (!use_malloc)
|
||||
wmessage = NULL;
|
||||
{
|
||||
if (__libc_use_alloca (len * sizeof (wchar_t)))
|
||||
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||
else
|
||||
{
|
||||
if (!use_malloc)
|
||||
wmessage = NULL;
|
||||
|
||||
wchar_t *p = (wchar_t *) realloc (wmessage,
|
||||
len * sizeof (wchar_t));
|
||||
if (p == NULL)
|
||||
{
|
||||
free (wmessage);
|
||||
fputws_unlocked (L"out of memory\n", stderr);
|
||||
return;
|
||||
}
|
||||
wmessage = p;
|
||||
use_malloc = true;
|
||||
}
|
||||
wchar_t *p = (wchar_t *) realloc (wmessage,
|
||||
len * sizeof (wchar_t));
|
||||
if (p == NULL)
|
||||
{
|
||||
free (wmessage);
|
||||
fputws_unlocked (L"out of memory\n", stderr);
|
||||
return;
|
||||
}
|
||||
wmessage = p;
|
||||
use_malloc = true;
|
||||
}
|
||||
|
||||
memset (&st, '\0', sizeof (st));
|
||||
tmp = message;
|
||||
memset (&st, '\0', sizeof (st));
|
||||
tmp = message;
|
||||
|
||||
res = mbsrtowcs (wmessage, &tmp, len, &st);
|
||||
if (res != len)
|
||||
break;
|
||||
res = mbsrtowcs (wmessage, &tmp, len, &st);
|
||||
if (res != len)
|
||||
break;
|
||||
|
||||
if (__builtin_expect (len >= SIZE_MAX / 2, 0))
|
||||
{
|
||||
/* This really should not happen if everything is fine. */
|
||||
res = (size_t) -1;
|
||||
break;
|
||||
}
|
||||
if (__builtin_expect (len >= SIZE_MAX / 2, 0))
|
||||
{
|
||||
/* This really should not happen if everything is fine. */
|
||||
res = (size_t) -1;
|
||||
break;
|
||||
}
|
||||
|
||||
len *= 2;
|
||||
}
|
||||
len *= 2;
|
||||
}
|
||||
|
||||
if (res == (size_t) -1)
|
||||
{
|
||||
/* The string cannot be converted. */
|
||||
if (use_malloc)
|
||||
{
|
||||
free (wmessage);
|
||||
use_malloc = false;
|
||||
}
|
||||
wmessage = (wchar_t *) L"???";
|
||||
}
|
||||
{
|
||||
/* The string cannot be converted. */
|
||||
if (use_malloc)
|
||||
{
|
||||
free (wmessage);
|
||||
use_malloc = false;
|
||||
}
|
||||
wmessage = (wchar_t *) L"???";
|
||||
}
|
||||
|
||||
__vfwprintf (stderr, wmessage, args);
|
||||
|
||||
if (use_malloc)
|
||||
free (wmessage);
|
||||
free (wmessage);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
|
@ -233,10 +289,10 @@ error (int status, int errnum, const char *message, ...)
|
|||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
0);
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
flush_stdout ();
|
||||
#ifdef _LIBC
|
||||
_IO_flockfile (stderr);
|
||||
#endif
|
||||
|
|
@ -268,7 +324,7 @@ int error_one_per_line;
|
|||
|
||||
void
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
unsigned int line_number, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
|
|
@ -278,10 +334,10 @@ error_at_line (int status, int errnum, const char *file_name,
|
|||
static unsigned int old_line_number;
|
||||
|
||||
if (old_line_number == line_number
|
||||
&& (file_name == old_file_name
|
||||
|| strcmp (old_file_name, file_name) == 0))
|
||||
/* Simply return and print nothing. */
|
||||
return;
|
||||
&& (file_name == old_file_name
|
||||
|| strcmp (old_file_name, file_name) == 0))
|
||||
/* Simply return and print nothing. */
|
||||
return;
|
||||
|
||||
old_file_name = file_name;
|
||||
old_line_number = line_number;
|
||||
|
|
@ -292,10 +348,10 @@ error_at_line (int status, int errnum, const char *file_name,
|
|||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
0);
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
flush_stdout ();
|
||||
#ifdef _LIBC
|
||||
_IO_flockfile (stderr);
|
||||
#endif
|
||||
|
|
@ -312,10 +368,10 @@ error_at_line (int status, int errnum, const char *file_name,
|
|||
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
|
||||
file_name, line_number);
|
||||
file_name, line_number);
|
||||
#else
|
||||
fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
|
||||
file_name, line_number);
|
||||
file_name, line_number);
|
||||
#endif
|
||||
|
||||
va_start (args, message);
|
||||
|
|
|
|||
24
gl/error.h
24
gl/error.h
|
|
@ -1,5 +1,6 @@
|
|||
/* Declaration for error-reporting function
|
||||
Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008, 2009, 2010 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,19 +20,18 @@
|
|||
#define _ERROR_H 1
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
/* The __attribute__ feature is available in gcc versions 2.5 and later.
|
||||
The __-protected variants of the attributes 'format' and 'printf' are
|
||||
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
|
||||
We enable __attribute__ only if these are supported too, because
|
||||
gnulib and libintl do '#define printf __printf__' when they override
|
||||
the 'printf' function. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ extern void error (int __status, int __errnum, const char *__format, ...)
|
|||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
|
||||
extern void error_at_line (int __status, int __errnum, const char *__fname,
|
||||
unsigned int __lineno, const char *__format, ...)
|
||||
unsigned int __lineno, const char *__format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
|
|
@ -58,7 +58,7 @@ extern unsigned int error_message_count;
|
|||
variable controls whether this mode is selected or not. */
|
||||
extern int error_one_per_line;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2003, 2005, 2006, 2007, 2009, 2010 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2009, 2010 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Like fcntl.h, but redefine some names to avoid glitches.
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2009-2010 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,3 +25,8 @@
|
|||
|
||||
#undef creat
|
||||
#define creat creat_safer
|
||||
|
||||
#if GNULIB_OPENAT_SAFER
|
||||
# undef openat
|
||||
# define openat openat_safer
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Invoke fcntl-like functions, but avoid some glitches.
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2009-2010 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
|
||||
|
|
@ -21,3 +21,7 @@
|
|||
|
||||
int open_safer (char const *, int, ...);
|
||||
int creat_safer (char const *, mode_t);
|
||||
|
||||
#if GNULIB_OPENAT_SAFER
|
||||
int openat_safer (int, char const *, int, ...);
|
||||
#endif
|
||||
|
|
|
|||
294
gl/fcntl.c
Normal file
294
gl/fcntl.c
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
/* Provide file descriptor control.
|
||||
|
||||
Copyright (C) 2009, 2010 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Eric Blake <ebb9@byu.net>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if !HAVE_FCNTL
|
||||
# define rpl_fcntl fcntl
|
||||
#endif
|
||||
#undef fcntl
|
||||
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
/* Get declarations of the Win32 API functions. */
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
|
||||
/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
|
||||
# define OPEN_MAX_MAX 0x10000
|
||||
|
||||
/* Duplicate OLDFD into the first available slot of at least NEWFD,
|
||||
which must be positive, with FLAGS determining whether the duplicate
|
||||
will be inheritable. */
|
||||
static int
|
||||
dupfd (int oldfd, int newfd, int flags)
|
||||
{
|
||||
/* Mingw has no way to create an arbitrary fd. Iterate until all
|
||||
file descriptors less than newfd are filled up. */
|
||||
HANDLE curr_process = GetCurrentProcess ();
|
||||
HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
|
||||
unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
|
||||
unsigned int fds_to_close_bound = 0;
|
||||
int result;
|
||||
BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
|
||||
int mode;
|
||||
|
||||
if (newfd < 0 || getdtablesize () <= newfd)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (old_handle == INVALID_HANDLE_VALUE
|
||||
|| (mode = setmode (oldfd, O_BINARY)) == -1)
|
||||
{
|
||||
/* oldfd is not open, or is an unassigned standard file
|
||||
descriptor. */
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
setmode (oldfd, mode);
|
||||
flags |= mode;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
HANDLE new_handle;
|
||||
int duplicated_fd;
|
||||
unsigned int index;
|
||||
|
||||
if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
|
||||
old_handle, /* SourceHandle */
|
||||
curr_process, /* TargetProcessHandle */
|
||||
(PHANDLE) &new_handle, /* TargetHandle */
|
||||
(DWORD) 0, /* DesiredAccess */
|
||||
inherit, /* InheritHandle */
|
||||
DUPLICATE_SAME_ACCESS)) /* Options */
|
||||
{
|
||||
/* TODO: Translate GetLastError () into errno. */
|
||||
errno = EMFILE;
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
duplicated_fd = _open_osfhandle ((long) new_handle, flags);
|
||||
if (duplicated_fd < 0)
|
||||
{
|
||||
CloseHandle (new_handle);
|
||||
errno = EMFILE;
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
if (newfd <= duplicated_fd)
|
||||
{
|
||||
result = duplicated_fd;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the bit duplicated_fd in fds_to_close[]. */
|
||||
index = (unsigned int) duplicated_fd / CHAR_BIT;
|
||||
if (fds_to_close_bound <= index)
|
||||
{
|
||||
if (sizeof fds_to_close <= index)
|
||||
/* Need to increase OPEN_MAX_MAX. */
|
||||
abort ();
|
||||
memset (fds_to_close + fds_to_close_bound, '\0',
|
||||
index + 1 - fds_to_close_bound);
|
||||
fds_to_close_bound = index + 1;
|
||||
}
|
||||
fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
|
||||
}
|
||||
|
||||
/* Close the previous fds that turned out to be too small. */
|
||||
{
|
||||
int saved_errno = errno;
|
||||
unsigned int duplicated_fd;
|
||||
|
||||
for (duplicated_fd = 0;
|
||||
duplicated_fd < fds_to_close_bound * CHAR_BIT;
|
||||
duplicated_fd++)
|
||||
if ((fds_to_close[duplicated_fd / CHAR_BIT]
|
||||
>> (duplicated_fd % CHAR_BIT))
|
||||
& 1)
|
||||
close (duplicated_fd);
|
||||
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
# if REPLACE_FCHDIR
|
||||
if (0 <= result)
|
||||
result = _gl_register_dup (oldfd, result);
|
||||
# endif
|
||||
return result;
|
||||
}
|
||||
#endif /* W32 */
|
||||
|
||||
/* Perform the specified ACTION on the file descriptor FD, possibly
|
||||
using the argument ARG further described below. This replacement
|
||||
handles the following actions, and forwards all others on to the
|
||||
native fcntl. An unrecognized ACTION returns -1 with errno set to
|
||||
EINVAL.
|
||||
|
||||
F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
|
||||
If successful, return the duplicate, which will be inheritable;
|
||||
otherwise return -1 and set errno.
|
||||
|
||||
F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
|
||||
target fd. If successful, return the duplicate, which will not be
|
||||
inheritable; otherwise return -1 and set errno.
|
||||
|
||||
F_GETFD - ARG need not be present. If successful, return a
|
||||
non-negative value containing the descriptor flags of FD (only
|
||||
FD_CLOEXEC is portable, but other flags may be present); otherwise
|
||||
return -1 and set errno. */
|
||||
|
||||
int
|
||||
rpl_fcntl (int fd, int action, /* arg */...)
|
||||
{
|
||||
va_list arg;
|
||||
int result = -1;
|
||||
va_start (arg, action);
|
||||
switch (action)
|
||||
{
|
||||
|
||||
#if !HAVE_FCNTL
|
||||
case F_DUPFD:
|
||||
{
|
||||
int target = va_arg (arg, int);
|
||||
result = dupfd (fd, target, 0);
|
||||
break;
|
||||
}
|
||||
#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
|
||||
case F_DUPFD:
|
||||
{
|
||||
int target = va_arg (arg, int);
|
||||
/* Detect invalid target; needed for cygwin 1.5.x. */
|
||||
if (target < 0 || getdtablesize () <= target)
|
||||
errno = EINVAL;
|
||||
else
|
||||
{
|
||||
result = fcntl (fd, action, target);
|
||||
# if REPLACE_FCHDIR
|
||||
if (0 <= result)
|
||||
result = _gl_register_dup (fd, result);
|
||||
# endif
|
||||
}
|
||||
break;
|
||||
} /* F_DUPFD */
|
||||
#endif /* FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR */
|
||||
|
||||
case F_DUPFD_CLOEXEC:
|
||||
{
|
||||
int target = va_arg (arg, int);
|
||||
|
||||
#if !HAVE_FCNTL
|
||||
result = dupfd (fd, target, O_CLOEXEC);
|
||||
break;
|
||||
#else /* HAVE_FCNTL */
|
||||
/* Try the system call first, if the headers claim it exists
|
||||
(that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
|
||||
may be running with a glibc that has the macro but with an
|
||||
older kernel that does not support it. Cache the
|
||||
information on whether the system call really works, but
|
||||
avoid caching failure if the corresponding F_DUPFD fails
|
||||
for any reason. 0 = unknown, 1 = yes, -1 = no. */
|
||||
static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
|
||||
if (0 <= have_dupfd_cloexec)
|
||||
{
|
||||
result = fcntl (fd, action, target);
|
||||
if (0 <= result || errno != EINVAL)
|
||||
{
|
||||
have_dupfd_cloexec = 1;
|
||||
# if REPLACE_FCHDIR
|
||||
if (0 <= result)
|
||||
result = _gl_register_dup (fd, result);
|
||||
# endif
|
||||
}
|
||||
else
|
||||
{
|
||||
result = rpl_fcntl (fd, F_DUPFD, target);
|
||||
if (result < 0)
|
||||
break;
|
||||
have_dupfd_cloexec = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
result = rpl_fcntl (fd, F_DUPFD, target);
|
||||
if (0 <= result && have_dupfd_cloexec == -1)
|
||||
{
|
||||
int flags = fcntl (result, F_GETFD);
|
||||
if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
close (result);
|
||||
errno = saved_errno;
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif /* HAVE_FCNTL */
|
||||
} /* F_DUPFD_CLOEXEC */
|
||||
|
||||
#if !HAVE_FCNTL
|
||||
case F_GETFD:
|
||||
{
|
||||
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
HANDLE handle = (HANDLE) _get_osfhandle (fd);
|
||||
DWORD flags;
|
||||
if (handle == INVALID_HANDLE_VALUE
|
||||
|| GetHandleInformation (handle, &flags) == 0)
|
||||
errno = EBADF;
|
||||
else
|
||||
result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
|
||||
# else /* !W32 */
|
||||
/* Use dup2 to reject invalid file descriptors. No way to
|
||||
access this information, so punt. */
|
||||
if (0 <= dup2 (fd, fd))
|
||||
result = 0;
|
||||
# endif /* !W32 */
|
||||
break;
|
||||
} /* F_GETFD */
|
||||
#endif /* !HAVE_FCNTL */
|
||||
|
||||
/* Implementing F_SETFD on mingw is not trivial - there is no
|
||||
API for changing the O_NOINHERIT bit on an fd, and merely
|
||||
changing the HANDLE_FLAG_INHERIT bit on the underlying handle
|
||||
can lead to odd state. It may be possible by duplicating the
|
||||
handle, using _open_osfhandle with the right flags, then
|
||||
using dup2 to move the duplicate onto the original, but that
|
||||
is not supported for now. */
|
||||
|
||||
default:
|
||||
{
|
||||
#if HAVE_FCNTL
|
||||
void *p = va_arg (arg, void *);
|
||||
result = fcntl (fd, action, p);
|
||||
#else
|
||||
errno = EINVAL;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end (arg);
|
||||
return result;
|
||||
}
|
||||
165
gl/fcntl.in.h
165
gl/fcntl.in.h
|
|
@ -1,6 +1,6 @@
|
|||
/* Like <fcntl.h>, but with non-working flags defined to 0.
|
||||
|
||||
Copyright (C) 2006-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2006-2010 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,8 +25,9 @@
|
|||
/* Special invocation convention. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
|
||||
|
||||
#else
|
||||
|
|
@ -35,38 +36,126 @@
|
|||
#ifndef _GL_FCNTL_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
|
||||
|
||||
#ifndef _GL_FCNTL_H
|
||||
#define _GL_FCNTL_H
|
||||
|
||||
#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
|
||||
/* Declare overridden functions. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#if @GNULIB_FCNTL@
|
||||
# if @REPLACE_FCNTL@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef fcntl
|
||||
# define fcntl rpl_fcntl
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
|
||||
_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
|
||||
# else
|
||||
# if !@HAVE_FCNTL@
|
||||
_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (fcntl);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fcntl
|
||||
# if HAVE_RAW_DECL_FCNTL
|
||||
_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
|
||||
"use gnulib module fcntl for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_OPEN@
|
||||
# if @REPLACE_OPEN@
|
||||
# undef open
|
||||
# define open rpl_open
|
||||
extern int open (const char *filename, int flags, ...);
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef open
|
||||
# define open rpl_open
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (open);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef open
|
||||
/* Assume open is always declared. */
|
||||
_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
|
||||
"use gnulib module open for portability");
|
||||
#endif
|
||||
|
||||
#if @GNULIB_OPENAT@
|
||||
# if @REPLACE_OPENAT@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef openat
|
||||
# define openat rpl_openat
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
_GL_CXXALIAS_RPL (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...));
|
||||
# else
|
||||
# if !@HAVE_OPENAT@
|
||||
_GL_FUNCDECL_SYS (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (openat, int,
|
||||
(int fd, char const *file, int flags, /* mode_t mode */ ...));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (openat);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef openat
|
||||
# if HAVE_RAW_DECL_OPENAT
|
||||
_GL_WARN_ON_USE (openat, "openat is not portable - "
|
||||
"use gnulib module openat for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef FCHDIR_REPLACEMENT
|
||||
/* gnulib internal function. */
|
||||
extern void _gl_register_fd (int fd, const char *filename);
|
||||
|
||||
/* Fix up the FD_* macros, only known to be missing on mingw. */
|
||||
|
||||
#ifndef FD_CLOEXEC
|
||||
# define FD_CLOEXEC 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
/* Fix up the supported F_* macros. Intentionally leave other F_*
|
||||
macros undefined. Only known to be missing on mingw. */
|
||||
|
||||
#ifndef F_DUPFD_CLOEXEC
|
||||
# define F_DUPFD_CLOEXEC 0x40000000
|
||||
/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
|
||||
# define GNULIB_defined_F_DUPFD_CLOEXEC 1
|
||||
#else
|
||||
# define GNULIB_defined_F_DUPFD_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
#ifndef F_DUPFD
|
||||
# define F_DUPFD 1
|
||||
#endif
|
||||
|
||||
#ifndef F_GETFD
|
||||
# define F_GETFD 2
|
||||
#endif
|
||||
|
||||
/* Fix up the O_* macros. */
|
||||
|
||||
|
|
@ -75,6 +164,12 @@ extern void _gl_register_fd (int fd, const char *filename);
|
|||
# define O_DIRECT O_DIRECTIO
|
||||
#endif
|
||||
|
||||
#if !defined O_CLOEXEC && defined O_NOINHERIT
|
||||
/* Mingw spells it `O_NOINHERIT'. Intentionally leave it
|
||||
undefined if not available. */
|
||||
# define O_CLOEXEC O_NOINHERIT
|
||||
#endif
|
||||
|
||||
#ifndef O_DIRECT
|
||||
# define O_DIRECT 0
|
||||
#endif
|
||||
|
|
@ -119,6 +214,10 @@ extern void _gl_register_fd (int fd, const char *filename);
|
|||
# define O_SYNC 0
|
||||
#endif
|
||||
|
||||
#ifndef O_TTY_INIT
|
||||
# define O_TTY_INIT 0
|
||||
#endif
|
||||
|
||||
/* For systems that distinguish between text and binary I/O.
|
||||
O_BINARY is usually declared in fcntl.h */
|
||||
#if !defined O_BINARY && defined _O_BINARY
|
||||
|
|
@ -138,6 +237,42 @@ extern void _gl_register_fd (int fd, const char *filename);
|
|||
# define O_TEXT 0
|
||||
#endif
|
||||
|
||||
/* Fix up the AT_* macros. */
|
||||
|
||||
/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
|
||||
value exceeds INT_MAX, so its use as an int doesn't conform to the
|
||||
C standard, and GCC and Sun C complain in some cases. If the bug
|
||||
is present, undef AT_FDCWD here, so it can be redefined below. */
|
||||
#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
|
||||
# undef AT_FDCWD
|
||||
#endif
|
||||
|
||||
/* Use the same bit pattern as Solaris 9, but with the proper
|
||||
signedness. The bit pattern is important, in case this actually is
|
||||
Solaris with the above workaround. */
|
||||
#ifndef AT_FDCWD
|
||||
# define AT_FDCWD (-3041965)
|
||||
#endif
|
||||
|
||||
/* Use the same values as Solaris 9. This shouldn't matter, but
|
||||
there's no real reason to differ. */
|
||||
#ifndef AT_SYMLINK_NOFOLLOW
|
||||
# define AT_SYMLINK_NOFOLLOW 4096
|
||||
#endif
|
||||
|
||||
#ifndef AT_REMOVEDIR
|
||||
# define AT_REMOVEDIR 1
|
||||
#endif
|
||||
|
||||
/* Solaris 9 lacks these two, so just pick unique values. */
|
||||
#ifndef AT_SYMLINK_FOLLOW
|
||||
# define AT_SYMLINK_FOLLOW 2
|
||||
#endif
|
||||
|
||||
#ifndef AT_EACCESS
|
||||
# define AT_EACCESS 4
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _GL_FCNTL_H */
|
||||
#endif /* _GL_FCNTL_H */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* Return a safer copy of a file descriptor.
|
||||
|
||||
Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2006, 2009-2010 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 @@
|
|||
#include "unistd-safer.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
/* Return FD, unless FD would be a copy of standard input, output, or
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Supplemental information about the floating-point formats.
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2007.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* A correct <float.h>.
|
||||
|
||||
Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007-2010 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
|
||||
|
|
|
|||
34
gl/floor.c
34
gl/floor.c
|
|
@ -1,5 +1,5 @@
|
|||
/* Round towards negative infinity.
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2009, 2010 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
|
||||
|
|
@ -67,27 +67,27 @@ FUNC (DOUBLE x)
|
|||
{
|
||||
/* Avoid rounding errors for values near 2^k, where k >= MANT_DIG-1. */
|
||||
if (z < TWO_MANT_DIG)
|
||||
{
|
||||
/* Round to the next integer (nearest or up or down, doesn't matter). */
|
||||
z += TWO_MANT_DIG;
|
||||
z -= TWO_MANT_DIG;
|
||||
/* Enforce rounding down. */
|
||||
if (z > y)
|
||||
z -= L_(1.0);
|
||||
}
|
||||
{
|
||||
/* Round to the next integer (nearest or up or down, doesn't matter). */
|
||||
z += TWO_MANT_DIG;
|
||||
z -= TWO_MANT_DIG;
|
||||
/* Enforce rounding down. */
|
||||
if (z > y)
|
||||
z -= L_(1.0);
|
||||
}
|
||||
}
|
||||
else if (z < L_(0.0))
|
||||
{
|
||||
/* Avoid rounding errors for values near -2^k, where k >= MANT_DIG-1. */
|
||||
if (z > - TWO_MANT_DIG)
|
||||
{
|
||||
/* Round to the next integer (nearest or up or down, doesn't matter). */
|
||||
z -= TWO_MANT_DIG;
|
||||
z += TWO_MANT_DIG;
|
||||
/* Enforce rounding down. */
|
||||
if (z > y)
|
||||
z -= L_(1.0);
|
||||
}
|
||||
{
|
||||
/* Round to the next integer (nearest or up or down, doesn't matter). */
|
||||
z -= TWO_MANT_DIG;
|
||||
z += TWO_MANT_DIG;
|
||||
/* Enforce rounding down. */
|
||||
if (z > y)
|
||||
z -= L_(1.0);
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Round towards negative infinity.
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2007, 2009, 2010 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
|
||||
|
|
|
|||
38
gl/fsusage.c
38
gl/fsusage.c
|
|
@ -1,7 +1,7 @@
|
|||
/* fsusage.c -- return space usage of mounted file systems
|
||||
|
||||
Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2010 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
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if STAT_STATVFS /* POSIX 1003.1-2001 (and later) with XSI */
|
||||
#if STAT_STATVFS /* POSIX 1003.1-2001 (and later) with XSI */
|
||||
# include <sys/statvfs.h>
|
||||
#else
|
||||
/* Don't include backward-compatibility files unless they're needed.
|
||||
|
|
@ -40,16 +40,16 @@
|
|||
# if HAVE_SYS_VFS_H
|
||||
# include <sys/vfs.h>
|
||||
# endif
|
||||
# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */
|
||||
# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */
|
||||
# include <sys/fs/s5param.h>
|
||||
# endif
|
||||
# if defined HAVE_SYS_FILSYS_H && !defined _CRAY
|
||||
# include <sys/filsys.h> /* SVR2 */
|
||||
# include <sys/filsys.h> /* SVR2 */
|
||||
# endif
|
||||
# if HAVE_SYS_STATFS_H
|
||||
# include <sys/statfs.h>
|
||||
# endif
|
||||
# if HAVE_DUSTAT_H /* AIX PS/2 */
|
||||
# if HAVE_DUSTAT_H /* AIX PS/2 */
|
||||
# include <sys/dustat.h>
|
||||
# endif
|
||||
# include "full-read.h"
|
||||
|
|
@ -67,13 +67,13 @@
|
|||
#define PROPAGATE_ALL_ONES(x) \
|
||||
((sizeof (x) < sizeof (uintmax_t) \
|
||||
&& (~ (x) == (sizeof (x) < sizeof (int) \
|
||||
? - (1 << (sizeof (x) * CHAR_BIT)) \
|
||||
: 0))) \
|
||||
? - (1 << (sizeof (x) * CHAR_BIT)) \
|
||||
: 0))) \
|
||||
? UINTMAX_MAX : (uintmax_t) (x))
|
||||
|
||||
/* Extract the top bit of X as an uintmax_t value. */
|
||||
#define EXTRACT_TOP_BIT(x) ((x) \
|
||||
& ((uintmax_t) 1 << (sizeof (x) * CHAR_BIT - 1)))
|
||||
& ((uintmax_t) 1 << (sizeof (x) * CHAR_BIT - 1)))
|
||||
|
||||
/* If a value is negative, many space usage primitives store it into an
|
||||
integer variable by assignment, even if the variable's type is unsigned.
|
||||
|
|
@ -94,7 +94,7 @@
|
|||
int
|
||||
get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
||||
{
|
||||
#if defined STAT_STATVFS /* POSIX */
|
||||
#if defined STAT_STATVFS /* POSIX */
|
||||
|
||||
struct statvfs fsd;
|
||||
|
||||
|
|
@ -103,10 +103,10 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
|||
|
||||
/* f_frsize isn't guaranteed to be supported. */
|
||||
fsp->fsu_blocksize = (fsd.f_frsize
|
||||
? PROPAGATE_ALL_ONES (fsd.f_frsize)
|
||||
: PROPAGATE_ALL_ONES (fsd.f_bsize));
|
||||
? PROPAGATE_ALL_ONES (fsd.f_frsize)
|
||||
: PROPAGATE_ALL_ONES (fsd.f_bsize));
|
||||
|
||||
#elif defined STAT_STATFS2_FS_DATA /* Ultrix */
|
||||
#elif defined STAT_STATFS2_FS_DATA /* Ultrix */
|
||||
|
||||
struct fs_data fsd;
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
|||
fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot);
|
||||
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
|
||||
|
||||
#elif defined STAT_READ_FILSYS /* SVR2 */
|
||||
#elif defined STAT_READ_FILSYS /* SVR2 */
|
||||
# ifndef SUPERBOFF
|
||||
# define SUPERBOFF (SUPERB * 512)
|
||||
# endif
|
||||
|
|
@ -152,8 +152,8 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
|||
fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.s_tfree);
|
||||
fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0;
|
||||
fsp->fsu_files = (fsd.s_isize == -1
|
||||
? UINTMAX_MAX
|
||||
: (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
|
||||
? UINTMAX_MAX
|
||||
: (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
|
||||
fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
|
||||
|
||||
#elif defined STAT_STATFS3_OSF1
|
||||
|
|
@ -165,7 +165,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
|||
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
||||
|
||||
#elif defined STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */
|
||||
#elif defined STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */
|
||||
|
||||
struct statfs fsd;
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
|||
}
|
||||
# endif /* STATFS_TRUNCATES_BLOCK_COUNTS */
|
||||
|
||||
#elif defined STAT_STATFS2_FSIZE /* 4.4BSD */
|
||||
#elif defined STAT_STATFS2_FSIZE /* 4.4BSD */
|
||||
|
||||
struct statfs fsd;
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
|
|||
|
||||
fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
|
||||
|
||||
#elif defined STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */
|
||||
#elif defined STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */
|
||||
|
||||
# if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN
|
||||
# define f_bavail f_bfree
|
||||
|
|
|
|||
16
gl/fsusage.h
16
gl/fsusage.h
|
|
@ -1,6 +1,6 @@
|
|||
/* fsusage.h -- declarations for file system space usage info
|
||||
|
||||
Copyright (C) 1991, 1992, 1997, 2003, 2004, 2005, 2006 Free Software
|
||||
Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -26,13 +26,13 @@
|
|||
|
||||
struct fs_usage
|
||||
{
|
||||
uintmax_t fsu_blocksize; /* Size of a block. */
|
||||
uintmax_t fsu_blocks; /* Total blocks. */
|
||||
uintmax_t fsu_bfree; /* Free blocks available to superuser. */
|
||||
uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */
|
||||
bool fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */
|
||||
uintmax_t fsu_files; /* Total file nodes. */
|
||||
uintmax_t fsu_ffree; /* Free file nodes. */
|
||||
uintmax_t fsu_blocksize; /* Size of a block. */
|
||||
uintmax_t fsu_blocks; /* Total blocks. */
|
||||
uintmax_t fsu_bfree; /* Free blocks available to superuser. */
|
||||
uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */
|
||||
bool fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */
|
||||
uintmax_t fsu_files; /* Total file nodes. */
|
||||
uintmax_t fsu_ffree; /* Free file nodes. */
|
||||
};
|
||||
|
||||
int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* An interface to read that retries after partial reads and interrupts.
|
||||
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2003, 2009-2010 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* An interface to read() that reads all it is asked to read.
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2009-2010 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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/* An interface to read and write that retries (if necessary) until complete.
|
||||
|
||||
Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
|
||||
2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993-1994, 1997-2006, 2009-2010 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
|
||||
|
|
@ -65,12 +64,12 @@ full_rw (int fd, const void *buf, size_t count)
|
|||
{
|
||||
size_t n_rw = safe_rw (fd, ptr, count);
|
||||
if (n_rw == (size_t) -1)
|
||||
break;
|
||||
break;
|
||||
if (n_rw == 0)
|
||||
{
|
||||
errno = ZERO_BYTE_TRANSFER_ERRNO;
|
||||
break;
|
||||
}
|
||||
{
|
||||
errno = ZERO_BYTE_TRANSFER_ERRNO;
|
||||
break;
|
||||
}
|
||||
total += n_rw;
|
||||
ptr += n_rw;
|
||||
count -= n_rw;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* An interface to write() that writes all it is asked to write.
|
||||
|
||||
Copyright (C) 2002-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2003, 2009-2010 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
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008, 2009, 2010 Free
|
||||
Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
|
||||
|
||||
|
|
|
|||
174
gl/getaddrinfo.c
174
gl/getaddrinfo.c
|
|
@ -1,6 +1,5 @@
|
|||
/* Get address information (partial implementation).
|
||||
Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free Software
|
||||
Foundation, Inc.
|
||||
Copyright (C) 1997, 2001-2002, 2004-2010 Free Software Foundation, Inc.
|
||||
Contributed by Simon Josefsson <simon@josefsson.org>.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -19,6 +18,10 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
|
||||
optimizes away the sa == NULL test below. */
|
||||
#define _GL_ARG_NONNULL(params)
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
#if HAVE_NETINET_IN_H
|
||||
|
|
@ -58,12 +61,12 @@
|
|||
|
||||
#ifdef WIN32_NATIVE
|
||||
typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
|
||||
const struct addrinfo*,
|
||||
struct addrinfo**);
|
||||
const struct addrinfo*,
|
||||
struct addrinfo**);
|
||||
typedef void (WSAAPI *freeaddrinfo_func) (struct addrinfo*);
|
||||
typedef int (WSAAPI *getnameinfo_func) (const struct sockaddr*,
|
||||
socklen_t, char*, DWORD,
|
||||
char*, DWORD, int);
|
||||
socklen_t, char*, DWORD,
|
||||
char*, DWORD, int);
|
||||
|
||||
static getaddrinfo_func getaddrinfo_ptr = NULL;
|
||||
static freeaddrinfo_func freeaddrinfo_ptr = NULL;
|
||||
|
|
@ -123,9 +126,9 @@ validate_family (int family)
|
|||
socket addresses. */
|
||||
int
|
||||
getaddrinfo (const char *restrict nodename,
|
||||
const char *restrict servname,
|
||||
const struct addrinfo *restrict hints,
|
||||
struct addrinfo **restrict res)
|
||||
const char *restrict servname,
|
||||
const struct addrinfo *restrict hints,
|
||||
struct addrinfo **restrict res)
|
||||
{
|
||||
struct addrinfo *tmp;
|
||||
int port = 0;
|
||||
|
|
@ -165,7 +168,7 @@ getaddrinfo (const char *restrict nodename,
|
|||
if (!nodename)
|
||||
{
|
||||
if (!(hints->ai_flags & AI_PASSIVE))
|
||||
return EAI_NONAME;
|
||||
return EAI_NONAME;
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0";
|
||||
|
|
@ -178,24 +181,24 @@ getaddrinfo (const char *restrict nodename,
|
|||
{
|
||||
struct servent *se = NULL;
|
||||
const char *proto =
|
||||
(hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp";
|
||||
(hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp";
|
||||
|
||||
if (hints == NULL || !(hints->ai_flags & AI_NUMERICSERV))
|
||||
/* FIXME: Use getservbyname_r if available. */
|
||||
se = getservbyname (servname, proto);
|
||||
/* FIXME: Use getservbyname_r if available. */
|
||||
se = getservbyname (servname, proto);
|
||||
|
||||
if (!se)
|
||||
{
|
||||
char *c;
|
||||
if (!(*servname >= '0' && *servname <= '9'))
|
||||
return EAI_NONAME;
|
||||
port = strtoul (servname, &c, 10);
|
||||
if (*c || port > 0xffff)
|
||||
return EAI_NONAME;
|
||||
port = htons (port);
|
||||
}
|
||||
{
|
||||
char *c;
|
||||
if (!(*servname >= '0' && *servname <= '9'))
|
||||
return EAI_NONAME;
|
||||
port = strtoul (servname, &c, 10);
|
||||
if (*c || port > 0xffff)
|
||||
return EAI_NONAME;
|
||||
port = htons (port);
|
||||
}
|
||||
else
|
||||
port = se->s_port;
|
||||
port = se->s_port;
|
||||
}
|
||||
|
||||
/* FIXME: Use gethostbyname_r if available. */
|
||||
|
|
@ -230,23 +233,23 @@ getaddrinfo (const char *restrict nodename,
|
|||
#if HAVE_IPV6
|
||||
case PF_INET6:
|
||||
{
|
||||
struct v6_pair *p = storage;
|
||||
struct sockaddr_in6 *sinp = &p->sockaddr_in6;
|
||||
tmp = &p->addrinfo;
|
||||
struct v6_pair *p = storage;
|
||||
struct sockaddr_in6 *sinp = &p->sockaddr_in6;
|
||||
tmp = &p->addrinfo;
|
||||
|
||||
if (port)
|
||||
sinp->sin6_port = port;
|
||||
if (port)
|
||||
sinp->sin6_port = port;
|
||||
|
||||
if (he->h_length != sizeof (sinp->sin6_addr))
|
||||
{
|
||||
free (storage);
|
||||
return EAI_SYSTEM; /* FIXME: Better return code? Set errno? */
|
||||
}
|
||||
if (he->h_length != sizeof (sinp->sin6_addr))
|
||||
{
|
||||
free (storage);
|
||||
return EAI_SYSTEM; /* FIXME: Better return code? Set errno? */
|
||||
}
|
||||
|
||||
memcpy (&sinp->sin6_addr, he->h_addr_list[0], sizeof sinp->sin6_addr);
|
||||
memcpy (&sinp->sin6_addr, he->h_addr_list[0], sizeof sinp->sin6_addr);
|
||||
|
||||
tmp->ai_addr = (struct sockaddr *) sinp;
|
||||
tmp->ai_addrlen = sizeof *sinp;
|
||||
tmp->ai_addr = (struct sockaddr *) sinp;
|
||||
tmp->ai_addrlen = sizeof *sinp;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
|
@ -254,23 +257,23 @@ getaddrinfo (const char *restrict nodename,
|
|||
#if HAVE_IPV4
|
||||
case PF_INET:
|
||||
{
|
||||
struct v4_pair *p = storage;
|
||||
struct sockaddr_in *sinp = &p->sockaddr_in;
|
||||
tmp = &p->addrinfo;
|
||||
struct v4_pair *p = storage;
|
||||
struct sockaddr_in *sinp = &p->sockaddr_in;
|
||||
tmp = &p->addrinfo;
|
||||
|
||||
if (port)
|
||||
sinp->sin_port = port;
|
||||
if (port)
|
||||
sinp->sin_port = port;
|
||||
|
||||
if (he->h_length != sizeof (sinp->sin_addr))
|
||||
{
|
||||
free (storage);
|
||||
return EAI_SYSTEM; /* FIXME: Better return code? Set errno? */
|
||||
}
|
||||
if (he->h_length != sizeof (sinp->sin_addr))
|
||||
{
|
||||
free (storage);
|
||||
return EAI_SYSTEM; /* FIXME: Better return code? Set errno? */
|
||||
}
|
||||
|
||||
memcpy (&sinp->sin_addr, he->h_addr_list[0], sizeof sinp->sin_addr);
|
||||
memcpy (&sinp->sin_addr, he->h_addr_list[0], sizeof sinp->sin_addr);
|
||||
|
||||
tmp->ai_addr = (struct sockaddr *) sinp;
|
||||
tmp->ai_addrlen = sizeof *sinp;
|
||||
tmp->ai_addr = (struct sockaddr *) sinp;
|
||||
tmp->ai_addrlen = sizeof *sinp;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
|
@ -284,16 +287,16 @@ getaddrinfo (const char *restrict nodename,
|
|||
{
|
||||
const char *cn;
|
||||
if (he->h_name)
|
||||
cn = he->h_name;
|
||||
cn = he->h_name;
|
||||
else
|
||||
cn = nodename;
|
||||
cn = nodename;
|
||||
|
||||
tmp->ai_canonname = strdup (cn);
|
||||
if (!tmp->ai_canonname)
|
||||
{
|
||||
free (storage);
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
{
|
||||
free (storage);
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
tmp->ai_protocol = (hints) ? hints->ai_protocol : 0;
|
||||
|
|
@ -348,15 +351,16 @@ freeaddrinfo (struct addrinfo *ai)
|
|||
}
|
||||
}
|
||||
|
||||
int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
|
||||
char *restrict node, socklen_t nodelen,
|
||||
char *restrict service, socklen_t servicelen,
|
||||
int flags)
|
||||
int
|
||||
getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
|
||||
char *restrict node, socklen_t nodelen,
|
||||
char *restrict service, socklen_t servicelen,
|
||||
int flags)
|
||||
{
|
||||
#ifdef WIN32_NATIVE
|
||||
if (use_win32_p ())
|
||||
return getnameinfo_ptr (sa, salen, node, nodelen,
|
||||
service, servicelen, flags);
|
||||
service, servicelen, flags);
|
||||
#endif
|
||||
|
||||
/* FIXME: Support other flags. */
|
||||
|
|
@ -373,13 +377,13 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
|
|||
#if HAVE_IPV4
|
||||
case AF_INET:
|
||||
if (salen < sizeof (struct sockaddr_in))
|
||||
return EAI_FAMILY;
|
||||
return EAI_FAMILY;
|
||||
break;
|
||||
#endif
|
||||
#if HAVE_IPV6
|
||||
case AF_INET6:
|
||||
if (salen < sizeof (struct sockaddr_in6))
|
||||
return EAI_FAMILY;
|
||||
return EAI_FAMILY;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
|
@ -389,28 +393,28 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
|
|||
if (node && nodelen > 0 && flags & NI_NUMERICHOST)
|
||||
{
|
||||
switch (sa->sa_family)
|
||||
{
|
||||
{
|
||||
#if HAVE_IPV4
|
||||
case AF_INET:
|
||||
if (!inet_ntop (AF_INET,
|
||||
&(((const struct sockaddr_in *) sa)->sin_addr),
|
||||
node, nodelen))
|
||||
return EAI_SYSTEM;
|
||||
break;
|
||||
case AF_INET:
|
||||
if (!inet_ntop (AF_INET,
|
||||
&(((const struct sockaddr_in *) sa)->sin_addr),
|
||||
node, nodelen))
|
||||
return EAI_SYSTEM;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if HAVE_IPV6
|
||||
case AF_INET6:
|
||||
if (!inet_ntop (AF_INET6,
|
||||
&(((const struct sockaddr_in6 *) sa)->sin6_addr),
|
||||
node, nodelen))
|
||||
return EAI_SYSTEM;
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (!inet_ntop (AF_INET6,
|
||||
&(((const struct sockaddr_in6 *) sa)->sin6_addr),
|
||||
node, nodelen))
|
||||
return EAI_SYSTEM;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return EAI_FAMILY;
|
||||
}
|
||||
default:
|
||||
return EAI_FAMILY;
|
||||
}
|
||||
}
|
||||
|
||||
if (service && servicelen > 0 && flags & NI_NUMERICSERV)
|
||||
|
|
@ -422,13 +426,13 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
|
|||
#if HAVE_IPV6
|
||||
case AF_INET6:
|
||||
#endif
|
||||
{
|
||||
unsigned short int port
|
||||
= ntohs (((const struct sockaddr_in *) sa)->sin_port);
|
||||
if (servicelen <= snprintf (service, servicelen, "%u", port))
|
||||
return EAI_OVERFLOW;
|
||||
}
|
||||
break;
|
||||
{
|
||||
unsigned short int port
|
||||
= ntohs (((const struct sockaddr_in *) sa)->sin_port);
|
||||
if (servicelen <= snprintf (service, servicelen, "%u", port))
|
||||
return EAI_OVERFLOW;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
63
gl/getdtablesize.c
Normal file
63
gl/getdtablesize.c
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/* getdtablesize() function for platforms that don't have it.
|
||||
Copyright (C) 2008-2010 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2008.
|
||||
|
||||
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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <unistd.h>
|
||||
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Cache for the previous getdtablesize () result. */
|
||||
static int dtablesize;
|
||||
|
||||
int
|
||||
getdtablesize (void)
|
||||
{
|
||||
if (dtablesize == 0)
|
||||
{
|
||||
/* We are looking for the number N such that the valid file descriptors
|
||||
are 0..N-1. It can be obtained through a loop as follows:
|
||||
{
|
||||
int fd;
|
||||
for (fd = 3; fd < 65536; fd++)
|
||||
if (dup2 (0, fd) == -1)
|
||||
break;
|
||||
return fd;
|
||||
}
|
||||
On Windows XP, the result is 2048.
|
||||
The drawback of this loop is that it allocates memory for a libc
|
||||
internal array that is never freed.
|
||||
|
||||
The number N can also be obtained as the upper bound for
|
||||
_getmaxstdio (). _getmaxstdio () returns the maximum number of open
|
||||
FILE objects. The sanity check in _setmaxstdio reveals the maximum
|
||||
number of file descriptors. This too allocates memory, but it is
|
||||
freed when we call _setmaxstdio with the original value. */
|
||||
int orig_max_stdio = _getmaxstdio ();
|
||||
unsigned int bound;
|
||||
for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2)
|
||||
;
|
||||
_setmaxstdio (orig_max_stdio);
|
||||
dtablesize = bound;
|
||||
}
|
||||
return dtablesize;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
/* gethostname emulation for SysV and POSIX.1.
|
||||
|
||||
Copyright (C) 1992, 2003, 2006, 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 1992, 2003, 2006, 2008, 2009, 2010 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
|
||||
|
|
@ -15,10 +16,14 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
/* David MacKenzie <djm@gnu.ai.mit.edu>
|
||||
Windows port by Simon Josefsson <simon@josefsson.org> */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
|
||||
/* Unix API. */
|
||||
|
||||
/* Specification. */
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
@ -50,7 +55,51 @@ gethostname (char *name, size_t len)
|
|||
}
|
||||
strncpy (name, uts.nodename, len);
|
||||
#else
|
||||
strcpy (name, ""); /* Hardcode your system name if you want. */
|
||||
strcpy (name, ""); /* Hardcode your system name if you want. */
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Native Windows API. Which primitive to choose?
|
||||
- gethostname() requires linking with -lws2_32.
|
||||
- GetComputerName() does not return the right kind of hostname.
|
||||
- GetComputerNameEx(ComputerNameDnsHostname,...) returns the right hostname,
|
||||
but it is hard to use portably:
|
||||
- It requires defining _WIN32_WINNT to at least 0x0500.
|
||||
- With mingw, it also requires
|
||||
"#define GetComputerNameEx GetComputerNameExA".
|
||||
- With older versions of mingw, none of the declarations are present at
|
||||
all, not even of the enum value ComputerNameDnsHostname.
|
||||
So we use gethostname(). Linking with -lws2_32 is the least evil. */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
/* Get winsock2.h. */
|
||||
#include <unistd.h>
|
||||
|
||||
/* Get INT_MAX. */
|
||||
#include <limits.h>
|
||||
|
||||
/* Get set_winsock_errno. */
|
||||
#include "w32sock.h"
|
||||
|
||||
#include "sockets.h"
|
||||
|
||||
#undef gethostname
|
||||
|
||||
int
|
||||
rpl_gethostname (char *name, size_t len)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (len > INT_MAX)
|
||||
len = INT_MAX;
|
||||
gl_sockets_startup (SOCKETS_1_1);
|
||||
r = gethostname (name, (int) len);
|
||||
if (r < 0)
|
||||
set_winsock_errno ();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
256
gl/getloadavg.c
256
gl/getloadavg.c
|
|
@ -1,8 +1,7 @@
|
|||
/* Get the system load averages.
|
||||
|
||||
Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994,
|
||||
1995, 1997, 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
|
||||
Software Foundation, Inc.
|
||||
Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with gnulib.
|
||||
Bugs can be reported to bug-gnulib@gnu.org.
|
||||
|
|
@ -22,58 +21,58 @@
|
|||
|
||||
/* Compile-time symbols that this file uses:
|
||||
|
||||
HAVE_PSTAT_GETDYNAMIC Define this if your system has the
|
||||
HAVE_PSTAT_GETDYNAMIC Define this if your system has the
|
||||
pstat_getdynamic function. I think it
|
||||
is unique to HPUX9. The best way to get the
|
||||
definition is through the AC_FUNC_GETLOADAVG
|
||||
macro that comes with autoconf 2.13 or newer.
|
||||
If that isn't an option, then just put
|
||||
AC_CHECK_FUNCS(pstat_getdynamic) in your
|
||||
configure.in file.
|
||||
is unique to HPUX9. The best way to get the
|
||||
definition is through the AC_FUNC_GETLOADAVG
|
||||
macro that comes with autoconf 2.13 or newer.
|
||||
If that isn't an option, then just put
|
||||
AC_CHECK_FUNCS(pstat_getdynamic) in your
|
||||
configure.in file.
|
||||
HAVE_LIBPERFSTAT Define this if your system has the
|
||||
perfstat_cpu_total function in libperfstat (AIX).
|
||||
FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
|
||||
KERNEL_FILE Name of the kernel file to nlist.
|
||||
LDAV_CVT() Scale the load average from the kernel.
|
||||
Returns a double.
|
||||
LDAV_SYMBOL Name of kernel symbol giving load average.
|
||||
LOAD_AVE_TYPE Type of the load average array in the kernel.
|
||||
Must be defined unless one of
|
||||
apollo, DGUX, NeXT, or UMAX is defined;
|
||||
perfstat_cpu_total function in libperfstat (AIX).
|
||||
FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
|
||||
KERNEL_FILE Name of the kernel file to nlist.
|
||||
LDAV_CVT() Scale the load average from the kernel.
|
||||
Returns a double.
|
||||
LDAV_SYMBOL Name of kernel symbol giving load average.
|
||||
LOAD_AVE_TYPE Type of the load average array in the kernel.
|
||||
Must be defined unless one of
|
||||
apollo, DGUX, NeXT, or UMAX is defined;
|
||||
or we have libkstat;
|
||||
otherwise, no load average is available.
|
||||
otherwise, no load average is available.
|
||||
HAVE_NLIST_H nlist.h is available. NLIST_STRUCT defaults
|
||||
to this.
|
||||
NLIST_STRUCT Include nlist.h, not a.out.h, and
|
||||
the nlist n_name element is a pointer,
|
||||
not an array.
|
||||
NLIST_STRUCT Include nlist.h, not a.out.h.
|
||||
N_NAME_POINTER The nlist n_name element is a pointer,
|
||||
not an array.
|
||||
HAVE_STRUCT_NLIST_N_UN_N_NAME `n_un.n_name' is member of `struct nlist'.
|
||||
LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing
|
||||
load averages.
|
||||
LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing
|
||||
load averages.
|
||||
|
||||
Specific system predefines this file uses, aside from setting
|
||||
default values if not emacs:
|
||||
|
||||
apollo
|
||||
BSD Real BSD, not just BSD-like.
|
||||
BSD Real BSD, not just BSD-like.
|
||||
convex
|
||||
DGUX
|
||||
eunice UNIX emulator under VMS.
|
||||
eunice UNIX emulator under VMS.
|
||||
hpux
|
||||
__MSDOS__ No-op for MSDOS.
|
||||
__MSDOS__ No-op for MSDOS.
|
||||
NeXT
|
||||
sgi
|
||||
sequent Sequent Dynix 3.x.x (BSD)
|
||||
_SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV)
|
||||
sequent Sequent Dynix 3.x.x (BSD)
|
||||
_SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV)
|
||||
sony_news NEWS-OS (works at least for 4.1C)
|
||||
UMAX
|
||||
UMAX4_3
|
||||
VMS
|
||||
WINDOWS32 No-op for Windows95/NT.
|
||||
__linux__ Linux: assumes /proc file system mounted.
|
||||
Support from Michael K. Johnson.
|
||||
__CYGWIN__ Cygwin emulates linux /proc/loadavg.
|
||||
__NetBSD__ NetBSD: assumes /kern file system mounted.
|
||||
WINDOWS32 No-op for Windows95/NT.
|
||||
__linux__ Linux: assumes /proc file system mounted.
|
||||
Support from Michael K. Johnson.
|
||||
__CYGWIN__ Cygwin emulates linux /proc/loadavg.
|
||||
__NetBSD__ NetBSD: assumes /kern file system mounted.
|
||||
|
||||
In addition, to avoid nesting many #ifdefs, we internally set
|
||||
LDAV_DONE to indicate that the load average has been computed.
|
||||
|
|
@ -112,7 +111,6 @@
|
|||
# include "c-strtod.h"
|
||||
# include "cloexec.h"
|
||||
# include "intprops.h"
|
||||
# include "xalloc.h"
|
||||
|
||||
/* The existing Emacs configuration files define a macro called
|
||||
LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and
|
||||
|
|
@ -203,7 +201,7 @@
|
|||
default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>. Combine
|
||||
that with a couple of other things and we'll have a unique match. */
|
||||
# if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES)
|
||||
# define tek4300 /* Define by emacs, but not by other users. */
|
||||
# define tek4300 /* Define by emacs, but not by other users. */
|
||||
# endif
|
||||
|
||||
|
||||
|
|
@ -317,7 +315,7 @@
|
|||
# define FSCALE 65536.0
|
||||
# endif
|
||||
|
||||
# endif /* Not FSCALE. */
|
||||
# endif /* Not FSCALE. */
|
||||
|
||||
# if !defined (LDAV_CVT) && defined (FSCALE)
|
||||
# define LDAV_CVT(n) (((double) (n)) / FSCALE)
|
||||
|
|
@ -478,7 +476,7 @@ static unsigned int samples;
|
|||
# endif /* UMAX */
|
||||
|
||||
# ifdef DGUX
|
||||
static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
|
||||
static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
|
||||
# endif /* DGUX */
|
||||
|
||||
# if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE)
|
||||
|
|
@ -507,7 +505,7 @@ static kvm_t *kd;
|
|||
int
|
||||
getloadavg (double loadavg[], int nelem)
|
||||
{
|
||||
int elem = 0; /* Return value. */
|
||||
int elem = 0; /* Return value. */
|
||||
|
||||
# ifdef NO_GET_LOAD_AVG
|
||||
# define LDAV_DONE
|
||||
|
|
@ -549,16 +547,16 @@ getloadavg (double loadavg[], int nelem)
|
|||
{
|
||||
kn = kstat_data_lookup (ksp, "avenrun_5min");
|
||||
if (kn != 0)
|
||||
{
|
||||
loadavg[elem++] = (double) kn->value.ul / FSCALE;
|
||||
{
|
||||
loadavg[elem++] = (double) kn->value.ul / FSCALE;
|
||||
|
||||
if (nelem >= 3)
|
||||
{
|
||||
kn = kstat_data_lookup (ksp, "avenrun_15min");
|
||||
if (kn != 0)
|
||||
loadavg[elem++] = (double) kn->value.ul / FSCALE;
|
||||
}
|
||||
}
|
||||
if (nelem >= 3)
|
||||
{
|
||||
kn = kstat_data_lookup (ksp, "avenrun_15min");
|
||||
if (kn != 0)
|
||||
loadavg[elem++] = (double) kn->value.ul / FSCALE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
kstat_close (kc);
|
||||
|
|
@ -626,11 +624,11 @@ getloadavg (double loadavg[], int nelem)
|
|||
errno = 0;
|
||||
d = c_strtod (ptr, &endptr);
|
||||
if (ptr == endptr || (d == 0 && errno != 0))
|
||||
{
|
||||
if (elem == 0)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (elem == 0)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
loadavg[elem] = d;
|
||||
ptr = endptr;
|
||||
}
|
||||
|
|
@ -655,8 +653,8 @@ getloadavg (double loadavg[], int nelem)
|
|||
if (fp == NULL)
|
||||
return -1;
|
||||
count = fscanf (fp, "%lu %lu %lu %lu\n",
|
||||
&load_ave[0], &load_ave[1], &load_ave[2],
|
||||
&scale);
|
||||
&load_ave[0], &load_ave[1], &load_ave[2],
|
||||
&scale);
|
||||
(void) fclose (fp);
|
||||
if (count != 4)
|
||||
return -1;
|
||||
|
|
@ -682,21 +680,21 @@ getloadavg (double loadavg[], int nelem)
|
|||
if (!getloadavg_initialized)
|
||||
{
|
||||
if (processor_set_default (host_self (), &default_set) == KERN_SUCCESS)
|
||||
getloadavg_initialized = true;
|
||||
getloadavg_initialized = true;
|
||||
}
|
||||
|
||||
if (getloadavg_initialized)
|
||||
{
|
||||
info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
|
||||
if (processor_set_info (default_set, PROCESSOR_SET_BASIC_INFO, &host,
|
||||
(processor_set_info_t) &info, &info_count)
|
||||
!= KERN_SUCCESS)
|
||||
getloadavg_initialized = false;
|
||||
(processor_set_info_t) &info, &info_count)
|
||||
!= KERN_SUCCESS)
|
||||
getloadavg_initialized = false;
|
||||
else
|
||||
{
|
||||
if (nelem > 0)
|
||||
loadavg[elem++] = (double) info.load_average / LOAD_SCALE;
|
||||
}
|
||||
{
|
||||
if (nelem > 0)
|
||||
loadavg[elem++] = (double) info.load_average / LOAD_SCALE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getloadavg_initialized)
|
||||
|
|
@ -728,24 +726,24 @@ getloadavg (double loadavg[], int nelem)
|
|||
desc.sd_size = sizeof conf;
|
||||
|
||||
if (inq_stats (1, &desc))
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
c = 0;
|
||||
for (i = 0; i < conf.config_maxclass; ++i)
|
||||
{
|
||||
struct class_stats stats;
|
||||
bzero ((char *) &stats, sizeof stats);
|
||||
{
|
||||
struct class_stats stats;
|
||||
bzero ((char *) &stats, sizeof stats);
|
||||
|
||||
desc.sd_type = CPUTYPE_CLASS;
|
||||
desc.sd_objid = i;
|
||||
desc.sd_addr = (char *) &stats;
|
||||
desc.sd_size = sizeof stats;
|
||||
desc.sd_type = CPUTYPE_CLASS;
|
||||
desc.sd_objid = i;
|
||||
desc.sd_addr = (char *) &stats;
|
||||
desc.sd_size = sizeof stats;
|
||||
|
||||
if (inq_stats (1, &desc))
|
||||
return -1;
|
||||
if (inq_stats (1, &desc))
|
||||
return -1;
|
||||
|
||||
c += stats.class_numcpus;
|
||||
}
|
||||
c += stats.class_numcpus;
|
||||
}
|
||||
cpus = c;
|
||||
samples = cpus < 2 ? 3 : (2 * cpus / 3);
|
||||
}
|
||||
|
|
@ -766,7 +764,7 @@ getloadavg (double loadavg[], int nelem)
|
|||
{
|
||||
load += proc_sum_data.ps_nrun[j];
|
||||
if (j++ == PS_NRUNSIZE)
|
||||
j = 0;
|
||||
j = 0;
|
||||
}
|
||||
|
||||
if (nelem > 0)
|
||||
|
|
@ -779,8 +777,8 @@ getloadavg (double loadavg[], int nelem)
|
|||
it's not supposed to fail. The first argument is for no
|
||||
apparent reason of type `long int *'. */
|
||||
dg_sys_info ((long int *) &load_info,
|
||||
DG_SYS_INFO_LOAD_INFO_TYPE,
|
||||
DG_SYS_INFO_LOAD_VERSION_0);
|
||||
DG_SYS_INFO_LOAD_INFO_TYPE,
|
||||
DG_SYS_INFO_LOAD_VERSION_0);
|
||||
|
||||
if (nelem > 0)
|
||||
loadavg[elem++] = load_info.one_minute;
|
||||
|
|
@ -824,7 +822,7 @@ getloadavg (double loadavg[], int nelem)
|
|||
= (load_ave.tl_lscale == 0
|
||||
? load_ave.tl_avenrun.d[0]
|
||||
: (load_ave.tl_avenrun.l[0] / (double) load_ave.tl_lscale));
|
||||
# endif /* OSF_MIPS */
|
||||
# endif /* OSF_MIPS */
|
||||
|
||||
# if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32))
|
||||
# define LDAV_DONE
|
||||
|
|
@ -844,8 +842,8 @@ getloadavg (double loadavg[], int nelem)
|
|||
for (elem = 0; elem < nelem; elem++)
|
||||
loadavg[elem]
|
||||
= (load_ave.tl_lscale == 0
|
||||
? load_ave.tl_avenrun.d[elem]
|
||||
: (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
|
||||
? load_ave.tl_avenrun.d[elem]
|
||||
: (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
|
||||
# endif /* OSF_ALPHA */
|
||||
|
||||
# if ! defined LDAV_DONE && defined __VMS
|
||||
|
|
@ -872,13 +870,13 @@ getloadavg (double loadavg[], int nelem)
|
|||
$DESCRIPTOR (descriptor, "LAV0:");
|
||||
# endif
|
||||
if (sys$assign (&descriptor, &channel, 0, 0) & 1)
|
||||
getloadavg_initialized = true;
|
||||
getloadavg_initialized = true;
|
||||
}
|
||||
|
||||
/* Read the load average vector. */
|
||||
if (getloadavg_initialized
|
||||
&& !(sys$qiow (0, channel, IO$_READVBLK, 0, 0, 0,
|
||||
load_ave, 12, 0, 0, 0, 0) & 1))
|
||||
load_ave, 12, 0, 0, 0, 0) & 1))
|
||||
{
|
||||
sys$dassgn (channel);
|
||||
getloadavg_initialized = false;
|
||||
|
|
@ -892,7 +890,7 @@ getloadavg (double loadavg[], int nelem)
|
|||
|
||||
/* UNIX-specific code -- read the average from /dev/kmem. */
|
||||
|
||||
# define LDAV_PRIVILEGED /* This code requires special installation. */
|
||||
# define LDAV_PRIVILEGED /* This code requires special installation. */
|
||||
|
||||
LOAD_AVE_TYPE load_ave[3];
|
||||
|
||||
|
|
@ -900,7 +898,7 @@ getloadavg (double loadavg[], int nelem)
|
|||
if (offset == 0)
|
||||
{
|
||||
# ifndef sgi
|
||||
# ifndef NLIST_STRUCT
|
||||
# if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
|
||||
strcpy (nl[0].n_name, LDAV_SYMBOL);
|
||||
strcpy (nl[1].n_name, "");
|
||||
# else /* NLIST_STRUCT */
|
||||
|
|
@ -916,25 +914,25 @@ getloadavg (double loadavg[], int nelem)
|
|||
# ifndef SUNOS_5
|
||||
if (
|
||||
# if !(defined (_AIX) && !defined (ps2))
|
||||
nlist (KERNEL_FILE, nl)
|
||||
nlist (KERNEL_FILE, nl)
|
||||
# else /* _AIX */
|
||||
knlist (nl, 1, sizeof (nl[0]))
|
||||
knlist (nl, 1, sizeof (nl[0]))
|
||||
# endif
|
||||
>= 0)
|
||||
/* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i. */
|
||||
{
|
||||
>= 0)
|
||||
/* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i. */
|
||||
{
|
||||
# ifdef FIXUP_KERNEL_SYMBOL_ADDR
|
||||
FIXUP_KERNEL_SYMBOL_ADDR (nl);
|
||||
FIXUP_KERNEL_SYMBOL_ADDR (nl);
|
||||
# endif
|
||||
offset = nl[0].n_value;
|
||||
}
|
||||
offset = nl[0].n_value;
|
||||
}
|
||||
# endif /* !SUNOS_5 */
|
||||
# else /* sgi */
|
||||
int ldav_off;
|
||||
|
||||
ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
|
||||
if (ldav_off != -1)
|
||||
offset = (long int) ldav_off & 0x7fffffff;
|
||||
offset = (long int) ldav_off & 0x7fffffff;
|
||||
# endif /* sgi */
|
||||
}
|
||||
|
||||
|
|
@ -944,23 +942,23 @@ getloadavg (double loadavg[], int nelem)
|
|||
# ifndef SUNOS_5
|
||||
channel = open ("/dev/kmem", O_RDONLY);
|
||||
if (channel >= 0)
|
||||
{
|
||||
/* Set the channel to close on exec, so it does not
|
||||
litter any child's descriptor table. */
|
||||
set_cloexec_flag (channel, true);
|
||||
getloadavg_initialized = true;
|
||||
}
|
||||
{
|
||||
/* Set the channel to close on exec, so it does not
|
||||
litter any child's descriptor table. */
|
||||
set_cloexec_flag (channel, true);
|
||||
getloadavg_initialized = true;
|
||||
}
|
||||
# else /* SUNOS_5 */
|
||||
/* We pass 0 for the kernel, corefile, and swapfile names
|
||||
to use the currently running kernel. */
|
||||
to use the currently running kernel. */
|
||||
kd = kvm_open (0, 0, 0, O_RDONLY, 0);
|
||||
if (kd != 0)
|
||||
{
|
||||
/* nlist the currently running kernel. */
|
||||
kvm_nlist (kd, nl);
|
||||
offset = nl[0].n_value;
|
||||
getloadavg_initialized = true;
|
||||
}
|
||||
{
|
||||
/* nlist the currently running kernel. */
|
||||
kvm_nlist (kd, nl);
|
||||
offset = nl[0].n_value;
|
||||
getloadavg_initialized = true;
|
||||
}
|
||||
# endif /* SUNOS_5 */
|
||||
}
|
||||
|
||||
|
|
@ -970,19 +968,19 @@ getloadavg (double loadavg[], int nelem)
|
|||
/* Try to read the load. */
|
||||
# ifndef SUNOS_5
|
||||
if (lseek (channel, offset, 0) == -1L
|
||||
|| read (channel, (char *) load_ave, sizeof (load_ave))
|
||||
!= sizeof (load_ave))
|
||||
{
|
||||
close (channel);
|
||||
getloadavg_initialized = false;
|
||||
}
|
||||
|| read (channel, (char *) load_ave, sizeof (load_ave))
|
||||
!= sizeof (load_ave))
|
||||
{
|
||||
close (channel);
|
||||
getloadavg_initialized = false;
|
||||
}
|
||||
# else /* SUNOS_5 */
|
||||
if (kvm_read (kd, offset, (char *) load_ave, sizeof (load_ave))
|
||||
!= sizeof (load_ave))
|
||||
{
|
||||
kvm_close (kd);
|
||||
getloadavg_initialized = false;
|
||||
}
|
||||
!= sizeof (load_ave))
|
||||
{
|
||||
kvm_close (kd);
|
||||
getloadavg_initialized = false;
|
||||
}
|
||||
# endif /* SUNOS_5 */
|
||||
}
|
||||
|
||||
|
|
@ -1026,24 +1024,24 @@ main (int argc, char **argv)
|
|||
double avg[3];
|
||||
int loads;
|
||||
|
||||
errno = 0; /* Don't be misled if it doesn't set errno. */
|
||||
errno = 0; /* Don't be misled if it doesn't set errno. */
|
||||
loads = getloadavg (avg, 3);
|
||||
if (loads == -1)
|
||||
{
|
||||
perror ("Error getting load average");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
{
|
||||
perror ("Error getting load average");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (loads > 0)
|
||||
printf ("1-minute: %f ", avg[0]);
|
||||
printf ("1-minute: %f ", avg[0]);
|
||||
if (loads > 1)
|
||||
printf ("5-minute: %f ", avg[1]);
|
||||
printf ("5-minute: %f ", avg[1]);
|
||||
if (loads > 2)
|
||||
printf ("15-minute: %f ", avg[2]);
|
||||
printf ("15-minute: %f ", avg[2]);
|
||||
if (loads > 0)
|
||||
putchar ('\n');
|
||||
putchar ('\n');
|
||||
|
||||
if (naptime == 0)
|
||||
break;
|
||||
break;
|
||||
sleep (naptime);
|
||||
}
|
||||
|
||||
|
|
|
|||
1262
gl/getopt.c
1262
gl/getopt.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
/* Declarations for getopt.
|
||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2010 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
|
||||
|
|
@ -16,24 +16,42 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#ifndef _GL_GETOPT_H
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. We must
|
||||
also inform the replacement unistd.h to not recursively use
|
||||
<getopt.h>; our definitions will be present soon enough. */
|
||||
#if @HAVE_GETOPT_H@
|
||||
# define _GL_SYSTEM_GETOPT
|
||||
# @INCLUDE_NEXT@ @NEXT_GETOPT_H@
|
||||
# undef _GL_SYSTEM_GETOPT
|
||||
#endif
|
||||
|
||||
#ifndef _GL_GETOPT_H
|
||||
|
||||
#ifndef __need_getopt
|
||||
# define _GETOPT_H 1
|
||||
# define _GL_GETOPT_H 1
|
||||
#endif
|
||||
|
||||
/* Standalone applications should #define __GETOPT_PREFIX to an
|
||||
identifier that prefixes the external functions and variables
|
||||
defined in this header. When this happens, include the
|
||||
headers that might declare getopt so that they will not cause
|
||||
confusion if included after this file. Then systematically rename
|
||||
confusion if included after this file (if the system had <getopt.h>,
|
||||
we have already included it). Then systematically rename
|
||||
identifiers so that they do not collide with the system functions
|
||||
and variables. Renaming avoids problems with some compilers and
|
||||
linkers. */
|
||||
#if defined __GETOPT_PREFIX && !defined __need_getopt
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
# if !@HAVE_GETOPT_H@
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
# undef __need_getopt
|
||||
# undef getopt
|
||||
# undef getopt_long
|
||||
|
|
@ -42,6 +60,7 @@
|
|||
# undef opterr
|
||||
# undef optind
|
||||
# undef optopt
|
||||
# undef option
|
||||
# define __GETOPT_CONCAT(x, y) x ## y
|
||||
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
|
||||
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
|
||||
|
|
@ -52,6 +71,8 @@
|
|||
# define opterr __GETOPT_ID (opterr)
|
||||
# define optind __GETOPT_ID (optind)
|
||||
# define optopt __GETOPT_ID (optopt)
|
||||
# define option __GETOPT_ID (option)
|
||||
# define _getopt_internal __GETOPT_ID (getopt_internal)
|
||||
#endif
|
||||
|
||||
/* Standalone applications get correct prototypes for getopt_long and
|
||||
|
|
@ -94,12 +115,14 @@
|
|||
# define __GNUC_PREREQ(maj, min) (0)
|
||||
# endif
|
||||
# if defined __cplusplus && __GNUC_PREREQ (2,8)
|
||||
# define __THROW throw ()
|
||||
# define __THROW throw ()
|
||||
# else
|
||||
# define __THROW
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -142,9 +165,9 @@ extern int optopt;
|
|||
zero.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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
|
||||
|
|
@ -169,10 +192,10 @@ struct option
|
|||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#endif /* need getopt */
|
||||
# define no_argument 0
|
||||
# define required_argument 1
|
||||
# define optional_argument 2
|
||||
#endif /* need getopt */
|
||||
|
||||
|
||||
/* Get definitions and prototypes for functions to process the
|
||||
|
|
@ -201,17 +224,17 @@ struct option
|
|||
the environment, then do not permute arguments. */
|
||||
|
||||
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
|
||||
__THROW;
|
||||
__THROW _GL_ARG_NONNULL ((2, 3));
|
||||
|
||||
#ifndef __need_getopt
|
||||
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW _GL_ARG_NONNULL ((2, 3));
|
||||
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW;
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind)
|
||||
__THROW _GL_ARG_NONNULL ((2, 3));
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -223,3 +246,4 @@ extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
|
|||
#undef __need_getopt
|
||||
|
||||
#endif /* getopt.h */
|
||||
#endif /* getopt.h */
|
||||
|
|
|
|||
126
gl/getopt1.c
126
gl/getopt1.c
|
|
@ -1,6 +1,6 @@
|
|||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006,2009
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
|
||||
1998, 2004, 2006, 2009, 2010 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
|
||||
|
|
@ -32,25 +32,25 @@
|
|||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||
opt_index, 0, 0);
|
||||
opt_index, 0, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_r (int argc, char **argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
{
|
||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||
0, 0, d);
|
||||
0, d, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
|
|
@ -60,20 +60,20 @@ _getopt_long_r (int argc, char **argv, const char *options,
|
|||
|
||||
int
|
||||
getopt_long_only (int argc, char *__getopt_argv_const *argv,
|
||||
const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
const char *options,
|
||||
const struct option *long_options, int *opt_index)
|
||||
{
|
||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||
opt_index, 1, 0);
|
||||
opt_index, 1, 0);
|
||||
}
|
||||
|
||||
int
|
||||
_getopt_long_only_r (int argc, char **argv, const char *options,
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
const struct option *long_options, int *opt_index,
|
||||
struct _getopt_data *d)
|
||||
{
|
||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||
1, 0, d);
|
||||
1, d, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -93,74 +93,74 @@ main (int argc, char **argv)
|
|||
int option_index = 0;
|
||||
static const struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
107
gl/getopt_int.h
107
gl/getopt_int.h
|
|
@ -1,6 +1,6 @@
|
|||
/* Internal declarations for getopt.
|
||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2010 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
|
||||
|
|
@ -17,17 +17,53 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GETOPT_INT_H
|
||||
#define _GETOPT_INT_H 1
|
||||
#define _GETOPT_INT_H 1
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
extern int _getopt_internal (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, int __posixly_correct);
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, int __posixly_correct);
|
||||
|
||||
|
||||
/* Reentrant versions which can handle parsing multiple argument
|
||||
vectors at the same time. */
|
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
This is what Unix does.
|
||||
This mode of operation is selected by either setting the environment
|
||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
||||
of the list of option characters, or by calling getopt.
|
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we
|
||||
scan, so that eventually all the non-options are at the end.
|
||||
This allows options to be given in any order, even with programs
|
||||
that were not written to expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were
|
||||
written to expect options and other ARGV-elements in any order
|
||||
and that care about the ordering of the two. We describe each
|
||||
non-option ARGV-element as if it were the argument of an option
|
||||
with character code 1. Using `-' as the first character of the
|
||||
list of option characters selects this mode of operation.
|
||||
|
||||
The special argument `--' forces an end of option-scanning regardless
|
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
||||
|
||||
enum __ord
|
||||
{
|
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||
};
|
||||
|
||||
/* Data type for reentrant functions. */
|
||||
struct _getopt_data
|
||||
{
|
||||
|
|
@ -52,39 +88,8 @@ struct _getopt_data
|
|||
by advancing to the next ARGV-element. */
|
||||
char *__nextchar;
|
||||
|
||||
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||
|
||||
If the caller did not specify anything,
|
||||
the default is REQUIRE_ORDER if the environment variable
|
||||
POSIXLY_CORRECT is defined, PERMUTE otherwise.
|
||||
|
||||
REQUIRE_ORDER means don't recognize them as options;
|
||||
stop option processing when the first non-option is seen.
|
||||
This is what Unix does.
|
||||
This mode of operation is selected by either setting the environment
|
||||
variable POSIXLY_CORRECT, or using `+' as the first character
|
||||
of the list of option characters, or by calling getopt.
|
||||
|
||||
PERMUTE is the default. We permute the contents of ARGV as we
|
||||
scan, so that eventually all the non-options are at the end.
|
||||
This allows options to be given in any order, even with programs
|
||||
that were not written to expect this.
|
||||
|
||||
RETURN_IN_ORDER is an option available to programs that were
|
||||
written to expect options and other ARGV-elements in any order
|
||||
and that care about the ordering of the two. We describe each
|
||||
non-option ARGV-element as if it were the argument of an option
|
||||
with character code 1. Using `-' as the first character of the
|
||||
list of option characters selects this mode of operation.
|
||||
|
||||
The special argument `--' forces an end of option-scanning regardless
|
||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
||||
|
||||
enum
|
||||
{
|
||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||
} __ordering;
|
||||
/* See __ord above. */
|
||||
enum __ord __ordering;
|
||||
|
||||
/* If the POSIXLY_CORRECT environment variable is set
|
||||
or getopt was called. */
|
||||
|
|
@ -108,23 +113,23 @@ struct _getopt_data
|
|||
|
||||
/* The initializer is necessary to set OPTIND and OPTERR to their
|
||||
default values and to clear the initialization flag. */
|
||||
#define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
||||
#define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
||||
|
||||
extern int _getopt_internal_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, int __posixly_correct,
|
||||
struct _getopt_data *__data);
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
int __long_only, struct _getopt_data *__data,
|
||||
int __posixly_correct);
|
||||
|
||||
extern int _getopt_long_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts, int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
extern int _getopt_long_only_r (int ___argc, char **___argv,
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts,
|
||||
int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
const char *__shortopts,
|
||||
const struct option *__longopts,
|
||||
int *__longind,
|
||||
struct _getopt_data *__data);
|
||||
|
||||
#endif /* getopt_int.h */
|
||||
|
|
|
|||
33
gl/gettext.h
33
gl/gettext.h
|
|
@ -1,5 +1,6 @@
|
|||
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2010 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
|
||||
|
|
@ -80,7 +81,7 @@
|
|||
((void) (Domainname), ngettext (Msgid1, Msgid2, N))
|
||||
# undef dcngettext
|
||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||
((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
|
||||
((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
|
||||
# undef textdomain
|
||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||
# undef bindtextdomain
|
||||
|
|
@ -140,8 +141,8 @@ inline
|
|||
#endif
|
||||
static const char *
|
||||
pgettext_aux (const char *domain,
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
int category)
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
int category)
|
||||
{
|
||||
const char *translation = dcgettext (domain, msg_ctxt_id, category);
|
||||
if (translation == msg_ctxt_id)
|
||||
|
|
@ -159,9 +160,9 @@ inline
|
|||
#endif
|
||||
static const char *
|
||||
npgettext_aux (const char *domain,
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
const char *msg_ctxt_id, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
{
|
||||
const char *translation =
|
||||
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||
|
|
@ -199,8 +200,8 @@ inline
|
|||
#endif
|
||||
static const char *
|
||||
dcpgettext_expr (const char *domain,
|
||||
const char *msgctxt, const char *msgid,
|
||||
int category)
|
||||
const char *msgctxt, const char *msgid,
|
||||
int category)
|
||||
{
|
||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||
size_t msgid_len = strlen (msgid) + 1;
|
||||
|
|
@ -222,10 +223,10 @@ dcpgettext_expr (const char *domain,
|
|||
translation = dcgettext (domain, msg_ctxt_id, category);
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
if (msg_ctxt_id != buf)
|
||||
free (msg_ctxt_id);
|
||||
free (msg_ctxt_id);
|
||||
#endif
|
||||
if (translation != msg_ctxt_id)
|
||||
return translation;
|
||||
return translation;
|
||||
}
|
||||
return msgid;
|
||||
}
|
||||
|
|
@ -244,9 +245,9 @@ inline
|
|||
#endif
|
||||
static const char *
|
||||
dcnpgettext_expr (const char *domain,
|
||||
const char *msgctxt, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
const char *msgctxt, const char *msgid,
|
||||
const char *msgid_plural, unsigned long int n,
|
||||
int category)
|
||||
{
|
||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||
size_t msgid_len = strlen (msgid) + 1;
|
||||
|
|
@ -268,10 +269,10 @@ dcnpgettext_expr (const char *domain,
|
|||
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||
if (msg_ctxt_id != buf)
|
||||
free (msg_ctxt_id);
|
||||
free (msg_ctxt_id);
|
||||
#endif
|
||||
if (!(translation == msg_ctxt_id || translation == msgid_plural))
|
||||
return translation;
|
||||
return translation;
|
||||
}
|
||||
return (n == 1 ? msgid : msgid_plural);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
|
||||
|
||||
Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2006, 2008-2010 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
|
||||
|
|
@ -42,10 +42,6 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef EAFNOSUPPORT
|
||||
# define EAFNOSUPPORT EINVAL
|
||||
#endif
|
||||
|
||||
#define NS_IN6ADDRSZ 16
|
||||
#define NS_INT16SZ 2
|
||||
|
||||
|
|
@ -63,15 +59,15 @@ static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t si
|
|||
|
||||
/* char *
|
||||
* inet_ntop(af, src, dst, size)
|
||||
* convert a network format address to presentation format.
|
||||
* convert a network format address to presentation format.
|
||||
* return:
|
||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
const char *
|
||||
inet_ntop (int af, const void *restrict src,
|
||||
char *restrict dst, socklen_t cnt)
|
||||
char *restrict dst, socklen_t cnt)
|
||||
{
|
||||
switch (af)
|
||||
{
|
||||
|
|
@ -94,14 +90,14 @@ inet_ntop (int af, const void *restrict src,
|
|||
|
||||
/* const char *
|
||||
* inet_ntop4(src, dst, size)
|
||||
* format an IPv4 address
|
||||
* format an IPv4 address
|
||||
* return:
|
||||
* `dst' (as a const)
|
||||
* `dst' (as a const)
|
||||
* notes:
|
||||
* (1) uses no statics
|
||||
* (2) takes a u_char* not an in_addr as input
|
||||
* (1) uses no statics
|
||||
* (2) takes a u_char* not an in_addr as input
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
|
||||
|
|
@ -126,9 +122,9 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
|
|||
|
||||
/* const char *
|
||||
* inet_ntop6(src, dst, size)
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
|
||||
|
|
@ -161,26 +157,26 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
|
|||
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
|
||||
{
|
||||
if (words[i] == 0)
|
||||
{
|
||||
if (cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else
|
||||
cur.len++;
|
||||
}
|
||||
{
|
||||
if (cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else
|
||||
cur.len++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cur.base != -1)
|
||||
{
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (cur.base != -1)
|
||||
{
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cur.base != -1)
|
||||
{
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
best = cur;
|
||||
}
|
||||
if (best.base != -1 && best.len < 2)
|
||||
best.base = -1;
|
||||
|
|
@ -193,28 +189,28 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
|
|||
{
|
||||
/* Are we inside the best run of 0x00's? */
|
||||
if (best.base != -1 && i >= best.base && i < (best.base + best.len))
|
||||
{
|
||||
if (i == best.base)
|
||||
*tp++ = ':';
|
||||
continue;
|
||||
}
|
||||
{
|
||||
if (i == best.base)
|
||||
*tp++ = ':';
|
||||
continue;
|
||||
}
|
||||
/* Are we following an initial run of 0x00s or any real hex? */
|
||||
if (i != 0)
|
||||
*tp++ = ':';
|
||||
*tp++ = ':';
|
||||
/* Is this address an encapsulated IPv4? */
|
||||
if (i == 6 && best.base == 0 &&
|
||||
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
||||
{
|
||||
if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
|
||||
return (NULL);
|
||||
tp += strlen (tp);
|
||||
break;
|
||||
}
|
||||
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
|
||||
{
|
||||
if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
|
||||
return (NULL);
|
||||
tp += strlen (tp);
|
||||
break;
|
||||
}
|
||||
{
|
||||
int len = sprintf (tp, "%x", words[i]);
|
||||
if (len < 0)
|
||||
return NULL;
|
||||
tp += len;
|
||||
int len = sprintf (tp, "%x", words[i]);
|
||||
if (len < 0)
|
||||
return NULL;
|
||||
tp += len;
|
||||
}
|
||||
}
|
||||
/* Was it a trailing run of 0x00's? */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/* intprops.h -- properties of integer types
|
||||
|
||||
Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010 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
|
||||
|
|
@ -17,40 +18,43 @@
|
|||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#include <limits.h>
|
||||
#ifndef GL_INTPROPS_H
|
||||
# define GL_INTPROPS_H
|
||||
|
||||
# include <limits.h>
|
||||
|
||||
/* The extra casts in the following macros work around compiler bugs,
|
||||
e.g., in Cray C 5.0.3.0. */
|
||||
|
||||
/* True if the arithmetic type T is an integer type. bool counts as
|
||||
an integer. */
|
||||
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
|
||||
# define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
|
||||
|
||||
/* True if negative values of the signed integer type T use two's
|
||||
complement, ones' complement, or signed magnitude representation,
|
||||
respectively. Much GNU code assumes two's complement, but some
|
||||
people like to be portable to all possible C hosts. */
|
||||
#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
|
||||
#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
|
||||
#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
|
||||
# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
|
||||
# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
|
||||
# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
|
||||
|
||||
/* True if the arithmetic type T is signed. */
|
||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
|
||||
/* The maximum and minimum values for the integer type T. These
|
||||
macros have undefined behavior if T is signed and has padding bits.
|
||||
If this is a problem for you, please let us know how to fix it for
|
||||
your host. */
|
||||
#define TYPE_MINIMUM(t) \
|
||||
# define TYPE_MINIMUM(t) \
|
||||
((t) (! TYPE_SIGNED (t) \
|
||||
? (t) 0 \
|
||||
: TYPE_SIGNED_MAGNITUDE (t) \
|
||||
? ~ (t) 0 \
|
||||
: ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
|
||||
#define TYPE_MAXIMUM(t) \
|
||||
? (t) 0 \
|
||||
: TYPE_SIGNED_MAGNITUDE (t) \
|
||||
? ~ (t) 0 \
|
||||
: ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
|
||||
# define TYPE_MAXIMUM(t) \
|
||||
((t) (! TYPE_SIGNED (t) \
|
||||
? (t) -1 \
|
||||
: ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
|
||||
? (t) -1 \
|
||||
: ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
|
||||
|
||||
/* Return zero if T can be determined to be an unsigned type.
|
||||
Otherwise, return 1.
|
||||
|
|
@ -58,20 +62,22 @@
|
|||
tighter bound. Otherwise, it overestimates the true bound by one byte
|
||||
when applied to unsigned types of size 2, 4, 16, ... bytes.
|
||||
The symbol signed_type_or_expr__ is private to this header file. */
|
||||
#if __GNUC__ >= 2
|
||||
# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
|
||||
#else
|
||||
# define signed_type_or_expr__(t) 1
|
||||
#endif
|
||||
# if __GNUC__ >= 2
|
||||
# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
|
||||
# else
|
||||
# define signed_type_or_expr__(t) 1
|
||||
# endif
|
||||
|
||||
/* Bound on length of the string representing an integer type or expression T.
|
||||
Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485;
|
||||
add 1 for integer division truncation; add 1 more for a minus sign
|
||||
if needed. */
|
||||
#define INT_STRLEN_BOUND(t) \
|
||||
# define INT_STRLEN_BOUND(t) \
|
||||
((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \
|
||||
+ signed_type_or_expr__ (t) + 1)
|
||||
|
||||
/* Bound on buffer size needed to represent an integer type or expression T,
|
||||
including the terminating null. */
|
||||
#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
|
||||
# define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
|
||||
|
||||
#endif /* GL_INTPROPS_H */
|
||||
|
|
|
|||
162
gl/langinfo.in.h
Normal file
162
gl/langinfo.in.h
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
/* Substitute for and wrapper around <langinfo.h>.
|
||||
Copyright (C) 2009, 2010 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 3, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/*
|
||||
* POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
|
||||
* <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
|
||||
*/
|
||||
|
||||
#ifndef _GL_LANGINFO_H
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#if @HAVE_LANGINFO_H@
|
||||
# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@
|
||||
#endif
|
||||
|
||||
#ifndef _GL_LANGINFO_H
|
||||
#define _GL_LANGINFO_H
|
||||
|
||||
|
||||
#if !@HAVE_LANGINFO_H@
|
||||
|
||||
/* A platform that lacks <langinfo.h>. */
|
||||
|
||||
/* Assume that it also lacks <nl_types.h> and the nl_item type. */
|
||||
typedef int nl_item;
|
||||
|
||||
/* nl_langinfo items of the LC_CTYPE category */
|
||||
# define CODESET 10000
|
||||
/* nl_langinfo items of the LC_NUMERIC category */
|
||||
# define RADIXCHAR 10001
|
||||
# define THOUSEP 10002
|
||||
/* nl_langinfo items of the LC_TIME category */
|
||||
# define D_T_FMT 10003
|
||||
# define D_FMT 10004
|
||||
# define T_FMT 10005
|
||||
# define T_FMT_AMPM 10006
|
||||
# define AM_STR 10007
|
||||
# define PM_STR 10008
|
||||
# define DAY_1 10009
|
||||
# define DAY_2 (DAY_1 + 1)
|
||||
# define DAY_3 (DAY_1 + 2)
|
||||
# define DAY_4 (DAY_1 + 3)
|
||||
# define DAY_5 (DAY_1 + 4)
|
||||
# define DAY_6 (DAY_1 + 5)
|
||||
# define DAY_7 (DAY_1 + 6)
|
||||
# define ABDAY_1 10016
|
||||
# define ABDAY_2 (ABDAY_1 + 1)
|
||||
# define ABDAY_3 (ABDAY_1 + 2)
|
||||
# define ABDAY_4 (ABDAY_1 + 3)
|
||||
# define ABDAY_5 (ABDAY_1 + 4)
|
||||
# define ABDAY_6 (ABDAY_1 + 5)
|
||||
# define ABDAY_7 (ABDAY_1 + 6)
|
||||
# define MON_1 10023
|
||||
# define MON_2 (MON_1 + 1)
|
||||
# define MON_3 (MON_1 + 2)
|
||||
# define MON_4 (MON_1 + 3)
|
||||
# define MON_5 (MON_1 + 4)
|
||||
# define MON_6 (MON_1 + 5)
|
||||
# define MON_7 (MON_1 + 6)
|
||||
# define MON_8 (MON_1 + 7)
|
||||
# define MON_9 (MON_1 + 8)
|
||||
# define MON_10 (MON_1 + 9)
|
||||
# define MON_11 (MON_1 + 10)
|
||||
# define MON_12 (MON_1 + 11)
|
||||
# define ABMON_1 10035
|
||||
# define ABMON_2 (ABMON_1 + 1)
|
||||
# define ABMON_3 (ABMON_1 + 2)
|
||||
# define ABMON_4 (ABMON_1 + 3)
|
||||
# define ABMON_5 (ABMON_1 + 4)
|
||||
# define ABMON_6 (ABMON_1 + 5)
|
||||
# define ABMON_7 (ABMON_1 + 6)
|
||||
# define ABMON_8 (ABMON_1 + 7)
|
||||
# define ABMON_9 (ABMON_1 + 8)
|
||||
# define ABMON_10 (ABMON_1 + 9)
|
||||
# define ABMON_11 (ABMON_1 + 10)
|
||||
# define ABMON_12 (ABMON_1 + 11)
|
||||
# define ERA 10047
|
||||
# define ERA_D_FMT 10048
|
||||
# define ERA_D_T_FMT 10049
|
||||
# define ERA_T_FMT 10050
|
||||
# define ALT_DIGITS 10051
|
||||
/* nl_langinfo items of the LC_MONETARY category */
|
||||
# define CRNCYSTR 10052
|
||||
/* nl_langinfo items of the LC_MESSAGES category */
|
||||
# define YESEXPR 10053
|
||||
# define NOEXPR 10054
|
||||
|
||||
#else
|
||||
|
||||
/* A platform that has <langinfo.h>. */
|
||||
|
||||
# if !@HAVE_LANGINFO_CODESET@
|
||||
# define CODESET 10000
|
||||
# define GNULIB_defined_CODESET 1
|
||||
# endif
|
||||
|
||||
# if !@HAVE_LANGINFO_ERA@
|
||||
# define ERA 10047
|
||||
# define ERA_D_FMT 10048
|
||||
# define ERA_D_T_FMT 10049
|
||||
# define ERA_T_FMT 10050
|
||||
# define ALT_DIGITS 10051
|
||||
# define GNULIB_defined_ERA 1
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
/* Declare overridden functions. */
|
||||
|
||||
|
||||
/* Return a piece of locale dependent information.
|
||||
Note: The difference between nl_langinfo (CODESET) and locale_charset ()
|
||||
is that the latter normalizes the encoding names to GNU conventions. */
|
||||
|
||||
#if @GNULIB_NL_LANGINFO@
|
||||
# if @REPLACE_NL_LANGINFO@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef nl_langinfo
|
||||
# define nl_langinfo rpl_nl_langinfo
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item));
|
||||
_GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item));
|
||||
# else
|
||||
# if !@HAVE_NL_LANGINFO@
|
||||
_GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (nl_langinfo);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef nl_langinfo
|
||||
# if HAVE_RAW_DECL_NL_LANGINFO
|
||||
_GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
|
||||
"use gnulib module nl_langinfo for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _GL_LANGINFO_H */
|
||||
#endif /* _GL_LANGINFO_H */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* Determine a canonical name for the current locale's character encoding.
|
||||
|
||||
Copyright (C) 2000-2006, 2008-2009 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2006, 2008-2010 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
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
/* Specification. */
|
||||
#include "localcharset.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -44,6 +45,7 @@
|
|||
#endif
|
||||
|
||||
#if !defined WIN32_NATIVE
|
||||
# include <unistd.h>
|
||||
# if HAVE_LANGINFO_CODESET
|
||||
# include <langinfo.h>
|
||||
# else
|
||||
|
|
@ -75,6 +77,11 @@
|
|||
# include "configmake.h"
|
||||
#endif
|
||||
|
||||
/* Define O_NOFOLLOW to 0 on platforms where it does not exist. */
|
||||
#ifndef O_NOFOLLOW
|
||||
# define O_NOFOLLOW 0
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
|
||||
/* Win32, Cygwin, OS/2, DOS */
|
||||
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
|
||||
|
|
@ -117,192 +124,219 @@ get_charset_aliases (void)
|
|||
if (cp == NULL)
|
||||
{
|
||||
#if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
|
||||
FILE *fp;
|
||||
const char *dir;
|
||||
const char *base = "charset.alias";
|
||||
char *file_name;
|
||||
|
||||
/* Make it possible to override the charset.alias location. This is
|
||||
necessary for running the testsuite before "make install". */
|
||||
necessary for running the testsuite before "make install". */
|
||||
dir = getenv ("CHARSETALIASDIR");
|
||||
if (dir == NULL || dir[0] == '\0')
|
||||
dir = relocate (LIBDIR);
|
||||
dir = relocate (LIBDIR);
|
||||
|
||||
/* Concatenate dir and base into freshly allocated file_name. */
|
||||
{
|
||||
size_t dir_len = strlen (dir);
|
||||
size_t base_len = strlen (base);
|
||||
int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
|
||||
file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
|
||||
if (file_name != NULL)
|
||||
{
|
||||
memcpy (file_name, dir, dir_len);
|
||||
if (add_slash)
|
||||
file_name[dir_len] = DIRECTORY_SEPARATOR;
|
||||
memcpy (file_name + dir_len + add_slash, base, base_len + 1);
|
||||
}
|
||||
size_t dir_len = strlen (dir);
|
||||
size_t base_len = strlen (base);
|
||||
int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
|
||||
file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
|
||||
if (file_name != NULL)
|
||||
{
|
||||
memcpy (file_name, dir, dir_len);
|
||||
if (add_slash)
|
||||
file_name[dir_len] = DIRECTORY_SEPARATOR;
|
||||
memcpy (file_name + dir_len + add_slash, base, base_len + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL)
|
||||
/* Out of memory or file not found, treat it as empty. */
|
||||
cp = "";
|
||||
if (file_name == NULL)
|
||||
/* Out of memory. Treat the file as empty. */
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
/* Parse the file's contents. */
|
||||
char *res_ptr = NULL;
|
||||
size_t res_size = 0;
|
||||
{
|
||||
int fd;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int c;
|
||||
char buf1[50+1];
|
||||
char buf2[50+1];
|
||||
size_t l1, l2;
|
||||
char *old_res_ptr;
|
||||
/* Open the file. Reject symbolic links on platforms that support
|
||||
O_NOFOLLOW. This is a security feature. Without it, an attacker
|
||||
could retrieve parts of the contents (namely, the tail of the
|
||||
first line that starts with "* ") of an arbitrary file by placing
|
||||
a symbolic link to that file under the name "charset.alias" in
|
||||
some writable directory and defining the environment variable
|
||||
CHARSETALIASDIR to point to that directory. */
|
||||
fd = open (file_name,
|
||||
O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
|
||||
if (fd < 0)
|
||||
/* File not found. Treat it as empty. */
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
c = getc (fp);
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (c == '\n' || c == ' ' || c == '\t')
|
||||
continue;
|
||||
if (c == '#')
|
||||
{
|
||||
/* Skip comment, to end of line. */
|
||||
do
|
||||
c = getc (fp);
|
||||
while (!(c == EOF || c == '\n'));
|
||||
if (c == EOF)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
ungetc (c, fp);
|
||||
if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
|
||||
break;
|
||||
l1 = strlen (buf1);
|
||||
l2 = strlen (buf2);
|
||||
old_res_ptr = res_ptr;
|
||||
if (res_size == 0)
|
||||
{
|
||||
res_size = l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) malloc (res_size + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
res_size += l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) realloc (res_ptr, res_size + 1);
|
||||
}
|
||||
if (res_ptr == NULL)
|
||||
{
|
||||
/* Out of memory. */
|
||||
res_size = 0;
|
||||
if (old_res_ptr != NULL)
|
||||
free (old_res_ptr);
|
||||
break;
|
||||
}
|
||||
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
|
||||
strcpy (res_ptr + res_size - (l2 + 1), buf2);
|
||||
}
|
||||
fclose (fp);
|
||||
if (res_size == 0)
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
*(res_ptr + res_size) = '\0';
|
||||
cp = res_ptr;
|
||||
}
|
||||
}
|
||||
fp = fdopen (fd, "r");
|
||||
if (fp == NULL)
|
||||
{
|
||||
/* Out of memory. Treat the file as empty. */
|
||||
close (fd);
|
||||
cp = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Parse the file's contents. */
|
||||
char *res_ptr = NULL;
|
||||
size_t res_size = 0;
|
||||
|
||||
if (file_name != NULL)
|
||||
free (file_name);
|
||||
for (;;)
|
||||
{
|
||||
int c;
|
||||
char buf1[50+1];
|
||||
char buf2[50+1];
|
||||
size_t l1, l2;
|
||||
char *old_res_ptr;
|
||||
|
||||
c = getc (fp);
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (c == '\n' || c == ' ' || c == '\t')
|
||||
continue;
|
||||
if (c == '#')
|
||||
{
|
||||
/* Skip comment, to end of line. */
|
||||
do
|
||||
c = getc (fp);
|
||||
while (!(c == EOF || c == '\n'));
|
||||
if (c == EOF)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
ungetc (c, fp);
|
||||
if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
|
||||
break;
|
||||
l1 = strlen (buf1);
|
||||
l2 = strlen (buf2);
|
||||
old_res_ptr = res_ptr;
|
||||
if (res_size == 0)
|
||||
{
|
||||
res_size = l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) malloc (res_size + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
res_size += l1 + 1 + l2 + 1;
|
||||
res_ptr = (char *) realloc (res_ptr, res_size + 1);
|
||||
}
|
||||
if (res_ptr == NULL)
|
||||
{
|
||||
/* Out of memory. */
|
||||
res_size = 0;
|
||||
if (old_res_ptr != NULL)
|
||||
free (old_res_ptr);
|
||||
break;
|
||||
}
|
||||
strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
|
||||
strcpy (res_ptr + res_size - (l2 + 1), buf2);
|
||||
}
|
||||
fclose (fp);
|
||||
if (res_size == 0)
|
||||
cp = "";
|
||||
else
|
||||
{
|
||||
*(res_ptr + res_size) = '\0';
|
||||
cp = res_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (file_name);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
# if defined DARWIN7
|
||||
/* To avoid the trouble of installing a file that is shared by many
|
||||
GNU packages -- many packaging systems have problems with this --,
|
||||
simply inline the aliases here. */
|
||||
GNU packages -- many packaging systems have problems with this --,
|
||||
simply inline the aliases here. */
|
||||
cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
|
||||
"ISO8859-2" "\0" "ISO-8859-2" "\0"
|
||||
"ISO8859-4" "\0" "ISO-8859-4" "\0"
|
||||
"ISO8859-5" "\0" "ISO-8859-5" "\0"
|
||||
"ISO8859-7" "\0" "ISO-8859-7" "\0"
|
||||
"ISO8859-9" "\0" "ISO-8859-9" "\0"
|
||||
"ISO8859-13" "\0" "ISO-8859-13" "\0"
|
||||
"ISO8859-15" "\0" "ISO-8859-15" "\0"
|
||||
"KOI8-R" "\0" "KOI8-R" "\0"
|
||||
"KOI8-U" "\0" "KOI8-U" "\0"
|
||||
"CP866" "\0" "CP866" "\0"
|
||||
"CP949" "\0" "CP949" "\0"
|
||||
"CP1131" "\0" "CP1131" "\0"
|
||||
"CP1251" "\0" "CP1251" "\0"
|
||||
"eucCN" "\0" "GB2312" "\0"
|
||||
"GB2312" "\0" "GB2312" "\0"
|
||||
"eucJP" "\0" "EUC-JP" "\0"
|
||||
"eucKR" "\0" "EUC-KR" "\0"
|
||||
"Big5" "\0" "BIG5" "\0"
|
||||
"Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
|
||||
"GBK" "\0" "GBK" "\0"
|
||||
"GB18030" "\0" "GB18030" "\0"
|
||||
"SJIS" "\0" "SHIFT_JIS" "\0"
|
||||
"ARMSCII-8" "\0" "ARMSCII-8" "\0"
|
||||
"PT154" "\0" "PT154" "\0"
|
||||
/*"ISCII-DEV" "\0" "?" "\0"*/
|
||||
"*" "\0" "UTF-8" "\0";
|
||||
"ISO8859-2" "\0" "ISO-8859-2" "\0"
|
||||
"ISO8859-4" "\0" "ISO-8859-4" "\0"
|
||||
"ISO8859-5" "\0" "ISO-8859-5" "\0"
|
||||
"ISO8859-7" "\0" "ISO-8859-7" "\0"
|
||||
"ISO8859-9" "\0" "ISO-8859-9" "\0"
|
||||
"ISO8859-13" "\0" "ISO-8859-13" "\0"
|
||||
"ISO8859-15" "\0" "ISO-8859-15" "\0"
|
||||
"KOI8-R" "\0" "KOI8-R" "\0"
|
||||
"KOI8-U" "\0" "KOI8-U" "\0"
|
||||
"CP866" "\0" "CP866" "\0"
|
||||
"CP949" "\0" "CP949" "\0"
|
||||
"CP1131" "\0" "CP1131" "\0"
|
||||
"CP1251" "\0" "CP1251" "\0"
|
||||
"eucCN" "\0" "GB2312" "\0"
|
||||
"GB2312" "\0" "GB2312" "\0"
|
||||
"eucJP" "\0" "EUC-JP" "\0"
|
||||
"eucKR" "\0" "EUC-KR" "\0"
|
||||
"Big5" "\0" "BIG5" "\0"
|
||||
"Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
|
||||
"GBK" "\0" "GBK" "\0"
|
||||
"GB18030" "\0" "GB18030" "\0"
|
||||
"SJIS" "\0" "SHIFT_JIS" "\0"
|
||||
"ARMSCII-8" "\0" "ARMSCII-8" "\0"
|
||||
"PT154" "\0" "PT154" "\0"
|
||||
/*"ISCII-DEV" "\0" "?" "\0"*/
|
||||
"*" "\0" "UTF-8" "\0";
|
||||
# endif
|
||||
|
||||
# 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. */
|
||||
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". */
|
||||
"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";
|
||||
"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_NATIVE || defined __CYGWIN__
|
||||
/* 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. */
|
||||
directory as the DLL and of retrieving the DLL's directory at
|
||||
runtime, simply inline the aliases here. */
|
||||
|
||||
cp = "CP936" "\0" "GBK" "\0"
|
||||
"CP1361" "\0" "JOHAB" "\0"
|
||||
"CP20127" "\0" "ASCII" "\0"
|
||||
"CP20866" "\0" "KOI8-R" "\0"
|
||||
"CP20936" "\0" "GB2312" "\0"
|
||||
"CP21866" "\0" "KOI8-RU" "\0"
|
||||
"CP28591" "\0" "ISO-8859-1" "\0"
|
||||
"CP28592" "\0" "ISO-8859-2" "\0"
|
||||
"CP28593" "\0" "ISO-8859-3" "\0"
|
||||
"CP28594" "\0" "ISO-8859-4" "\0"
|
||||
"CP28595" "\0" "ISO-8859-5" "\0"
|
||||
"CP28596" "\0" "ISO-8859-6" "\0"
|
||||
"CP28597" "\0" "ISO-8859-7" "\0"
|
||||
"CP28598" "\0" "ISO-8859-8" "\0"
|
||||
"CP28599" "\0" "ISO-8859-9" "\0"
|
||||
"CP28605" "\0" "ISO-8859-15" "\0"
|
||||
"CP38598" "\0" "ISO-8859-8" "\0"
|
||||
"CP51932" "\0" "EUC-JP" "\0"
|
||||
"CP51936" "\0" "GB2312" "\0"
|
||||
"CP51949" "\0" "EUC-KR" "\0"
|
||||
"CP51950" "\0" "EUC-TW" "\0"
|
||||
"CP54936" "\0" "GB18030" "\0"
|
||||
"CP65001" "\0" "UTF-8" "\0";
|
||||
"CP1361" "\0" "JOHAB" "\0"
|
||||
"CP20127" "\0" "ASCII" "\0"
|
||||
"CP20866" "\0" "KOI8-R" "\0"
|
||||
"CP20936" "\0" "GB2312" "\0"
|
||||
"CP21866" "\0" "KOI8-RU" "\0"
|
||||
"CP28591" "\0" "ISO-8859-1" "\0"
|
||||
"CP28592" "\0" "ISO-8859-2" "\0"
|
||||
"CP28593" "\0" "ISO-8859-3" "\0"
|
||||
"CP28594" "\0" "ISO-8859-4" "\0"
|
||||
"CP28595" "\0" "ISO-8859-5" "\0"
|
||||
"CP28596" "\0" "ISO-8859-6" "\0"
|
||||
"CP28597" "\0" "ISO-8859-7" "\0"
|
||||
"CP28598" "\0" "ISO-8859-8" "\0"
|
||||
"CP28599" "\0" "ISO-8859-9" "\0"
|
||||
"CP28605" "\0" "ISO-8859-15" "\0"
|
||||
"CP38598" "\0" "ISO-8859-8" "\0"
|
||||
"CP51932" "\0" "EUC-JP" "\0"
|
||||
"CP51936" "\0" "GB2312" "\0"
|
||||
"CP51949" "\0" "EUC-KR" "\0"
|
||||
"CP51950" "\0" "EUC-TW" "\0"
|
||||
"CP54936" "\0" "GB18030" "\0"
|
||||
"CP65001" "\0" "UTF-8" "\0";
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
@ -335,10 +369,9 @@ locale_charset (void)
|
|||
codeset = nl_langinfo (CODESET);
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
/* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always
|
||||
returns "US-ASCII". As long as this is not fixed, return the suffix
|
||||
of the locale name from the environment variables (if present) or
|
||||
the codepage as a number. */
|
||||
/* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always
|
||||
returns "US-ASCII". Return the suffix of the locale name from the
|
||||
environment variables (if present) or the codepage as a number. */
|
||||
if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
|
||||
{
|
||||
const char *locale;
|
||||
|
|
@ -346,36 +379,46 @@ locale_charset (void)
|
|||
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
if (locale != NULL && locale[0] != '\0')
|
||||
{
|
||||
/* If the locale name contains an encoding after the dot, return
|
||||
it. */
|
||||
const char *dot = strchr (locale, '.');
|
||||
{
|
||||
/* If the locale name contains an encoding after the dot, return
|
||||
it. */
|
||||
const char *dot = strchr (locale, '.');
|
||||
|
||||
if (dot != NULL)
|
||||
{
|
||||
const char *modifier;
|
||||
if (dot != NULL)
|
||||
{
|
||||
const char *modifier;
|
||||
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Woe32 has a function returning the locale's codepage as a number. */
|
||||
/* Woe32 has a function returning the locale's codepage as a number:
|
||||
GetACP(). This encoding is used by Cygwin, unless the user has set
|
||||
the environment variable CYGWIN=codepage:oem (which very few people
|
||||
do).
|
||||
Output directed to console windows needs to be converted (to
|
||||
GetOEMCP() if the console is using a raster font, or to
|
||||
GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
|
||||
this conversion transparently (see winsup/cygwin/fhandler_console.cc),
|
||||
converting to GetConsoleOutputCP(). This leads to correct results,
|
||||
except when SetConsoleOutputCP has been called and a raster font is
|
||||
in use. */
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
codeset = buf;
|
||||
}
|
||||
|
|
@ -397,11 +440,11 @@ locale_charset (void)
|
|||
{
|
||||
locale = getenv ("LC_ALL");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
}
|
||||
|
||||
/* On some old systems, one used to set locale = "iso8859_1". On others,
|
||||
|
|
@ -415,7 +458,13 @@ locale_charset (void)
|
|||
|
||||
static char buf[2 + 10 + 1];
|
||||
|
||||
/* Woe32 has a function returning the locale's codepage as a number. */
|
||||
/* Woe32 has a function returning the locale's codepage as a number:
|
||||
GetACP().
|
||||
When the output goes to a console window, it needs to be provided in
|
||||
GetOEMCP() encoding if the console is using a raster font, or in
|
||||
GetConsoleOutputCP() encoding if it is using a TrueType font.
|
||||
But in GUI programs and for output sent to files and pipes, GetACP()
|
||||
encoding is the best bet. */
|
||||
sprintf (buf, "CP%u", GetACP ());
|
||||
codeset = buf;
|
||||
|
||||
|
|
@ -433,7 +482,7 @@ locale_charset (void)
|
|||
{
|
||||
locale = getenv ("LC_CTYPE");
|
||||
if (locale == NULL || locale[0] == '\0')
|
||||
locale = getenv ("LANG");
|
||||
locale = getenv ("LANG");
|
||||
}
|
||||
if (locale != NULL && locale[0] != '\0')
|
||||
{
|
||||
|
|
@ -441,21 +490,21 @@ locale_charset (void)
|
|||
const char *dot = strchr (locale, '.');
|
||||
|
||||
if (dot != NULL)
|
||||
{
|
||||
const char *modifier;
|
||||
{
|
||||
const char *modifier;
|
||||
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
dot++;
|
||||
/* Look for the possible @... trailer and remove it, if any. */
|
||||
modifier = strchr (dot, '@');
|
||||
if (modifier == NULL)
|
||||
return dot;
|
||||
if (modifier - dot < sizeof (buf))
|
||||
{
|
||||
memcpy (buf, dot, modifier - dot);
|
||||
buf [modifier - dot] = '\0';
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
/* Resolve through the charset.alias file. */
|
||||
codeset = locale;
|
||||
|
|
@ -464,12 +513,12 @@ locale_charset (void)
|
|||
{
|
||||
/* OS/2 has a function returning the locale's codepage as a number. */
|
||||
if (DosQueryCp (sizeof (cp), cp, &cplen))
|
||||
codeset = "";
|
||||
codeset = "";
|
||||
else
|
||||
{
|
||||
sprintf (buf, "CP%u", cp[0]);
|
||||
codeset = buf;
|
||||
}
|
||||
{
|
||||
sprintf (buf, "CP%u", cp[0]);
|
||||
codeset = buf;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -483,10 +532,10 @@ locale_charset (void)
|
|||
*aliases != '\0';
|
||||
aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
|
||||
if (strcmp (codeset, aliases) == 0
|
||||
|| (aliases[0] == '*' && aliases[1] == '\0'))
|
||||
|| (aliases[0] == '*' && aliases[1] == '\0'))
|
||||
{
|
||||
codeset = aliases + strlen (aliases) + 1;
|
||||
break;
|
||||
codeset = aliases + strlen (aliases) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Don't return an empty string. GNU libc and GNU libiconv interpret
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Determine a canonical name for the current locale's character encoding.
|
||||
Copyright (C) 2000-2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2003, 2009-2010 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
|
||||
|
|
|
|||
74
gl/locale.in.h
Normal file
74
gl/locale.in.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/* A POSIX <locale.h>.
|
||||
Copyright (C) 2007-2010 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _GL_LOCALE_H
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
|
||||
|
||||
#ifndef _GL_LOCALE_H
|
||||
#define _GL_LOCALE_H
|
||||
|
||||
/* NetBSD 5.0 mis-defines NULL. */
|
||||
#include <stddef.h>
|
||||
|
||||
/* MacOS X 10.5 defines the locale_t type in <xlocale.h>. */
|
||||
#if @HAVE_XLOCALE_H@
|
||||
# include <xlocale.h>
|
||||
#endif
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
/* The definition of _GL_ARG_NONNULL is copied here. */
|
||||
|
||||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
/* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
|
||||
On systems that don't define it, use the same value as GNU libintl. */
|
||||
#if !defined LC_MESSAGES
|
||||
# define LC_MESSAGES 1729
|
||||
#endif
|
||||
|
||||
#if @GNULIB_DUPLOCALE@
|
||||
# if @REPLACE_DUPLOCALE@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef duplocale
|
||||
# define duplocale rpl_duplocale
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
|
||||
# else
|
||||
# if @HAVE_DUPLOCALE@
|
||||
_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
|
||||
# endif
|
||||
# endif
|
||||
# if @HAVE_DUPLOCALE@
|
||||
_GL_CXXALIASWARN (duplocale);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef duplocale
|
||||
# if HAVE_RAW_DECL_DUPLOCALE
|
||||
_GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
|
||||
"use gnulib module duplocale for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _GL_LOCALE_H */
|
||||
#endif /* _GL_LOCALE_H */
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# 00gnulib.m4 serial 2
|
||||
dnl Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2009-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
# alloca.m4 serial 9
|
||||
dnl Copyright (C) 2002-2004, 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2002-2004, 2006-2007, 2009-2010 Free Software Foundation,
|
||||
dnl Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# arpa_inet_h.m4 serial 5
|
||||
dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc.
|
||||
# arpa_inet_h.m4 serial 8
|
||||
dnl Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -16,27 +16,35 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
|
|||
if test $ac_cv_header_arpa_inet_h = yes; then
|
||||
HAVE_ARPA_INET_H=1
|
||||
else
|
||||
ARPA_INET_H='arpa/inet.h'
|
||||
HAVE_ARPA_INET_H=0
|
||||
fi
|
||||
AC_SUBST([HAVE_ARPA_INET_H])
|
||||
dnl Execute this unconditionally, because ARPA_INET_H may be set by other
|
||||
dnl modules, after this code is executed.
|
||||
dnl <arpa/inet.h> is always overridden, because of GNULIB_POSIXCHECK.
|
||||
gl_CHECK_NEXT_HEADERS([arpa/inet.h])
|
||||
|
||||
dnl Check for declarations of anything we want to poison if the
|
||||
dnl corresponding gnulib module is not in use.
|
||||
gl_WARN_ON_USE_PREPARE([[
|
||||
/* On some systems, this header is not self-consistent. */
|
||||
#ifndef __GLIBC__
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#include <arpa/inet.h>
|
||||
]], [inet_ntop inet_pton])
|
||||
])
|
||||
|
||||
dnl Unconditionally enables the replacement of <arpa/inet.h>.
|
||||
AC_DEFUN([gl_REPLACE_ARPA_INET_H],
|
||||
[
|
||||
AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
|
||||
ARPA_INET_H='arpa/inet.h'
|
||||
dnl This is a no-op, because <arpa/inet.h> is always overridden.
|
||||
:
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
|
||||
AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
|
||||
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
|
||||
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
|
||||
|
|
@ -46,5 +54,4 @@ AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
|
|||
dnl Assume proper GNU behavior unless another module says otherwise.
|
||||
HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP])
|
||||
HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON])
|
||||
ARPA_INET_H=''; AC_SUBST([ARPA_INET_H])
|
||||
])
|
||||
|
|
|
|||
48
gl/m4/asm-underscore.m4
Normal file
48
gl/m4/asm-underscore.m4
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# asm-underscore.m4 serial 1
|
||||
dnl Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp.
|
||||
|
||||
# gl_ASM_SYMBOL_PREFIX
|
||||
# Tests for the prefix of C symbols at the assembly language level and the
|
||||
# linker level. This prefix is either an underscore or empty. Defines the
|
||||
# C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to
|
||||
# a stringified variant of this prefix.
|
||||
|
||||
AC_DEFUN([gl_ASM_SYMBOL_PREFIX],
|
||||
[
|
||||
dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because
|
||||
dnl 1. It works only for GCC.
|
||||
dnl 2. It is incorrectly defined on some platforms, in some GCC versions.
|
||||
AC_CACHE_CHECK(
|
||||
[whether C symbols are prefixed with underscore at the linker level],
|
||||
[gl_cv_prog_as_underscore],
|
||||
[cat > conftest.c <<EOF
|
||||
#ifdef __cplusplus
|
||||
extern "C" int foo (void);
|
||||
#endif
|
||||
int foo(void) { return 0; }
|
||||
EOF
|
||||
# Look for the assembly language name in the .s file.
|
||||
AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c) >/dev/null 2>&1
|
||||
if grep _foo conftest.s >/dev/null ; then
|
||||
gl_cv_prog_as_underscore=yes
|
||||
else
|
||||
gl_cv_prog_as_underscore=no
|
||||
fi
|
||||
rm -f conftest*
|
||||
])
|
||||
if test $gl_cv_prog_as_underscore = yes; then
|
||||
USER_LABEL_PREFIX=_
|
||||
else
|
||||
USER_LABEL_PREFIX=
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX],
|
||||
[Define to the prefix of C symbols at the assembler and linker level,
|
||||
either an underscore or empty.])
|
||||
ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"'
|
||||
AC_SUBST([ASM_SYMBOL_PREFIX])
|
||||
])
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# base64.m4 serial 3
|
||||
dnl Copyright (C) 2004, 2006 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# btowc.m4 serial 4
|
||||
dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
|
||||
# btowc.m4 serial 6
|
||||
dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -8,15 +8,49 @@ AC_DEFUN([gl_FUNC_BTOWC],
|
|||
[
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
|
||||
dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
|
||||
dnl program below may lead to an endless loop. See
|
||||
dnl <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>.
|
||||
AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
|
||||
|
||||
AC_CHECK_FUNCS_ONCE([btowc])
|
||||
if test $ac_cv_func_btowc = no; then
|
||||
HAVE_BTOWC=0
|
||||
else
|
||||
|
||||
dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gt_LOCALE_FR])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
|
||||
dnl Cygwin 1.7.2 btowc('\0') is WEOF, not 0.
|
||||
AC_CACHE_CHECK([whether btowc(0) is correct],
|
||||
[gl_cv_func_btowc_nul],
|
||||
[
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
int main ()
|
||||
{
|
||||
if (btowc ('\0') != 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}],
|
||||
[gl_cv_func_btowc_nul=yes],
|
||||
[gl_cv_func_btowc_nul=no],
|
||||
[
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
# Guess no on Cygwin.
|
||||
cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
|
||||
# Guess yes otherwise.
|
||||
*) gl_cv_func_btowc_nul="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
])
|
||||
])
|
||||
|
||||
dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
|
||||
AC_CACHE_CHECK([whether btowc(EOF) is correct],
|
||||
[gl_cv_func_btowc_eof],
|
||||
[
|
||||
|
|
@ -50,6 +84,11 @@ int main ()
|
|||
[:])
|
||||
fi
|
||||
])
|
||||
|
||||
case "$gl_cv_func_btowc_nul" in
|
||||
*yes) ;;
|
||||
*) REPLACE_BTOWC=1 ;;
|
||||
esac
|
||||
case "$gl_cv_func_btowc_eof" in
|
||||
*yes) ;;
|
||||
*) REPLACE_BTOWC=1 ;;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# c-strtod.m4 serial 11
|
||||
|
||||
# Copyright (C) 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2004-2006, 2009-2010 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -14,17 +14,17 @@ AC_DEFUN([gl_C99_STRTOLD],
|
|||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[/* On HP-UX before 11.23, strtold returns a struct instead of
|
||||
long double. Reject implementations like that, by requiring
|
||||
compatibility with the C99 prototype. */
|
||||
#include <stdlib.h>
|
||||
static long double (*p) (char const *, char **) = strtold;
|
||||
static long double
|
||||
test (char const *nptr, char **endptr)
|
||||
{
|
||||
long double r;
|
||||
r = strtold (nptr, endptr);
|
||||
return r;
|
||||
}]],
|
||||
long double. Reject implementations like that, by requiring
|
||||
compatibility with the C99 prototype. */
|
||||
#include <stdlib.h>
|
||||
static long double (*p) (char const *, char **) = strtold;
|
||||
static long double
|
||||
test (char const *nptr, char **endptr)
|
||||
{
|
||||
long double r;
|
||||
r = strtold (nptr, endptr);
|
||||
return r;
|
||||
}]],
|
||||
[[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
|
||||
[gl_cv_func_c99_strtold=yes],
|
||||
[gl_cv_func_c99_strtold=no])])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#serial 6
|
||||
dnl Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2004-2006, 2009-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# codeset.m4 serial 4 (gettext-0.18)
|
||||
dnl Copyright (C) 2000-2002, 2006, 2008, 2009 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
|
|||
|
|
@ -1,18 +1,26 @@
|
|||
#serial 7 -*- autoconf -*-
|
||||
dnl Copyright (C) 2002-2006 Free Software Foundation, Inc.
|
||||
#serial 8 -*- autoconf -*-
|
||||
dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_DIRNAME],
|
||||
[
|
||||
AC_REQUIRE([gl_DIRNAME_LGPL])
|
||||
AC_LIBOBJ([basename])
|
||||
AC_LIBOBJ([dirname])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_DIRNAME_LGPL],
|
||||
[
|
||||
AC_LIBOBJ([basename-lgpl])
|
||||
AC_LIBOBJ([dirname-lgpl])
|
||||
AC_LIBOBJ([stripslash])
|
||||
|
||||
dnl Prerequisites of lib/dirname.h.
|
||||
AC_REQUIRE([gl_AC_DOS])
|
||||
AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
|
||||
|
||||
dnl No prerequisites of lib/basename.c, lib/dirname.c, lib/stripslash.c.
|
||||
dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c,
|
||||
dnl lib/stripslash.c.
|
||||
])
|
||||
|
|
|
|||
34
gl/m4/dos.m4
34
gl/m4/dos.m4
|
|
@ -1,9 +1,9 @@
|
|||
#serial 10 -*- autoconf -*-
|
||||
#serial 11 -*- autoconf -*-
|
||||
|
||||
# Define some macros required for proper operation of code in lib/*.c
|
||||
# on MSDOS/Windows systems.
|
||||
|
||||
# Copyright (C) 2000, 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2000-2001, 2004-2006, 2009-2010 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -14,31 +14,31 @@ AC_DEFUN([gl_AC_DOS],
|
|||
[
|
||||
AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos],
|
||||
[
|
||||
AC_TRY_COMPILE([],
|
||||
[#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
|
||||
#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
|
||||
neither MSDOS nor Windows
|
||||
#endif],
|
||||
[ac_cv_win_or_dos=yes],
|
||||
[ac_cv_win_or_dos=no])
|
||||
#endif]])],
|
||||
[ac_cv_win_or_dos=yes],
|
||||
[ac_cv_win_or_dos=no])
|
||||
])
|
||||
|
||||
if test x"$ac_cv_win_or_dos" = xyes; then
|
||||
ac_fs_accepts_drive_letter_prefix=1
|
||||
ac_fs_backslash_is_file_name_separator=1
|
||||
AC_CACHE_CHECK([whether drive letter can start relative path],
|
||||
[ac_cv_drive_letter_can_be_relative],
|
||||
[
|
||||
AC_TRY_COMPILE([],
|
||||
[#if defined __CYGWIN__
|
||||
[ac_cv_drive_letter_can_be_relative],
|
||||
[
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
|
||||
#if defined __CYGWIN__
|
||||
drive letters are always absolute
|
||||
#endif],
|
||||
[ac_cv_drive_letter_can_be_relative=yes],
|
||||
[ac_cv_drive_letter_can_be_relative=no])
|
||||
])
|
||||
#endif]])],
|
||||
[ac_cv_drive_letter_can_be_relative=yes],
|
||||
[ac_cv_drive_letter_can_be_relative=no])
|
||||
])
|
||||
if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
|
||||
ac_fs_drive_letter_can_be_relative=1
|
||||
ac_fs_drive_letter_can_be_relative=1
|
||||
else
|
||||
ac_fs_drive_letter_can_be_relative=0
|
||||
ac_fs_drive_letter_can_be_relative=0
|
||||
fi
|
||||
else
|
||||
ac_fs_accepts_drive_letter_prefix=0
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# double-slash-root.m4 serial 4 -*- Autoconf -*-
|
||||
dnl Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2006, 2008-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -9,27 +9,27 @@ AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
|
|||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root],
|
||||
[ if test x"$cross_compiling" = xyes ; then
|
||||
# When cross-compiling, there is no way to tell whether // is special
|
||||
# short of a list of hosts. However, the only known hosts to date
|
||||
# that have a distinct // are Apollo DomainOS (too old to port to),
|
||||
# Cygwin, and z/OS. If anyone knows of another system for which // has
|
||||
# special semantics and is distinct from /, please report it to
|
||||
# <bug-gnulib@gnu.org>.
|
||||
case $host in
|
||||
*-cygwin | i370-ibm-openedition)
|
||||
gl_cv_double_slash_root=yes ;;
|
||||
*)
|
||||
# Be optimistic and assume that / and // are the same when we
|
||||
# don't know.
|
||||
gl_cv_double_slash_root='unknown, assuming no' ;;
|
||||
esac
|
||||
# When cross-compiling, there is no way to tell whether // is special
|
||||
# short of a list of hosts. However, the only known hosts to date
|
||||
# that have a distinct // are Apollo DomainOS (too old to port to),
|
||||
# Cygwin, and z/OS. If anyone knows of another system for which // has
|
||||
# special semantics and is distinct from /, please report it to
|
||||
# <bug-gnulib@gnu.org>.
|
||||
case $host in
|
||||
*-cygwin | i370-ibm-openedition)
|
||||
gl_cv_double_slash_root=yes ;;
|
||||
*)
|
||||
# Be optimistic and assume that / and // are the same when we
|
||||
# don't know.
|
||||
gl_cv_double_slash_root='unknown, assuming no' ;;
|
||||
esac
|
||||
else
|
||||
set x `ls -di / // 2>/dev/null`
|
||||
if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
|
||||
gl_cv_double_slash_root=no
|
||||
else
|
||||
gl_cv_double_slash_root=yes
|
||||
fi
|
||||
set x `ls -di / // 2>/dev/null`
|
||||
if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
|
||||
gl_cv_double_slash_root=no
|
||||
else
|
||||
gl_cv_double_slash_root=yes
|
||||
fi
|
||||
fi])
|
||||
if test "$gl_cv_double_slash_root" = yes; then
|
||||
AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1],
|
||||
|
|
|
|||
58
gl/m4/dup2.m4
Normal file
58
gl/m4/dup2.m4
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#serial 10
|
||||
dnl Copyright (C) 2002, 2005, 2007, 2009-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_DUP2],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CHECK_FUNCS_ONCE([dup2])
|
||||
if test $ac_cv_func_dup2 = no; then
|
||||
HAVE_DUP2=0
|
||||
AC_LIBOBJ([dup2])
|
||||
else
|
||||
AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
|
||||
[AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([[#include <unistd.h>
|
||||
#include <errno.h>]],
|
||||
[if (dup2 (1, 1) == 0)
|
||||
return 1;
|
||||
close (0);
|
||||
if (dup2 (0, 0) != -1)
|
||||
return 2;
|
||||
/* Many gnulib modules require POSIX conformance of EBADF. */
|
||||
if (dup2 (1, 1000000) == -1 && errno != EBADF)
|
||||
return 3;
|
||||
return 0;
|
||||
])
|
||||
],
|
||||
[gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
|
||||
[case "$host_os" in
|
||||
mingw*) # on this platform, dup2 always returns 0 for success
|
||||
gl_cv_func_dup2_works=no;;
|
||||
cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
|
||||
gl_cv_func_dup2_works=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=no;;
|
||||
freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
|
||||
gl_cv_func_dup2_works=no;;
|
||||
*) gl_cv_func_dup2_works=yes;;
|
||||
esac])
|
||||
])
|
||||
if test "$gl_cv_func_dup2_works" = no; then
|
||||
gl_REPLACE_DUP2
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_REPLACE_DUP2],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
if test $ac_cv_func_dup2 = yes; then
|
||||
REPLACE_DUP2=1
|
||||
fi
|
||||
AC_LIBOBJ([dup2])
|
||||
])
|
||||
32
gl/m4/eealloc.m4
Normal file
32
gl/m4/eealloc.m4
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# eealloc.m4 serial 2
|
||||
dnl Copyright (C) 2003, 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_EEALLOC],
|
||||
[
|
||||
AC_REQUIRE([gl_EEMALLOC])
|
||||
AC_REQUIRE([gl_EEREALLOC])
|
||||
AC_REQUIRE([AC_C_INLINE])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_EEMALLOC],
|
||||
[
|
||||
_AC_FUNC_MALLOC_IF(
|
||||
[gl_cv_func_malloc_0_nonnull=1],
|
||||
[gl_cv_func_malloc_0_nonnull=0])
|
||||
AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull],
|
||||
[If malloc(0) is != NULL, define this to 1. Otherwise define this
|
||||
to 0.])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_EEREALLOC],
|
||||
[
|
||||
_AC_FUNC_REALLOC_IF(
|
||||
[gl_cv_func_realloc_0_nonnull=1],
|
||||
[gl_cv_func_realloc_0_nonnull=0])
|
||||
AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull],
|
||||
[If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this
|
||||
to 0.])
|
||||
])
|
||||
36
gl/m4/environ.m4
Normal file
36
gl/m4/environ.m4
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# environ.m4 serial 4
|
||||
dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN_ONCE([gl_ENVIRON],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
dnl Persuade glibc <unistd.h> to declare environ.
|
||||
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
||||
gt_CHECK_VAR_DECL([#include <unistd.h>], environ)
|
||||
if test $gt_cv_var_environ_declaration != yes; then
|
||||
HAVE_DECL_ENVIRON=0
|
||||
fi
|
||||
])
|
||||
|
||||
# Check if a variable is properly declared.
|
||||
# gt_CHECK_VAR_DECL(includes,variable)
|
||||
AC_DEFUN([gt_CHECK_VAR_DECL],
|
||||
[
|
||||
define([gt_cv_var], [gt_cv_var_]$2[_declaration])
|
||||
AC_MSG_CHECKING([if $2 is properly declared])
|
||||
AC_CACHE_VAL([gt_cv_var], [
|
||||
AC_TRY_COMPILE([$1
|
||||
extern struct { int foo; } $2;],
|
||||
[$2.foo = 1;],
|
||||
gt_cv_var=no,
|
||||
gt_cv_var=yes)])
|
||||
AC_MSG_RESULT([$gt_cv_var])
|
||||
if test $gt_cv_var = yes; then
|
||||
AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
|
||||
[Define if you have the declaration of $2.])
|
||||
fi
|
||||
undefine([gt_cv_var])
|
||||
])
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# errno_h.m4 serial 5
|
||||
dnl Copyright (C) 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
|
||||
# errno_h.m4 serial 6
|
||||
dnl Copyright (C) 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -34,6 +34,9 @@ booboo
|
|||
#if !defined ENOTSUP
|
||||
booboo
|
||||
#endif
|
||||
#if !defined ESTALE
|
||||
booboo
|
||||
#endif
|
||||
#if !defined ECANCELED
|
||||
booboo
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#serial 11
|
||||
#serial 12
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004 Free Software
|
||||
# Foundation, Inc.
|
||||
# Copyright (C) 1996-1998, 2001-2004, 2009-2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
|
@ -18,5 +17,6 @@ AC_DEFUN([gl_ERROR],
|
|||
AC_DEFUN([gl_PREREQ_ERROR],
|
||||
[
|
||||
AC_REQUIRE([AC_FUNC_STRERROR_R])
|
||||
AC_REQUIRE([AC_C_INLINE])
|
||||
:
|
||||
])
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
# exitfail.m4 serial 6
|
||||
dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_EXITFAIL],
|
||||
[
|
||||
AC_LIBOBJ([exitfail])
|
||||
|
||||
dnl No prerequisites of lib/exitfail.c.
|
||||
:
|
||||
])
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
# serial 8 -*- Autoconf -*-
|
||||
# serial 9 -*- Autoconf -*-
|
||||
# Enable extensions on systems that normally disable them.
|
||||
|
||||
# Copyright (C) 2003, 2006-2009 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003, 2006-2010 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -12,6 +12,20 @@
|
|||
# enough in this area it's likely we'll need to redefine
|
||||
# AC_USE_SYSTEM_EXTENSIONS for quite some time.
|
||||
|
||||
# If autoconf reports a warning
|
||||
# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
|
||||
# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
|
||||
# the fix is
|
||||
# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
|
||||
# but always AC_REQUIREd,
|
||||
# 2) to ensure that for each occurrence of
|
||||
# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
# or
|
||||
# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
||||
# the corresponding gnulib module description has 'extensions' among
|
||||
# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
|
||||
# invocation occurs in gl_EARLY, not in gl_INIT.
|
||||
|
||||
# AC_USE_SYSTEM_EXTENSIONS
|
||||
# ------------------------
|
||||
# Enable extensions on systems that normally disable them,
|
||||
|
|
@ -74,8 +88,8 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
|
|||
[ac_cv_safe_to_define___extensions__],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
# define __EXTENSIONS__ 1
|
||||
]AC_INCLUDES_DEFAULT])],
|
||||
# define __EXTENSIONS__ 1
|
||||
]AC_INCLUDES_DEFAULT])],
|
||||
[ac_cv_safe_to_define___extensions__=yes],
|
||||
[ac_cv_safe_to_define___extensions__=no])])
|
||||
test $ac_cv_safe_to_define___extensions__ = yes &&
|
||||
|
|
|
|||
81
gl/m4/fcntl-o.m4
Normal file
81
gl/m4/fcntl-o.m4
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# fcntl-o.m4 serial 1
|
||||
dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl Written by Paul Eggert.
|
||||
|
||||
# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
|
||||
# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
|
||||
# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
|
||||
AC_DEFUN([gl_FCNTL_O_FLAGS],
|
||||
[
|
||||
dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef O_NOATIME
|
||||
#define O_NOATIME 0
|
||||
#endif
|
||||
#ifndef O_NOFOLLOW
|
||||
#define O_NOFOLLOW 0
|
||||
#endif
|
||||
static int const constants[] =
|
||||
{
|
||||
O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
|
||||
O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
|
||||
};
|
||||
]],
|
||||
[[
|
||||
int status = !constants;
|
||||
{
|
||||
static char const sym[] = "conftest.sym";
|
||||
if (symlink (".", sym) != 0
|
||||
|| close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
|
||||
status |= 32;
|
||||
unlink (sym);
|
||||
}
|
||||
{
|
||||
static char const file[] = "confdefs.h";
|
||||
int fd = open (file, O_RDONLY | O_NOATIME);
|
||||
char c;
|
||||
struct stat st0, st1;
|
||||
if (fd < 0
|
||||
|| fstat (fd, &st0) != 0
|
||||
|| sleep (1) != 0
|
||||
|| read (fd, &c, 1) != 1
|
||||
|| close (fd) != 0
|
||||
|| stat (file, &st1) != 0
|
||||
|| st0.st_atime != st1.st_atime)
|
||||
status |= 64;
|
||||
}
|
||||
return status;]])],
|
||||
[gl_cv_header_working_fcntl_h=yes],
|
||||
[case $? in #(
|
||||
32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
|
||||
64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
|
||||
96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
|
||||
*) gl_cv_header_working_fcntl_h='no';;
|
||||
esac],
|
||||
[gl_cv_header_working_fcntl_h=cross-compiling])])
|
||||
|
||||
case $gl_cv_header_working_fcntl_h in #(
|
||||
*O_NOATIME* | no | cross-compiling) ac_val=0;; #(
|
||||
*) ac_val=1;;
|
||||
esac
|
||||
AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
|
||||
[Define to 1 if O_NOATIME works.])
|
||||
|
||||
case $gl_cv_header_working_fcntl_h in #(
|
||||
*O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
|
||||
*) ac_val=1;;
|
||||
esac
|
||||
AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
|
||||
[Define to 1 if O_NOFOLLOW works.])
|
||||
])
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#serial 5
|
||||
dnl Copyright (C) 2005-2007 Free Software Foundation, Inc.
|
||||
#serial 7
|
||||
dnl Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -8,4 +8,12 @@ AC_DEFUN([gl_FCNTL_SAFER],
|
|||
[
|
||||
AC_LIBOBJ([open-safer])
|
||||
AC_LIBOBJ([creat-safer])
|
||||
# Prerequisites of lib/open-safer.c.
|
||||
AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_OPENAT_SAFER],
|
||||
[
|
||||
AC_REQUIRE([gl_FCNTL_SAFER])
|
||||
AC_LIBOBJ([openat-safer])
|
||||
])
|
||||
|
|
|
|||
83
gl/m4/fcntl.m4
Normal file
83
gl/m4/fcntl.m4
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
# fcntl.m4 serial 3
|
||||
dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# For now, this module ensures that fcntl()
|
||||
# - supports F_DUPFD correctly
|
||||
# - supports or emulates F_DUPFD_CLOEXEC
|
||||
# - supports F_GETFD
|
||||
# Still to be ported to mingw:
|
||||
# - F_SETFD
|
||||
# - F_GETFL, F_SETFL
|
||||
# - F_GETOWN, F_SETOWN
|
||||
# - F_GETLK, F_SETLK, F_SETLKW
|
||||
AC_DEFUN([gl_FUNC_FCNTL],
|
||||
[
|
||||
dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
|
||||
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
||||
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_CHECK_FUNCS_ONCE([fcntl])
|
||||
if test $ac_cv_func_fcntl = no; then
|
||||
gl_REPLACE_FCNTL
|
||||
else
|
||||
dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
|
||||
AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
|
||||
[gl_cv_func_fcntl_f_dupfd_works],
|
||||
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <fcntl.h>
|
||||
]], [[return fcntl (0, F_DUPFD, -1) != -1;
|
||||
]])],
|
||||
[gl_cv_func_fcntl_f_dupfd_works=yes],
|
||||
[gl_cv_func_fcntl_f_dupfd_works=no],
|
||||
[# Guess that it works on glibc systems
|
||||
case $host_os in #((
|
||||
*-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
|
||||
*) gl_cv_func_fcntl_f_dupfd_works="guessing no";;
|
||||
esac])])
|
||||
case $gl_cv_func_fcntl_f_dupfd_works in
|
||||
*yes) ;;
|
||||
*) gl_REPLACE_FCNTL
|
||||
AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
|
||||
behavior does not match POSIX]) ;;
|
||||
esac
|
||||
|
||||
dnl Many systems lack F_DUPFD_CLOEXEC
|
||||
AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
|
||||
[gl_cv_func_fcntl_f_dupfd_cloexec],
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <fcntl.h>
|
||||
#ifndef F_DUPFD_CLOEXEC
|
||||
choke me
|
||||
#endif
|
||||
]])],
|
||||
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
#ifdef __linux__
|
||||
/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
|
||||
it to support the semantics on older kernels that failed with EINVAL. */
|
||||
choke me
|
||||
#endif
|
||||
]])],
|
||||
[gl_cv_func_fcntl_f_dupfd_cloexec=yes],
|
||||
[gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])],
|
||||
[gl_cv_func_fcntl_f_dupfd_cloexec=no])])
|
||||
if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
|
||||
gl_REPLACE_FCNTL
|
||||
dnl No witness macro needed for this bug.
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_REPLACE_FCNTL],
|
||||
[
|
||||
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
|
||||
AC_CHECK_FUNCS_ONCE([fcntl])
|
||||
if test $ac_cv_func_fcntl = no; then
|
||||
HAVE_FCNTL=0
|
||||
else
|
||||
REPLACE_FCNTL=1
|
||||
fi
|
||||
AC_LIBOBJ([fcntl])
|
||||
])
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
# serial 12
|
||||
# Configure fcntl.h.
|
||||
dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -9,88 +10,34 @@ dnl Written by Paul Eggert.
|
|||
AC_DEFUN([gl_FCNTL_H],
|
||||
[
|
||||
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
|
||||
dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef O_NOATIME
|
||||
#define O_NOATIME 0
|
||||
#endif
|
||||
#ifndef O_NOFOLLOW
|
||||
#define O_NOFOLLOW 0
|
||||
#endif
|
||||
static int const constants[] =
|
||||
{
|
||||
O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
|
||||
O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
|
||||
};
|
||||
]],
|
||||
[[
|
||||
int status = !constants;
|
||||
{
|
||||
static char const sym[] = "conftest.sym";
|
||||
if (symlink (".", sym) != 0
|
||||
|| close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
|
||||
status |= 32;
|
||||
}
|
||||
{
|
||||
static char const file[] = "confdefs.h";
|
||||
int fd = open (file, O_RDONLY | O_NOATIME);
|
||||
char c;
|
||||
struct stat st0, st1;
|
||||
if (fd < 0
|
||||
|| fstat (fd, &st0) != 0
|
||||
|| sleep (1) != 0
|
||||
|| read (fd, &c, 1) != 1
|
||||
|| close (fd) != 0
|
||||
|| stat (file, &st1) != 0
|
||||
|| st0.st_atime != st1.st_atime)
|
||||
status |= 64;
|
||||
}
|
||||
return status;]])],
|
||||
[gl_cv_header_working_fcntl_h=yes],
|
||||
[case $? in #(
|
||||
32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
|
||||
64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
|
||||
96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
|
||||
*) gl_cv_header_working_fcntl_h='no';;
|
||||
esac],
|
||||
[gl_cv_header_working_fcntl_h=cross-compiling])])
|
||||
|
||||
case $gl_cv_header_working_fcntl_h in #(
|
||||
*O_NOATIME* | no | cross-compiling) ac_val=0;; #(
|
||||
*) ac_val=1;;
|
||||
esac
|
||||
AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
|
||||
[Define to 1 if O_NOATIME works.])
|
||||
|
||||
case $gl_cv_header_working_fcntl_h in #(
|
||||
*O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
|
||||
*) ac_val=1;;
|
||||
esac
|
||||
AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
|
||||
[Define to 1 if O_NOFOLLOW works.])
|
||||
|
||||
AC_REQUIRE([gl_FCNTL_O_FLAGS])
|
||||
gl_CHECK_NEXT_HEADERS([fcntl.h])
|
||||
FCNTL_H='fcntl.h'
|
||||
AC_SUBST([FCNTL_H])
|
||||
|
||||
dnl Check for declarations of anything we want to poison if the
|
||||
dnl corresponding gnulib module is not in use, if it is not common
|
||||
dnl enough to be declared everywhere.
|
||||
gl_WARN_ON_USE_PREPARE([[#include <fcntl.h>
|
||||
]], [fcntl openat])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
|
||||
AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
|
||||
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
|
||||
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
|
||||
dnl Define it also as a C macro, for the benefit of the unit tests.
|
||||
gl_MODULE_INDICATOR_FOR_TESTS([$1])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_FCNTL_H_DEFAULTS],
|
||||
[
|
||||
GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
|
||||
GNULIB_FCNTL=0; AC_SUBST([GNULIB_FCNTL])
|
||||
GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
|
||||
GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT])
|
||||
dnl Assume proper GNU behavior unless another module says otherwise.
|
||||
REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
|
||||
HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL])
|
||||
HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
|
||||
REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL])
|
||||
REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
|
||||
REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])
|
||||
])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# float_h.m4 serial 3
|
||||
dnl Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# floorf.m4 serial 4
|
||||
dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
|
||||
# floorf.m4 serial 6
|
||||
dnl Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -20,13 +20,12 @@ AC_DEFUN([gl_FUNC_FLOORF],
|
|||
REPLACE_FLOORF=1
|
||||
fi
|
||||
else
|
||||
REPLACE_FLOORF=1
|
||||
HAVE_DECL_FLOORF=0
|
||||
fi
|
||||
if test $REPLACE_FLOORF = 1; then
|
||||
if test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1; then
|
||||
AC_LIBOBJ([floorf])
|
||||
FLOORF_LIBM=
|
||||
fi
|
||||
AC_SUBST([REPLACE_FLOORF])
|
||||
AC_SUBST([FLOORF_LIBM])
|
||||
])
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ dnl See if struct statfs has the f_fstypename member.
|
|||
dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME.
|
||||
dnl
|
||||
|
||||
# Copyright (C) 1998, 1999, 2001, 2004, 2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2010 Free Software
|
||||
# Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# serial 24
|
||||
# serial 25
|
||||
# Obtaining file system usage information.
|
||||
|
||||
# Copyright (C) 1997-1998, 2000-2001, 2003-2009 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1997-1998, 2000-2001, 2003-2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
|
@ -46,7 +46,7 @@ ac_fsusage_space=no
|
|||
if test $ac_fsusage_space = no; then
|
||||
# SVR4
|
||||
AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs],
|
||||
[AC_TRY_LINK([#include <sys/types.h>
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
|
||||
#if defined __GLIBC__ && defined __linux__
|
||||
Do not use statvfs on systems with GNU libc on Linux, because that function
|
||||
stats all preceding entries in /proc/mounts, and that makes df hang if even
|
||||
|
|
@ -59,14 +59,14 @@ a system call.
|
|||
"Do not use Tru64's statvfs implementation"
|
||||
#endif
|
||||
|
||||
#include <sys/statvfs.h>],
|
||||
[struct statvfs fsd; statvfs (0, &fsd);],
|
||||
fu_cv_sys_stat_statvfs=yes,
|
||||
fu_cv_sys_stat_statvfs=no)])
|
||||
#include <sys/statvfs.h>]],
|
||||
[[struct statvfs fsd; statvfs (0, &fsd);]])],
|
||||
[fu_cv_sys_stat_statvfs=yes],
|
||||
[fu_cv_sys_stat_statvfs=no])])
|
||||
if test $fu_cv_sys_stat_statvfs = yes; then
|
||||
ac_fsusage_space=yes
|
||||
AC_DEFINE([STAT_STATVFS], [1],
|
||||
[ Define if there is a function named statvfs. (SVR4)])
|
||||
[ Define if there is a function named statvfs. (SVR4)])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ if test $ac_fsusage_space = no; then
|
|||
# DEC Alpha running OSF/1
|
||||
AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
|
||||
AC_CACHE_VAL([fu_cv_sys_stat_statfs3_osf1],
|
||||
[AC_TRY_RUN([
|
||||
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
|
|
@ -84,15 +84,15 @@ if test $ac_fsusage_space = no; then
|
|||
struct statfs fsd;
|
||||
fsd.f_fsize = 0;
|
||||
return statfs (".", &fsd, sizeof (struct statfs)) != 0;
|
||||
}],
|
||||
fu_cv_sys_stat_statfs3_osf1=yes,
|
||||
fu_cv_sys_stat_statfs3_osf1=no,
|
||||
fu_cv_sys_stat_statfs3_osf1=no)])
|
||||
}]])],
|
||||
[fu_cv_sys_stat_statfs3_osf1=yes],
|
||||
[fu_cv_sys_stat_statfs3_osf1=no],
|
||||
[fu_cv_sys_stat_statfs3_osf1=no])])
|
||||
AC_MSG_RESULT([$fu_cv_sys_stat_statfs3_osf1])
|
||||
if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
|
||||
ac_fsusage_space=yes
|
||||
AC_DEFINE([STAT_STATFS3_OSF1], [1],
|
||||
[ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
|
||||
[ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ if test $ac_fsusage_space = no; then
|
|||
AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
|
||||
member (AIX, 4.3BSD)])
|
||||
AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize],
|
||||
[AC_TRY_RUN([
|
||||
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
|
@ -117,10 +117,10 @@ member (AIX, 4.3BSD)])
|
|||
struct statfs fsd;
|
||||
fsd.f_bsize = 0;
|
||||
return statfs (".", &fsd) != 0;
|
||||
}],
|
||||
fu_cv_sys_stat_statfs2_bsize=yes,
|
||||
fu_cv_sys_stat_statfs2_bsize=no,
|
||||
fu_cv_sys_stat_statfs2_bsize=no)])
|
||||
}]])],
|
||||
[fu_cv_sys_stat_statfs2_bsize=yes],
|
||||
[fu_cv_sys_stat_statfs2_bsize=no],
|
||||
[fu_cv_sys_stat_statfs2_bsize=no])])
|
||||
AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize])
|
||||
if test $fu_cv_sys_stat_statfs2_bsize = yes; then
|
||||
ac_fsusage_space=yes
|
||||
|
|
@ -134,22 +134,23 @@ if test $ac_fsusage_space = no; then
|
|||
# SVR3
|
||||
AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
|
||||
AC_CACHE_VAL([fu_cv_sys_stat_statfs4],
|
||||
[AC_TRY_RUN([#include <sys/types.h>
|
||||
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <sys/types.h>
|
||||
#include <sys/statfs.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
struct statfs fsd;
|
||||
return statfs (".", &fsd, sizeof fsd, 0) != 0;
|
||||
}],
|
||||
fu_cv_sys_stat_statfs4=yes,
|
||||
fu_cv_sys_stat_statfs4=no,
|
||||
fu_cv_sys_stat_statfs4=no)])
|
||||
}]])],
|
||||
[fu_cv_sys_stat_statfs4=yes],
|
||||
[fu_cv_sys_stat_statfs4=no],
|
||||
[fu_cv_sys_stat_statfs4=no])])
|
||||
AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
|
||||
if test $fu_cv_sys_stat_statfs4 = yes; then
|
||||
ac_fsusage_space=yes
|
||||
AC_DEFINE([STAT_STATFS4], [1],
|
||||
[ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
|
||||
[ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -158,7 +159,8 @@ if test $ac_fsusage_space = no; then
|
|||
AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
|
||||
member (4.4BSD and NetBSD)])
|
||||
AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize],
|
||||
[AC_TRY_RUN([#include <sys/types.h>
|
||||
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
|
@ -171,10 +173,10 @@ member (4.4BSD and NetBSD)])
|
|||
struct statfs fsd;
|
||||
fsd.f_fsize = 0;
|
||||
return statfs (".", &fsd) != 0;
|
||||
}],
|
||||
fu_cv_sys_stat_statfs2_fsize=yes,
|
||||
fu_cv_sys_stat_statfs2_fsize=no,
|
||||
fu_cv_sys_stat_statfs2_fsize=no)])
|
||||
}]])],
|
||||
[fu_cv_sys_stat_statfs2_fsize=yes],
|
||||
[fu_cv_sys_stat_statfs2_fsize=no],
|
||||
[fu_cv_sys_stat_statfs2_fsize=no])])
|
||||
AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize])
|
||||
if test $fu_cv_sys_stat_statfs2_fsize = yes; then
|
||||
ac_fsusage_space=yes
|
||||
|
|
@ -188,7 +190,8 @@ if test $ac_fsusage_space = no; then
|
|||
# Ultrix
|
||||
AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
|
||||
AC_CACHE_VAL([fu_cv_sys_stat_fs_data],
|
||||
[AC_TRY_RUN([#include <sys/types.h>
|
||||
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
|
@ -205,10 +208,10 @@ if test $ac_fsusage_space = no; then
|
|||
/* Ultrix's statfs returns 1 for success,
|
||||
0 for not mounted, -1 for failure. */
|
||||
return statfs (".", &fsd) != 1;
|
||||
}],
|
||||
fu_cv_sys_stat_fs_data=yes,
|
||||
fu_cv_sys_stat_fs_data=no,
|
||||
fu_cv_sys_stat_fs_data=no)])
|
||||
}]])],
|
||||
[fu_cv_sys_stat_fs_data=yes],
|
||||
[fu_cv_sys_stat_fs_data=no],
|
||||
[fu_cv_sys_stat_fs_data=no])])
|
||||
AC_MSG_RESULT([$fu_cv_sys_stat_fs_data])
|
||||
if test $fu_cv_sys_stat_fs_data = yes; then
|
||||
ac_fsusage_space=yes
|
||||
|
|
@ -220,12 +223,12 @@ fi
|
|||
|
||||
if test $ac_fsusage_space = no; then
|
||||
# SVR2
|
||||
AC_TRY_CPP([#include <sys/filsys.h>
|
||||
],
|
||||
AC_DEFINE([STAT_READ_FILSYS], [1],
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h>
|
||||
]])],
|
||||
[AC_DEFINE([STAT_READ_FILSYS], [1],
|
||||
[Define if there is no specific function for reading file systems usage
|
||||
information and you have the <sys/filsys.h> header file. (SVR2)])
|
||||
ac_fsusage_space=yes)
|
||||
ac_fsusage_space=yes])
|
||||
fi
|
||||
|
||||
AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
|
||||
|
|
@ -246,8 +249,8 @@ choke -- this is a workaround for a Sun-specific problem
|
|||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/vfs.h>]],
|
||||
[[struct statfs t; long c = *(t.f_spare);
|
||||
if (c) return 0;]])],
|
||||
[[struct statfs t; long c = *(t.f_spare);
|
||||
if (c) return 0;]])],
|
||||
[fu_cv_sys_truncating_statfs=yes],
|
||||
[fu_cv_sys_truncating_statfs=no])])
|
||||
if test $fu_cv_sys_truncating_statfs = yes; then
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# getaddrinfo.m4 serial 20
|
||||
dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
|
||||
# getaddrinfo.m4 serial 23
|
||||
dnl Copyright (C) 2004-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -25,7 +25,7 @@ AC_DEFUN([gl_GETADDRINFO],
|
|||
LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
|
||||
|
||||
AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [
|
||||
AC_TRY_LINK([
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
|
|
@ -34,21 +34,21 @@ AC_DEFUN([gl_GETADDRINFO],
|
|||
#include <netdb.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
], [getaddrinfo("", "", NULL, NULL);],
|
||||
]], [[getaddrinfo("", "", NULL, NULL);]])],
|
||||
[gl_cv_func_getaddrinfo=yes],
|
||||
[gl_cv_func_getaddrinfo=no])])
|
||||
if test $gl_cv_func_getaddrinfo = no; then
|
||||
AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32],
|
||||
gl_cv_w32_getaddrinfo, [
|
||||
gl_cv_w32_getaddrinfo, [
|
||||
gl_cv_w32_getaddrinfo=no
|
||||
am_save_LIBS="$LIBS"
|
||||
LIBS="$LIBS -lws2_32"
|
||||
AC_TRY_LINK([
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
], [getaddrinfo(NULL, NULL, NULL, NULL);], gl_cv_w32_getaddrinfo=yes)
|
||||
]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], [gl_cv_w32_getaddrinfo=yes])
|
||||
LIBS="$am_save_LIBS"
|
||||
])
|
||||
if test "$gl_cv_w32_getaddrinfo" = "yes"; then
|
||||
|
|
@ -64,7 +64,7 @@ AC_DEFUN([gl_GETADDRINFO],
|
|||
# header included somehow.
|
||||
AC_CACHE_CHECK([for gai_strerror (possibly via ws2tcpip.h)],
|
||||
gl_cv_func_gai_strerror, [
|
||||
AC_TRY_LINK([
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
|
|
@ -76,7 +76,7 @@ AC_DEFUN([gl_GETADDRINFO],
|
|||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
], [gai_strerror (NULL);],
|
||||
]], [[gai_strerror (NULL);]])],
|
||||
[gl_cv_func_gai_strerror=yes],
|
||||
[gl_cv_func_gai_strerror=no])])
|
||||
if test $gl_cv_func_gai_strerror = no; then
|
||||
|
|
@ -96,6 +96,7 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
|
|||
AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
|
||||
AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB
|
||||
AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB
|
||||
AC_REQUIRE([gl_FUNC_INET_NTOP]) dnl for INET_NTOP_LIB
|
||||
AC_REQUIRE([AC_C_RESTRICT])
|
||||
AC_REQUIRE([gl_SOCKET_FAMILIES])
|
||||
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
|
||||
|
|
@ -163,4 +164,10 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
|
|||
*" $SERVENT_LIB "*) ;;
|
||||
*) GETADDRINFO_LIB="$GETADDRINFO_LIB $SERVENT_LIB" ;;
|
||||
esac
|
||||
|
||||
dnl Append $INET_NTOP_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
|
||||
case " $GETADDRINFO_LIB " in
|
||||
*" $INET_NTOP_LIB "*) ;;
|
||||
*) GETADDRINFO_LIB="$GETADDRINFO_LIB $INET_NTOP_LIB" ;;
|
||||
esac
|
||||
])
|
||||
|
|
|
|||
15
gl/m4/getdtablesize.m4
Normal file
15
gl/m4/getdtablesize.m4
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# getdtablesize.m4 serial 1
|
||||
dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_GETDTABLESIZE],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
AC_CHECK_FUNCS_ONCE([getdtablesize])
|
||||
if test $ac_cv_func_getdtablesize != yes; then
|
||||
HAVE_GETDTABLESIZE=0
|
||||
AC_LIBOBJ([getdtablesize])
|
||||
fi
|
||||
])
|
||||
|
|
@ -1,21 +1,101 @@
|
|||
# gethostname.m4 serial 5
|
||||
dnl Copyright (C) 2002, 2008, 2009 Free Software Foundation, Inc.
|
||||
# gethostname.m4 serial 9
|
||||
dnl Copyright (C) 2002, 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# Ensure
|
||||
# - the gethostname() function,
|
||||
# - the HOST_NAME_MAX macro in <limits.h>.
|
||||
AC_DEFUN([gl_FUNC_GETHOSTNAME],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
gl_PREREQ_SYS_H_WINSOCK2
|
||||
AC_REPLACE_FUNCS([gethostname])
|
||||
if test $ac_cv_func_gethostname = no; then
|
||||
|
||||
dnl Where is gethostname() defined?
|
||||
dnl - On native Windows, it is in ws2_32.dll.
|
||||
dnl - Otherwise is is in libc.
|
||||
GETHOSTNAME_LIB=
|
||||
AC_CHECK_FUNCS([gethostname], , [
|
||||
AC_CACHE_CHECK([for gethostname in winsock2.h and -lws2_32],
|
||||
[gl_cv_w32_gethostname],
|
||||
[gl_cv_w32_gethostname=no
|
||||
gl_save_LIBS="$LIBS"
|
||||
LIBS="$LIBS -lws2_32"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
]], [[gethostname(NULL, 0);]])], [gl_cv_w32_gethostname=yes])
|
||||
LIBS="$gl_save_LIBS"
|
||||
])
|
||||
if test "$gl_cv_w32_gethostname" = "yes"; then
|
||||
GETHOSTNAME_LIB="-lws2_32"
|
||||
fi
|
||||
])
|
||||
AC_SUBST([GETHOSTNAME_LIB])
|
||||
|
||||
if test "$ac_cv_func_gethostname" = no; then
|
||||
AC_LIBOBJ([gethostname])
|
||||
HAVE_GETHOSTNAME=0
|
||||
gl_PREREQ_GETHOSTNAME
|
||||
fi
|
||||
|
||||
dnl Also provide HOST_NAME_MAX when <limits.h> lacks it.
|
||||
dnl - On most Unix systems, use MAXHOSTNAMELEN from <sys/param.h> instead.
|
||||
dnl - On Solaris, Cygwin, BeOS, use MAXHOSTNAMELEN from <netdb.h> instead.
|
||||
dnl - On mingw, use 256, because
|
||||
dnl <http://msdn.microsoft.com/en-us/library/ms738527.aspx> says:
|
||||
dnl "if a buffer of 256 bytes is passed in the name parameter and
|
||||
dnl the namelen parameter is set to 256, the buffer size will always
|
||||
dnl be adequate."
|
||||
dnl With this, there is no need to use sysconf (_SC_HOST_NAME_MAX), which
|
||||
dnl is not a compile-time constant.
|
||||
dnl We cannot override <limits.h> using the usual technique, because
|
||||
dnl gl_CHECK_NEXT_HEADERS does not work for <limits.h>. Therefore retrieve
|
||||
dnl the value of HOST_NAME_MAX at configure time.
|
||||
AC_CHECK_HEADERS_ONCE([sys/param.h])
|
||||
AC_CHECK_HEADERS_ONCE([sys/socket.h])
|
||||
AC_CHECK_HEADERS_ONCE([netdb.h])
|
||||
AC_CACHE_CHECK([for HOST_NAME_MAX], [gl_cv_decl_HOST_NAME_MAX], [
|
||||
gl_cv_decl_HOST_NAME_MAX=
|
||||
AC_EGREP_CPP([lucky], [
|
||||
#include <limits.h>
|
||||
#ifdef HOST_NAME_MAX
|
||||
lucky
|
||||
#endif
|
||||
], [gl_cv_decl_HOST_NAME_MAX=yes])
|
||||
if test -z "$gl_cv_decl_HOST_NAME_MAX"; then
|
||||
dnl It's not defined in <limits.h>. Substitute it.
|
||||
if test "$gl_cv_w32_gethostname" = yes; then
|
||||
dnl mingw.
|
||||
gl_cv_decl_HOST_NAME_MAX=256
|
||||
else
|
||||
_AC_COMPUTE_INT([MAXHOSTNAMELEN], [gl_cv_decl_HOST_NAME_MAX], [
|
||||
#include <sys/types.h>
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#if HAVE_NETDB_H
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
])
|
||||
fi
|
||||
fi
|
||||
])
|
||||
if test "$gl_cv_decl_HOST_NAME_MAX" != yes; then
|
||||
AC_DEFINE_UNQUOTED([HOST_NAME_MAX], [$gl_cv_decl_HOST_NAME_MAX],
|
||||
[Define HOST_NAME_MAX when <limits.h> does not define it.])
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/gethostname.c.
|
||||
AC_DEFUN([gl_PREREQ_GETHOSTNAME], [
|
||||
AC_CHECK_FUNCS([uname])
|
||||
if test "$gl_cv_w32_gethostname" != "yes"; then
|
||||
AC_CHECK_FUNCS([uname])
|
||||
fi
|
||||
])
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Check for getloadavg.
|
||||
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2002, 2003,
|
||||
# 2006, 2008, 2009 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2010 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
|
@ -60,17 +60,17 @@ if test $gl_have_func = no; then
|
|||
gl_getloadavg_LIBS=$LIBS
|
||||
LIBS="-L/usr/local/lib $LIBS"
|
||||
AC_CHECK_LIB([getloadavg], [getloadavg],
|
||||
[LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS])
|
||||
[LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS])
|
||||
fi
|
||||
|
||||
# Make sure it is really in the library, if we think we found it,
|
||||
# otherwise set up the replacement function.
|
||||
AC_CHECK_FUNCS([getloadavg], [],
|
||||
[gl_PREREQ_GETLOADAVG])
|
||||
[gl_PREREQ_GETLOADAVG])
|
||||
|
||||
# Some definitions of getloadavg require that the program be installed setgid.
|
||||
AC_CACHE_CHECK([whether getloadavg requires setgid],
|
||||
gl_cv_func_getloadavg_setgid,
|
||||
gl_cv_func_getloadavg_setgid,
|
||||
[AC_EGREP_CPP([Yowza Am I SETGID yet],
|
||||
[#define CONFIGURING_GETLOADAVG
|
||||
#include "$srcdir/$1/getloadavg.c"
|
||||
|
|
@ -78,13 +78,13 @@ AC_CACHE_CHECK([whether getloadavg requires setgid],
|
|||
Yowza Am I SETGID yet
|
||||
#endif
|
||||
],
|
||||
gl_cv_func_getloadavg_setgid=yes,
|
||||
gl_cv_func_getloadavg_setgid=no)])
|
||||
gl_cv_func_getloadavg_setgid=yes,
|
||||
gl_cv_func_getloadavg_setgid=no)])
|
||||
if test $gl_cv_func_getloadavg_setgid = yes; then
|
||||
NEED_SETGID=true
|
||||
AC_DEFINE([GETLOADAVG_PRIVILEGED], [1],
|
||||
[Define to 1 if the `getloadavg' function needs to be run setuid
|
||||
or setgid.])
|
||||
[Define to 1 if the `getloadavg' function needs to be run setuid
|
||||
or setgid.])
|
||||
else
|
||||
NEED_SETGID=false
|
||||
fi
|
||||
|
|
@ -98,8 +98,8 @@ if test $gl_cv_func_getloadavg_setgid = yes; then
|
|||
test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
|
||||
gl_cv_group_kmem=`echo $ac_ls_output \
|
||||
| sed -ne ['s/[ ][ ]*/ /g
|
||||
s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/
|
||||
/ /s/.* //;p']`
|
||||
s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/
|
||||
/ /s/.* //;p']`
|
||||
])
|
||||
AC_SUBST([KMEM_GROUP], [$gl_cv_group_kmem])dnl
|
||||
fi
|
||||
|
|
@ -154,8 +154,8 @@ if test $gl_have_func = no; then
|
|||
[gl_have_func=yes
|
||||
AC_DEFINE([UMAX], [1], [Define to 1 for Encore UMAX.])
|
||||
AC_DEFINE([UMAX4_3], [1],
|
||||
[Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
|
||||
instead of <sys/cpustats.h>.])])
|
||||
[Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
|
||||
instead of <sys/cpustats.h>.])])
|
||||
fi
|
||||
|
||||
if test $gl_have_func = no; then
|
||||
|
|
@ -169,10 +169,19 @@ fi
|
|||
|
||||
AC_CHECK_HEADERS([nlist.h],
|
||||
[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
|
||||
[AC_DEFINE([NLIST_NAME_UNION], [1],
|
||||
[Define to 1 if your `struct nlist' has an
|
||||
`n_un' member. Obsolete, depend on
|
||||
`HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
|
||||
[@%:@include <nlist.h>])
|
||||
[AC_DEFINE([NLIST_NAME_UNION], [1],
|
||||
[Define to 1 if your `struct nlist' has an
|
||||
`n_un' member. Obsolete, depend on
|
||||
`HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
|
||||
[@%:@include <nlist.h>])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
|
||||
[[struct nlist x;
|
||||
#ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
|
||||
x.n_un.n_name = "";
|
||||
#else
|
||||
x.n_name = "";
|
||||
#endif]])],
|
||||
[AC_DEFINE([N_NAME_POINTER], [1],
|
||||
[Define to 1 if the nlist n_name member is a pointer])])
|
||||
])dnl
|
||||
])# gl_PREREQ_GETLOADAVG
|
||||
|
|
|
|||
341
gl/m4/getopt.m4
341
gl/m4/getopt.m4
|
|
@ -1,21 +1,294 @@
|
|||
# getopt.m4 serial 14
|
||||
dnl Copyright (C) 2002-2006, 2008 Free Software Foundation, Inc.
|
||||
# getopt.m4 serial 28
|
||||
dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# The getopt module assume you want GNU getopt, with getopt_long etc,
|
||||
# rather than vanilla POSIX getopt. This means your code should
|
||||
# always include <getopt.h> for the getopt prototypes.
|
||||
|
||||
AC_DEFUN([gl_GETOPT_SUBSTITUTE],
|
||||
# Request a POSIX compliant getopt function.
|
||||
AC_DEFUN([gl_FUNC_GETOPT_POSIX],
|
||||
[
|
||||
m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX])
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
gl_GETOPT_IFELSE([
|
||||
gl_REPLACE_GETOPT
|
||||
],
|
||||
[])
|
||||
])
|
||||
|
||||
# Request a POSIX compliant getopt function with GNU extensions (such as
|
||||
# options with optional arguments) and the functions getopt_long,
|
||||
# getopt_long_only.
|
||||
AC_DEFUN([gl_FUNC_GETOPT_GNU],
|
||||
[
|
||||
m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
|
||||
|
||||
AC_REQUIRE([gl_FUNC_GETOPT_POSIX])
|
||||
])
|
||||
|
||||
# Request the gnulib implementation of the getopt functions unconditionally.
|
||||
# argp.m4 uses this.
|
||||
AC_DEFUN([gl_REPLACE_GETOPT],
|
||||
[
|
||||
dnl Arrange for getopt.h to be created.
|
||||
gl_GETOPT_SUBSTITUTE_HEADER
|
||||
dnl Arrange for unistd.h to include getopt.h.
|
||||
GNULIB_UNISTD_H_GETOPT=1
|
||||
dnl Arrange to compile the getopt implementation.
|
||||
AC_LIBOBJ([getopt])
|
||||
AC_LIBOBJ([getopt1])
|
||||
gl_GETOPT_SUBSTITUTE_HEADER
|
||||
gl_PREREQ_GETOPT
|
||||
])
|
||||
|
||||
# emacs' configure.in uses this.
|
||||
AC_DEFUN([gl_GETOPT_IFELSE],
|
||||
[
|
||||
AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
|
||||
AS_IF([test -n "$gl_replace_getopt"], [$1], [$2])
|
||||
])
|
||||
|
||||
# Determine whether to replace the entire getopt facility.
|
||||
AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
|
||||
[
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
|
||||
dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt.
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
|
||||
gl_CHECK_NEXT_HEADERS([getopt.h])
|
||||
AC_CHECK_HEADERS_ONCE([getopt.h])
|
||||
if test $ac_cv_header_getopt_h = yes; then
|
||||
HAVE_GETOPT_H=1
|
||||
else
|
||||
HAVE_GETOPT_H=0
|
||||
fi
|
||||
AC_SUBST([HAVE_GETOPT_H])
|
||||
|
||||
gl_replace_getopt=
|
||||
|
||||
dnl Test whether <getopt.h> is available.
|
||||
if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
|
||||
AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes])
|
||||
fi
|
||||
|
||||
dnl Test whether the function getopt_long is available.
|
||||
if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
|
||||
AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes])
|
||||
fi
|
||||
|
||||
dnl BSD getopt_long uses an incompatible method to reset option processing.
|
||||
dnl Existence of the variable, in and of itself, is not a reason to replace
|
||||
dnl getopt, but knowledge of the variable is needed to determine how to
|
||||
dnl reset and whether a reset reparses the environment.
|
||||
dnl Solaris supports neither optreset nor optind=0, but keeps no state that
|
||||
dnl needs a reset beyond setting optind=1; detect Solaris by getopt_clip.
|
||||
if test -z "$gl_replace_getopt"; then
|
||||
AC_CHECK_DECLS([optreset], [],
|
||||
[AC_CHECK_DECLS([getopt_clip], [], [],
|
||||
[[#include <getopt.h>]])
|
||||
],
|
||||
[[#include <getopt.h>]])
|
||||
fi
|
||||
|
||||
dnl mingw's getopt (in libmingwex.a) does weird things when the options
|
||||
dnl strings starts with '+' and it's not the first call. Some internal state
|
||||
dnl is left over from earlier calls, and neither setting optind = 0 nor
|
||||
dnl setting optreset = 1 get rid of this internal state.
|
||||
dnl POSIX is silent on optind vs. optreset, so we allow either behavior.
|
||||
dnl POSIX 2008 does not specify leading '+' behavior, but see
|
||||
dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on
|
||||
dnl the next version of POSIX. For now, we only guarantee leading '+'
|
||||
dnl behavior with getopt-gnu.
|
||||
if test -z "$gl_replace_getopt"; then
|
||||
AC_CACHE_CHECK([whether getopt is POSIX compatible],
|
||||
[gl_cv_func_getopt_posix],
|
||||
[
|
||||
dnl This test fails on mingw and succeeds on all other platforms.
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !HAVE_DECL_OPTRESET && !HAVE_DECL_GETOPT_CLIP
|
||||
# define OPTIND_MIN 0
|
||||
#else
|
||||
# define OPTIND_MIN 1
|
||||
#endif
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
{
|
||||
int argc = 0;
|
||||
char *argv[10];
|
||||
int c;
|
||||
|
||||
argv[argc++] = "program";
|
||||
argv[argc++] = "-a";
|
||||
argv[argc++] = "foo";
|
||||
argv[argc++] = "bar";
|
||||
argv[argc] = NULL;
|
||||
optind = OPTIND_MIN;
|
||||
opterr = 0;
|
||||
|
||||
c = getopt (argc, argv, "ab");
|
||||
if (!(c == 'a'))
|
||||
return 1;
|
||||
c = getopt (argc, argv, "ab");
|
||||
if (!(c == -1))
|
||||
return 2;
|
||||
if (!(optind == 2))
|
||||
return 3;
|
||||
}
|
||||
/* Some internal state exists at this point. */
|
||||
{
|
||||
int argc = 0;
|
||||
char *argv[10];
|
||||
int c;
|
||||
|
||||
argv[argc++] = "program";
|
||||
argv[argc++] = "donald";
|
||||
argv[argc++] = "-p";
|
||||
argv[argc++] = "billy";
|
||||
argv[argc++] = "duck";
|
||||
argv[argc++] = "-a";
|
||||
argv[argc++] = "bar";
|
||||
argv[argc] = NULL;
|
||||
optind = OPTIND_MIN;
|
||||
opterr = 0;
|
||||
|
||||
c = getopt (argc, argv, "+abp:q:");
|
||||
if (!(c == -1))
|
||||
return 4;
|
||||
if (!(strcmp (argv[0], "program") == 0))
|
||||
return 5;
|
||||
if (!(strcmp (argv[1], "donald") == 0))
|
||||
return 6;
|
||||
if (!(strcmp (argv[2], "-p") == 0))
|
||||
return 7;
|
||||
if (!(strcmp (argv[3], "billy") == 0))
|
||||
return 8;
|
||||
if (!(strcmp (argv[4], "duck") == 0))
|
||||
return 9;
|
||||
if (!(strcmp (argv[5], "-a") == 0))
|
||||
return 10;
|
||||
if (!(strcmp (argv[6], "bar") == 0))
|
||||
return 11;
|
||||
if (!(optind == 1))
|
||||
return 12;
|
||||
}
|
||||
/* Detect MacOS 10.5 bug. */
|
||||
{
|
||||
char *argv[3] = { "program", "-ab", NULL };
|
||||
optind = OPTIND_MIN;
|
||||
opterr = 0;
|
||||
if (getopt (2, argv, "ab:") != 'a')
|
||||
return 13;
|
||||
if (getopt (2, argv, "ab:") != '?')
|
||||
return 14;
|
||||
if (optopt != 'b')
|
||||
return 15;
|
||||
if (optind != 2)
|
||||
return 16;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
]])],
|
||||
[gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no],
|
||||
[case "$host_os" in
|
||||
mingw*) gl_cv_func_getopt_posix="guessing no";;
|
||||
darwin*) gl_cv_func_getopt_posix="guessing no";;
|
||||
*) gl_cv_func_getopt_posix="guessing yes";;
|
||||
esac
|
||||
])
|
||||
])
|
||||
case "$gl_cv_func_getopt_posix" in
|
||||
*no) gl_replace_getopt=yes ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
|
||||
AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_getopt_gnu],
|
||||
[# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the
|
||||
# optstring is necessary for programs like m4 that have POSIX-mandated
|
||||
# semantics for supporting options interspersed with files.
|
||||
# Also, since getopt_long is a GNU extension, we require optind=0.
|
||||
gl_had_POSIXLY_CORRECT=${POSIXLY_CORRECT:+yes}
|
||||
POSIXLY_CORRECT=1
|
||||
export POSIXLY_CORRECT
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([[#include <getopt.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
]], [[
|
||||
/* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
|
||||
and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
|
||||
OSF/1 5.1, Solaris 10. */
|
||||
{
|
||||
char *myargv[3];
|
||||
myargv[0] = "conftest";
|
||||
myargv[1] = "-+";
|
||||
myargv[2] = 0;
|
||||
opterr = 0;
|
||||
if (getopt (2, myargv, "+a") != '?')
|
||||
return 1;
|
||||
}
|
||||
/* This code succeeds on glibc 2.8, mingw,
|
||||
and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
|
||||
IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */
|
||||
{
|
||||
char *argv[] = { "program", "-p", "foo", "bar", NULL };
|
||||
|
||||
optind = 1;
|
||||
if (getopt (4, argv, "p::") != 'p')
|
||||
return 2;
|
||||
if (optarg != NULL)
|
||||
return 3;
|
||||
if (getopt (4, argv, "p::") != -1)
|
||||
return 4;
|
||||
if (optind != 2)
|
||||
return 5;
|
||||
}
|
||||
/* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */
|
||||
{
|
||||
char *argv[] = { "program", "foo", "-p", NULL };
|
||||
optind = 0;
|
||||
if (getopt (3, argv, "-p") != 1)
|
||||
return 6;
|
||||
if (getopt (3, argv, "-p") != 'p')
|
||||
return 7;
|
||||
}
|
||||
/* This code fails on glibc 2.11. */
|
||||
{
|
||||
char *argv[] = { "program", "-b", "-a", NULL };
|
||||
optind = opterr = 0;
|
||||
if (getopt (3, argv, "+:a:b") != 'b')
|
||||
return 8;
|
||||
if (getopt (3, argv, "+:a:b") != ':')
|
||||
return 9;
|
||||
}
|
||||
return 0;
|
||||
]])],
|
||||
[gl_cv_func_getopt_gnu=yes],
|
||||
[gl_cv_func_getopt_gnu=no],
|
||||
[dnl Cross compiling. Guess based on host and declarations.
|
||||
case $host_os:$ac_cv_have_decl_optreset in
|
||||
*-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;;
|
||||
*:yes) gl_cv_func_getopt_gnu=no;;
|
||||
*) gl_cv_func_getopt_gnu=yes;;
|
||||
esac
|
||||
])
|
||||
if test "$gl_had_POSIXLY_CORRECT" != yes; then
|
||||
AS_UNSET([POSIXLY_CORRECT])
|
||||
fi
|
||||
])
|
||||
if test "$gl_cv_func_getopt_gnu" = "no"; then
|
||||
gl_replace_getopt=yes
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
# emacs' configure.in uses this.
|
||||
AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
|
||||
[
|
||||
GETOPT_H=getopt.h
|
||||
|
|
@ -25,58 +298,8 @@ AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
|
|||
AC_SUBST([GETOPT_H])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
|
||||
[
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
|
||||
fi
|
||||
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
|
||||
fi
|
||||
|
||||
dnl BSD getopt_long uses an incompatible method to reset option processing,
|
||||
dnl and (as of 2004-10-15) mishandles optional option-arguments.
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
|
||||
fi
|
||||
|
||||
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
|
||||
dnl option string (as of 2005-05-05).
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([[#include <getopt.h>]],
|
||||
[[
|
||||
char *myargv[3];
|
||||
myargv[0] = "conftest";
|
||||
myargv[1] = "-+";
|
||||
myargv[2] = 0;
|
||||
return getopt (2, myargv, "+a") != '?';
|
||||
]])],
|
||||
[gl_cv_func_gnu_getopt=yes],
|
||||
[gl_cv_func_gnu_getopt=no],
|
||||
[dnl cross compiling - pessimistically guess based on decls
|
||||
dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
|
||||
dnl option string (as of 2005-05-05).
|
||||
AC_CHECK_DECL([getopt_clip],
|
||||
[gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes],
|
||||
[#include <getopt.h>])])])
|
||||
if test "$gl_cv_func_gnu_getopt" = "no"; then
|
||||
GETOPT_H=getopt.h
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT_IFELSE],
|
||||
[
|
||||
AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
|
||||
AS_IF([test -n "$GETOPT_H"], [$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_GETOPT], [gl_GETOPT_IFELSE([gl_GETOPT_SUBSTITUTE])])
|
||||
|
||||
# Prerequisites of lib/getopt*.
|
||||
# emacs' configure.in uses this.
|
||||
AC_DEFUN([gl_PREREQ_GETOPT],
|
||||
[
|
||||
AC_CHECK_DECLS_ONCE([getenv])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# gettext.m4 serial 62 (gettext-0.18)
|
||||
dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
|
||||
# gettext.m4 serial 63 (gettext-0.18)
|
||||
dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -15,7 +15,7 @@ dnl They are *not* in the public domain.
|
|||
|
||||
dnl Authors:
|
||||
dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
|
||||
dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006.
|
||||
dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010.
|
||||
|
||||
dnl Macro to add for using GNU gettext.
|
||||
|
||||
|
|
@ -60,6 +60,8 @@ AC_DEFUN([AM_GNU_GETTEXT],
|
|||
ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
|
||||
[errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
|
||||
])])])])])
|
||||
ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
|
||||
[AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])])
|
||||
ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
|
||||
[errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
|
||||
])])])])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# glibc21.m4 serial 4
|
||||
dnl Copyright (C) 2000-2002, 2004, 2008 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -12,16 +12,16 @@ AC_DEFUN([gl_GLIBC21],
|
|||
AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
|
||||
[ac_cv_gnu_library_2_1],
|
||||
[AC_EGREP_CPP([Lucky GNU user],
|
||||
[
|
||||
[
|
||||
#include <features.h>
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
|
||||
Lucky GNU user
|
||||
#endif
|
||||
#endif
|
||||
],
|
||||
[ac_cv_gnu_library_2_1=yes],
|
||||
[ac_cv_gnu_library_2_1=no])
|
||||
],
|
||||
[ac_cv_gnu_library_2_1=yes],
|
||||
[ac_cv_gnu_library_2_1=no])
|
||||
]
|
||||
)
|
||||
AC_SUBST([GLIBC21])
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2002-2009 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software, distributed under the terms of the GNU
|
||||
# General Public License. As a special exception to the GNU General
|
||||
|
|
@ -15,13 +15,15 @@
|
|||
|
||||
|
||||
# Specification in the form of a command-line invocation:
|
||||
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex timegm vasprintf vsnprintf
|
||||
# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex setenv strsep timegm unsetenv vasprintf vsnprintf
|
||||
|
||||
# Specification in the form of a few gnulib-tool.m4 macro invocations:
|
||||
gl_LOCAL_DIR([])
|
||||
gl_MODULES([
|
||||
base64
|
||||
crypto/sha1
|
||||
dirname
|
||||
environ
|
||||
floorf
|
||||
fsusage
|
||||
getaddrinfo
|
||||
|
|
@ -31,7 +33,10 @@ gl_MODULES([
|
|||
gettext
|
||||
mountlist
|
||||
regex
|
||||
setenv
|
||||
strsep
|
||||
timegm
|
||||
unsetenv
|
||||
vasprintf
|
||||
vsnprintf
|
||||
])
|
||||
|
|
@ -45,3 +50,4 @@ gl_LIB([libgnu])
|
|||
gl_MAKEFILE_NAME([])
|
||||
gl_MACRO_PREFIX([gl])
|
||||
gl_PO_DOMAIN([])
|
||||
gl_VC_FILES([false])
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# gnulib-common.m4 serial 11
|
||||
dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
|
||||
# gnulib-common.m4 serial 20
|
||||
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
@ -23,23 +23,83 @@ AC_DEFUN([gl_COMMON_BODY], [
|
|||
# define __GNUC_STDC_INLINE__ 1
|
||||
#endif])
|
||||
AH_VERBATIM([unused_parameter],
|
||||
[/* Define as a marker that can be attached to function parameter declarations
|
||||
for parameters that are not used. This helps to reduce warnings, such as
|
||||
from GCC -Wunused-parameter. */
|
||||
[/* Define as a marker that can be attached to declarations that might not
|
||||
be used. This helps to reduce warnings, such as from
|
||||
GCC -Wunused-parameter. */
|
||||
#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
|
||||
# define _UNUSED_PARAMETER_ __attribute__ ((__unused__))
|
||||
# define _GL_UNUSED __attribute__ ((__unused__))
|
||||
#else
|
||||
# define _UNUSED_PARAMETER_
|
||||
# define _GL_UNUSED
|
||||
#endif
|
||||
/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
|
||||
is a misnomer outside of parameter lists. */
|
||||
#define _UNUSED_PARAMETER_ _GL_UNUSED
|
||||
])
|
||||
dnl Preparation for running test programs:
|
||||
dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
|
||||
dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
|
||||
dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
|
||||
LIBC_FATAL_STDERR_=1
|
||||
export LIBC_FATAL_STDERR_
|
||||
])
|
||||
|
||||
# gl_MODULE_INDICATOR_CONDITION
|
||||
# expands to a C preprocessor expression that evaluates to 1 or 0, depending
|
||||
# whether a gnulib module that has been requested shall be considered present
|
||||
# or not.
|
||||
AC_DEFUN([gl_MODULE_INDICATOR_CONDITION], [1])
|
||||
|
||||
# gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
|
||||
# sets the shell variable that indicates the presence of the given module to
|
||||
# a C preprocessor expression that will evaluate to 1.
|
||||
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
|
||||
[
|
||||
GNULIB_[]m4_translit([[$1]],
|
||||
[abcdefghijklmnopqrstuvwxyz./-],
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=gl_MODULE_INDICATOR_CONDITION
|
||||
])
|
||||
|
||||
# gl_MODULE_INDICATOR([modulename])
|
||||
# defines a C macro indicating the presence of the given module.
|
||||
# defines a C macro indicating the presence of the given module
|
||||
# in a location where it can be used.
|
||||
# | Value | Value |
|
||||
# | in lib/ | in tests/ |
|
||||
# --------------------------------------------+---------+-----------+
|
||||
# Module present among main modules: | 1 | 1 |
|
||||
# --------------------------------------------+---------+-----------+
|
||||
# Module present among tests-related modules: | 0 | 1 |
|
||||
# --------------------------------------------+---------+-----------+
|
||||
# Module not present at all: | 0 | 0 |
|
||||
# --------------------------------------------+---------+-----------+
|
||||
AC_DEFUN([gl_MODULE_INDICATOR],
|
||||
[
|
||||
AC_DEFINE([GNULIB_]translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
|
||||
[Define to 1 when using the gnulib module ]$1[.])
|
||||
AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]],
|
||||
[abcdefghijklmnopqrstuvwxyz./-],
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]),
|
||||
[gl_MODULE_INDICATOR_CONDITION],
|
||||
[Define to a C preprocessor expression that evaluates to 1 or 0,
|
||||
depending whether the gnulib module $1 shall be considered present.])
|
||||
])
|
||||
|
||||
# gl_MODULE_INDICATOR_FOR_TESTS([modulename])
|
||||
# defines a C macro indicating the presence of the given module
|
||||
# in lib or tests. This is useful to determine whether the module
|
||||
# should be tested.
|
||||
# | Value | Value |
|
||||
# | in lib/ | in tests/ |
|
||||
# --------------------------------------------+---------+-----------+
|
||||
# Module present among main modules: | 1 | 1 |
|
||||
# --------------------------------------------+---------+-----------+
|
||||
# Module present among tests-related modules: | 1 | 1 |
|
||||
# --------------------------------------------+---------+-----------+
|
||||
# Module not present at all: | 0 | 0 |
|
||||
# --------------------------------------------+---------+-----------+
|
||||
AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
|
||||
[
|
||||
AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]],
|
||||
[abcdefghijklmnopqrstuvwxyz./-],
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
|
||||
[Define to 1 when the gnulib module $1 should be tested.])
|
||||
])
|
||||
|
||||
# m4_foreach_w
|
||||
|
|
@ -49,10 +109,25 @@ m4_ifndef([m4_foreach_w],
|
|||
[m4_define([m4_foreach_w],
|
||||
[m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
|
||||
|
||||
# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
|
||||
# ----------------------------------------------------
|
||||
# Backport of autoconf-2.63b's macro.
|
||||
# Remove this macro when we can assume autoconf >= 2.64.
|
||||
m4_ifndef([AS_VAR_IF],
|
||||
[m4_define([AS_VAR_IF],
|
||||
[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
|
||||
|
||||
# AC_PROG_MKDIR_P
|
||||
# is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
|
||||
# Remove this macro when we can assume autoconf >= 2.60.
|
||||
m4_ifdef([AC_PROG_MKDIR_P], [], [
|
||||
# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
|
||||
# for interoperability with automake-1.9.6 from autoconf-2.62.
|
||||
# Remove this macro when we can assume autoconf >= 2.62 or
|
||||
# autoconf >= 2.60 && automake >= 1.10.
|
||||
m4_ifdef([AC_PROG_MKDIR_P], [
|
||||
dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
|
||||
m4_define([AC_PROG_MKDIR_P],
|
||||
m4_defn([AC_PROG_MKDIR_P])[
|
||||
AC_SUBST([MKDIR_P])])], [
|
||||
dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
|
||||
AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
|
||||
[AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
|
||||
MKDIR_P='$(mkdir_p)'
|
||||
|
|
@ -63,6 +138,7 @@ m4_ifdef([AC_PROG_MKDIR_P], [], [
|
|||
# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
|
||||
# works.
|
||||
# This definition can be removed once autoconf >= 2.62 can be assumed.
|
||||
m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[
|
||||
AC_DEFUN([AC_C_RESTRICT],
|
||||
[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
|
||||
[ac_cv_c_restrict=no
|
||||
|
|
@ -70,13 +146,13 @@ AC_DEFUN([AC_C_RESTRICT],
|
|||
for ac_kw in __restrict __restrict__ _Restrict restrict; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
||||
[[typedef int * int_ptr;
|
||||
int foo (int_ptr $ac_kw ip) {
|
||||
return ip[0];
|
||||
int foo (int_ptr $ac_kw ip) {
|
||||
return ip[0];
|
||||
}]],
|
||||
[[int s[1];
|
||||
int * $ac_kw t = s;
|
||||
t[0] = 0;
|
||||
return foo(t)]])],
|
||||
int * $ac_kw t = s;
|
||||
t[0] = 0;
|
||||
return foo(t)]])],
|
||||
[ac_cv_c_restrict=$ac_kw])
|
||||
test "$ac_cv_c_restrict" != no && break
|
||||
done
|
||||
|
|
@ -100,6 +176,7 @@ AC_DEFUN([AC_C_RESTRICT],
|
|||
*) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
|
||||
esac
|
||||
])
|
||||
])
|
||||
|
||||
# gl_BIGENDIAN
|
||||
# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# DO NOT EDIT! GENERATED AUTOMATICALLY!
|
||||
# Copyright (C) 2002-2009 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software, distributed under the terms of the GNU
|
||||
# General Public License. As a special exception to the GNU General
|
||||
|
|
@ -25,7 +25,113 @@ AC_DEFUN([gl_EARLY],
|
|||
m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
|
||||
m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
|
||||
AC_REQUIRE([AC_PROG_RANLIB])
|
||||
# Code from module alignof:
|
||||
# Code from module alloca-opt:
|
||||
# Code from module arg-nonnull:
|
||||
# Code from module arpa_inet:
|
||||
# Code from module base64:
|
||||
# Code from module btowc:
|
||||
# Code from module c++defs:
|
||||
# Code from module c-strtod:
|
||||
# Code from module cloexec:
|
||||
# Code from module close-hook:
|
||||
# Code from module configmake:
|
||||
# Code from module crypto/sha1:
|
||||
# Code from module dirname:
|
||||
# Code from module dirname-lgpl:
|
||||
# Code from module double-slash-root:
|
||||
# Code from module dup2:
|
||||
# Code from module environ:
|
||||
# Code from module errno:
|
||||
# Code from module error:
|
||||
# Code from module exitfail:
|
||||
# Code from module extensions:
|
||||
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
||||
# Code from module fcntl:
|
||||
# Code from module fcntl-h:
|
||||
# Code from module fcntl-safer:
|
||||
# Code from module float:
|
||||
# Code from module floorf:
|
||||
# Code from module fsusage:
|
||||
# Code from module full-read:
|
||||
# Code from module full-write:
|
||||
# Code from module getaddrinfo:
|
||||
# Code from module getdtablesize:
|
||||
# Code from module gethostname:
|
||||
# Code from module getloadavg:
|
||||
# Code from module getopt:
|
||||
# Code from module getopt-gnu:
|
||||
# Code from module getopt-posix:
|
||||
# Code from module gettext:
|
||||
# Code from module gettext-h:
|
||||
# Code from module havelib:
|
||||
# Code from module hostent:
|
||||
# Code from module include_next:
|
||||
# Code from module inet_ntop:
|
||||
# Code from module inline:
|
||||
# Code from module intprops:
|
||||
# Code from module langinfo:
|
||||
# Code from module localcharset:
|
||||
# Code from module locale:
|
||||
# Code from module malloc:
|
||||
# Code from module malloc-posix:
|
||||
# Code from module malloca:
|
||||
# Code from module math:
|
||||
# Code from module mbrtowc:
|
||||
# Code from module mbsinit:
|
||||
# Code from module memchr:
|
||||
# Code from module mktime:
|
||||
# Code from module mountlist:
|
||||
# Code from module multiarch:
|
||||
# Code from module netdb:
|
||||
# Code from module netinet_in:
|
||||
# Code from module nl_langinfo:
|
||||
# Code from module open:
|
||||
# Code from module regex:
|
||||
# Code from module safe-read:
|
||||
# Code from module safe-write:
|
||||
# Code from module servent:
|
||||
# Code from module setenv:
|
||||
# Code from module size_max:
|
||||
# Code from module snprintf:
|
||||
# Code from module sockets:
|
||||
# Code from module socklen:
|
||||
# Code from module ssize_t:
|
||||
# Code from module stat:
|
||||
# Code from module stdbool:
|
||||
# Code from module stddef:
|
||||
# Code from module stdint:
|
||||
# Code from module stdio:
|
||||
# Code from module stdlib:
|
||||
# Code from module strdup-posix:
|
||||
# Code from module streq:
|
||||
# Code from module strerror:
|
||||
# Code from module string:
|
||||
# Code from module strndup:
|
||||
# Code from module strnlen:
|
||||
# Code from module strsep:
|
||||
# Code from module strstr-simple:
|
||||
# Code from module sys_socket:
|
||||
# Code from module sys_stat:
|
||||
# Code from module time:
|
||||
# Code from module time_r:
|
||||
# Code from module timegm:
|
||||
# Code from module unistd:
|
||||
# Code from module unistd-safer:
|
||||
# Code from module unsetenv:
|
||||
# Code from module vasnprintf:
|
||||
# Code from module vasprintf:
|
||||
# Code from module verify:
|
||||
# Code from module vsnprintf:
|
||||
# Code from module warn-on-use:
|
||||
# Code from module wchar:
|
||||
# Code from module wcrtomb:
|
||||
# Code from module wctype:
|
||||
# Code from module write:
|
||||
# Code from module xalloc:
|
||||
# Code from module xalloc-die:
|
||||
# Code from module xsize:
|
||||
# Code from module xstrndup:
|
||||
])
|
||||
|
||||
# This macro should be invoked from ./configure.in, in the section
|
||||
|
|
@ -36,6 +142,7 @@ AC_DEFUN([gl_INIT],
|
|||
gl_cond_libtool=false
|
||||
gl_libdeps=
|
||||
gl_ltlibdeps=
|
||||
gl_m4_base='gl/m4'
|
||||
m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ]))
|
||||
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS]))
|
||||
m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
|
||||
|
|
@ -43,111 +150,254 @@ AC_DEFUN([gl_INIT],
|
|||
m4_pushdef([gl_LIBSOURCES_DIR], [])
|
||||
gl_COMMON
|
||||
gl_source_base='gl'
|
||||
# Code from module alignof:
|
||||
# Code from module alloca-opt:
|
||||
gl_FUNC_ALLOCA
|
||||
# Code from module arg-nonnull:
|
||||
# Code from module arpa_inet:
|
||||
gl_HEADER_ARPA_INET
|
||||
AC_PROG_MKDIR_P
|
||||
# Code from module base64:
|
||||
gl_FUNC_BASE64
|
||||
# Code from module btowc:
|
||||
gl_FUNC_BTOWC
|
||||
gl_WCHAR_MODULE_INDICATOR([btowc])
|
||||
# Code from module c++defs:
|
||||
# Code from module c-strtod:
|
||||
gl_C_STRTOD
|
||||
# Code from module cloexec:
|
||||
gl_CLOEXEC
|
||||
gl_MODULE_INDICATOR_FOR_TESTS([cloexec])
|
||||
# Code from module close-hook:
|
||||
# Code from module configmake:
|
||||
# Code from module crypto/sha1:
|
||||
gl_SHA1
|
||||
# Code from module dirname:
|
||||
gl_DIRNAME
|
||||
gl_MODULE_INDICATOR([dirname])
|
||||
# Code from module dirname-lgpl:
|
||||
gl_DIRNAME_LGPL
|
||||
# Code from module double-slash-root:
|
||||
gl_DOUBLE_SLASH_ROOT
|
||||
# Code from module dup2:
|
||||
gl_FUNC_DUP2
|
||||
gl_UNISTD_MODULE_INDICATOR([dup2])
|
||||
# Code from module environ:
|
||||
gl_ENVIRON
|
||||
gl_UNISTD_MODULE_INDICATOR([environ])
|
||||
# Code from module errno:
|
||||
gl_HEADER_ERRNO_H
|
||||
# Code from module error:
|
||||
gl_ERROR
|
||||
m4_ifdef([AM_XGETTEXT_OPTION],
|
||||
[AM_XGETTEXT_OPTION([--flag=error:3:c-format])
|
||||
AM_XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
|
||||
gl_EXITFAIL
|
||||
[AM_][XGETTEXT_OPTION([--flag=error:3:c-format])
|
||||
AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
|
||||
# Code from module exitfail:
|
||||
# Code from module extensions:
|
||||
# Code from module fcntl:
|
||||
gl_FUNC_FCNTL
|
||||
gl_FCNTL_MODULE_INDICATOR([fcntl])
|
||||
# Code from module fcntl-h:
|
||||
gl_FCNTL_H
|
||||
# Code from module fcntl-safer:
|
||||
gl_FCNTL_SAFER
|
||||
gl_MODULE_INDICATOR([fcntl-safer])
|
||||
# Code from module float:
|
||||
gl_FLOAT_H
|
||||
# Code from module floorf:
|
||||
gl_FUNC_FLOORF
|
||||
gl_MATH_MODULE_INDICATOR([floorf])
|
||||
# Code from module fsusage:
|
||||
gl_FSUSAGE
|
||||
# Code from module full-read:
|
||||
# Code from module full-write:
|
||||
# Code from module getaddrinfo:
|
||||
gl_GETADDRINFO
|
||||
gl_NETDB_MODULE_INDICATOR([getaddrinfo])
|
||||
# Code from module getdtablesize:
|
||||
gl_FUNC_GETDTABLESIZE
|
||||
gl_UNISTD_MODULE_INDICATOR([getdtablesize])
|
||||
# Code from module gethostname:
|
||||
gl_FUNC_GETHOSTNAME
|
||||
gl_UNISTD_MODULE_INDICATOR([gethostname])
|
||||
# Code from module getloadavg:
|
||||
gl_GETLOADAVG([$gl_source_base])
|
||||
gl_STDLIB_MODULE_INDICATOR([getloadavg])
|
||||
gl_GETOPT
|
||||
# Code from module getopt:
|
||||
# Code from module getopt-gnu:
|
||||
gl_FUNC_GETOPT_GNU
|
||||
gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
|
||||
# Code from module getopt-posix:
|
||||
gl_FUNC_GETOPT_POSIX
|
||||
# Code from module gettext:
|
||||
dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac.
|
||||
AM_GNU_GETTEXT_VERSION([0.17])
|
||||
AM_GNU_GETTEXT_VERSION([0.18.1])
|
||||
# Code from module gettext-h:
|
||||
AC_SUBST([LIBINTL])
|
||||
AC_SUBST([LTLIBINTL])
|
||||
# Code from module havelib:
|
||||
# Code from module hostent:
|
||||
gl_HOSTENT
|
||||
gl_INET_NTOP
|
||||
# Code from module include_next:
|
||||
# Code from module inet_ntop:
|
||||
gl_FUNC_INET_NTOP
|
||||
gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
|
||||
# Code from module inline:
|
||||
gl_INLINE
|
||||
# Code from module intprops:
|
||||
# Code from module langinfo:
|
||||
gl_LANGINFO_H
|
||||
# Code from module localcharset:
|
||||
gl_LOCALCHARSET
|
||||
LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
|
||||
AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
|
||||
# Code from module locale:
|
||||
gl_LOCALE_H
|
||||
# Code from module malloc:
|
||||
AC_FUNC_MALLOC
|
||||
AC_DEFINE([GNULIB_MALLOC_GNU], 1, [Define to indicate the 'malloc' module.])
|
||||
# Code from module malloc-posix:
|
||||
gl_FUNC_MALLOC_POSIX
|
||||
gl_STDLIB_MODULE_INDICATOR([malloc-posix])
|
||||
# Code from module malloca:
|
||||
gl_MALLOCA
|
||||
# Code from module math:
|
||||
gl_MATH_H
|
||||
# Code from module mbrtowc:
|
||||
gl_FUNC_MBRTOWC
|
||||
gl_WCHAR_MODULE_INDICATOR([mbrtowc])
|
||||
# Code from module mbsinit:
|
||||
gl_FUNC_MBSINIT
|
||||
gl_WCHAR_MODULE_INDICATOR([mbsinit])
|
||||
# Code from module memchr:
|
||||
gl_FUNC_MEMCHR
|
||||
gl_STRING_MODULE_INDICATOR([memchr])
|
||||
# Code from module mktime:
|
||||
gl_FUNC_MKTIME
|
||||
gl_TIME_MODULE_INDICATOR([mktime])
|
||||
# Code from module mountlist:
|
||||
gl_MOUNTLIST
|
||||
# Code from module multiarch:
|
||||
gl_MULTIARCH
|
||||
# Code from module netdb:
|
||||
gl_HEADER_NETDB
|
||||
# Code from module netinet_in:
|
||||
gl_HEADER_NETINET_IN
|
||||
AC_PROG_MKDIR_P
|
||||
# Code from module nl_langinfo:
|
||||
gl_FUNC_NL_LANGINFO
|
||||
gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
|
||||
# Code from module open:
|
||||
gl_FUNC_OPEN
|
||||
gl_MODULE_INDICATOR([open])
|
||||
gl_FCNTL_MODULE_INDICATOR([open])
|
||||
# Code from module regex:
|
||||
gl_REGEX
|
||||
# Code from module safe-read:
|
||||
gl_SAFE_READ
|
||||
# Code from module safe-write:
|
||||
gl_SAFE_WRITE
|
||||
# Code from module servent:
|
||||
gl_SERVENT
|
||||
# Code from module setenv:
|
||||
gl_FUNC_SETENV
|
||||
gl_STDLIB_MODULE_INDICATOR([setenv])
|
||||
# Code from module size_max:
|
||||
gl_SIZE_MAX
|
||||
# Code from module snprintf:
|
||||
gl_FUNC_SNPRINTF
|
||||
gl_STDIO_MODULE_INDICATOR([snprintf])
|
||||
# Code from module sockets:
|
||||
gl_SOCKETS
|
||||
# Code from module socklen:
|
||||
gl_TYPE_SOCKLEN_T
|
||||
# Code from module ssize_t:
|
||||
gt_TYPE_SSIZE_T
|
||||
# Code from module stat:
|
||||
gl_FUNC_STAT
|
||||
gl_SYS_STAT_MODULE_INDICATOR([stat])
|
||||
# Code from module stdbool:
|
||||
AM_STDBOOL_H
|
||||
# Code from module stddef:
|
||||
gl_STDDEF_H
|
||||
# Code from module stdint:
|
||||
gl_STDINT_H
|
||||
# Code from module stdio:
|
||||
gl_STDIO_H
|
||||
# Code from module stdlib:
|
||||
gl_STDLIB_H
|
||||
# Code from module strdup-posix:
|
||||
gl_FUNC_STRDUP_POSIX
|
||||
gl_STRING_MODULE_INDICATOR([strdup])
|
||||
# Code from module streq:
|
||||
# Code from module strerror:
|
||||
gl_FUNC_STRERROR
|
||||
gl_STRING_MODULE_INDICATOR([strerror])
|
||||
# Code from module string:
|
||||
gl_HEADER_STRING_H
|
||||
# Code from module strndup:
|
||||
gl_FUNC_STRNDUP
|
||||
gl_STRING_MODULE_INDICATOR([strndup])
|
||||
# Code from module strnlen:
|
||||
gl_FUNC_STRNLEN
|
||||
gl_STRING_MODULE_INDICATOR([strnlen])
|
||||
# Code from module strsep:
|
||||
gl_FUNC_STRSEP
|
||||
gl_STRING_MODULE_INDICATOR([strsep])
|
||||
# Code from module strstr-simple:
|
||||
gl_FUNC_STRSTR_SIMPLE
|
||||
gl_STRING_MODULE_INDICATOR([strstr])
|
||||
# Code from module sys_socket:
|
||||
gl_HEADER_SYS_SOCKET
|
||||
AC_PROG_MKDIR_P
|
||||
# Code from module sys_stat:
|
||||
gl_HEADER_SYS_STAT_H
|
||||
AC_PROG_MKDIR_P
|
||||
# Code from module time:
|
||||
gl_HEADER_TIME_H
|
||||
# Code from module time_r:
|
||||
gl_TIME_R
|
||||
gl_TIME_MODULE_INDICATOR([time_r])
|
||||
# Code from module timegm:
|
||||
gl_FUNC_TIMEGM
|
||||
gl_TIME_MODULE_INDICATOR([timegm])
|
||||
# Code from module unistd:
|
||||
gl_UNISTD_H
|
||||
# Code from module unistd-safer:
|
||||
gl_UNISTD_SAFER
|
||||
# Code from module unsetenv:
|
||||
gl_FUNC_UNSETENV
|
||||
gl_STDLIB_MODULE_INDICATOR([unsetenv])
|
||||
# Code from module vasnprintf:
|
||||
gl_FUNC_VASNPRINTF
|
||||
# Code from module vasprintf:
|
||||
gl_FUNC_VASPRINTF
|
||||
gl_STDIO_MODULE_INDICATOR([vasprintf])
|
||||
m4_ifdef([AM_XGETTEXT_OPTION],
|
||||
[AM_XGETTEXT_OPTION([--flag=asprintf:2:c-format])
|
||||
AM_XGETTEXT_OPTION([--flag=vasprintf:2:c-format])])
|
||||
[AM_][XGETTEXT_OPTION([--flag=asprintf:2:c-format])
|
||||
AM_][XGETTEXT_OPTION([--flag=vasprintf:2:c-format])])
|
||||
# Code from module verify:
|
||||
# Code from module vsnprintf:
|
||||
gl_FUNC_VSNPRINTF
|
||||
gl_STDIO_MODULE_INDICATOR([vsnprintf])
|
||||
# Code from module warn-on-use:
|
||||
# Code from module wchar:
|
||||
gl_WCHAR_H
|
||||
# Code from module wcrtomb:
|
||||
gl_FUNC_WCRTOMB
|
||||
gl_WCHAR_MODULE_INDICATOR([wcrtomb])
|
||||
# Code from module wctype:
|
||||
gl_WCTYPE_H
|
||||
# Code from module write:
|
||||
gl_FUNC_WRITE
|
||||
gl_UNISTD_MODULE_INDICATOR([write])
|
||||
# Code from module xalloc:
|
||||
gl_XALLOC
|
||||
# Code from module xalloc-die:
|
||||
# Code from module xsize:
|
||||
gl_XSIZE
|
||||
# Code from module xstrndup:
|
||||
gl_XSTRNDUP
|
||||
# End of code from modules
|
||||
m4_ifval(gl_LIBSOURCES_LIST, [
|
||||
m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
|
||||
for gl_file in ]gl_LIBSOURCES_LIST[ ; do
|
||||
|
|
@ -170,7 +420,7 @@ AC_DEFUN([gl_INIT],
|
|||
if test -n "$gl_LIBOBJS"; then
|
||||
# Remove the extension.
|
||||
sed_drop_objext='s/\.o$//;s/\.obj$//'
|
||||
for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
|
||||
for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
|
||||
gl_libobjs="$gl_libobjs $i.$ac_objext"
|
||||
gl_ltlibobjs="$gl_ltlibobjs $i.lo"
|
||||
done
|
||||
|
|
@ -187,6 +437,13 @@ AC_DEFUN([gl_INIT],
|
|||
m4_pushdef([gltests_LIBSOURCES_DIR], [])
|
||||
gl_COMMON
|
||||
gl_source_base='tests'
|
||||
changequote(,)dnl
|
||||
gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS
|
||||
changequote([, ])dnl
|
||||
AC_SUBST([gltests_WITNESS])
|
||||
gl_module_indicator_condition=$gltests_WITNESS
|
||||
m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition])
|
||||
m4_popdef([gl_MODULE_INDICATOR_CONDITION])
|
||||
m4_ifval(gltests_LIBSOURCES_LIST, [
|
||||
m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ ||
|
||||
for gl_file in ]gltests_LIBSOURCES_LIST[ ; do
|
||||
|
|
@ -209,7 +466,7 @@ AC_DEFUN([gl_INIT],
|
|||
if test -n "$gltests_LIBOBJS"; then
|
||||
# Remove the extension.
|
||||
sed_drop_objext='s/\.o$//;s/\.obj$//'
|
||||
for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
|
||||
for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
|
||||
gltests_libobjs="$gltests_libobjs $i.$ac_objext"
|
||||
gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
|
||||
done
|
||||
|
|
@ -280,27 +537,33 @@ AC_DEFUN([gltests_LIBSOURCES], [
|
|||
# This macro records the list of files which have been installed by
|
||||
# gnulib-tool and may be removed by future gnulib-tool invocations.
|
||||
AC_DEFUN([gl_FILE_LIST], [
|
||||
build-aux/arg-nonnull.h
|
||||
build-aux/c++defs.h
|
||||
build-aux/config.rpath
|
||||
build-aux/link-warning.h
|
||||
build-aux/warn-on-use.h
|
||||
lib/alignof.h
|
||||
lib/alloca.c
|
||||
lib/alloca.in.h
|
||||
lib/arpa_inet.in.h
|
||||
lib/asnprintf.c
|
||||
lib/asprintf.c
|
||||
lib/base64.c
|
||||
lib/base64.h
|
||||
lib/basename-lgpl.c
|
||||
lib/basename.c
|
||||
lib/btowc.c
|
||||
lib/c-strtod.c
|
||||
lib/c-strtod.h
|
||||
lib/cloexec.c
|
||||
lib/cloexec.h
|
||||
lib/close-hook.c
|
||||
lib/close-hook.h
|
||||
lib/config.charset
|
||||
lib/creat-safer.c
|
||||
lib/dirname-lgpl.c
|
||||
lib/dirname.c
|
||||
lib/dirname.h
|
||||
lib/dup-safer.c
|
||||
lib/dup2.c
|
||||
lib/errno.in.h
|
||||
lib/error.c
|
||||
lib/error.h
|
||||
|
|
@ -308,6 +571,7 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/exitfail.h
|
||||
lib/fcntl--.h
|
||||
lib/fcntl-safer.h
|
||||
lib/fcntl.c
|
||||
lib/fcntl.in.h
|
||||
lib/fd-safer.c
|
||||
lib/float+.h
|
||||
|
|
@ -322,6 +586,7 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/full-write.h
|
||||
lib/gai_strerror.c
|
||||
lib/getaddrinfo.c
|
||||
lib/getdtablesize.c
|
||||
lib/gethostname.c
|
||||
lib/getloadavg.c
|
||||
lib/getopt.c
|
||||
|
|
@ -331,17 +596,26 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/gettext.h
|
||||
lib/inet_ntop.c
|
||||
lib/intprops.h
|
||||
lib/langinfo.in.h
|
||||
lib/localcharset.c
|
||||
lib/localcharset.h
|
||||
lib/locale.in.h
|
||||
lib/malloc.c
|
||||
lib/malloca.c
|
||||
lib/malloca.h
|
||||
lib/malloca.valgrind
|
||||
lib/math.in.h
|
||||
lib/mbrtowc.c
|
||||
lib/mbsinit.c
|
||||
lib/memchr.c
|
||||
lib/memchr.valgrind
|
||||
lib/mktime-internal.h
|
||||
lib/mktime.c
|
||||
lib/mountlist.c
|
||||
lib/mountlist.h
|
||||
lib/netdb.in.h
|
||||
lib/netinet_in.in.h
|
||||
lib/nl_langinfo.c
|
||||
lib/open-safer.c
|
||||
lib/open.c
|
||||
lib/pipe-safer.c
|
||||
|
|
@ -361,13 +635,21 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/safe-read.h
|
||||
lib/safe-write.c
|
||||
lib/safe-write.h
|
||||
lib/setenv.c
|
||||
lib/sha1.c
|
||||
lib/sha1.h
|
||||
lib/size_max.h
|
||||
lib/snprintf.c
|
||||
lib/sockets.c
|
||||
lib/sockets.h
|
||||
lib/stat.c
|
||||
lib/stdbool.in.h
|
||||
lib/stddef.in.h
|
||||
lib/stdint.in.h
|
||||
lib/stdio-write.c
|
||||
lib/stdio.in.h
|
||||
lib/stdlib.in.h
|
||||
lib/str-two-way.h
|
||||
lib/strdup.c
|
||||
lib/streq.h
|
||||
lib/strerror.c
|
||||
|
|
@ -375,18 +657,23 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
lib/stripslash.c
|
||||
lib/strndup.c
|
||||
lib/strnlen.c
|
||||
lib/strsep.c
|
||||
lib/strstr.c
|
||||
lib/sys_socket.in.h
|
||||
lib/sys_stat.in.h
|
||||
lib/time.in.h
|
||||
lib/time_r.c
|
||||
lib/timegm.c
|
||||
lib/unistd--.h
|
||||
lib/unistd-safer.h
|
||||
lib/unistd.in.h
|
||||
lib/unsetenv.c
|
||||
lib/vasnprintf.c
|
||||
lib/vasnprintf.h
|
||||
lib/vasprintf.c
|
||||
lib/verify.h
|
||||
lib/vsnprintf.c
|
||||
lib/w32sock.h
|
||||
lib/wchar.in.h
|
||||
lib/wcrtomb.c
|
||||
lib/wctype.in.h
|
||||
|
|
@ -400,6 +687,7 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/00gnulib.m4
|
||||
m4/alloca.m4
|
||||
m4/arpa_inet_h.m4
|
||||
m4/asm-underscore.m4
|
||||
m4/base64.m4
|
||||
m4/btowc.m4
|
||||
m4/c-strtod.m4
|
||||
|
|
@ -408,17 +696,22 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/dirname.m4
|
||||
m4/dos.m4
|
||||
m4/double-slash-root.m4
|
||||
m4/dup2.m4
|
||||
m4/eealloc.m4
|
||||
m4/environ.m4
|
||||
m4/errno_h.m4
|
||||
m4/error.m4
|
||||
m4/exitfail.m4
|
||||
m4/extensions.m4
|
||||
m4/fcntl-o.m4
|
||||
m4/fcntl-safer.m4
|
||||
m4/fcntl.m4
|
||||
m4/fcntl_h.m4
|
||||
m4/float_h.m4
|
||||
m4/floorf.m4
|
||||
m4/fstypename.m4
|
||||
m4/fsusage.m4
|
||||
m4/getaddrinfo.m4
|
||||
m4/getdtablesize.m4
|
||||
m4/gethostname.m4
|
||||
m4/getloadavg.m4
|
||||
m4/getopt.m4
|
||||
|
|
@ -439,6 +732,7 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/intmax_t.m4
|
||||
m4/inttypes-pri.m4
|
||||
m4/inttypes_h.m4
|
||||
m4/langinfo_h.m4
|
||||
m4/lcmessage.m4
|
||||
m4/lib-ld.m4
|
||||
m4/lib-link.m4
|
||||
|
|
@ -447,19 +741,25 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/locale-fr.m4
|
||||
m4/locale-ja.m4
|
||||
m4/locale-zh.m4
|
||||
m4/locale_h.m4
|
||||
m4/lock.m4
|
||||
m4/longlong.m4
|
||||
m4/ls-mntd-fs.m4
|
||||
m4/malloc.m4
|
||||
m4/malloca.m4
|
||||
m4/math_h.m4
|
||||
m4/mbrtowc.m4
|
||||
m4/mbsinit.m4
|
||||
m4/mbstate_t.m4
|
||||
m4/memchr.m4
|
||||
m4/mktime.m4
|
||||
m4/mmap-anon.m4
|
||||
m4/mode_t.m4
|
||||
m4/mountlist.m4
|
||||
m4/multiarch.m4
|
||||
m4/netdb_h.m4
|
||||
m4/netinet_in_h.m4
|
||||
m4/nl_langinfo.m4
|
||||
m4/nls.m4
|
||||
m4/onceonly.m4
|
||||
m4/open.m4
|
||||
|
|
@ -471,12 +771,17 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/safe-read.m4
|
||||
m4/safe-write.m4
|
||||
m4/servent.m4
|
||||
m4/setenv.m4
|
||||
m4/sha1.m4
|
||||
m4/size_max.m4
|
||||
m4/snprintf.m4
|
||||
m4/sockets.m4
|
||||
m4/socklen.m4
|
||||
m4/sockpfaf.m4
|
||||
m4/ssize_t.m4
|
||||
m4/stat.m4
|
||||
m4/stdbool.m4
|
||||
m4/stddef_h.m4
|
||||
m4/stdint.m4
|
||||
m4/stdint_h.m4
|
||||
m4/stdio_h.m4
|
||||
|
|
@ -486,7 +791,10 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/string_h.m4
|
||||
m4/strndup.m4
|
||||
m4/strnlen.m4
|
||||
m4/strsep.m4
|
||||
m4/strstr.m4
|
||||
m4/sys_socket_h.m4
|
||||
m4/sys_stat_h.m4
|
||||
m4/threadlib.m4
|
||||
m4/time_h.m4
|
||||
m4/time_r.m4
|
||||
|
|
@ -498,10 +806,11 @@ AC_DEFUN([gl_FILE_LIST], [
|
|||
m4/vasprintf.m4
|
||||
m4/visibility.m4
|
||||
m4/vsnprintf.m4
|
||||
m4/wchar.m4
|
||||
m4/warn-on-use.m4
|
||||
m4/wchar_h.m4
|
||||
m4/wchar_t.m4
|
||||
m4/wcrtomb.m4
|
||||
m4/wctype.m4
|
||||
m4/wctype_h.m4
|
||||
m4/wint_t.m4
|
||||
m4/write.m4
|
||||
m4/xalloc.m4
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# hostent.m4 serial 1
|
||||
dnl Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue