summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/systems.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-12-20 20:30:25 +0000
committerbrian <brian@FreeBSD.org>1999-12-20 20:30:25 +0000
commit0a37c5b3adc8d2ab7afb405ebd6cda1842b9ad2e (patch)
tree0d608d4289b702e64a3a108753af44172abdf1c6 /usr.sbin/ppp/systems.c
parent4145fb0c1be9e8321d6d4e6f465453c2cc0aed50 (diff)
downloadFreeBSD-src-0a37c5b3adc8d2ab7afb405ebd6cda1842b9ad2e.zip
FreeBSD-src-0a37c5b3adc8d2ab7afb405ebd6cda1842b9ad2e.tar.gz
Handle comments at the end of lines.
Diffstat (limited to 'usr.sbin/ppp/systems.c')
-rw-r--r--usr.sbin/ppp/systems.c36
1 files changed, 30 insertions, 6 deletions
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",
OpenPOWER on IntegriCloud