]> xenbits.xensource.com Git - seabios.git/commitdiff
Enhance nullTrailingSpace() so that it can also skip leading spaces.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 1 Feb 2014 00:38:36 +0000 (19:38 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 17 Feb 2014 19:15:43 +0000 (14:15 -0500)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/boot.c
src/fw/coreboot.c
src/string.c
src/string.h

index 183f4f37216f1197aeaf12b0bff2738cd323c280..133e2063f2adffb30f804336318ceb38b87ef412 100644 (file)
@@ -60,7 +60,7 @@ loadBootOrder(void)
         f = strchr(f, '\n');
         if (f)
             *(f++) = '\0';
-        nullTrailingSpace(Bootorder[i]);
+        Bootorder[i] = nullTrailingSpace(Bootorder[i]);
         dprintf(1, "%d: %s\n", i+1, Bootorder[i]);
         i++;
     } while (f);
index cfb7a70289121e9cd1206c6ad0dd84babfebe6a1..2f39e3e20161d2fd810b45d2fcf5404e41c126a8 100644 (file)
@@ -419,18 +419,15 @@ coreboot_cbfs_init(void)
         next = strchr(linkname, '\n');
         if (next)
             *next++ = '\0';
-        while (*linkname && *linkname <= ' ')
-            linkname++;
         char *comment = strchr(linkname, '#');
         if (comment)
             *comment = '\0';
-        nullTrailingSpace(linkname);
+        linkname = nullTrailingSpace(linkname);
         char *destname = strchr(linkname, ' ');
         if (!destname)
             continue;
         *destname++ = '\0';
-        while (*destname && *destname <= ' ')
-            destname++;
+        destname = nullTrailingSpace(destname);
         // Lookup destname and create new romfile entry for linkname
         struct romfile_s *ufile = romfile_find(destname);
         if (!ufile)
index 574c13e7488f0ba5e58f296b19b72f45968f972c..8556fe986293b3c0b6223305fe396f3404f6cbe2 100644 (file)
@@ -225,11 +225,14 @@ strchr(const char *s, int c)
 }
 
 // Remove any trailing blank characters (spaces, new lines, carriage returns)
-void
+char *
 nullTrailingSpace(char *buf)
 {
     int len = strlen(buf);
     char *end = &buf[len-1];
     while (end >= buf && *end <= ' ')
         *(end--) = '\0';
+    while (*buf && *buf <= ' ')
+        buf++;
+    return buf;
 }
index 7c4c5ee96b86b6fda5a96824c854c5aa3f69cc5f..ca751a45976c09da24d6e01170e994147c6415d1 100644 (file)
@@ -25,6 +25,6 @@ void iomemcpy(void *d, const void *s, u32 len);
 void *memmove(void *d, const void *s, size_t len);
 char *strtcpy(char *dest, const char *src, size_t len);
 char *strchr(const char *s, int c);
-void nullTrailingSpace(char *buf);
+char *nullTrailingSpace(char *buf);
 
 #endif // string.h