aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/getopt.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-05-29 15:10:23 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-05-29 15:10:23 -0700
commitf43e1e5232a37afb90dfaacd8ef815ca7a34c5b8 (patch)
treebcd9317a1557546b082928136006d046841aa7b6 /com32/lib/getopt.c
parent4481998e7aced8dcd501afdb459402fef1e98959 (diff)
downloadsyslinux-f43e1e5232a37afb90dfaacd8ef815ca7a34c5b8.tar.gz
syslinux-f43e1e5232a37afb90dfaacd8ef815ca7a34c5b8.tar.xz
syslinux-f43e1e5232a37afb90dfaacd8ef815ca7a34c5b8.zip
Run Nindent on com32/lib/getopt.c
Automatically reformat com32/lib/getopt.c using Nindent. Do this for all files except HDT, gPXE and externally maintained libraries (zlib, tinyjpeg, libpng). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/lib/getopt.c')
-rw-r--r--com32/lib/getopt.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/com32/lib/getopt.c b/com32/lib/getopt.c
index 49b007a6..5e9b7c63 100644
--- a/com32/lib/getopt.c
+++ b/com32/lib/getopt.c
@@ -13,60 +13,60 @@ int optind = 1;
int opterr, optopt;
static const char *__optptr;
-int getopt(int argc, char * const *argv, const char *optstring)
+int getopt(int argc, char *const *argv, const char *optstring)
{
- const char *carg = argv[optind];
- const char *osptr;
- int opt;
+ const char *carg = argv[optind];
+ const char *osptr;
+ int opt;
- /* We don't actually need argc */
- (void)argc;
+ /* We don't actually need argc */
+ (void)argc;
- /* First, eliminate all non-option cases */
+ /* First, eliminate all non-option cases */
- if ( !carg || carg[0] != '-' || !carg[1] ) {
- return -1;
- }
+ if (!carg || carg[0] != '-' || !carg[1]) {
+ return -1;
+ }
- if ( carg[1] == '-' && !carg[2] ) {
- optind++;
- return -1;
- }
+ if (carg[1] == '-' && !carg[2]) {
+ optind++;
+ return -1;
+ }
- if ( (uintptr_t)(__optptr-carg) > (uintptr_t)strlen(carg) )
- __optptr = carg+1; /* Someone frobbed optind, change to new opt. */
+ if ((uintptr_t) (__optptr - carg) > (uintptr_t) strlen(carg))
+ __optptr = carg + 1; /* Someone frobbed optind, change to new opt. */
- opt = *__optptr++;
+ opt = *__optptr++;
- if ( opt != ':' && (osptr = strchr(optstring, opt)) ) {
- if ( osptr[1] == ':' ) {
- if ( *__optptr ) {
- /* Argument-taking option with attached argument */
- optarg = (char *)__optptr;
- optind++;
- } else {
- /* Argument-taking option with non-attached argument */
- if ( argv[optind+1] ) {
- optarg = (char *)argv[optind+1];
- optind += 2;
+ if (opt != ':' && (osptr = strchr(optstring, opt))) {
+ if (osptr[1] == ':') {
+ if (*__optptr) {
+ /* Argument-taking option with attached argument */
+ optarg = (char *)__optptr;
+ optind++;
+ } else {
+ /* Argument-taking option with non-attached argument */
+ if (argv[optind + 1]) {
+ optarg = (char *)argv[optind + 1];
+ optind += 2;
+ } else {
+ /* Missing argument */
+ return (optstring[0] == ':') ? ':' : '?';
+ }
+ }
+ return opt;
} else {
- /* Missing argument */
- return (optstring[0] == ':') ? ':' : '?';
+ /* Non-argument-taking option */
+ /* __optptr will remember the exact position to resume at */
+ if (!*__optptr)
+ optind++;
+ return opt;
}
- }
- return opt;
} else {
- /* Non-argument-taking option */
- /* __optptr will remember the exact position to resume at */
- if ( ! *__optptr )
- optind++;
- return opt;
+ /* Unknown option */
+ optopt = opt;
+ if (!*__optptr)
+ optind++;
+ return '?';
}
- } else {
- /* Unknown option */
- optopt = opt;
- if ( ! *__optptr )
- optind++;
- return '?';
- }
}