diff options
author | Brian Somers <brian@FreeBSD.org> | 1999-12-20 20:30:25 +0000 |
---|---|---|
committer | Brian Somers <brian@FreeBSD.org> | 1999-12-20 20:30:25 +0000 |
commit | 9409953d8411081fa9617be994740890afb791fe (patch) | |
tree | 3aa647236402cead547aad1d3841f7b2f42b09cf /usr.sbin | |
parent | c39aa54ec8245817e058c8493f4cf7236bf24a96 (diff) | |
download | src-9409953d8411081fa9617be994740890afb791fe.tar.gz src-9409953d8411081fa9617be994740890afb791fe.zip |
Handle comments at the end of lines.
Notes
Notes:
svn path=/head/; revision=54915
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 6e7d5c90b256..b7ee588f11e1 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 4999f8b43dd3..0a510810939e 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 5c8216d5d585..cc187199b1d4 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", |