[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] getopt: handle W; without long options in getopt
From: |
Eric Blake |
Subject: |
[PATCH] getopt: handle W; without long options in getopt |
Date: |
Thu, 7 Jul 2011 09:22:57 -0600 |
This reverts commit cbf381169705782b144b2733798a62c11aa473a5, in
favor of the upstream glibc fix (commit 01636b214) plus a C89 fix.
[BZ #12922]
* lib/getopt.c (_getopt_internal_r): When "W;" is in short options
but no long options are defined, just return 'W'.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 6 ++++++
lib/getopt.c | 11 ++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4d2b71d..a5d52ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-07-07 Ulrich Drepper <address@hidden>
+
+ getopt: handle W; without long options in getopt [BZ #12922]
+ * lib/getopt.c (_getopt_internal_r): When "W;" is in short options
+ but no long options are defined, just return 'W'.
+
2011-07-07 Bruno Haible <address@hidden>
Avoid literal tabs.
diff --git a/lib/getopt.c b/lib/getopt.c
index 2af8352..7c9f704 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -829,7 +829,7 @@ _getopt_internal_r (int argc, char **argv, const char
*optstring,
return '?';
}
/* Convenience. Treat POSIX -W foo same as long option --foo */
- if (temp[0] == 'W' && temp[1] == ';' && longopts)
+ if (temp[0] == 'W' && temp[1] == ';')
{
char *nameend;
const struct option *p;
@@ -839,6 +839,9 @@ _getopt_internal_r (int argc, char **argv, const char
*optstring,
int indfound = 0;
int option_index;
+ if (longopts == NULL)
+ goto no_longs;
+
/* This is an option that requires an argument. */
if (*d->__nextchar != '\0')
{
@@ -1046,8 +1049,10 @@ _getopt_internal_r (int argc, char **argv, const char
*optstring,
}
return pfound->val;
}
- d->__nextchar = NULL;
- return 'W'; /* Let the application handle it. */
+
+ no_longs:
+ d->__nextchar = NULL;
+ return 'W'; /* Let the application handle it. */
}
if (temp[1] == ':')
{
--
1.7.4.4
- [PATCH] getopt: handle W; without long options in getopt,
Eric Blake <=
- [PATCH] getopt-gnu: avoid crash in glibc getopt, Eric Blake, 2011/07/07
- Re: [PATCH] getopt-gnu: avoid crash in glibc getopt, Pádraig Brady, 2011/07/19
- Re: [PATCH] getopt-gnu: avoid crash in glibc getopt, Eric Blake, 2011/07/19
- Re: [PATCH] getopt-gnu: avoid crash in glibc getopt, Pádraig Brady, 2011/07/19
- Re: [PATCH] getopt-gnu: avoid crash in glibc getopt, Eric Blake, 2011/07/19
- Re: [PATCH] getopt-gnu: avoid crash in glibc getopt, Bruno Haible, 2011/07/19
- Re: [PATCH] getopt-gnu: avoid crash in glibc getopt, Pádraig Brady, 2011/07/19
[PATCH] getopt: avoid compiler warning during configure, Eric Blake, 2011/07/07