Author: jkim
Date: Mon Apr 29 21:04:37 2013
New Revision: 250066
URL: http://svnweb.freebsd.org/changeset/base/250066

Log:
  MFC:  r248777
  
  Loosen restrictions for quoted strings.  Now we can use more complex strings
  and "escaped" quote characters.

Modified:
  stable/9/usr.sbin/config/main.c
Directory Properties:
  stable/9/usr.sbin/config/   (props changed)

Modified: stable/9/usr.sbin/config/main.c
==============================================================================
--- stable/9/usr.sbin/config/main.c     Mon Apr 29 20:32:09 2013        
(r250065)
+++ stable/9/usr.sbin/config/main.c     Mon Apr 29 21:04:37 2013        
(r250066)
@@ -350,16 +350,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;
_______________________________________________
svn-src-stable-9@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"

Reply via email to