1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Initial gnulib-tool --import.

This commit is contained in:
Micah Cowan 2007-10-13 22:37:15 -07:00
parent 613c317785
commit 981d279da3
24 changed files with 3977 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2007-10-13 Micah Cowan <micah@cowan.name>
* GNUMakefile, maint.mk: Added as part of the gnulib-ization.
* Makefile.am, configure.ac: gnulib-ized.
2007-10-12 Micah Cowan <micah@cowan.name>
* PATCHES: Removed.

60
GNUmakefile Normal file
View File

@ -0,0 +1,60 @@
# Having a separate GNUmakefile lets me `include' the dynamically
# generated rules created via Makefile.maint as well as Makefile.maint itself.
# This makefile is used only if you run GNU Make.
# It is necessary if you want to build targets usually of interest
# only to the maintainer.
# Copyright (C) 2001, 2003, 2006, 2007 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/>.
# Systems where /bin/sh is not the default shell need this. The $(shell)
# command below won't work with e.g. stock DOS/Windows shells.
ifeq ($(wildcard /bin/s[h]),/bin/sh)
SHELL = /bin/sh
else
# will be used only with the next shell-test line, then overwritten
# by a configured-in value
SHELL = sh
endif
# Make tar archive easier to reproduce.
export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
# Ran autoreconf and configure or not?
have-Makefile := $(shell test -f Makefile && echo yes)
ifeq ($(have-Makefile),yes)
include Makefile
-include $(srcdir)/maint-cfg.mk
include $(srcdir)/maint.mk
else
.DEFAULT_GOAL := abort-due-to-no-makefile
-include ./maint-cfg.mk
include ./maint.mk
abort-due-to-no-makefile:
@echo There seems to be no Makefile in this directory. 1>&2
@echo "You must run ./configure before running \`make'." 1>&2
@exit 1
endif
# Tell version 3.79 and up of GNU make to not build goals in this
# directory in parallel. This is necessary in case someone tries to
# build multiple targets on one command line.
.NOTPARALLEL:

View File

@ -33,7 +33,7 @@
ACLOCAL_AMFLAGS = -I m4
# subdirectories in the distribution
SUBDIRS = src doc po tests util windows
SUBDIRS = lib src doc po tests util windows
test: all
cd tests && $(MAKE) $(AM_MAKEFLAGS) $@

View File

@ -106,6 +106,7 @@ test -z "$CC" && cc_specified=yes
AC_PROG_CC
AM_PROG_CC_C_O
AC_AIX
gl_EARLY
AC_PROG_RANLIB
@ -183,6 +184,9 @@ AC_CHECK_TYPES(sig_atomic_t, [], [], [
#include <signal.h>
])
# gnulib
gl_INIT
dnl
dnl Checks for library functions.
dnl
@ -460,7 +464,7 @@ dnl Create output
dnl
AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile util/Makefile
po/Makefile.in tests/Makefile tests/WgetTest.pm
windows/Makefile])
lib/Makefile windows/Makefile])
AC_CONFIG_HEADERS([src/config.h])
AH_BOTTOM([
#include "config-post.h"

148
lib/Makefile.am Normal file
View File

@ -0,0 +1,148 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
# Copyright (C) 2004-2007 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
# Public License, this file may be distributed as part of a program
# that contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=. --no-libtool --macro-prefix=gl c-ctype getopt maintainer-makefile md5
AUTOMAKE_OPTIONS = 1.5 gnits
noinst_HEADERS =
noinst_LIBRARIES =
noinst_LTLIBRARIES =
EXTRA_DIST =
BUILT_SOURCES =
SUFFIXES =
MOSTLYCLEANFILES = core *.stackdump
MOSTLYCLEANDIRS =
CLEANFILES =
DISTCLEANFILES =
MAINTAINERCLEANFILES =
AM_CPPFLAGS =
noinst_LIBRARIES += libgnu.a
libgnu_a_SOURCES =
libgnu_a_LIBADD = $(gl_LIBOBJS)
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
EXTRA_libgnu_a_SOURCES =
## begin gnulib module c-ctype
libgnu_a_SOURCES += c-ctype.h c-ctype.c
## end gnulib module c-ctype
## begin gnulib module getopt
BUILT_SOURCES += $(GETOPT_H)
# We need the following in order to create <getopt.h> when the system
# doesn't have one that works with the given compiler.
getopt.h: getopt.in.h
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
cat $(srcdir)/getopt.in.h; \
} > $@-t
mv -f $@-t $@
MOSTLYCLEANFILES += getopt.h getopt.h-t
EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_int.h
EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c
## end gnulib module getopt
## begin gnulib module gettext-h
libgnu_a_SOURCES += gettext.h
## end gnulib module gettext-h
## begin gnulib module link-warning
LINK_WARNING_H=$(top_srcdir)/./link-warning.h
EXTRA_DIST += $(top_srcdir)/./link-warning.h
## end gnulib module link-warning
## begin gnulib module maintainer-makefile
EXTRA_DIST += $(top_srcdir)/./GNUmakefile $(top_srcdir)/./maint.mk
## end gnulib module maintainer-makefile
## begin gnulib module stdbool
BUILT_SOURCES += $(STDBOOL_H)
# We need the following in order to create <stdbool.h> when the system
# doesn't have one that works.
stdbool.h: stdbool.in.h
rm -f $@-t $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
} > $@-t
mv $@-t $@
MOSTLYCLEANFILES += stdbool.h stdbool.h-t
EXTRA_DIST += stdbool.in.h
## end gnulib module stdbool
## begin gnulib module unistd
BUILT_SOURCES += unistd.h
# We need the following in order to create an empty placeholder for
# <unistd.h> when the system doesn't have one.
unistd.h: unistd.in.h
rm -f $@-t $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
-e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
-e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
-e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
-e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
-e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
-e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
-e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
-e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
-e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
-e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
-e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
-e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
-e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
-e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
-e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
-e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
-e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
-e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
-e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
-e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
-e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
< $(srcdir)/unistd.in.h; \
} > $@-t
mv $@-t $@
MOSTLYCLEANFILES += unistd.h unistd.h-t
EXTRA_DIST += unistd.in.h
## end gnulib module unistd
mostlyclean-local: mostlyclean-generic
@for dir in '' $(MOSTLYCLEANDIRS); do \
if test -n "$$dir" && test -d $$dir; then \
echo "rmdir $$dir"; rmdir $$dir; \
fi; \
done; \
:

396
lib/c-ctype.c Normal file
View File

@ -0,0 +1,396 @@
/* Character handling in C locale.
Copyright 2000-2003, 2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#include <config.h>
/* Specification. */
#define NO_C_CTYPE_MACROS
#include "c-ctype.h"
/* The function isascii is not locale dependent. Its use in EBCDIC is
questionable. */
bool
c_isascii (int c)
{
return (c >= 0x00 && c <= 0x7f);
}
bool
c_isalnum (int c)
{
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
return ((c >= '0' && c <= '9')
|| ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'));
#else
return ((c >= '0' && c <= '9')
|| (c >= 'A' && c <= 'Z')
|| (c >= 'a' && c <= 'z'));
#endif
#else
switch (c)
{
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
return 1;
default:
return 0;
}
#endif
}
bool
c_isalpha (int c)
{
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z');
#else
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
#endif
#else
switch (c)
{
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
return 1;
default:
return 0;
}
#endif
}
bool
c_isblank (int c)
{
return (c == ' ' || c == '\t');
}
bool
c_iscntrl (int c)
{
#if C_CTYPE_ASCII
return ((c & ~0x1f) == 0 || c == 0x7f);
#else
switch (c)
{
case ' ': case '!': case '"': case '#': case '$': case '%':
case '&': case '\'': case '(': case ')': case '*': case '+':
case ',': case '-': case '.': case '/':
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case ':': case ';': case '<': case '=': case '>': case '?':
case '@':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case '[': case '\\': case ']': case '^': case '_': case '`':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '{': case '|': case '}': case '~':
return 0;
default:
return 1;
}
#endif
}
bool
c_isdigit (int c)
{
#if C_CTYPE_CONSECUTIVE_DIGITS
return (c >= '0' && c <= '9');
#else
switch (c)
{
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
return 1;
default:
return 0;
}
#endif
}
bool
c_islower (int c)
{
#if C_CTYPE_CONSECUTIVE_LOWERCASE
return (c >= 'a' && c <= 'z');
#else
switch (c)
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
return 1;
default:
return 0;
}
#endif
}
bool
c_isgraph (int c)
{
#if C_CTYPE_ASCII
return (c >= '!' && c <= '~');
#else
switch (c)
{
case '!': case '"': case '#': case '$': case '%': case '&':
case '\'': case '(': case ')': case '*': case '+': case ',':
case '-': case '.': case '/':
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case ':': case ';': case '<': case '=': case '>': case '?':
case '@':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case '[': case '\\': case ']': case '^': case '_': case '`':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '{': case '|': case '}': case '~':
return 1;
default:
return 0;
}
#endif
}
bool
c_isprint (int c)
{
#if C_CTYPE_ASCII
return (c >= ' ' && c <= '~');
#else
switch (c)
{
case ' ': case '!': case '"': case '#': case '$': case '%':
case '&': case '\'': case '(': case ')': case '*': case '+':
case ',': case '-': case '.': case '/':
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case ':': case ';': case '<': case '=': case '>': case '?':
case '@':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case '[': case '\\': case ']': case '^': case '_': case '`':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '{': case '|': case '}': case '~':
return 1;
default:
return 0;
}
#endif
}
bool
c_ispunct (int c)
{
#if C_CTYPE_ASCII
return ((c >= '!' && c <= '~')
&& !((c >= '0' && c <= '9')
|| ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')));
#else
switch (c)
{
case '!': case '"': case '#': case '$': case '%': case '&':
case '\'': case '(': case ')': case '*': case '+': case ',':
case '-': case '.': case '/':
case ':': case ';': case '<': case '=': case '>': case '?':
case '@':
case '[': case '\\': case ']': case '^': case '_': case '`':
case '{': case '|': case '}': case '~':
return 1;
default:
return 0;
}
#endif
}
bool
c_isspace (int c)
{
return (c == ' ' || c == '\t'
|| c == '\n' || c == '\v' || c == '\f' || c == '\r');
}
bool
c_isupper (int c)
{
#if C_CTYPE_CONSECUTIVE_UPPERCASE
return (c >= 'A' && c <= 'Z');
#else
switch (c)
{
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
return 1;
default:
return 0;
}
#endif
}
bool
c_isxdigit (int c)
{
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
return ((c >= '0' && c <= '9')
|| ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F'));
#else
return ((c >= '0' && c <= '9')
|| (c >= 'A' && c <= 'F')
|| (c >= 'a' && c <= 'f'));
#endif
#else
switch (c)
{
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
return 1;
default:
return 0;
}
#endif
}
int
c_tolower (int c)
{
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c);
#else
switch (c)
{
case 'A': return 'a';
case 'B': return 'b';
case 'C': return 'c';
case 'D': return 'd';
case 'E': return 'e';
case 'F': return 'f';
case 'G': return 'g';
case 'H': return 'h';
case 'I': return 'i';
case 'J': return 'j';
case 'K': return 'k';
case 'L': return 'l';
case 'M': return 'm';
case 'N': return 'n';
case 'O': return 'o';
case 'P': return 'p';
case 'Q': return 'q';
case 'R': return 'r';
case 'S': return 's';
case 'T': return 't';
case 'U': return 'u';
case 'V': return 'v';
case 'W': return 'w';
case 'X': return 'x';
case 'Y': return 'y';
case 'Z': return 'z';
default: return c;
}
#endif
}
int
c_toupper (int c)
{
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c);
#else
switch (c)
{
case 'a': return 'A';
case 'b': return 'B';
case 'c': return 'C';
case 'd': return 'D';
case 'e': return 'E';
case 'f': return 'F';
case 'g': return 'G';
case 'h': return 'H';
case 'i': return 'I';
case 'j': return 'J';
case 'k': return 'K';
case 'l': return 'L';
case 'm': return 'M';
case 'n': return 'N';
case 'o': return 'O';
case 'p': return 'P';
case 'q': return 'Q';
case 'r': return 'R';
case 's': return 'S';
case 't': return 'T';
case 'u': return 'U';
case 'v': return 'V';
case 'w': return 'W';
case 'x': return 'X';
case 'y': return 'Y';
case 'z': return 'Z';
default: return c;
}
#endif
}

280
lib/c-ctype.h Normal file
View File

@ -0,0 +1,280 @@
/* Character handling in C locale.
These functions work like the corresponding functions in <ctype.h>,
except that they have the C (POSIX) locale hardwired, whereas the
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
Copyright (C) 2000-2003, 2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef C_CTYPE_H
#define C_CTYPE_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The functions defined in this file assume the "C" locale and a character
set without diacritics (ASCII-US or EBCDIC-US or something like that).
Even if the "C" locale on a particular system is an extension of the ASCII
character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it
is ISO-8859-1), the functions in this file recognize only the ASCII
characters. */
/* Check whether the ASCII optimizations apply. */
/* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that
'0', '1', ..., '9' have consecutive integer values. */
#define C_CTYPE_CONSECUTIVE_DIGITS 1
#if ('A' <= 'Z') \
&& ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \
&& ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \
&& ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \
&& ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \
&& ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \
&& ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \
&& ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \
&& ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \
&& ('Y' + 1 == 'Z')
#define C_CTYPE_CONSECUTIVE_UPPERCASE 1
#endif
#if ('a' <= 'z') \
&& ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \
&& ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \
&& ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \
&& ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \
&& ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \
&& ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \
&& ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \
&& ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \
&& ('y' + 1 == 'z')
#define C_CTYPE_CONSECUTIVE_LOWERCASE 1
#endif
#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
/* The character set is ASCII or one of its variants or extensions, not EBCDIC.
Testing the value of '\n' and '\r' is not relevant. */
#define C_CTYPE_ASCII 1
#endif
/* Function declarations. */
extern bool c_isascii (int c); /* not locale dependent */
extern bool c_isalnum (int c);
extern bool c_isalpha (int c);
extern bool c_isblank (int c);
extern bool c_iscntrl (int c);
extern bool c_isdigit (int c);
extern bool c_islower (int c);
extern bool c_isgraph (int c);
extern bool c_isprint (int c);
extern bool c_ispunct (int c);
extern bool c_isspace (int c);
extern bool c_isupper (int c);
extern bool c_isxdigit (int c);
extern int c_tolower (int c);
extern int c_toupper (int c);
#if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS
/* ASCII optimizations. */
#undef c_isascii
#define c_isascii(c) \
({ int __c = (c); \
(__c >= 0x00 && __c <= 0x7f); \
})
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
#undef c_isalnum
#define c_isalnum(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \
})
#else
#undef c_isalnum
#define c_isalnum(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| (__c >= 'A' && __c <= 'Z') \
|| (__c >= 'a' && __c <= 'z')); \
})
#endif
#endif
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
#undef c_isalpha
#define c_isalpha(c) \
({ int __c = (c); \
((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \
})
#else
#undef c_isalpha
#define c_isalpha(c) \
({ int __c = (c); \
((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \
})
#endif
#endif
#undef c_isblank
#define c_isblank(c) \
({ int __c = (c); \
(__c == ' ' || __c == '\t'); \
})
#if C_CTYPE_ASCII
#undef c_iscntrl
#define c_iscntrl(c) \
({ int __c = (c); \
((__c & ~0x1f) == 0 || __c == 0x7f); \
})
#endif
#if C_CTYPE_CONSECUTIVE_DIGITS
#undef c_isdigit
#define c_isdigit(c) \
({ int __c = (c); \
(__c >= '0' && __c <= '9'); \
})
#endif
#if C_CTYPE_CONSECUTIVE_LOWERCASE
#undef c_islower
#define c_islower(c) \
({ int __c = (c); \
(__c >= 'a' && __c <= 'z'); \
})
#endif
#if C_CTYPE_ASCII
#undef c_isgraph
#define c_isgraph(c) \
({ int __c = (c); \
(__c >= '!' && __c <= '~'); \
})
#endif
#if C_CTYPE_ASCII
#undef c_isprint
#define c_isprint(c) \
({ int __c = (c); \
(__c >= ' ' && __c <= '~'); \
})
#endif
#if C_CTYPE_ASCII
#undef c_ispunct
#define c_ispunct(c) \
({ int _c = (c); \
(c_isgraph (_c) && ! c_isalnum (_c)); \
})
#endif
#undef c_isspace
#define c_isspace(c) \
({ int __c = (c); \
(__c == ' ' || __c == '\t' \
|| __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \
})
#if C_CTYPE_CONSECUTIVE_UPPERCASE
#undef c_isupper
#define c_isupper(c) \
({ int __c = (c); \
(__c >= 'A' && __c <= 'Z'); \
})
#endif
#if C_CTYPE_CONSECUTIVE_DIGITS \
&& C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#if C_CTYPE_ASCII
#undef c_isxdigit
#define c_isxdigit(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \
})
#else
#undef c_isxdigit
#define c_isxdigit(c) \
({ int __c = (c); \
((__c >= '0' && __c <= '9') \
|| (__c >= 'A' && __c <= 'F') \
|| (__c >= 'a' && __c <= 'f')); \
})
#endif
#endif
#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
#undef c_tolower
#define c_tolower(c) \
({ int __c = (c); \
(__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \
})
#undef c_toupper
#define c_toupper(c) \
({ int __c = (c); \
(__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \
})
#endif
#endif /* optimizing for speed */
#ifdef __cplusplus
}
#endif
#endif /* C_CTYPE_H */

1190
lib/getopt.c Normal file

File diff suppressed because it is too large Load Diff

225
lib/getopt.in.h Normal file
View File

@ -0,0 +1,225 @@
/* Declarations for getopt.
Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007
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
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 _GETOPT_H
#ifndef __need_getopt
# define _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
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>
# undef __need_getopt
# undef getopt
# undef getopt_long
# undef getopt_long_only
# undef optarg
# undef opterr
# undef optind
# undef optopt
# 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)
# define getopt __GETOPT_ID (getopt)
# define getopt_long __GETOPT_ID (getopt_long)
# define getopt_long_only __GETOPT_ID (getopt_long_only)
# define optarg __GETOPT_ID (optarg)
# define opterr __GETOPT_ID (opterr)
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
#endif
/* Standalone applications get correct prototypes for getopt_long and
getopt_long_only; they declare "char **argv". libc uses prototypes
with "char *const *argv" that are incorrect because getopt_long and
getopt_long_only can permute argv; this is required for backward
compatibility (e.g., for LSB 2.0.1).
This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt',
but it caused redefinition warnings if both unistd.h and getopt.h were
included, since unistd.h includes getopt.h having previously defined
__need_getopt.
The only place where __getopt_argv_const is used is in definitions
of getopt_long and getopt_long_only below, but these are visible
only if __need_getopt is not defined, so it is quite safe to rewrite
the conditional as follows:
*/
#if !defined __need_getopt
# if defined __GETOPT_PREFIX
# define __getopt_argv_const /* empty */
# else
# define __getopt_argv_const const
# endif
#endif
/* If __GNU_LIBRARY__ is not already defined, either we are being used
standalone, or this is the first header included in the source file.
If we are being used with glibc, we need to include <features.h>, but
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
not defined, include <ctype.h>, which will pull in <features.h> for us
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
doesn't flood the namespace with stuff the way some other headers do.) */
#if !defined __GNU_LIBRARY__
# include <ctype.h>
#endif
#ifndef __THROW
# ifndef __GNUC_PREREQ
# define __GNUC_PREREQ(maj, min) (0)
# endif
# if defined __cplusplus && __GNUC_PREREQ (2,8)
# define __THROW throw ()
# else
# define __THROW
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
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.
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
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
const char *name;
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* 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 */
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, `optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU `getopt'.
The argument `--' causes premature termination of argument
scanning, explicitly telling `getopt' that there are no more
options.
If OPTS begins with `-', then non-option arguments are treated as
arguments to the option '\1'. This behavior is specific to the GNU
`getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in
the environment, then do not permute arguments. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
__THROW;
#ifndef __need_getopt
extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW;
extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
__THROW;
#endif
#ifdef __cplusplus
}
#endif
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
#endif /* getopt.h */

170
lib/getopt1.c Normal file
View File

@ -0,0 +1,170 @@
/* 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
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
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/>. */
#ifdef _LIBC
# include <getopt.h>
#else
# include <config.h>
# include "getopt.h"
#endif
#include "getopt_int.h"
#include <stdio.h>
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
#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)
{
return _getopt_internal (argc, (char **) argv, options, long_options,
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)
{
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
0, 0, d);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int
getopt_long_only (int argc, char *__getopt_argv_const *argv,
const char *options,
const struct option *long_options, int *opt_index)
{
return _getopt_internal (argc, (char **) argv, options, long_options,
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)
{
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
1, 0, d);
}
#ifdef TEST
#include <stdio.h>
int
main (int argc, char **argv)
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static 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}
};
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == -1)
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':
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 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
case '?':
break;
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 ("\n");
}
exit (0);
}
#endif /* TEST */

130
lib/getopt_int.h Normal file
View File

@ -0,0 +1,130 @@
/* Internal declarations for getopt.
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
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
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 _GETOPT_INT_H
#define _GETOPT_INT_H 1
extern int _getopt_internal (int ___argc, char **___argv,
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. */
/* Data type for reentrant functions. */
struct _getopt_data
{
/* These have exactly the same meaning as the corresponding global
variables, except that they are used for the reentrant
versions of getopt. */
int optind;
int opterr;
int optopt;
char *optarg;
/* Internal members. */
/* True if the internal members have been initialized. */
int __initialized;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
This allows us to pick up the scan where we left off.
If this is zero, or a null string, it means resume the scan
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;
/* If the POSIXLY_CORRECT environment variable is set
or getopt was called. */
int __posixly_correct;
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
been skipped. `first_nonopt' is the index in ARGV of the first
of them; `last_nonopt' is the index after the last of them. */
int __first_nonopt;
int __last_nonopt;
#if defined _LIBC && defined USE_NONOPTION_FLAGS
int __nonoption_flags_max_len;
int __nonoption_flags_len;
# endif
};
/* 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 }
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);
extern int _getopt_long_r (int ___argc, char **___argv,
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);
#endif /* getopt_int.h */

270
lib/gettext.h Normal file
View File

@ -0,0 +1,270 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002, 2004-2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
/* NLS can be disabled through the configure --disable-nls option. */
#if ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
# include <libintl.h>
/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
the gettext() and ngettext() macros. This is an alternative to calling
textdomain(), and is useful for libraries. */
# ifdef DEFAULT_TEXT_DOMAIN
# undef gettext
# define gettext(Msgid) \
dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
# undef ngettext
# define ngettext(Msgid1, Msgid2, N) \
dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
# endif
#else
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
chokes if dcgettext is defined as a macro. So include it now, to make
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
as well because people using "gettext.h" will not include <libintl.h>,
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
is OK. */
#if defined(__sun)
# include <locale.h>
#endif
/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
<libintl.h>, which chokes if dcgettext is defined as a macro. So include
it now, to make later inclusions of <libintl.h> a NOP. */
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
# include <cstdlib>
# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
# include <libintl.h>
# endif
#endif
/* Disabled NLS.
The casts to 'const char *' serve the purpose of producing warnings
for invalid uses of the value returned from these functions.
On pre-ANSI systems without 'const', the config.h file is supposed to
contain "#define const". */
# define gettext(Msgid) ((const char *) (Msgid))
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
# define dcgettext(Domainname, Msgid, Category) \
((void) (Category), dgettext (Domainname, Msgid))
# define ngettext(Msgid1, Msgid2, N) \
((N) == 1 \
? ((void) (Msgid2), (const char *) (Msgid1)) \
: ((void) (Msgid1), (const char *) (Msgid2)))
# define dngettext(Domainname, Msgid1, Msgid2, N) \
((void) (Domainname), ngettext (Msgid1, Msgid2, N))
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
# define textdomain(Domainname) ((const char *) (Domainname))
# define bindtextdomain(Domainname, Dirname) \
((void) (Domainname), (const char *) (Dirname))
# define bind_textdomain_codeset(Domainname, Codeset) \
((void) (Domainname), (const char *) (Codeset))
#endif
/* A pseudo function call that serves as a marker for the automated
extraction of messages, but does not call gettext(). The run-time
translation is done at a different place in the code.
The argument, String, should be a literal string. Concatenated strings
and other string expressions won't work.
The macro's expansion is not parenthesized, so that it is suitable as
initializer for static 'char[]' or 'const char[]' variables. */
#define gettext_noop(String) String
/* The separator between msgctxt and msgid in a .mo file. */
#define GETTEXT_CONTEXT_GLUE "\004"
/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
short and rarely need to change.
The letter 'p' stands for 'particular' or 'special'. */
#ifdef DEFAULT_TEXT_DOMAIN
# define pgettext(Msgctxt, Msgid) \
pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#else
# define pgettext(Msgctxt, Msgid) \
pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#endif
#define dpgettext(Domainname, Msgctxt, Msgid) \
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
#ifdef DEFAULT_TEXT_DOMAIN
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#else
# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#endif
#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
pgettext_aux (const char *domain,
const char *msg_ctxt_id, const char *msgid,
int category)
{
const char *translation = dcgettext (domain, msg_ctxt_id, category);
if (translation == msg_ctxt_id)
return msgid;
else
return translation;
}
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#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 *translation =
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
if (translation == msg_ctxt_id || translation == msgid_plural)
return (n == 1 ? msgid : msgid_plural);
else
return translation;
}
/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
can be arbitrary expressions. But for string literals these macros are
less efficient than those above. */
#include <string.h>
#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
(((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
/* || __STDC_VERSION__ >= 199901L */ )
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
#include <stdlib.h>
#endif
#define pgettext_expr(Msgctxt, Msgid) \
dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static const char *
dcpgettext_expr (const char *domain,
const char *msgctxt, const char *msgid,
int category)
{
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
const char *translation;
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
char msg_ctxt_id[msgctxt_len + msgid_len];
#else
char buf[1024];
char *msg_ctxt_id =
(msgctxt_len + msgid_len <= sizeof (buf)
? buf
: (char *) malloc (msgctxt_len + msgid_len));
if (msg_ctxt_id != NULL)
#endif
{
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
translation = dcgettext (domain, msg_ctxt_id, category);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
if (translation != msg_ctxt_id)
return translation;
}
return msgid;
}
#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#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)
{
size_t msgctxt_len = strlen (msgctxt) + 1;
size_t msgid_len = strlen (msgid) + 1;
const char *translation;
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
char msg_ctxt_id[msgctxt_len + msgid_len];
#else
char buf[1024];
char *msg_ctxt_id =
(msgctxt_len + msgid_len <= sizeof (buf)
? buf
: (char *) malloc (msgctxt_len + msgid_len));
if (msg_ctxt_id != NULL)
#endif
{
memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
msg_ctxt_id[msgctxt_len - 1] = '\004';
memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
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);
#endif
if (!(translation == msg_ctxt_id || translation == msgid_plural))
return translation;
}
return (n == 1 ? msgid : msgid_plural);
}
#endif /* _LIBGETTEXT_H */

118
lib/stdbool.in.h Normal file
View File

@ -0,0 +1,118 @@
/* Copyright (C) 2001, 2002, 2003, 2006, 2007 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _GL_STDBOOL_H
#define _GL_STDBOOL_H
/* ISO C 99 <stdbool.h> for platforms that lack it. */
/* Usage suggestions:
Programs that use <stdbool.h> should be aware of some limitations
and standards compliance issues.
Standards compliance:
- <stdbool.h> must be #included before 'bool', 'false', 'true'
can be used.
- You cannot assume that sizeof (bool) == 1.
- Programs should not undefine the macros bool, true, and false,
as C99 lists that as an "obsolescent feature".
Limitations of this substitute, when used in a C89 environment:
- <stdbool.h> must be #included before the '_Bool' type can be used.
- You cannot assume that _Bool is a typedef; it might be a macro.
- Bit-fields of type 'bool' are not supported. Portable code
should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
- In C99, casts and automatic conversions to '_Bool' or 'bool' are
performed in such a way that every nonzero value gets converted
to 'true', and zero gets converted to 'false'. This doesn't work
with this substitute. With this substitute, only the values 0 and 1
give the expected result when converted to _Bool' or 'bool'.
Also, it is suggested that programs use 'bool' rather than '_Bool';
this isn't required, but 'bool' is more common. */
/* 7.16. Boolean type and values */
/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
definitions below, but temporarily we have to #undef them. */
#ifdef __BEOS__
# include <OS.h> /* defines bool but not _Bool */
# undef false
# undef true
#endif
/* For the sake of symbolic names in gdb, we define true and false as
enum constants, not only as macros.
It is tempting to write
typedef enum { false = 0, true = 1 } _Bool;
so that gdb prints values of type 'bool' symbolically. But if we do
this, values of type '_Bool' may promote to 'int' or 'unsigned int'
(see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
(see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
enum; this ensures that '_Bool' promotes to 'int'. */
#if defined __cplusplus || defined __BEOS__
/* A compiler known to have 'bool'. */
/* If the compiler already has both 'bool' and '_Bool', we can assume they
are the same types. */
# if !@HAVE__BOOL@
typedef bool _Bool;
# endif
#else
# if !defined __GNUC__
/* If @HAVE__BOOL@:
Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
the built-in _Bool type is used. See
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
Similar bugs are likely with other compilers as well; this file
wouldn't be used if <stdbool.h> was working.
So we override the _Bool type.
If !@HAVE__BOOL@:
Need to define _Bool ourselves. As 'signed char' or as an enum type?
Use of a typedef, with SunPRO C, leads to a stupid
"warning: _Bool is a keyword in ISO C99".
Use of an enum type, with IRIX cc, leads to a stupid
"warning(1185): enumerated type mixed with another type".
The only benefit of the enum type, debuggability, is not important
with these compilers. So use 'signed char' and no typedef. */
# define _Bool signed char
enum { false = 0, true = 1 };
# else
/* With this compiler, trust the _Bool type if the compiler has it. */
# if !@HAVE__BOOL@
typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
# endif
# endif
#endif
#define bool _Bool
/* The other macros must be usable in preprocessor directives. */
#define false 0
#define true 1
#define __bool_true_false_are_defined 1
#endif /* _GL_STDBOOL_H */

262
lib/unistd.in.h Normal file
View File

@ -0,0 +1,262 @@
/* Substitute for and wrapper around <unistd.h>.
Copyright (C) 2004-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _GL_UNISTD_H
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_UNISTD_H@
# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
#endif
#ifndef _GL_UNISTD_H
#define _GL_UNISTD_H
/* mingw doesn't define the SEEK_* macros in <unistd.h>. */
#if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
# include <stdio.h>
#endif
/* mingw fails to declare _exit in <unistd.h>. */
#include <stdlib.h>
/* The definition of GL_LINK_WARNING is copied here. */
/* Declare overridden functions. */
#ifdef __cplusplus
extern "C" {
#endif
#if @GNULIB_CHOWN@
# if @REPLACE_CHOWN@
# ifndef REPLACE_CHOWN
# define REPLACE_CHOWN 1
# endif
# if REPLACE_CHOWN
/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
to GID (if GID is not -1). Follow symbolic links.
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/chown.html>. */
# define chown rpl_chown
extern int chown (const char *file, uid_t uid, gid_t gid);
# endif
# endif
#elif defined GNULIB_POSIXCHECK
# undef chown
# define chown(f,u,g) \
(GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
"doesn't treat a uid or gid of -1 on some systems - " \
"use gnulib module chown for portability"), \
chown (f, u, g))
#endif
#if @GNULIB_DUP2@
# if !@HAVE_DUP2@
/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
NEWFD = OLDFD, otherwise close NEWFD first if it is open.
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/dup2.html>. */
extern int dup2 (int oldfd, int newfd);
# endif
#elif defined GNULIB_POSIXCHECK
# undef dup2
# define dup2(o,n) \
(GL_LINK_WARNING ("dup2 is unportable - " \
"use gnulib module dup2 for portability"), \
dup2 (o, n))
#endif
#if @GNULIB_FCHDIR@
# if @REPLACE_FCHDIR@
/* Change the process' current working directory to the directory on which
the given file descriptor is open.
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/fchdir.html>. */
extern int fchdir (int /*fd*/);
# define close rpl_close
extern int close (int);
# define dup rpl_dup
extern int dup (int);
# define dup2 rpl_dup2
extern int dup2 (int, int);
# endif
#elif defined GNULIB_POSIXCHECK
# undef fchdir
# define fchdir(f) \
(GL_LINK_WARNING ("fchdir is unportable - " \
"use gnulib module fchdir for portability"), \
fchdir (f))
#endif
#if @GNULIB_FTRUNCATE@
# if !@HAVE_FTRUNCATE@
/* Change the size of the file to which FD is opened to become equal to LENGTH.
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/ftruncate.html>. */
extern int ftruncate (int fd, off_t length);
# endif
#elif defined GNULIB_POSIXCHECK
# undef ftruncate
# define ftruncate(f,l) \
(GL_LINK_WARNING ("ftruncate is unportable - " \
"use gnulib module ftruncate for portability"), \
ftruncate (f, l))
#endif
#if @GNULIB_GETCWD@
/* Include the headers that might declare getcwd so that they will not
cause confusion if included after this file. */
# include <stdlib.h>
# if @REPLACE_GETCWD@
/* Get the name of the current working directory, and put it in SIZE bytes
of BUF.
Return BUF if successful, or NULL if the directory couldn't be determined
or SIZE was too small.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/getcwd.html>.
Additionally, the gnulib module 'getcwd' guarantees the following GNU
extension: If BUF is NULL, an array is allocated with 'malloc'; the array
is SIZE bytes long, unless SIZE == 0, in which case it is as big as
necessary. */
# define getcwd rpl_getcwd
extern char * getcwd (char *buf, size_t size);
# endif
#elif defined GNULIB_POSIXCHECK
# undef getcwd
# define getcwd(b,s) \
(GL_LINK_WARNING ("getcwd is unportable - " \
"use gnulib module getcwd for portability"), \
getcwd (b, s))
#endif
#if @GNULIB_GETLOGIN_R@
/* Copies the user's login name to NAME.
The array pointed to by NAME has room for SIZE bytes.
Returns 0 if successful. Upon error, an error number is returned, or -1 in
the case that the login name cannot be found but no specific error is
provided (this case is hopefully rare but is left open by the POSIX spec).
See <http://www.opengroup.org/susv3xsh/getlogin.html>.
*/
# if !@HAVE_DECL_GETLOGIN_R@
# include <stddef.h>
extern int getlogin_r (char *name, size_t size);
# endif
#elif defined GNULIB_POSIXCHECK
# undef getlogin_r
# define getlogin_r(n,s) \
(GL_LINK_WARNING ("getlogin_r is unportable - " \
"use gnulib module getlogin_r for portability"), \
getlogin_r (n, s))
#endif
#if @GNULIB_LCHOWN@
# if @REPLACE_LCHOWN@
/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
to GID (if GID is not -1). Do not follow symbolic links.
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/lchown.html>. */
# define lchown rpl_lchown
extern int lchown (char const *file, uid_t owner, gid_t group);
# endif
#elif defined GNULIB_POSIXCHECK
# undef lchown
# define lchown(f,u,g) \
(GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
"systems - use gnulib module lchown for portability"), \
lchown (f, u, g))
#endif
#if @GNULIB_LSEEK@
# if @REPLACE_LSEEK@
/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
Return the new offset if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/lseek.html>. */
# define lseek rpl_lseek
extern off_t lseek (int fd, off_t offset, int whence);
# endif
#elif defined GNULIB_POSIXCHECK
# undef lseek
# define lseek(f,o,w) \
(GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
"systems - use gnulib module lseek for portability"), \
lseek (f, o, w))
#endif
#if @GNULIB_READLINK@
/* Read the contents of the symbolic link FILE and place the first BUFSIZE
bytes of it into BUF. Return the number of bytes placed into BUF if
successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/readlink.html>. */
# if !@HAVE_READLINK@
# include <stddef.h>
extern int readlink (const char *file, char *buf, size_t bufsize);
# endif
#elif defined GNULIB_POSIXCHECK
# undef readlink
# define readlink(f,b,s) \
(GL_LINK_WARNING ("readlink is unportable - " \
"use gnulib module readlink for portability"), \
readlink (f, b, s))
#endif
#if @GNULIB_SLEEP@
/* Pause the execution of the current thread for N seconds.
Returns the number of seconds left to sleep.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/sleep.html>. */
# if !@HAVE_SLEEP@
extern unsigned int sleep (unsigned int n);
# endif
#elif defined GNULIB_POSIXCHECK
# undef sleep
# define sleep(n) \
(GL_LINK_WARNING ("sleep is unportable - " \
"use gnulib module sleep for portability"), \
sleep (n))
#endif
#ifdef __cplusplus
}
#endif
#endif /* _GL_UNISTD_H */
#endif /* _GL_UNISTD_H */

28
link-warning.h Normal file
View File

@ -0,0 +1,28 @@
/* GL_LINK_WARNING("literal string") arranges to emit the literal string as
a linker warning on most glibc systems.
We use a linker warning rather than a preprocessor warning, because
#warning cannot be used inside macros. */
#ifndef GL_LINK_WARNING
/* This works on platforms with GNU ld and ELF object format.
Testing __GLIBC__ is sufficient for asserting that GNU ld is in use.
Testing __ELF__ guarantees the ELF object format.
Testing __GNUC__ is necessary for the compound expression syntax. */
# if defined __GLIBC__ && defined __ELF__ && defined __GNUC__
# define GL_LINK_WARNING(message) \
GL_LINK_WARNING1 (__FILE__, __LINE__, message)
# define GL_LINK_WARNING1(file, line, message) \
GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */
# define GL_LINK_WARNING2(file, line, message) \
GL_LINK_WARNING3 (file ":" #line ": warning: " message)
# define GL_LINK_WARNING3(message) \
({ static const char warning[sizeof (message)] \
__attribute__ ((__unused__, \
__section__ (".gnu.warning"), \
__aligned__ (1))) \
= message "\n"; \
(void)0; \
})
# else
# define GL_LINK_WARNING(message) ((void) 0)
# endif
#endif

83
m4/getopt.m4 Normal file
View File

@ -0,0 +1,83 @@
# getopt.m4 serial 13
dnl Copyright (C) 2002, 2003, 2004, 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.
# 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],
[
AC_LIBOBJ([getopt])
AC_LIBOBJ([getopt1])
gl_GETOPT_SUBSTITUTE_HEADER
gl_PREREQ_GETOPT
])
AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
[
GETOPT_H=getopt.h
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
[Define to rpl_ if the getopt replacement functions and variables
should be used.])
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*.
AC_DEFUN([gl_PREREQ_GETOPT],
[
AC_CHECK_DECLS_ONCE([getenv])
])

32
m4/gnulib-cache.m4 Normal file
View File

@ -0,0 +1,32 @@
# Copyright (C) 2004-2007 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
# Public License, this file may be distributed as part of a program
# that contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
#
# This file represents the specification of how gnulib-tool is used.
# It acts as a cache: It is written and read by gnulib-tool.
# In projects using CVS, this file is meant to be stored in CVS,
# like the configure.ac and various Makefile.am files.
# Specification in the form of a command-line invocation:
# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=. --no-libtool --macro-prefix=gl c-ctype getopt maintainer-makefile md5
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
gl_MODULES([c-ctype getopt maintainer-makefile md5])
gl_AVOID([])
gl_SOURCE_BASE([lib])
gl_M4_BASE([m4])
gl_PO_BASE([])
gl_DOC_BASE([doc])
gl_TESTS_BASE([tests])
gl_LIB([libgnu])
gl_MAKEFILE_NAME([])
gl_MACRO_PREFIX([gl])
gl_PO_DOMAIN([])

22
m4/gnulib-common.m4 Normal file
View File

@ -0,0 +1,22 @@
# gnulib-common.m4 serial 2
dnl Copyright (C) 2007 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.
# gl_MODULE_INDICATOR([modulename])
# defines a C macro indicating the presence of the given module.
AC_DEFUN([gl_MODULE_INDICATOR],
[
AC_DEFINE([GNULIB_]translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
[Define to 1 when using the gnulib module ]$1[.])
])
# 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], [], [
AC_DEFUN([AC_PROG_MKDIR_P],
[AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
MKDIR_P='$(mkdir_p)'
AC_SUBST([MKDIR_P])])])

118
m4/gnulib-comp.m4 Normal file
View File

@ -0,0 +1,118 @@
# DO NOT EDIT! GENERATED AUTOMATICALLY!
# Copyright (C) 2004-2007 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
# Public License, this file may be distributed as part of a program
# that contains a configuration script generated by Autoconf, under
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
#
# This file represents the compiled summary of the specification in
# gnulib-cache.m4. It lists the computed macro invocations that need
# to be invoked from configure.ac.
# In projects using CVS, this file can be treated like other built files.
# This macro should be invoked from ./configure.ac, in the section
# "Checks for programs", right after AC_PROG_CC, and certainly before
# any checks for libraries, header files, types and library functions.
AC_DEFUN([gl_EARLY],
[
m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace
m4_pattern_allow([^gl_ES$])dnl a valid locale name
m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
AC_REQUIRE([AC_PROG_RANLIB])
])
# This macro should be invoked from ./configure.ac, in the section
# "Check for header files, types and library functions".
AC_DEFUN([gl_INIT],
[
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]))
AM_CONDITIONAL([GL_COND_LIBTOOL], [false])
gl_cond_libtool=false
gl_libdeps=
gl_ltlibdeps=
gl_source_base='lib'
gl_GETOPT
AC_SUBST([LIBINTL])
AC_SUBST([LTLIBINTL])
AM_STDBOOL_H
gl_UNISTD_H
LIBGNU_LIBDEPS="$gl_libdeps"
AC_SUBST([LIBGNU_LIBDEPS])
LIBGNU_LTLIBDEPS="$gl_ltlibdeps"
AC_SUBST([LIBGNU_LTLIBDEPS])
m4_popdef([AC_LIBSOURCES])
m4_popdef([AC_REPLACE_FUNCS])
m4_popdef([AC_LIBOBJ])
AC_CONFIG_COMMANDS_PRE([
gl_libobjs=
gl_ltlibobjs=
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
gl_libobjs="$gl_libobjs $i.$ac_objext"
gl_ltlibobjs="$gl_ltlibobjs $i.lo"
done
fi
AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
])
])
# Like AC_LIBOBJ, except that the module name goes
# into gl_LIBOBJS instead of into LIBOBJS.
AC_DEFUN([gl_LIBOBJ], [
AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl
gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext"
])
# Like AC_REPLACE_FUNCS, except that the module name goes
# into gl_LIBOBJS instead of into LIBOBJS.
AC_DEFUN([gl_REPLACE_FUNCS], [
m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)])
])
# Like AC_LIBSOURCES, except the directory where the source file is
# expected is derived from the gnulib-tool parametrization,
# and alloca is special cased (for the alloca-opt module).
# We could also entirely rely on EXTRA_lib..._SOURCES.
AC_DEFUN([gl_LIBSOURCES], [
m4_foreach([_gl_NAME], [$1], [
m4_if(_gl_NAME, [alloca.c], [], [
m4_syscmd([test -r lib/]_gl_NAME[ || test ! -d lib])dnl
m4_if(m4_sysval, [0], [],
[AC_FATAL([missing lib/]_gl_NAME)])
])
])
])
# 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/GNUmakefile
build-aux/link-warning.h
build-aux/maint.mk
lib/c-ctype.c
lib/c-ctype.h
lib/getopt.c
lib/getopt.in.h
lib/getopt1.c
lib/getopt_int.h
lib/gettext.h
lib/stdbool.in.h
lib/unistd.in.h
m4/getopt.m4
m4/gnulib-common.m4
m4/include_next.m4
m4/stdbool.m4
m4/unistd_h.m4
])

33
m4/gnulib-tool.m4 Normal file
View File

@ -0,0 +1,33 @@
# gnulib-tool.m4 serial 1
dnl Copyright (C) 2004-2005 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 The following macros need not be invoked explicitly.
dnl Invoking them does nothing except to declare default arguments
dnl for "gnulib-tool --import".
dnl Usage: gl_MODULES([module1 module2 ...])
AC_DEFUN([gl_MODULES], [])
dnl Usage: gl_AVOID([module1 module2 ...])
AC_DEFUN([gl_AVOID], [])
dnl Usage: gl_SOURCE_BASE([DIR])
AC_DEFUN([gl_SOURCE_BASE], [])
dnl Usage: gl_M4_BASE([DIR])
AC_DEFUN([gl_M4_BASE], [])
dnl Usage: gl_LIB([LIBNAME])
AC_DEFUN([gl_LIB], [])
dnl Usage: gl_LGPL
AC_DEFUN([gl_LGPL], [])
dnl Usage: gl_LIBTOOL
AC_DEFUN([gl_LIBTOOL], [])
dnl Usage: gl_MACRO_PREFIX([PREFIX])
AC_DEFUN([gl_MACRO_PREFIX], [])

107
m4/include_next.m4 Normal file
View File

@ -0,0 +1,107 @@
# include_next.m4 serial 4
dnl Copyright (C) 2006, 2007 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 Paul Eggert and Derek Price.
AC_DEFUN([gl_INCLUDE_NEXT],
[
AC_LANG_PREPROC_REQUIRE()
AC_CACHE_CHECK([whether the preprocessor supports include_next],
[gl_cv_have_include_next],
[rm -rf conftestd1 conftestd2
mkdir conftestd1 conftestd2
cat <<EOF > conftestd1/conftest.h
#define DEFINED_IN_CONFTESTD1
#include_next <conftest.h>
#ifdef DEFINED_IN_CONFTESTD2
int foo;
#else
#error "include_next doesn't work"
#endif
EOF
cat <<EOF > conftestd2/conftest.h
#ifndef DEFINED_IN_CONFTESTD1
#error "include_next test doesn't work"
#endif
#define DEFINED_IN_CONFTESTD2
EOF
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -Iconftestd1 -Iconftestd2"
AC_COMPILE_IFELSE([#include <conftest.h>],
[gl_cv_have_include_next=yes],
[gl_cv_have_include_next=no])
CPPFLAGS="$save_CPPFLAGS"
rm -rf conftestd1 conftestd2
])
if test $gl_cv_have_include_next = yes; then
dnl FIXME: Remove HAVE_INCLUDE_NEXT and update everything that uses it
dnl to use @INCLUDE_NEXT@ instead.
AC_DEFINE([HAVE_INCLUDE_NEXT], 1,
[Define if your compiler supports the #include_next directive.])
INCLUDE_NEXT=include_next
else
INCLUDE_NEXT=include
fi
AC_SUBST([INCLUDE_NEXT])
])
# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
# ------------------------------------------
# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
# '<foo.h>'; otherwise define it to be
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
# That way, a header file with the following line:
# #@INCLUDE_NEXT@ @NEXT_FOO_H@
# behaves (after sed substitution) as if it contained
# #include_next <foo.h>
# even if the compiler does not support include_next.
# The three "///" are to pacify Sun C 5.8, which otherwise would say
# "warning: #include of /usr/include/... may be non-portable".
# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
AC_DEFUN([gl_CHECK_NEXT_HEADERS],
[
AC_REQUIRE([gl_INCLUDE_NEXT])
AC_CHECK_HEADERS_ONCE([$1])
AC_FOREACH([gl_HEADER_NAME], [$1],
[AS_VAR_PUSHDEF([gl_next_header],
[gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
if test $gl_cv_have_include_next = yes; then
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
else
AC_CACHE_CHECK(
[absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
m4_quote(m4_defn([gl_next_header])),
[AS_VAR_PUSHDEF([gl_header_exists],
[ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
if test AS_VAR_GET(gl_header_exists) = yes; then
AC_LANG_CONFTEST(
[AC_LANG_SOURCE(
[[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
)])
dnl eval is necessary to expand ac_cpp.
dnl Ultrix and Pyramid sh refuse to redirect output of eval,
dnl so use subshell.
AS_VAR_SET([gl_next_header],
['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
s#^/[^/]#//&#
p
q
}'`'"'])
else
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
fi
AS_VAR_POPDEF([gl_header_exists])])
fi
AC_SUBST(
AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))),
[AS_VAR_GET([gl_next_header])])
AS_VAR_POPDEF([gl_next_header])])
])

115
m4/stdbool.m4 Normal file
View File

@ -0,0 +1,115 @@
# Check for stdbool.h that conforms to C99.
dnl Copyright (C) 2002-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.
# Prepare for substituting <stdbool.h> if it is not supported.
AC_DEFUN([AM_STDBOOL_H],
[
AC_REQUIRE([AC_HEADER_STDBOOL])
# Define two additional variables used in the Makefile substitution.
if test "$ac_cv_header_stdbool_h" = yes; then
STDBOOL_H=''
else
STDBOOL_H='stdbool.h'
fi
AC_SUBST([STDBOOL_H])
if test "$ac_cv_type__Bool" = yes; then
HAVE__BOOL=1
else
HAVE__BOOL=0
fi
AC_SUBST([HAVE__BOOL])
])
# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
# This macro is only needed in autoconf <= 2.59. Newer versions of autoconf
# have this macro built-in.
AC_DEFUN([AC_HEADER_STDBOOL],
[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
[ac_cv_header_stdbool_h],
[AC_TRY_COMPILE(
[
#include <stdbool.h>
#ifndef bool
"error: bool is not defined"
#endif
#ifndef false
"error: false is not defined"
#endif
#if false
"error: false is not 0"
#endif
#ifndef true
"error: true is not defined"
#endif
#if true != 1
"error: true is not 1"
#endif
#ifndef __bool_true_false_are_defined
"error: __bool_true_false_are_defined is not defined"
#endif
struct s { _Bool s: 1; _Bool t; } s;
char a[true == 1 ? 1 : -1];
char b[false == 0 ? 1 : -1];
char c[__bool_true_false_are_defined == 1 ? 1 : -1];
char d[(bool) 0.5 == true ? 1 : -1];
bool e = &s;
char f[(_Bool) 0.0 == false ? 1 : -1];
char g[true];
char h[sizeof (_Bool)];
char i[sizeof s.t];
enum { j = false, k = true, l = false * true, m = true * 256 };
_Bool n[m];
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
#if defined __xlc__ || defined __GNUC__
/* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
reported by James Lemley on 2005-10-05; see
http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
This test is not quite right, since xlc is allowed to
reject this program, as the initializer for xlcbug is
not one of the forms that C requires support for.
However, doing the test right would require a run-time
test, and that would make cross-compilation harder.
Let us hope that IBM fixes the xlc bug, and also adds
support for this kind of constant expression. In the
meantime, this test will reject xlc, which is OK, since
our stdbool.h substitute should suffice. We also test
this with GCC, where it should work, to detect more
quickly whether someone messes up the test in the
future. */
char digs[] = "0123456789";
int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
#endif
/* Catch a bug in an HP-UX C compiler. See
http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
*/
_Bool q = true;
_Bool *pq = &q;
],
[
*pq |= q;
*pq |= ! q;
/* Refer to every declared value, to avoid compiler optimizations. */
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ !m + !n + !o + !p + !q + !pq);
],
[ac_cv_header_stdbool_h=yes],
[ac_cv_header_stdbool_h=no])])
AC_CHECK_TYPES([_Bool])
if test $ac_cv_header_stdbool_h = yes; then
AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
fi])

56
m4/unistd_h.m4 Normal file
View File

@ -0,0 +1,56 @@
# unistd_h.m4 serial 9
dnl Copyright (C) 2006-2007 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 Simon Josefsson, Bruno Haible.
AC_DEFUN([gl_UNISTD_H],
[
dnl Use AC_REQUIRE here, so that the default behavior below is expanded
dnl once only, before all statements that occur in other macros.
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
gl_CHECK_NEXT_HEADERS([unistd.h])
AC_CHECK_HEADERS_ONCE([unistd.h])
if test $ac_cv_header_unistd_h = yes; then
HAVE_UNISTD_H=1
else
HAVE_UNISTD_H=0
fi
AC_SUBST([HAVE_UNISTD_H])
])
AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
[
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
])
AC_DEFUN([gl_UNISTD_H_DEFAULTS],
[
GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN])
GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_DUP2=1; AC_SUBST([HAVE_DUP2])
HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
])

123
maint.mk Normal file
View File

@ -0,0 +1,123 @@
# -*-Makefile-*-
# This Makefile fragment is intended to be useful by any GNU-like project.
# This file originate from coreutils, CPPI, Bison, and Autoconf.
# Copyright (C) 2001-2007 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/>.
ME := maint.mk
# List of all C-like source code files that will be tested for
# stylistic "errors". You may want to define this to something
# more complex in Makefile.cfg.
C_SOURCES ?= $(shell find . -name '*.[chly]')
# Add some more files to check, typically set in Makefile.cfg.
C_SOURCES += $(C_SOURCES_ADD)
# Do not save the original name or timestamp in the .tar.gz file.
# Use --rsyncable if available.
gzip_rsyncable := \
$(shell gzip --help|grep rsyncable >/dev/null && echo --rsyncable)
GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
# Prevent programs like 'sort' from considering distinct strings to be equal.
# Doing it here saves us from having to set LC_ALL elsewhere in this file.
export LC_ALL = C
# Casting arguments to free is never necessary.
sc_cast_of_argument_to_free:
@grep -nE '\<free *\( *\(' $(C_SOURCES) && \
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
exit 1; } || :
sc_cast_of_x_alloc_return_value:
@grep -nE '\*\) *x(m|c|re)alloc\>' $(C_SOURCES) && \
{ echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
exit 1; } || :
sc_cast_of_alloca_return_value:
@grep -nE '\*\) *alloca\>' $(C_SOURCES) && \
{ echo '$(ME): don'\''t cast alloca return value' 1>&2; \
exit 1; } || :
sc_space_tab:
@grep -n '[ ] ' $(C_SOURCES) && \
{ echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
1>&2; exit 1; } || :
# Don't use the old ato* functions in `real' code.
# They provide no error checking mechanism.
# Instead, use strto* functions.
sc_prohibit_atoi_atof:
@grep -nE '\<ato([filq]|ll)\>' $(C_SOURCES) && \
{ echo '$(ME): do not use ato''f, ato''i, ato''l, ato''ll, or ato''q' \
1>&2; exit 1; } || :
# Using EXIT_SUCCESS as the first argument to error is misleading,
# since when that parameter is 0, error does not exit. Use `0' instead.
sc_error_exit_success:
@grep -nF 'error (EXIT_SUCCESS,' $(C_SOURCES) && \
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
exit 1; } || :
# Stylistic, use #ifdef instead of #if
sc_no_if_have_config_h:
@grep -n '^# *if HAVE_CONFIG_H' $(C_SOURCES) && \
{ echo '$(ME): found use of #if HAVE_CONFIG_H; use #ifdef' \
1>&2; exit 1; } || :
# Prohibit the inclusion of assert.h without an actual use of assert.
sc_prohibit_assert_without_use:
@files=$$(grep -l '# *include [<"]assert\.h[>"]' $(C_SOURCES) \
| grep '\.[cy]$$') && \
grep -L '\<assert (' $$files \
| grep . && \
{ echo "$(ME): the above files include <assert.h> but don't use it" \
1>&2; exit 1; } || :
sc_obsolete_symbols:
@grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' $(C_SOURCES) && \
{ echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
1>&2; exit 1; } || :
# Each nonempty line must start with a year number, or a TAB.
sc_changelog:
@grep -n '^[^12 ]' $$(find . -name ChangeLog) && \
{ echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
exit 1; } || :
# Collect the names of rules starting with `sc_'.
syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
.PHONY: $(syntax-check-rules)
syntax-check: $(syntax-check-rules)
# Update gettext files.
PACKAGE ?= $(shell basename $(PWD))
POURL = http://translationproject.org/latest/$(PACKAGE)/
PODIR ?= po
refresh-po:
rm -f $(PODIR)/*.po && \
echo "$(ME): getting translations into po (please ignore the robots.txt ERROR 404)..." && \
wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursive --level 1 --accept .po --accept .po.1 $(POURL) && \
echo 'en@boldquot' > $(PODIR)/LINGUAS && \
echo 'en@quot' >> $(PODIR)/LINGUAS && \
ls $(PODIR)/*.po | sed 's/.po//' | sed 's,$(PODIR)/,,' | sort >> $(PODIR)/LINGUAS
INDENT_SOURCES ?= $(C_SOURCES)
.PHONY: indent
indent:
indent $(INDENT_SOURCES)