From efa760e156417ddf7ac1f60cc955b2bdc40df712 Mon Sep 17 00:00:00 2001 From: jkim Date: Tue, 26 Mar 2013 23:58:13 +0000 Subject: Loosen restrictions for quoted strings. Now we can use more complex strings and "escaped" quote characters. MFC after: 1 month --- usr.sbin/config/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'usr.sbin') 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; -- cgit v1.1