From 9bcc3a2714beddc156f05c0f389ee3ada23f459f Mon Sep 17 00:00:00 2001 From: hpa Date: Fri, 26 Aug 2005 05:34:35 +0000 Subject: [PATCH] Avoid doing the same job more than once... --- com32/modules/readconfig.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c index c8c57c0..3c69979 100644 --- a/com32/modules/readconfig.c +++ b/com32/modules/readconfig.c @@ -94,10 +94,11 @@ skipspace(char *p) } /* Check to see if we are at a certain keyword (case insensitive) */ -static int -looking_at(const char *line, const char *kwd) +/* Returns a pointer to the first character past the keyword */ +static char * +looking_at(char *line, const char *kwd) { - const char *p = line; + char *p = line; const char *q = kwd; while ( *p && *q && ((*p^*q) & ~0x20) == 0 ) { @@ -106,9 +107,9 @@ looking_at(const char *line, const char *kwd) } if ( *q ) - return 0; /* Didn't see the keyword */ + return NULL; /* Didn't see the keyword */ - return *p <= ' '; /* Must be EOL or whitespace */ + return (*p <= ' ') ? p : NULL; /* Must be EOL or whitespace */ } struct labeldata { @@ -184,7 +185,7 @@ record(struct labeldata *ld, char *append) void parse_config(const char *filename) { - char line[MAX_LINE], *p; + char line[MAX_LINE], *p, *ep; FILE *f; char *append = NULL; static struct labeldata ld; @@ -228,12 +229,11 @@ void parse_config(const char *filename) menu_master_passwd = strdup(skipspace(p+6)); } } else { - /* Unknown, check for parameters */ + /* Unknown, check for layout parameters */ struct menu_parameter *pp; for ( pp = mparm ; pp->name ; pp++ ) { - if ( looking_at(p, pp->name) ) { - p = skipspace(p+strlen(pp->name)); - pp->value = atoi(p); + if ( (ep = looking_at(p, pp->name)) ) { + pp->value = atoi(skipspace(ep)); break; } } -- 2.7.4