# HG changeset patch # User Rob Landley # Date 1163975375 18000 # Node ID 75b80e55bcfc1f1c04b0675c849bf5ee47cfbb48 # Parent eb46bb5626cbfbd951271b093cbfdd5ba057bfc9 Add one if() that has lots of whitespace fallout. diff -r eb46bb5626cb -r 75b80e55bcfc lib/args.c --- a/lib/args.c Sun Nov 19 02:49:22 2006 -0500 +++ b/lib/args.c Sun Nov 19 17:29:35 2006 -0500 @@ -130,74 +130,76 @@ long *nextarg = (long *)&toy; char *options = toys.which->options; - // Parse leading special behavior indicators - for (;;) { - if (*options == '+') stopearly++; - else if (*options == '<') minargs=*(++options)-'0'; - else if (*options == '>') maxargs=*(++options)-'0'; - else if (*options == '#') gof.noerror++; - else if (*options == '&') nodash++; - else break; - options++; - } + if (options) { + // Parse leading special behavior indicators + for (;;) { + if (*options == '+') stopearly++; + else if (*options == '<') minargs=*(++options)-'0'; + else if (*options == '>') maxargs=*(++options)-'0'; + else if (*options == '#') gof.noerror++; + else if (*options == '&') nodash++; + else break; + options++; + } - // Parse rest of opts into array - while (*options) { + // Parse rest of opts into array + while (*options) { - // Allocate a new option entry when necessary - if (!gof.this) { - gof.this = xzalloc(sizeof(struct opts)); - gof.this->next = gof.opts; - gof.opts = gof.this; - } - // Each option must start with (or an option character. (Bare - // longopts only come at the start of the string.) - if (*options == '(') { - char *end; - struct longopts *lo = xmalloc(sizeof(struct longopts)); + // Allocate a new option entry when necessary + if (!gof.this) { + gof.this = xzalloc(sizeof(struct opts)); + gof.this->next = gof.opts; + gof.opts = gof.this; + } + // Each option must start with (or an option character. (Bare + // longopts only come at the start of the string.) + if (*options == '(') { + char *end; + struct longopts *lo = xmalloc(sizeof(struct longopts)); - // Find the end of the longopt - for (end = ++options; *end && *end != ')'; end++); - if (CFG_DEBUG && !*end) error_exit("Unterminated optstring"); + // Find the end of the longopt + for (end = ++options; *end && *end != ')'; end++); + if (CFG_DEBUG && !*end) error_exit("Unterminated optstring"); - // Allocate and init a new struct longopts - lo = xmalloc(sizeof(struct longopts)); - lo->next = longopts; - lo->opt = gof.this; - lo->str = options; - lo->len = end-options; - longopts = lo; - options = end; + // Allocate and init a new struct longopts + lo = xmalloc(sizeof(struct longopts)); + lo->next = longopts; + lo->opt = gof.this; + lo->str = options; + lo->len = end-options; + longopts = lo; + options = end; - // For leading longopts (with no corresponding short opt), note - // that this option struct has been used. - gof.this->shift++; + // For leading longopts (with no corresponding short opt), note + // that this option struct has been used. + gof.this->shift++; - // If this is the start of a new option that wasn't a longopt, + // If this is the start of a new option that wasn't a longopt, - } else if (index(":*?@", *options)) { - gof.this->type |= *options; - // Pointer and long guaranteed to be the same size by LP64. - *(++nextarg) = 0; - gof.this->arg = (void *)nextarg; - } else if (*options == '|') { - } else if (*options == '+') { - } else if (*options == '~') { - } else if (*options == '!') { - } else if (*options == '[') { + } else if (index(":*?@", *options)) { + gof.this->type |= *options; + // Pointer and long guaranteed to be the same size by LP64. + *(++nextarg) = 0; + gof.this->arg = (void *)nextarg; + } else if (*options == '|') { + } else if (*options == '+') { + } else if (*options == '~') { + } else if (*options == '!') { + } else if (*options == '[') { - // At this point, we've hit the end of the previous option. The - // current character is the start of a new option. If we've already - // assigned an option to this struct, loop to allocate a new one. - // (It'll get back here afterwards.) - } else if(gof.this->shift || gof.this->c) { - gof.this = NULL; - continue; + // At this point, we've hit the end of the previous option. The + // current character is the start of a new option. If we've already + // assigned an option to this struct, loop to allocate a new one. + // (It'll get back here afterwards.) + } else if(gof.this->shift || gof.this->c) { + gof.this = NULL; + continue; - // Claim this option, loop to see what's after it. - } else gof.this->c = *options; + // Claim this option, loop to see what's after it. + } else gof.this->c = *options; - options++; + options++; + } } // Initialize shift bits (have to calculate this ahead of time because