From: Kevin O'Connor Date: Sat, 1 Feb 2014 00:38:36 +0000 (-0500) Subject: Enhance nullTrailingSpace() so that it can also skip leading spaces. X-Git-Tag: rel-1.7.5-rc1~37 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d15b0107d6f0f10e259a8937f7695e2130d5e9e4;p=seabios.git Enhance nullTrailingSpace() so that it can also skip leading spaces. Signed-off-by: Kevin O'Connor --- diff --git a/src/boot.c b/src/boot.c index 183f4f3..133e206 100644 --- a/src/boot.c +++ b/src/boot.c @@ -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); diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c index cfb7a70..2f39e3e 100644 --- a/src/fw/coreboot.c +++ b/src/fw/coreboot.c @@ -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) diff --git a/src/string.c b/src/string.c index 574c13e..8556fe9 100644 --- a/src/string.c +++ b/src/string.c @@ -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; } diff --git a/src/string.h b/src/string.h index 7c4c5ee..ca751a4 100644 --- a/src/string.h +++ b/src/string.h @@ -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