]> mj.ucw.cz Git - libucw.git/commitdiff
conf2: correct unescaping of C-strings
authorRobert Spalek <robert@ucw.cz>
Mon, 24 Apr 2006 13:58:28 +0000 (15:58 +0200)
committerRobert Spalek <robert@ucw.cz>
Mon, 24 Apr 2006 13:58:28 +0000 (15:58 +0200)
lib/conf2.c
lib/conf2.t

index 670bf73dfbd0ba5cfbfddb1b422bc576f9b11462..3c930e4273c74e3052c7303c868c2c8f63c4e555 100644 (file)
@@ -15,6 +15,7 @@
 #include "lib/fastbuf.h"
 #include "lib/chartype.h"
 #include "lib/lfs.h"
+#include "lib/stkstring.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -1058,16 +1059,7 @@ get_word(uns is_command_name)
     }
     line++;
 
-    // FIXME: this is utterly bogus, since printf() only expands these
-    // percents, and the \n, \x1b codes are actually expanded by the compiler
-    for (byte *c=copy_buf.ptr+start_copy; *c; c++)
-      if (*c == '%') {
-       if (c[1] != '%')
-         return "Formating sequences are not allowed";
-       else
-         c++;
-      }
-    byte *tmp = cf_printf(copy_buf.ptr + start_copy);
+    byte *tmp = stk_str_unesc(copy_buf.ptr + start_copy);
     uns l = strlen(tmp);
     bb_grow(&copy_buf, start_copy + l + 1);
     strcpy(copy_buf.ptr + start_copy, tmp);
index 95216e137c9466699d4ab34a38e67b691a44135f..9ffc82cc514a8fd7253cd598ae7a99d072d4eb1a 100644 (file)
@@ -9,7 +9,7 @@ Top { \
            \
            17M
   nrs2 3 3k 3 3 3 ; \
-  str1 "hello, world%%\n"
+  str1 "hello,\t\x2bworld%%\n"
   str2 'Hagenuk,
       the best' "\
       " qu'est-ce que c'est?