Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: nss/mozilla/nsprpub/lib/libc/src/plgetopt.c

Issue 3135002: Update to NSS 3.12.7 and NSPR 4.8.6.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: nss/mozilla/nsprpub/lib/libc/src/plgetopt.c
===================================================================
--- nss/mozilla/nsprpub/lib/libc/src/plgetopt.c (revision 55475)
+++ nss/mozilla/nsprpub/lib/libc/src/plgetopt.c (working copy)
@@ -177,13 +177,13 @@
** option. See if we can find a match in the list of possible
** options supplied.
*/
-
if (internal->minus == 2)
{
char * foundEqual = strchr(internal->xargv,'=');
PRIntn optNameLen = foundEqual ? (foundEqual - internal->xargv) :
strlen(internal->xargv);
const PLLongOpt *longOpt = internal->longOpts;
+ PLOptStatus result = PL_OPT_BAD;
opt->option = 0;
opt->value = NULL;
@@ -197,19 +197,31 @@
/* option name match */
opt->longOptIndex = longOpt - internal->longOpts;
opt->longOption = longOpt->longOption;
+ /* value is part of the current argv[] element if = was found */
+ /* note: this sets value even for long options that do not
+ * require option if specified as --long=value */
if (foundEqual)
{
- opt->value = foundEqual[1] ? foundEqual + 1 : NULL;
+ opt->value = foundEqual + 1;
}
else if (longOpt->valueRequired)
{
- opt->value = internal->argv[++(internal->xargc)];
+ /* value is the next argv[] element, if any */
+ if (internal->xargc + 1 < internal->argc)
+ {
+ opt->value = internal->argv[++(internal->xargc)];
+ }
+ /* missing value */
+ else
+ {
+ break; /* return PL_OPT_BAD */
+ }
}
- internal->xargv = &static_Nul; /* consume this */
- return PL_OPT_OK;
+ result = PL_OPT_OK;
+ break;
}
internal->xargv = &static_Nul; /* consume this */
- return PL_OPT_BAD;
+ return result;
}
if (internal->minus)
{
@@ -223,14 +235,27 @@
opt->longOption = opt->option & 0xff;
/*
** if options indicates that there's an associated
- ** value, this argv is finished and the next is the
- ** option's value.
+ ** value, it must be provided, either as part of this
+ ** argv[] element or as the next one
*/
if (':' == internal->options[cop + 1])
{
- if (0 != *internal->xargv)
+ /* value is part of the current argv[] element */
+ if (0 != *internal->xargv)
+ {
+ opt->value = internal->xargv;
+ }
+ /* value is the next argv[] element, if any */
+ else if (internal->xargc + 1 < internal->argc)
+ {
+ opt->value = internal->argv[++(internal->xargc)];
+ }
+ /* missing value */
+ else
+ {
return PL_OPT_BAD;
- opt->value = internal->argv[++(internal->xargc)];
+ }
+
internal->xargv = &static_Nul;
internal->minus = 0;
}
@@ -242,6 +267,7 @@
internal->xargv += 1; /* consume that option */
return PL_OPT_BAD;
}
+
/*
** No '-', so it must be a standalone value. The option is nul.
*/

Powered by Google App Engine
This is Rietveld 408576698