Resync with gnulib.

* Makefile.in (GNULIB_CFLAGS): New variable.
	* conf/common.rmk (grub_mkisofs_CFLAGS): Add GNULIB_CFLAGS.
	(grub_script_check_CFLAGS): New variable.
	* gnulib/alloca.h: Resync with gnulib.
	* gnulib/error.c: Likewise.
	* gnulib/error.h: Likewise.
	* gnulib/fnmatch.c: Likewise.
	* gnulib/fnmatch_loop.c: Likewise.
	* gnulib/getdelim.c: Likewise.
	* gnulib/getline.c: Likewise.
	* gnulib/getopt.c: Likewise.
	* gnulib/getopt1.c: Likewise.
	* gnulib/getopt_int.h: Likewise.
	* gnulib/gettext.h: Likewise.
	* gnulib/progname.c: Likewise.
	* gnulib/progname.h: Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-27 12:53:40 +01:00
parent 394a3120a7
commit 3506b90b0d
16 changed files with 1891 additions and 1821 deletions

View file

@ -1,3 +1,24 @@
2010-03-27 Vladimir Serbinenko <phcoder@gmail.com>
Resync with gnulib.
* Makefile.in (GNULIB_CFLAGS): New variable.
* conf/common.rmk (grub_mkisofs_CFLAGS): Add GNULIB_CFLAGS.
(grub_script_check_CFLAGS): New variable.
* gnulib/alloca.h: Resync with gnulib.
* gnulib/error.c: Likewise.
* gnulib/error.h: Likewise.
* gnulib/fnmatch.c: Likewise.
* gnulib/fnmatch_loop.c: Likewise.
* gnulib/getdelim.c: Likewise.
* gnulib/getline.c: Likewise.
* gnulib/getopt.c: Likewise.
* gnulib/getopt1.c: Likewise.
* gnulib/getopt_int.h: Likewise.
* gnulib/gettext.h: Likewise.
* gnulib/progname.c: Likewise.
* gnulib/progname.h: Likewise.
2010-03-27 Grégoire Sutre <gregoire.sutre@gmail.com>
Fix a build failure (-Wundef -Werror) when ENABLE_NLS is not defined,

View file

@ -79,6 +79,7 @@ LIBS = @LIBS@ $(LIBINTL)
CC = @CC@
CFLAGS = @CFLAGS@
GNULIB_CFLAGS = -Wno-undef -D_GL_UNUSED="__attribute__ ((unused))"
ASFLAGS = @ASFLAGS@
LDFLAGS = @LDFLAGS@ $(LIBS)
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \

View file

@ -56,7 +56,7 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \
gnulib/error.c gnulib/progname.c
grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
-I$(srcdir)/util/mkisofs/include \
-Wno-all -Werror
-Wno-all -Werror $(GNULIB_CFLAGS)
# For grub-fstest.
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
@ -111,7 +111,7 @@ grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c
kern/handler.c kern/err.c kern/parser.c kern/list.c \
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
grub_script.yy.c
grub_script_check_CFLAGS = $(GNULIB_CFLAGS)
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
DEFSYMFILES += kernel_syms.lst

View file

@ -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

View file

@ -1,5 +1,5 @@
/* Error handler for noninteractive utilities
Copyright (C) 1990-1998, 2000-2007, 2009 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
@ -86,6 +86,7 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
#else /* not _LIBC */
# include <fcntl.h>
# include <unistd.h>
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
# ifndef HAVE_DECL_STRERROR_R
@ -103,6 +104,31 @@ extern char *program_name;
# endif /* HAVE_STRERROR_R || defined strerror_r */
#endif /* not _LIBC */
static inline void
flush_stdout (void)
{
#if !_LIBC && defined F_GETFL
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 && 0 <= fcntl (stdout_fd, F_GETFL))
#endif
fflush (stdout);
}
static void
print_errno_message (int errnum)
{
@ -238,13 +264,7 @@ error (int status, int errnum, const char *message, ...)
0);
#endif
#if !_LIBC && defined F_GETFL
/* 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 <= fcntl (1, F_GETFL))
#endif
fflush (stdout);
flush_stdout ();
#ifdef _LIBC
_IO_flockfile (stderr);
#endif
@ -303,13 +323,7 @@ error_at_line (int status, int errnum, const char *file_name,
0);
#endif
#if !_LIBC && defined F_GETFL
/* 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 <= fcntl (1, F_GETFL))
#endif
fflush (stdout);
flush_stdout ();
#ifdef _LIBC
_IO_flockfile (stderr);
#endif

View file

@ -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,15 +20,14 @@
#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

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007
Free Software Foundation, Inc.
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
2003, 2004, 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
@ -89,7 +89,7 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
# define isblank(c) ((c) == ' ' || (c) == '\t')
# endif
# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
# define STREQ(s1, s2) (strcmp (s1, s2) == 0)
# if defined _LIBC || WIDE_CHAR_SUPPORT
/* The GNU C library provides support for user-defined character classes

View file

@ -1,5 +1,5 @@
/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006
Free Software Foundation, Inc.
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
2003, 2004, 2005, 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
@ -382,15 +382,20 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
/* We found a table entry. Now see whether the
character we are currently at has the same
equivalance class value. */
int len = weights[idx];
int len = weights[idx & 0xffffff];
int32_t idx2;
const UCHAR *np = (const UCHAR *) n;
idx2 = findidx (&np);
if (idx2 != 0 && len == weights[idx2])
if (idx2 != 0
&& (idx >> 24) == (idx2 >> 24)
&& len == weights[idx2 & 0xffffff])
{
int cnt = 0;
idx &= 0xffffff;
idx2 &= 0xffffff;
while (cnt < len
&& (weights[idx + 1 + cnt]
== weights[idx2 + 1 + cnt]))
@ -1069,10 +1074,9 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
size_t plensize; \
size_t newpsize; \
\
assert (p > startp); \
plen = (opt == L_('?') || opt == L_('@') \
? pattern_len \
: (unsigned) (p - startp) + 1); \
: p - startp + 1UL); \
plensize = plen * sizeof (CHAR); \
newpsize = offsetof (struct patternlist, str) + plensize; \
if ((size_t) -1 / sizeof (CHAR) < plen \

View file

@ -1,6 +1,6 @@
/* getdelim.c --- Implementation of replacement getdelim function.
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007,
2008, 2009 Free Software Foundation, Inc.
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007, 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
@ -21,13 +21,16 @@
#include <config.h>
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */
#define _GL_ARG_NONNULL(params)
#include <stdio.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#ifndef SSIZE_MAX
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))

View file

@ -1,5 +1,5 @@
/* getline.c --- Implementation of replacement getline function.
Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
Copyright (C) 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

View file

@ -1,9 +1,9 @@
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
NOTE: getopt is part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to drepper@gnu.org
before changing it!
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006,2008
Free Software Foundation, Inc.
Copyright (C) 1987-1996, 1998-2004, 2006, 2008-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
@ -41,12 +41,9 @@
# include <wchar.h>
#endif
#ifndef attribute_hidden
# define attribute_hidden
#endif
/* Unlike standard Unix `getopt', functions like `getopt_long'
let the user intersperse the options with the other arguments.
/* This version of `getopt' appears to the caller like standard Unix `getopt'
but it behaves differently for the user, since it allows the user
to intersperse the options with the other arguments.
As `getopt_long' works, it permutes the elements of ARGV so that,
when it is done, all the options precede everything else. Thus
@ -54,7 +51,7 @@
Using `getopt' or setting the environment variable POSIXLY_CORRECT
disables permutation.
Then the application's behavior is completely standard.
Then the behavior is completely standard.
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments. */
@ -225,8 +222,9 @@ exchange (char **argv, struct _getopt_data *d)
/* Initialize the internal data when the first call is made. */
static const char *
_getopt_initialize (int argc, char **argv, const char *optstring,
int posixly_correct, struct _getopt_data *d)
_getopt_initialize (int argc _GL_UNUSED,
char **argv _GL_UNUSED, const char *optstring,
struct _getopt_data *d, int posixly_correct)
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
@ -330,6 +328,10 @@ _getopt_initialize (int argc, char **argv, const char *optstring,
`flag' field is nonzero, the value of the option's `val' field
if the `flag' field is zero.
The elements of ARGV aren't really const, because we permute them.
But we pretend they're const in the prototype to be compatible
with other systems.
LONGOPTS is a vector of `struct option' terminated by an
element containing a name which is zero.
@ -338,15 +340,12 @@ _getopt_initialize (int argc, char **argv, const char *optstring,
recent call.
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
long-named options.
If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT
environment variable were set. */
long-named options. */
int
_getopt_internal_r (int argc, char **argv, const char *optstring,
const struct option *longopts, int *longind,
int long_only, int posixly_correct, struct _getopt_data *d)
int long_only, struct _getopt_data *d, int posixly_correct)
{
int print_errors = d->opterr;
if (optstring[0] == ':')
@ -361,8 +360,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
{
if (d->optind == 0)
d->optind = 1; /* Don't scan ARGV[0], the program name. */
optstring = _getopt_initialize (argc, argv, optstring,
posixly_correct, d);
optstring = _getopt_initialize (argc, argv, optstring, d,
posixly_correct);
d->__initialized = 1;
}
@ -523,7 +522,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
#if defined _LIBC && defined USE_IN_LIBIO
char *buf;
if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"),
argv[0], argv[d->optind]) >= 0)
{
_IO_flockfile (stderr);
@ -539,7 +538,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
free (buf);
}
#else
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
argv[0], argv[d->optind]);
#endif
}
@ -573,11 +572,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
/* --option */
#if defined _LIBC && defined USE_IN_LIBIO
n = __asprintf (&buf, _("\
%s: option `--%s' doesn't allow an argument\n"),
%s: option '--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
#else
fprintf (stderr, _("\
%s: option `--%s' doesn't allow an argument\n"),
%s: option '--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
#endif
}
@ -586,12 +585,12 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
/* +option or -option */
#if defined _LIBC && defined USE_IN_LIBIO
n = __asprintf (&buf, _("\
%s: option `%c%s' doesn't allow an argument\n"),
%s: option '%c%s' doesn't allow an argument\n"),
argv[0], argv[d->optind - 1][0],
pfound->name);
#else
fprintf (stderr, _("\
%s: option `%c%s' doesn't allow an argument\n"),
%s: option '%c%s' doesn't allow an argument\n"),
argv[0], argv[d->optind - 1][0],
pfound->name);
#endif
@ -634,7 +633,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
char *buf;
if (__asprintf (&buf, _("\
%s: option `%s' requires an argument\n"),
%s: option '%s' requires an argument\n"),
argv[0], argv[d->optind - 1]) >= 0)
{
_IO_flockfile (stderr);
@ -652,7 +651,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
}
#else
fprintf (stderr,
_("%s: option `%s' requires an argument\n"),
_("%s: option '%s' requires an argument\n"),
argv[0], argv[d->optind - 1]);
#endif
}
@ -690,10 +689,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
{
/* --option */
#if defined _LIBC && defined USE_IN_LIBIO
n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"),
argv[0], d->__nextchar);
#else
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
argv[0], d->__nextchar);
#endif
}
@ -701,10 +700,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
{
/* +option or -option */
#if defined _LIBC && defined USE_IN_LIBIO
n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"),
argv[0], argv[d->optind][0], d->__nextchar);
#else
fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
fprintf (stderr, _("%s: unrecognized option '%c%s'\n"),
argv[0], argv[d->optind][0], d->__nextchar);
#endif
}
@ -752,25 +751,12 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
int n;
#endif
if (d->__posixly_correct)
{
/* 1003.2 specifies the format of this message. */
#if defined _LIBC && defined USE_IN_LIBIO
n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"),
argv[0], c);
#else
fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
#endif
}
else
{
#if defined _LIBC && defined USE_IN_LIBIO
n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
argv[0], c);
#else
fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
#endif
}
#if defined _LIBC && defined USE_IN_LIBIO
if (n >= 0)
@ -815,12 +801,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
{
if (print_errors)
{
/* 1003.2 specifies the format of this message. */
#if defined _LIBC && defined USE_IN_LIBIO
char *buf;
if (__asprintf (&buf,
_("%s: option requires an argument -- %c\n"),
_("%s: option requires an argument -- '%c'\n"),
argv[0], c) >= 0)
{
_IO_flockfile (stderr);
@ -836,7 +821,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
free (buf);
}
#else
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
fprintf (stderr,
_("%s: option requires an argument -- '%c'\n"),
argv[0], c);
#endif
}
@ -889,7 +875,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
#if defined _LIBC && defined USE_IN_LIBIO
char *buf;
if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"),
argv[0], argv[d->optind]) >= 0)
{
_IO_flockfile (stderr);
@ -905,7 +891,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
free (buf);
}
#else
fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
argv[0], argv[d->optind]);
#endif
}
@ -930,7 +916,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
char *buf;
if (__asprintf (&buf, _("\
%s: option `-W %s' doesn't allow an argument\n"),
%s: option '-W %s' doesn't allow an argument\n"),
argv[0], pfound->name) >= 0)
{
_IO_flockfile (stderr);
@ -948,7 +934,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
}
#else
fprintf (stderr, _("\
%s: option `-W %s' doesn't allow an argument\n"),
%s: option '-W %s' doesn't allow an argument\n"),
argv[0], pfound->name);
#endif
}
@ -969,7 +955,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
char *buf;
if (__asprintf (&buf, _("\
%s: option `%s' requires an argument\n"),
%s: option '%s' requires an argument\n"),
argv[0], argv[d->optind - 1]) >= 0)
{
_IO_flockfile (stderr);
@ -987,7 +973,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
}
#else
fprintf (stderr,
_("%s: option `%s' requires an argument\n"),
_("%s: option '%s' requires an argument\n"),
argv[0], argv[d->optind - 1]);
#endif
}
@ -1036,12 +1022,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
{
if (print_errors)
{
/* 1003.2 specifies the format of this message. */
#if defined _LIBC && defined USE_IN_LIBIO
char *buf;
if (__asprintf (&buf, _("\
%s: option requires an argument -- %c\n"),
%s: option requires an argument -- '%c'\n"),
argv[0], c) >= 0)
{
_IO_flockfile (stderr);
@ -1058,7 +1043,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
}
#else
fprintf (stderr,
_("%s: option requires an argument -- %c\n"),
_("%s: option requires an argument -- '%c'\n"),
argv[0], c);
#endif
}
@ -1081,16 +1066,17 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
int
_getopt_internal (int argc, char **argv, const char *optstring,
const struct option *longopts, int *longind,
int long_only, int posixly_correct)
const struct option *longopts, int *longind, int long_only,
int posixly_correct)
{
int result;
getopt_data.optind = optind;
getopt_data.opterr = opterr;
result = _getopt_internal_r (argc, argv, optstring, longopts, longind,
long_only, posixly_correct, &getopt_data);
result = _getopt_internal_r (argc, argv, optstring, longopts,
longind, long_only, &getopt_data,
posixly_correct);
optind = getopt_data.optind;
optarg = getopt_data.optarg;
@ -1110,10 +1096,23 @@ enum { POSIXLY_CORRECT = 1 };
int
getopt (int argc, char *const *argv, const char *optstring)
{
return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0,
POSIXLY_CORRECT);
return _getopt_internal (argc, (char **) argv, optstring,
(const struct option *) 0,
(int *) 0,
0, POSIXLY_CORRECT);
}
#ifdef _LIBC
int
__posix_getopt (int argc, char *const *argv, const char *optstring)
{
return _getopt_internal (argc, argv, optstring,
(const struct option *) 0,
(int *) 0,
0, 1);
}
#endif
#ifdef TEST
@ -1161,7 +1160,7 @@ main (int argc, char **argv)
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
printf ("option c with value '%s'\n", optarg);
break;
case '?':

View file

@ -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
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
@ -50,7 +50,7 @@ _getopt_long_r (int argc, char **argv, const char *options,
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.
@ -73,7 +73,7 @@ _getopt_long_only_r (int argc, char **argv, const char *options,
struct _getopt_data *d)
{
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
1, 0, d);
1, d, 0);
}
@ -91,7 +91,7 @@ main (int argc, char **argv)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
static const struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},

View file

@ -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
@ -19,6 +19,8 @@
#ifndef _GETOPT_INT_H
#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,
@ -113,8 +115,8 @@ struct _getopt_data
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);
int __long_only, struct _getopt_data *__data,
int __posixly_correct);
extern int _getopt_long_r (int ___argc, char **___argv,
const char *__shortopts,

View file

@ -1,5 +1,6 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002, 2004-2006 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
@ -63,21 +64,30 @@
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". */
# undef gettext
# define gettext(Msgid) ((const char *) (Msgid))
# undef dgettext
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
# undef dcgettext
# define dcgettext(Domainname, Msgid, Category) \
((void) (Category), dgettext (Domainname, Msgid))
# undef ngettext
# define ngettext(Msgid1, Msgid2, N) \
((N) == 1 \
? ((void) (Msgid2), (const char *) (Msgid1)) \
: ((void) (Msgid1), (const char *) (Msgid2)))
# undef dngettext
# define dngettext(Domainname, Msgid1, Msgid2, N) \
((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
# define bindtextdomain(Domainname, Dirname) \
((void) (Domainname), (const char *) (Dirname))
# undef bind_textdomain_codeset
# define bind_textdomain_codeset(Domainname, Codeset) \
((void) (Domainname), (const char *) (Codeset))

View file

@ -1,6 +1,6 @@
/* Program name management.
Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.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
@ -23,6 +23,8 @@
#include "progname.h"
#include <errno.h> /* get program_invocation_name declaration */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -30,7 +32,9 @@
To be initialized by main(). */
const char *program_name = NULL;
/* Set program_name, based on argv[0]. */
/* Set program_name, based on argv[0].
argv0 must be a string allocated with indefinite extent, and must not be
modified after this call. */
void
set_program_name (const char *argv0)
{
@ -42,6 +46,16 @@ set_program_name (const char *argv0)
const char *slash;
const char *base;
/* Sanity check. POSIX requires the invoking process to pass a non-NULL
argv[0]. */
if (argv0 == NULL)
{
/* It's a bug in the invoking program. Help diagnosing it. */
fputs ("A NULL argv[0] was passed through an exec system call.\n",
stderr);
abort ();
}
slash = strrchr (argv0, '/');
base = (slash != NULL ? slash + 1 : argv0);
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)

View file

@ -1,6 +1,6 @@
/* Program name management.
Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
Copyright (C) 2001-2004, 2006, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.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
@ -31,7 +31,9 @@ extern "C" {
/* String containing name the program is called with. */
extern const char *program_name;
/* Set program_name, based on argv[0]. */
/* Set program_name, based on argv[0].
argv0 must be a string allocated with indefinite extent, and must not be
modified after this call. */
extern void set_program_name (const char *argv0);
#if ENABLE_RELOCATABLE