* grub-core/gnulib/error.c: Resynced.
* grub-core/gnulib/getopt.c: Likewise. * grub-core/gnulib/getopt_int.h: Likewise. * grub-core/gnulib/regex.h: Likewise. * grub-core/gnulib/regex_internal.c: Likewise. * grub-core/gnulib/regex_internal.h: Likewise.
This commit is contained in:
parent
014f47b74f
commit
5dcdf93ad6
7 changed files with 113 additions and 62 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2010-09-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/gnulib/error.c: Resynced.
|
||||||
|
* grub-core/gnulib/getopt.c: Likewise.
|
||||||
|
* grub-core/gnulib/getopt_int.h: Likewise.
|
||||||
|
* grub-core/gnulib/regex.h: Likewise.
|
||||||
|
* grub-core/gnulib/regex_internal.c: Likewise.
|
||||||
|
* grub-core/gnulib/regex_internal.h: Likewise.
|
||||||
|
|
||||||
2010-09-15 Szymon Janc <szymon@janc.net.pl>
|
2010-09-15 Szymon Janc <szymon@janc.net.pl>
|
||||||
|
|
||||||
* grub-core/lib/xzembed/xz_dec_stream.c (dec_main): Fix index and block
|
* grub-core/lib/xzembed/xz_dec_stream.c (dec_main): Fix index and block
|
||||||
|
|
|
@ -88,6 +88,15 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
|
||||||
|
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||||
|
/* Get declarations of the Win32 API functions. */
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h>
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* The gnulib override of fcntl is not needed in this file. */
|
||||||
|
# undef fcntl
|
||||||
|
|
||||||
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||||
# ifndef HAVE_DECL_STRERROR_R
|
# ifndef HAVE_DECL_STRERROR_R
|
||||||
"this configure-time declaration test was not run"
|
"this configure-time declaration test was not run"
|
||||||
|
@ -104,10 +113,29 @@ extern char *program_name;
|
||||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||||
#endif /* not _LIBC */
|
#endif /* not _LIBC */
|
||||||
|
|
||||||
|
#if !_LIBC
|
||||||
|
/* Return non-zero if FD is open. */
|
||||||
|
static inline int
|
||||||
|
is_open (int fd)
|
||||||
|
{
|
||||||
|
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||||
|
/* On Win32: The initial state of unassigned standard file descriptors is
|
||||||
|
that they are open but point to an INVALID_HANDLE_VALUE. There is no
|
||||||
|
fcntl, and the gnulib replacement fcntl does not support F_GETFL. */
|
||||||
|
return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
|
||||||
|
# else
|
||||||
|
# ifndef F_GETFL
|
||||||
|
# error Please port fcntl to your platform
|
||||||
|
# endif
|
||||||
|
return 0 <= fcntl (fd, F_GETFL);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
flush_stdout (void)
|
flush_stdout (void)
|
||||||
{
|
{
|
||||||
#if !_LIBC && defined F_GETFL
|
#if !_LIBC
|
||||||
int stdout_fd;
|
int stdout_fd;
|
||||||
|
|
||||||
# if GNULIB_FREOPEN_SAFER
|
# if GNULIB_FREOPEN_SAFER
|
||||||
|
@ -124,7 +152,7 @@ flush_stdout (void)
|
||||||
/* POSIX states that fflush (stdout) after fclose is unspecified; it
|
/* POSIX states that fflush (stdout) after fclose is unspecified; it
|
||||||
is safe in glibc, but not on all other platforms. fflush (NULL)
|
is safe in glibc, but not on all other platforms. fflush (NULL)
|
||||||
is always defined, but too draconian. */
|
is always defined, but too draconian. */
|
||||||
if (0 <= stdout_fd && 0 <= fcntl (stdout_fd, F_GETFL))
|
if (0 <= stdout_fd && is_open (stdout_fd))
|
||||||
#endif
|
#endif
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,8 +348,6 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
int long_only, struct _getopt_data *d, int posixly_correct)
|
int long_only, struct _getopt_data *d, int posixly_correct)
|
||||||
{
|
{
|
||||||
int print_errors = d->opterr;
|
int print_errors = d->opterr;
|
||||||
if (optstring[0] == ':')
|
|
||||||
print_errors = 0;
|
|
||||||
|
|
||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -364,6 +362,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
posixly_correct);
|
posixly_correct);
|
||||||
d->__initialized = 1;
|
d->__initialized = 1;
|
||||||
}
|
}
|
||||||
|
else if (optstring[0] == '-' || optstring[0] == '+')
|
||||||
|
optstring++;
|
||||||
|
if (optstring[0] == ':')
|
||||||
|
print_errors = 0;
|
||||||
|
|
||||||
/* Test whether ARGV[optind] points to a non-option argument.
|
/* Test whether ARGV[optind] points to a non-option argument.
|
||||||
Either it does not have option syntax, or there is an environment flag
|
Either it does not have option syntax, or there is an environment flag
|
||||||
|
@ -633,8 +635,8 @@ _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], pfound->name) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
|
||||||
|
@ -651,8 +653,8 @@ _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], pfound->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
d->__nextchar += strlen (d->__nextchar);
|
d->__nextchar += strlen (d->__nextchar);
|
||||||
|
@ -736,13 +738,13 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
|
|
||||||
{
|
{
|
||||||
char c = *d->__nextchar++;
|
char c = *d->__nextchar++;
|
||||||
char *temp = strchr (optstring, c);
|
const char *temp = strchr (optstring, c);
|
||||||
|
|
||||||
/* Increment `optind' when we start to process its last character. */
|
/* Increment `optind' when we start to process its last character. */
|
||||||
if (*d->__nextchar == '\0')
|
if (*d->__nextchar == '\0')
|
||||||
++d->optind;
|
++d->optind;
|
||||||
|
|
||||||
if (temp == NULL || c == ':')
|
if (temp == NULL || c == ':' || c == ';')
|
||||||
{
|
{
|
||||||
if (print_errors)
|
if (print_errors)
|
||||||
{
|
{
|
||||||
|
@ -864,7 +866,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
pfound = p;
|
pfound = p;
|
||||||
indfound = option_index;
|
indfound = option_index;
|
||||||
}
|
}
|
||||||
else
|
else if (long_only
|
||||||
|
|| pfound->has_arg != p->has_arg
|
||||||
|
|| pfound->flag != p->flag
|
||||||
|
|| pfound->val != p->val)
|
||||||
/* Second or later nonexact match found. */
|
/* Second or later nonexact match found. */
|
||||||
ambig = 1;
|
ambig = 1;
|
||||||
}
|
}
|
||||||
|
@ -876,7 +881,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
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], d->optarg) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
|
||||||
|
@ -892,7 +897,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
}
|
}
|
||||||
#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], d->optarg);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
d->__nextchar += strlen (d->__nextchar);
|
d->__nextchar += strlen (d->__nextchar);
|
||||||
|
@ -955,8 +960,8 @@ _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 '-W %s' requires an argument\n"),
|
||||||
argv[0], argv[d->optind - 1]) >= 0)
|
argv[0], pfound->name) >= 0)
|
||||||
{
|
{
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
|
|
||||||
|
@ -972,15 +977,17 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
|
||||||
free (buf);
|
free (buf);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf (stderr,
|
fprintf (stderr, _("\
|
||||||
_("%s: option '%s' requires an argument\n"),
|
%s: option '-W %s' requires an argument\n"),
|
||||||
argv[0], argv[d->optind - 1]);
|
argv[0], pfound->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
d->__nextchar += strlen (d->__nextchar);
|
d->__nextchar += strlen (d->__nextchar);
|
||||||
return optstring[0] == ':' ? ':' : '?';
|
return optstring[0] == ':' ? ':' : '?';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
d->optarg = NULL;
|
||||||
d->__nextchar += strlen (d->__nextchar);
|
d->__nextchar += strlen (d->__nextchar);
|
||||||
if (longind != NULL)
|
if (longind != NULL)
|
||||||
*longind = option_index;
|
*longind = option_index;
|
||||||
|
|
|
@ -30,31 +30,7 @@ extern int _getopt_internal (int ___argc, char **___argv,
|
||||||
/* Reentrant versions which can handle parsing multiple argument
|
/* Reentrant versions which can handle parsing multiple argument
|
||||||
vectors at the same time. */
|
vectors at the same time. */
|
||||||
|
|
||||||
/* Data type for reentrant functions. */
|
/* Describe how to deal with options that follow non-option ARGV-elements.
|
||||||
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,
|
If the caller did not specify anything,
|
||||||
the default is REQUIRE_ORDER if the environment variable
|
the default is REQUIRE_ORDER if the environment variable
|
||||||
|
@ -83,10 +59,37 @@ struct _getopt_data
|
||||||
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
|
||||||
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
`--' can cause `getopt' to return -1 with `optind' != ARGC. */
|
||||||
|
|
||||||
enum
|
enum __ord
|
||||||
{
|
{
|
||||||
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
|
||||||
} __ordering;
|
};
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
|
||||||
|
/* See __ord above. */
|
||||||
|
enum __ord __ordering;
|
||||||
|
|
||||||
/* If the POSIXLY_CORRECT environment variable is set
|
/* If the POSIXLY_CORRECT environment variable is set
|
||||||
or getopt was called. */
|
or getopt was called. */
|
||||||
|
|
|
@ -219,8 +219,8 @@ typedef unsigned long int reg_syntax_t;
|
||||||
whether ^ should be special. */
|
whether ^ should be special. */
|
||||||
# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
|
# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
|
||||||
|
|
||||||
/* If this bit is set, then \{ cannot be first in an bre or
|
/* If this bit is set, then \{ cannot be first in a regex or
|
||||||
immediately after an alternation or begin-group operator. */
|
immediately after an alternation, open-group or \} operator. */
|
||||||
# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
|
# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
|
||||||
|
|
||||||
/* If this bit is set, then no_sub will be set to 1 during
|
/* If this bit is set, then no_sub will be set to 1 during
|
||||||
|
@ -495,8 +495,8 @@ struct re_pattern_buffer
|
||||||
#endif
|
#endif
|
||||||
unsigned int _REG_RE_NAME (regs_allocated) : 2;
|
unsigned int _REG_RE_NAME (regs_allocated) : 2;
|
||||||
|
|
||||||
/* Set to zero when `regex_compile' compiles a pattern; set to one
|
/* Set to zero when `re_compile_pattern' compiles a pattern; set to
|
||||||
by `re_compile_fastmap' if it updates the fastmap. */
|
one by `re_compile_fastmap' if it updates the fastmap. */
|
||||||
unsigned int _REG_RE_NAME (fastmap_accurate) : 1;
|
unsigned int _REG_RE_NAME (fastmap_accurate) : 1;
|
||||||
|
|
||||||
/* If set, `re_match_2' does not return information about
|
/* If set, `re_match_2' does not return information about
|
||||||
|
@ -610,8 +610,8 @@ extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
|
||||||
register data.
|
register data.
|
||||||
|
|
||||||
Unless this function is called, the first search or match using
|
Unless this function is called, the first search or match using
|
||||||
PATTERN_BUFFER will allocate its own register data, without
|
BUFFER will allocate its own register data, without freeing the old
|
||||||
freeing the old data. */
|
data. */
|
||||||
extern void re_set_registers (struct re_pattern_buffer *__buffer,
|
extern void re_set_registers (struct re_pattern_buffer *__buffer,
|
||||||
struct re_registers *__regs,
|
struct re_registers *__regs,
|
||||||
__re_size_t __num_regs,
|
__re_size_t __num_regs,
|
||||||
|
|
|
@ -733,15 +733,17 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
|
||||||
mbstate_t cur_state;
|
mbstate_t cur_state;
|
||||||
wchar_t wc2;
|
wchar_t wc2;
|
||||||
Idx mlen = raw + pstr->len - p;
|
Idx mlen = raw + pstr->len - p;
|
||||||
unsigned char buf[6];
|
|
||||||
size_t mbclen;
|
size_t mbclen;
|
||||||
|
|
||||||
|
#if 0 /* dead code: buf is set but never used */
|
||||||
|
unsigned char buf[6];
|
||||||
if (BE (pstr->trans != NULL, 0))
|
if (BE (pstr->trans != NULL, 0))
|
||||||
{
|
{
|
||||||
int i = mlen < 6 ? mlen : 6;
|
int i = mlen < 6 ? mlen : 6;
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
buf[i] = pstr->trans[p[i]];
|
buf[i] = pstr->trans[p[i]];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* XXX Don't use mbrtowc, we know which conversion
|
/* XXX Don't use mbrtowc, we know which conversion
|
||||||
to use (UTF-8 -> UCS4). */
|
to use (UTF-8 -> UCS4). */
|
||||||
memset (&cur_state, 0, sizeof (cur_state));
|
memset (&cur_state, 0, sizeof (cur_state));
|
||||||
|
|
|
@ -467,6 +467,8 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
|
||||||
# else
|
# else
|
||||||
/* alloca is implemented with malloc, so just use malloc. */
|
/* alloca is implemented with malloc, so just use malloc. */
|
||||||
# define __libc_use_alloca(n) 0
|
# define __libc_use_alloca(n) 0
|
||||||
|
# undef alloca
|
||||||
|
# define alloca(n) malloc (n)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue