diff options
author | brian <brian@FreeBSD.org> | 1999-12-20 20:30:25 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-12-20 20:30:25 +0000 |
commit | 0a37c5b3adc8d2ab7afb405ebd6cda1842b9ad2e (patch) | |
tree | 0d608d4289b702e64a3a108753af44172abdf1c6 /usr.sbin | |
parent | 4145fb0c1be9e8321d6d4e6f465453c2cc0aed50 (diff) | |
download | FreeBSD-src-0a37c5b3adc8d2ab7afb405ebd6cda1842b9ad2e.zip FreeBSD-src-0a37c5b3adc8d2ab7afb405ebd6cda1842b9ad2e.tar.gz |
Handle comments at the end of lines.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/defs.c | 32 | ||||
-rw-r--r-- | usr.sbin/ppp/defs.h | 1 | ||||
-rw-r--r-- | usr.sbin/ppp/systems.c | 36 |
3 files changed, 44 insertions, 25 deletions
diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c index 6e7d5c9..b7ee588 100644 --- a/usr.sbin/ppp/defs.c +++ b/usr.sbin/ppp/defs.c @@ -263,29 +263,21 @@ IntToSpeed(int nspeed) return B0; } -static char * +char * findblank(char *p, int instring) { - if (instring) { - while (*p) { - if (*p == '\\') { - memmove(p, p + 1, strlen(p)); - if (!*p) - break; - } else if (*p == '"') - return (p); - p++; - } - return NULL; - } else { - while (*p) { - if (issep(*p)) - return (p); - p++; - } + while (*p) { + if (*p == '\\') { + memmove(p, p + 1, strlen(p)); + if (!*p) + break; + } else if ((instring && *p == '"') || + (!instring && (issep(*p) || *p == '#'))) + return p; + p++; } - return p; + return instring ? NULL : p; } int @@ -314,6 +306,8 @@ MakeArgs(char *script, char **pvect, int maxargs) script = findblank(script, instring); if (script == NULL) return -1; + else if (*script == '#') + *script = '\0'; else if (*script) *script++ = '\0'; } diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h index 4999f8b..0a51081 100644 --- a/usr.sbin/ppp/defs.h +++ b/usr.sbin/ppp/defs.h @@ -98,4 +98,5 @@ extern int Nam2mode(const char *); extern struct in_addr GetIpAddr(const char *); extern int SpeedToInt(speed_t); extern speed_t IntToSpeed(int); +extern char *findblank(char *, int); extern int MakeArgs(char *, char **, int); diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c index 5c8216d..cc18719 100644 --- a/usr.sbin/ppp/systems.c +++ b/usr.sbin/ppp/systems.c @@ -59,8 +59,8 @@ CloseSecret(FILE *fp) } /* Move string from ``from'' to ``to'', interpreting ``~'' and $.... */ -static void -InterpretArg(char *from, char *to) +static const char * +InterpretArg(const char *from, char *to) { const char *env; char *ptr, *startto, *endto; @@ -71,6 +71,7 @@ InterpretArg(char *from, char *to) while(issep(*from)) from++; + if (*from == '~') { ptr = strchr(++from, '/'); len = ptr ? ptr - from : strlen(from); @@ -95,7 +96,7 @@ InterpretArg(char *from, char *to) from += len; } - while (to < endto && *from != '\0') { + while (to < endto && !issep(*from) && *from != '#' && *from != '\0') { if (*from == '$') { if (from[1] == '$') { *to = '\0'; /* For an empty var name below */ @@ -131,9 +132,13 @@ InterpretArg(char *from, char *to) *endto = '\0'; to += strlen(to); } - } else + } else { + if (*from == '\\') + from++; *to++ = *from++; + } } + while (to > startto) { to--; if (!issep(*to)) { @@ -142,6 +147,11 @@ InterpretArg(char *from, char *to) } } *to = '\0'; + + while (issep(*from)) + from++; + + return from; } #define CTRL_UNKNOWN (0) @@ -150,9 +160,14 @@ InterpretArg(char *from, char *to) static int DecodeCtrlCommand(char *line, char *arg) { + const char *end; + if (!strncasecmp(line, "include", 7) && issep(line[7])) { - InterpretArg(line+8, arg); - return CTRL_INCLUDE; + end = InterpretArg(line+8, arg); + if (*end && *end != '#') + log_Printf(LogWARN, "Usage: !include filename\n"); + else + return CTRL_INCLUDE; } return CTRL_UNKNOWN; } @@ -308,6 +323,15 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file, break; default: + if ((wp = findblank(cp, 0)) != NULL) { + while (issep(*wp)) + *wp++ = '\0'; + if (*wp != '#' && *wp != '\0') { + log_Printf(LogWARN, "Bad label in %s (line %d) - too many words.\n", + filename, linenum); + continue; + } + } wp = strchr(cp, ':'); if (wp == NULL || wp[1] != '\0') { log_Printf(LogWARN, "Bad rule in %s (line %d) - missing colon.\n", |