diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2014-01-31 19:38:36 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2014-02-17 14:15:43 -0500 |
commit | d15b0107d6f0f10e259a8937f7695e2130d5e9e4 (patch) | |
tree | 2d0416c5a71d7d822cb16c2fe7d60ed604a5a739 /src | |
parent | 2a3ed1eb9583625b318bbb26458926394b80901e (diff) | |
download | seabios-hppa-d15b0107d6f0f10e259a8937f7695e2130d5e9e4.zip seabios-hppa-d15b0107d6f0f10e259a8937f7695e2130d5e9e4.tar.gz seabios-hppa-d15b0107d6f0f10e259a8937f7695e2130d5e9e4.tar.bz2 |
Enhance nullTrailingSpace() so that it can also skip leading spaces.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/boot.c | 2 | ||||
-rw-r--r-- | src/fw/coreboot.c | 7 | ||||
-rw-r--r-- | src/string.c | 5 | ||||
-rw-r--r-- | src/string.h | 2 |
4 files changed, 8 insertions, 8 deletions
@@ -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 |