svn commit: trunk/busybox/libbb

vda at busybox.net vda at busybox.net
Wed Mar 19 23:25:00 UTC 2008


Author: vda
Date: 2008-03-19 16:25:00 -0700 (Wed, 19 Mar 2008)
New Revision: 21406

Log:
die_if_bad_username: shrink:  88 -> 77 bytes



Modified:
   trunk/busybox/libbb/die_if_bad_username.c


Changeset:
Modified: trunk/busybox/libbb/die_if_bad_username.c
===================================================================
--- trunk/busybox/libbb/die_if_bad_username.c	2008-03-19 23:15:55 UTC (rev 21405)
+++ trunk/busybox/libbb/die_if_bad_username.c	2008-03-19 23:25:00 UTC (rev 21406)
@@ -18,17 +18,19 @@
 
 void die_if_bad_username(const char *name)
 {
-	int i = 0;
-
+	goto skip; /* 1st char being dash isn't valid */
 	do {
-		if (!isalnum(*name)
-		 && !(*name == '_')
-		 && !(*name == '.')
-		 && !(*name == '@')
-		 && !(*name == '-' && i)
-		 && !(*name == '$' && !*(name + 1))
-		)
-			bb_error_msg_and_die("illegal character '%c'", *name);
-		i++;
+		if (*name == '-')
+			continue;
+ skip:
+		if (isalnum(*name)
+		 || *name == '_'
+		 || *name == '.'
+		 || *name == '@'
+		 || (*name == '$' && !*(name + 1))
+		) {
+			continue;
+		}
+		bb_error_msg_and_die("illegal character '%c'", *name);
 	} while (*++name);
 }




More information about the busybox-cvs mailing list