summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config/main.c
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2013-03-26 23:58:13 +0000
committerjkim <jkim@FreeBSD.org>2013-03-26 23:58:13 +0000
commitefa760e156417ddf7ac1f60cc955b2bdc40df712 (patch)
treefdd350b70419a06299c6bfa60bee7b979168452b /usr.sbin/config/main.c
parent3110b3975c872ef7583196d2e4f1574de133c826 (diff)
downloadFreeBSD-src-efa760e156417ddf7ac1f60cc955b2bdc40df712.zip
FreeBSD-src-efa760e156417ddf7ac1f60cc955b2bdc40df712.tar.gz
Loosen restrictions for quoted strings. Now we can use more complex strings
and "escaped" quote characters. MFC after: 1 month
Diffstat (limited to 'usr.sbin/config/main.c')
-rw-r--r--usr.sbin/config/main.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 14061c2..3ed5495 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -351,16 +351,24 @@ begin:
if (ch == '"' || ch == '\'') {
int quote = ch;
+ escaped_nl = 0;
while ((ch = getc(fp)) != EOF) {
- if (ch == quote)
+ if (ch == quote && !escaped_nl)
break;
- if (ch == '\n') {
+ if (ch == '\n' && !escaped_nl) {
*cp = 0;
printf("config: missing quote reading `%s'\n",
line);
exit(2);
}
+ if (ch == '\\' && !escaped_nl) {
+ escaped_nl = 1;
+ continue;
+ }
+ if (ch != quote && escaped_nl)
+ *cp++ = '\\';
*cp++ = ch;
+ escaped_nl = 0;
}
} else {
*cp++ = ch;
OpenPOWER on IntegriCloud