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:
parent
394a3120a7
commit
3506b90b0d
16 changed files with 1891 additions and 1821 deletions
21
ChangeLog
21
ChangeLog
|
@ -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>
|
2010-03-27 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||||
|
|
||||||
Fix a build failure (-Wundef -Werror) when ENABLE_NLS is not defined,
|
Fix a build failure (-Wundef -Werror) when ENABLE_NLS is not defined,
|
||||||
|
|
|
@ -79,6 +79,7 @@ LIBS = @LIBS@ $(LIBINTL)
|
||||||
|
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
|
GNULIB_CFLAGS = -Wno-undef -D_GL_UNUSED="__attribute__ ((unused))"
|
||||||
ASFLAGS = @ASFLAGS@
|
ASFLAGS = @ASFLAGS@
|
||||||
LDFLAGS = @LDFLAGS@ $(LIBS)
|
LDFLAGS = @LDFLAGS@ $(LIBS)
|
||||||
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
|
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
|
||||||
|
|
|
@ -56,7 +56,7 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \
|
||||||
gnulib/error.c gnulib/progname.c
|
gnulib/error.c gnulib/progname.c
|
||||||
grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
|
grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
|
||||||
-I$(srcdir)/util/mkisofs/include \
|
-I$(srcdir)/util/mkisofs/include \
|
||||||
-Wno-all -Werror
|
-Wno-all -Werror $(GNULIB_CFLAGS)
|
||||||
|
|
||||||
# For grub-fstest.
|
# For grub-fstest.
|
||||||
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
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/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 \
|
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
|
||||||
grub_script.yy.c
|
grub_script.yy.c
|
||||||
|
grub_script_check_CFLAGS = $(GNULIB_CFLAGS)
|
||||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||||
DEFSYMFILES += kernel_syms.lst
|
DEFSYMFILES += kernel_syms.lst
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* Memory allocation on the stack.
|
/* Memory allocation on the stack.
|
||||||
|
|
||||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
|
Copyright (C) 1995, 1999, 2001-2004, 2006-2010 Free Software Foundation,
|
||||||
Foundation, Inc.
|
Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
||||||
under the terms of the GNU General Public License as published
|
under the terms of the GNU General Public License as published
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Error handler for noninteractive utilities
|
/* 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 file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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 */
|
#else /* not _LIBC */
|
||||||
|
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
|
||||||
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||||
# ifndef HAVE_DECL_STRERROR_R
|
# ifndef HAVE_DECL_STRERROR_R
|
||||||
|
@ -103,6 +104,31 @@ extern char *program_name;
|
||||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||||
#endif /* not _LIBC */
|
#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
|
static void
|
||||||
print_errno_message (int errnum)
|
print_errno_message (int errnum)
|
||||||
{
|
{
|
||||||
|
@ -238,13 +264,7 @@ error (int status, int errnum, const char *message, ...)
|
||||||
0);
|
0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !_LIBC && defined F_GETFL
|
flush_stdout ();
|
||||||
/* 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);
|
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -303,13 +323,7 @@ error_at_line (int status, int errnum, const char *file_name,
|
||||||
0);
|
0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !_LIBC && defined F_GETFL
|
flush_stdout ();
|
||||||
/* 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);
|
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* Declaration for error-reporting function
|
/* 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 file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -19,15 +20,14 @@
|
||||||
#define _ERROR_H 1
|
#define _ERROR_H 1
|
||||||
|
|
||||||
#ifndef __attribute__
|
#ifndef __attribute__
|
||||||
/* This feature is available in gcc versions 2.5 and later. */
|
/* The __attribute__ feature is available in gcc versions 2.5 and later.
|
||||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
The __-protected variants of the attributes 'format' and 'printf' are
|
||||||
# define __attribute__(Spec) /* empty */
|
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
|
||||||
# endif
|
We enable __attribute__ only if these are supported too, because
|
||||||
/* The __-protected variants of `format' and `printf' attributes
|
gnulib and libintl do '#define printf __printf__' when they override
|
||||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
the 'printf' function. */
|
||||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||||
# define __format__ format
|
# define __attribute__(Spec) /* empty */
|
||||||
# define __printf__ printf
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007
|
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||||
Free Software Foundation, Inc.
|
2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
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')
|
# define isblank(c) ((c) == ' ' || (c) == '\t')
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
|
# define STREQ(s1, s2) (strcmp (s1, s2) == 0)
|
||||||
|
|
||||||
# if defined _LIBC || WIDE_CHAR_SUPPORT
|
# if defined _LIBC || WIDE_CHAR_SUPPORT
|
||||||
/* The GNU C library provides support for user-defined character classes
|
/* The GNU C library provides support for user-defined character classes
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006
|
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||||
Free Software Foundation, Inc.
|
2003, 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
/* We found a table entry. Now see whether the
|
||||||
character we are currently at has the same
|
character we are currently at has the same
|
||||||
equivalance class value. */
|
equivalance class value. */
|
||||||
int len = weights[idx];
|
int len = weights[idx & 0xffffff];
|
||||||
int32_t idx2;
|
int32_t idx2;
|
||||||
const UCHAR *np = (const UCHAR *) n;
|
const UCHAR *np = (const UCHAR *) n;
|
||||||
|
|
||||||
idx2 = findidx (&np);
|
idx2 = findidx (&np);
|
||||||
if (idx2 != 0 && len == weights[idx2])
|
if (idx2 != 0
|
||||||
|
&& (idx >> 24) == (idx2 >> 24)
|
||||||
|
&& len == weights[idx2 & 0xffffff])
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
|
idx &= 0xffffff;
|
||||||
|
idx2 &= 0xffffff;
|
||||||
|
|
||||||
while (cnt < len
|
while (cnt < len
|
||||||
&& (weights[idx + 1 + cnt]
|
&& (weights[idx + 1 + cnt]
|
||||||
== weights[idx2 + 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 plensize; \
|
||||||
size_t newpsize; \
|
size_t newpsize; \
|
||||||
\
|
\
|
||||||
assert (p > startp); \
|
|
||||||
plen = (opt == L_('?') || opt == L_('@') \
|
plen = (opt == L_('?') || opt == L_('@') \
|
||||||
? pattern_len \
|
? pattern_len \
|
||||||
: (unsigned) (p - startp) + 1); \
|
: p - startp + 1UL); \
|
||||||
plensize = plen * sizeof (CHAR); \
|
plensize = plen * sizeof (CHAR); \
|
||||||
newpsize = offsetof (struct patternlist, str) + plensize; \
|
newpsize = offsetof (struct patternlist, str) + plensize; \
|
||||||
if ((size_t) -1 / sizeof (CHAR) < plen \
|
if ((size_t) -1 / sizeof (CHAR) < plen \
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* getdelim.c --- Implementation of replacement getdelim function.
|
/* getdelim.c --- Implementation of replacement getdelim function.
|
||||||
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007,
|
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007, 2008,
|
||||||
2008, 2009 Free Software Foundation, Inc.
|
2009, 2010 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
modify it under the terms of the GNU General Public License as
|
||||||
|
@ -21,13 +21,16 @@
|
||||||
|
|
||||||
#include <config.h>
|
#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 <stdio.h>
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#ifndef SSIZE_MAX
|
#ifndef SSIZE_MAX
|
||||||
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
|
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* getline.c --- Implementation of replacement getline function.
|
/* 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
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
modify it under the terms of the GNU General Public License as
|
||||||
|
|
129
gnulib/getopt.c
129
gnulib/getopt.c
|
@ -1,9 +1,9 @@
|
||||||
/* Getopt for GNU.
|
/* 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
|
"Keep this file name-space clean" means, talk to drepper@gnu.org
|
||||||
before changing it!
|
before changing it!
|
||||||
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006,2008
|
Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2010 Free Software
|
||||||
Free Software Foundation, Inc.
|
Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -41,12 +41,9 @@
|
||||||
# include <wchar.h>
|
# include <wchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef attribute_hidden
|
/* This version of `getopt' appears to the caller like standard Unix `getopt'
|
||||||
# define attribute_hidden
|
but it behaves differently for the user, since it allows the user
|
||||||
#endif
|
to intersperse the options with the other arguments.
|
||||||
|
|
||||||
/* Unlike standard Unix `getopt', functions like `getopt_long'
|
|
||||||
let the user intersperse the options with the other arguments.
|
|
||||||
|
|
||||||
As `getopt_long' works, it permutes the elements of ARGV so that,
|
As `getopt_long' works, it permutes the elements of ARGV so that,
|
||||||
when it is done, all the options precede everything else. Thus
|
when it is done, all the options precede everything else. Thus
|
||||||
|
@ -54,7 +51,7 @@
|
||||||
|
|
||||||
Using `getopt' or setting the environment variable POSIXLY_CORRECT
|
Using `getopt' or setting the environment variable POSIXLY_CORRECT
|
||||||
disables permutation.
|
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
|
GNU application programs can use a third alternative mode in which
|
||||||
they can distinguish the relative order of options and other arguments. */
|
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. */
|
/* Initialize the internal data when the first call is made. */
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_getopt_initialize (int argc, char **argv, const char *optstring,
|
_getopt_initialize (int argc _GL_UNUSED,
|
||||||
int posixly_correct, struct _getopt_data *d)
|
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
|
/* Start processing options with ARGV-element 1 (since ARGV-element 0
|
||||||
is the program name); the sequence of previously skipped
|
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
|
`flag' field is nonzero, the value of the option's `val' field
|
||||||
if the `flag' field is zero.
|
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
|
LONGOPTS is a vector of `struct option' terminated by an
|
||||||
element containing a name which is zero.
|
element containing a name which is zero.
|
||||||
|
|
||||||
|
@ -338,15 +340,12 @@ _getopt_initialize (int argc, char **argv, const char *optstring,
|
||||||
recent call.
|
recent call.
|
||||||
|
|
||||||
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
|
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
|
||||||
long-named options.
|
long-named options. */
|
||||||
|
|
||||||
If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT
|
|
||||||
environment variable were set. */
|
|
||||||
|
|
||||||
int
|
int
|
||||||
_getopt_internal_r (int argc, char **argv, const char *optstring,
|
_getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
const struct option *longopts, int *longind,
|
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;
|
int print_errors = d->opterr;
|
||||||
if (optstring[0] == ':')
|
if (optstring[0] == ':')
|
||||||
|
@ -361,8 +360,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
{
|
{
|
||||||
if (d->optind == 0)
|
if (d->optind == 0)
|
||||||
d->optind = 1; /* Don't scan ARGV[0], the program name. */
|
d->optind = 1; /* Don't scan ARGV[0], the program name. */
|
||||||
optstring = _getopt_initialize (argc, argv, optstring,
|
optstring = _getopt_initialize (argc, argv, optstring, d,
|
||||||
posixly_correct, d);
|
posixly_correct);
|
||||||
d->__initialized = 1;
|
d->__initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,7 +522,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
char *buf;
|
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)
|
argv[0], argv[d->optind]) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
@ -539,7 +538,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
free (buf);
|
free (buf);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
|
fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
|
||||||
argv[0], argv[d->optind]);
|
argv[0], argv[d->optind]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -573,11 +572,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
/* --option */
|
/* --option */
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
n = __asprintf (&buf, _("\
|
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);
|
argv[0], pfound->name);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, _("\
|
fprintf (stderr, _("\
|
||||||
%s: option `--%s' doesn't allow an argument\n"),
|
%s: option '--%s' doesn't allow an argument\n"),
|
||||||
argv[0], pfound->name);
|
argv[0], pfound->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -586,12 +585,12 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
/* +option or -option */
|
/* +option or -option */
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
n = __asprintf (&buf, _("\
|
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],
|
argv[0], argv[d->optind - 1][0],
|
||||||
pfound->name);
|
pfound->name);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, _("\
|
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],
|
argv[0], argv[d->optind - 1][0],
|
||||||
pfound->name);
|
pfound->name);
|
||||||
#endif
|
#endif
|
||||||
|
@ -634,7 +633,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (__asprintf (&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)
|
argv[0], argv[d->optind - 1]) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
@ -652,7 +651,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option `%s' requires an argument\n"),
|
_("%s: option '%s' requires an argument\n"),
|
||||||
argv[0], argv[d->optind - 1]);
|
argv[0], argv[d->optind - 1]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -690,10 +689,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
{
|
{
|
||||||
/* --option */
|
/* --option */
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
#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);
|
argv[0], d->__nextchar);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
|
fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
|
||||||
argv[0], d->__nextchar);
|
argv[0], d->__nextchar);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -701,10 +700,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
{
|
{
|
||||||
/* +option or -option */
|
/* +option or -option */
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
#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);
|
argv[0], argv[d->optind][0], d->__nextchar);
|
||||||
#else
|
#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);
|
argv[0], argv[d->optind][0], d->__nextchar);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -752,25 +751,12 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
int n;
|
int n;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (d->__posixly_correct)
|
|
||||||
{
|
|
||||||
/* 1003.2 specifies the format of this message. */
|
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
#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);
|
argv[0], c);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
|
fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
|
||||||
#endif
|
#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 defined _LIBC && defined USE_IN_LIBIO
|
||||||
if (n >= 0)
|
if (n >= 0)
|
||||||
|
@ -815,12 +801,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (__asprintf (&buf,
|
if (__asprintf (&buf,
|
||||||
_("%s: option requires an argument -- %c\n"),
|
_("%s: option requires an argument -- '%c'\n"),
|
||||||
argv[0], c) >= 0)
|
argv[0], c) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
@ -836,7 +821,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
free (buf);
|
free (buf);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, _("%s: option requires an argument -- %c\n"),
|
fprintf (stderr,
|
||||||
|
_("%s: option requires an argument -- '%c'\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -889,7 +875,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
char *buf;
|
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)
|
argv[0], argv[d->optind]) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
@ -905,7 +891,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
free (buf);
|
free (buf);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
|
fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
|
||||||
argv[0], argv[d->optind]);
|
argv[0], argv[d->optind]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -930,7 +916,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (__asprintf (&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)
|
argv[0], pfound->name) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
@ -948,7 +934,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, _("\
|
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);
|
argv[0], pfound->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -969,7 +955,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (__asprintf (&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)
|
argv[0], argv[d->optind - 1]) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
@ -987,7 +973,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option `%s' requires an argument\n"),
|
_("%s: option '%s' requires an argument\n"),
|
||||||
argv[0], argv[d->optind - 1]);
|
argv[0], argv[d->optind - 1]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1036,12 +1022,11 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
/* 1003.2 specifies the format of this message. */
|
|
||||||
#if defined _LIBC && defined USE_IN_LIBIO
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (__asprintf (&buf, _("\
|
if (__asprintf (&buf, _("\
|
||||||
%s: option requires an argument -- %c\n"),
|
%s: option requires an argument -- '%c'\n"),
|
||||||
argv[0], c) >= 0)
|
argv[0], c) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
@ -1058,7 +1043,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: option requires an argument -- %c\n"),
|
_("%s: option requires an argument -- '%c'\n"),
|
||||||
argv[0], c);
|
argv[0], c);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1081,16 +1066,17 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
|
|
||||||
int
|
int
|
||||||
_getopt_internal (int argc, char **argv, const char *optstring,
|
_getopt_internal (int argc, char **argv, const char *optstring,
|
||||||
const struct option *longopts, int *longind,
|
const struct option *longopts, int *longind, int long_only,
|
||||||
int long_only, int posixly_correct)
|
int posixly_correct)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
getopt_data.optind = optind;
|
getopt_data.optind = optind;
|
||||||
getopt_data.opterr = opterr;
|
getopt_data.opterr = opterr;
|
||||||
|
|
||||||
result = _getopt_internal_r (argc, argv, optstring, longopts, longind,
|
result = _getopt_internal_r (argc, argv, optstring, longopts,
|
||||||
long_only, posixly_correct, &getopt_data);
|
longind, long_only, &getopt_data,
|
||||||
|
posixly_correct);
|
||||||
|
|
||||||
optind = getopt_data.optind;
|
optind = getopt_data.optind;
|
||||||
optarg = getopt_data.optarg;
|
optarg = getopt_data.optarg;
|
||||||
|
@ -1110,10 +1096,23 @@ enum { POSIXLY_CORRECT = 1 };
|
||||||
int
|
int
|
||||||
getopt (int argc, char *const *argv, const char *optstring)
|
getopt (int argc, char *const *argv, const char *optstring)
|
||||||
{
|
{
|
||||||
return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0,
|
return _getopt_internal (argc, (char **) argv, optstring,
|
||||||
POSIXLY_CORRECT);
|
(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
|
#ifdef TEST
|
||||||
|
|
||||||
|
@ -1161,7 +1160,7 @@ main (int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
printf ("option c with value `%s'\n", optarg);
|
printf ("option c with value '%s'\n", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
/* 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
|
Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
|
||||||
Free Software Foundation, Inc.
|
1998, 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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)
|
struct _getopt_data *d)
|
||||||
{
|
{
|
||||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
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.
|
/* 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)
|
struct _getopt_data *d)
|
||||||
{
|
{
|
||||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
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 this_option_optind = optind ? optind : 1;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
static struct option long_options[] =
|
static const struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"add", 1, 0, 0},
|
{"add", 1, 0, 0},
|
||||||
{"append", 0, 0, 0},
|
{"append", 0, 0, 0},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Internal declarations for getopt.
|
/* Internal declarations for getopt.
|
||||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
|
Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2010 Free Software
|
||||||
Free Software Foundation, Inc.
|
Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -19,6 +19,8 @@
|
||||||
#ifndef _GETOPT_INT_H
|
#ifndef _GETOPT_INT_H
|
||||||
#define _GETOPT_INT_H 1
|
#define _GETOPT_INT_H 1
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
extern int _getopt_internal (int ___argc, char **___argv,
|
extern int _getopt_internal (int ___argc, char **___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
const struct option *__longopts, int *__longind,
|
const struct option *__longopts, int *__longind,
|
||||||
|
@ -113,8 +115,8 @@ struct _getopt_data
|
||||||
extern int _getopt_internal_r (int ___argc, char **___argv,
|
extern int _getopt_internal_r (int ___argc, char **___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
const struct option *__longopts, int *__longind,
|
const struct option *__longopts, int *__longind,
|
||||||
int __long_only, int __posixly_correct,
|
int __long_only, struct _getopt_data *__data,
|
||||||
struct _getopt_data *__data);
|
int __posixly_correct);
|
||||||
|
|
||||||
extern int _getopt_long_r (int ___argc, char **___argv,
|
extern int _getopt_long_r (int ___argc, char **___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* Convenience header for conditional use of GNU <libintl.h>.
|
/* 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
|
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
|
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.
|
for invalid uses of the value returned from these functions.
|
||||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||||
contain "#define const". */
|
contain "#define const". */
|
||||||
|
# undef gettext
|
||||||
# define gettext(Msgid) ((const char *) (Msgid))
|
# define gettext(Msgid) ((const char *) (Msgid))
|
||||||
|
# undef dgettext
|
||||||
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
|
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
|
||||||
|
# undef dcgettext
|
||||||
# define dcgettext(Domainname, Msgid, Category) \
|
# define dcgettext(Domainname, Msgid, Category) \
|
||||||
((void) (Category), dgettext (Domainname, Msgid))
|
((void) (Category), dgettext (Domainname, Msgid))
|
||||||
|
# undef ngettext
|
||||||
# define ngettext(Msgid1, Msgid2, N) \
|
# define ngettext(Msgid1, Msgid2, N) \
|
||||||
((N) == 1 \
|
((N) == 1 \
|
||||||
? ((void) (Msgid2), (const char *) (Msgid1)) \
|
? ((void) (Msgid2), (const char *) (Msgid1)) \
|
||||||
: ((void) (Msgid1), (const char *) (Msgid2)))
|
: ((void) (Msgid1), (const char *) (Msgid2)))
|
||||||
|
# undef dngettext
|
||||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||||
((void) (Domainname), ngettext (Msgid1, Msgid2, N))
|
((void) (Domainname), ngettext (Msgid1, Msgid2, N))
|
||||||
|
# undef dcngettext
|
||||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
# 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))
|
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||||
|
# undef bindtextdomain
|
||||||
# define bindtextdomain(Domainname, Dirname) \
|
# define bindtextdomain(Domainname, Dirname) \
|
||||||
((void) (Domainname), (const char *) (Dirname))
|
((void) (Domainname), (const char *) (Dirname))
|
||||||
|
# undef bind_textdomain_codeset
|
||||||
# define bind_textdomain_codeset(Domainname, Codeset) \
|
# define bind_textdomain_codeset(Domainname, Codeset) \
|
||||||
((void) (Domainname), (const char *) (Codeset))
|
((void) (Domainname), (const char *) (Codeset))
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Program name management.
|
/* Program name management.
|
||||||
Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
|
Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc.
|
||||||
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
|
Written by Bruno Haible <bruno@clisp.org>, 2001.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,6 +23,8 @@
|
||||||
#include "progname.h"
|
#include "progname.h"
|
||||||
|
|
||||||
#include <errno.h> /* get program_invocation_name declaration */
|
#include <errno.h> /* get program_invocation_name declaration */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +32,9 @@
|
||||||
To be initialized by main(). */
|
To be initialized by main(). */
|
||||||
const char *program_name = NULL;
|
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
|
void
|
||||||
set_program_name (const char *argv0)
|
set_program_name (const char *argv0)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +46,16 @@ set_program_name (const char *argv0)
|
||||||
const char *slash;
|
const char *slash;
|
||||||
const char *base;
|
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, '/');
|
slash = strrchr (argv0, '/');
|
||||||
base = (slash != NULL ? slash + 1 : argv0);
|
base = (slash != NULL ? slash + 1 : argv0);
|
||||||
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
|
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Program name management.
|
/* Program name management.
|
||||||
Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc.
|
Copyright (C) 2001-2004, 2006, 2009-2010 Free Software Foundation, Inc.
|
||||||
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
|
Written by Bruno Haible <bruno@clisp.org>, 2001.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
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. */
|
/* String containing name the program is called with. */
|
||||||
extern const char *program_name;
|
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);
|
extern void set_program_name (const char *argv0);
|
||||||
|
|
||||||
#if ENABLE_RELOCATABLE
|
#if ENABLE_RELOCATABLE
|
||||||
|
|
Loading…
Reference in a new issue