Clean up the handling of "extended whitespace"; fix typos
authorH. Peter Anvin <hpa@zytor.com>
Thu, 19 Jan 2006 16:52:09 +0000 (08:52 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Thu, 19 Jan 2006 16:52:09 +0000 (08:52 -0800)
com32/modules/menu.c
com32/modules/menu.h
com32/modules/readconfig.c

index df0fe99..2a29cf6 100644 (file)
@@ -458,10 +458,10 @@ edit_cmdline(char *input, int top)
       if ( cursor ) {
        int prevcursor = cursor;
 
-       while ( cursor && (cmdline[cursor-1] <= ' ') )
+       while ( cursor && my_isspace(cmdline[cursor-1]) )
          cursor--;
 
-       while ( cursor && (cmdline[cursor-1] > ' ') )
+       while ( cursor && !my_isspace(cmdline[cursor-1]) )
          cursor--;
 
        memmove(cmdline+cursor, cmdline+prevcursor, len-prevcursor+1);
@@ -790,13 +790,13 @@ execute(const char *cmdline)
 
   kernel = q;
   p = cmdline;
-  while ( *p && *p > ' ' ) {
+  while ( *p && !my_isspace(*p) ) {
     *q++ = *p++;
   }
   *q++ = '\0';
   
   args = q;
-  while ( *p && *p <= ' ' )
+  while ( *p && my_isspace(*p) )
     p++;
   
   strcpy(q, p);
index 53af400..59247df 100644 (file)
@@ -65,5 +65,10 @@ extern char *menu_master_passwd;
 
 void parse_config(const char *filename);
 
+static inline int my_isspace(char c)
+{
+  return (unsigned char)c <= ' ';
+}
+
 #endif /* MENU_H */
 
index 2208d23..4fb5b07 100644 (file)
@@ -89,7 +89,7 @@ get_config(void)
 static char *
 skipspace(char *p)
 {
-  while ( *p && *p <= ' ' )
+  while ( *p && my_isspace(*p) )
     p++;
   
   return p;
@@ -111,7 +111,7 @@ looking_at(char *line, const char *kwd)
   if ( *q )
     return NULL;               /* Didn't see the keyword */
 
-  return (*p <= ' ') ? p : NULL; /* Must be EOL or whitespace */
+  return my_isspace(*p) ? p : NULL; /* Must be EOL or whitespace */
 }
 
 struct labeldata {
@@ -195,14 +195,14 @@ unlabel(char *str)
   int i, pos;
 
   p = str;
-  while ( *p && !isspace(*p) )
+  while ( *p && !my_isspace(*p) )
     p++;
 
   /* p now points to the first byte beyond the kernel name */
   pos = p-str;
 
   for ( i = 0 ; i < nentries ; i++ ) {
-    me = &menu_entry[i];
+    me = &menu_entries[i];
 
     if ( !strncmp(str, me->label, pos) && !me->label[pos] ) {
       /* Found matching label */