diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:01:38 +0100 |
commit | f7d30133221896638f7bf4f66c504255c4b14f48 (patch) | |
tree | 5f3e07a049f388a3a309a615b8884318f6668a98 /nsprpub/lib/libc/src/plgetopt.c | |
parent | 26b297510a11758727438df4669357a2a2bc42ce (diff) | |
download | UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.gz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.lz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.tar.xz UXP-f7d30133221896638f7bf4f66c504255c4b14f48.zip |
Issue #1338 - Part 1: Update NSPR to 4.24
Diffstat (limited to 'nsprpub/lib/libc/src/plgetopt.c')
-rw-r--r-- | nsprpub/lib/libc/src/plgetopt.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/nsprpub/lib/libc/src/plgetopt.c b/nsprpub/lib/libc/src/plgetopt.c index 960decfec..4e37e65f5 100644 --- a/nsprpub/lib/libc/src/plgetopt.c +++ b/nsprpub/lib/libc/src/plgetopt.c @@ -45,20 +45,20 @@ PR_IMPLEMENT(PLOptState*) PL_CreateOptState( } /* PL_CreateOptState */ PR_IMPLEMENT(PLOptState*) PL_CreateLongOptState( - PRIntn argc, char **argv, const char *options, + PRIntn argc, char **argv, const char *options, const PLLongOpt *longOpts) { PLOptState *opt = NULL; PLOptionInternal *internal; - if (NULL == options) + if (NULL == options) { PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); return opt; } opt = PR_NEWZAP(PLOptState); - if (NULL == opt) + if (NULL == opt) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0); return opt; @@ -124,15 +124,15 @@ PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt) } internal->xargv = internal->argv[internal->xargc]; internal->minus = 0; - if (!internal->endOfOpts && ('-' == *internal->xargv)) + if (!internal->endOfOpts && ('-' == *internal->xargv)) { internal->minus++; internal->xargv++; /* and consume */ - if ('-' == *internal->xargv && internal->longOpts) + if ('-' == *internal->xargv && internal->longOpts) { internal->minus++; internal->xargv++; - if (0 == *internal->xargv) + if (0 == *internal->xargv) { internal->endOfOpts = PR_TRUE; } @@ -145,7 +145,7 @@ PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt) ** option. See if we can find a match in the list of possible ** options supplied. */ - if (internal->minus == 2) + if (internal->minus == 2) { char * foundEqual = strchr(internal->xargv,'='); PRIntn optNameLen = foundEqual ? (foundEqual - internal->xargv) : @@ -156,19 +156,21 @@ PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt) opt->option = 0; opt->value = NULL; - for (; longOpt->longOptName; ++longOpt) + for (; longOpt->longOptName; ++longOpt) { - if (strncmp(longOpt->longOptName, internal->xargv, optNameLen)) - continue; /* not a possible match */ - if (strlen(longOpt->longOptName) != optNameLen) - continue; /* not a match */ + if (strncmp(longOpt->longOptName, internal->xargv, optNameLen)) { + continue; /* not a possible match */ + } + if (strlen(longOpt->longOptName) != optNameLen) { + continue; /* not a match */ + } /* 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) + if (foundEqual) { opt->value = foundEqual + 1; } @@ -227,8 +229,9 @@ PR_IMPLEMENT(PLOptStatus) PL_GetNextOpt(PLOptState *opt) internal->xargv = &static_Nul; internal->minus = 0; } - else - opt->value = NULL; + else { + opt->value = NULL; + } return PL_OPT_OK; } } |