changeset 26:75b80e55bcfc

Add one if() that has lots of whitespace fallout.
author Rob Landley <rob@landley.net>
date Sun, 19 Nov 2006 17:29:35 -0500
parents eb46bb5626cb
children c471910a14e4
files lib/args.c
diffstat 1 files changed, 60 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- 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