From: Robert Spalek Date: Mon, 24 Apr 2006 13:58:28 +0000 (+0200) Subject: conf2: correct unescaping of C-strings X-Git-Tag: holmes-import~645^2~11^2~54 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=461724cdbe88fede989a3ddebd4aac8b88e68b0d;p=libucw.git conf2: correct unescaping of C-strings --- diff --git a/lib/conf2.c b/lib/conf2.c index 670bf73d..3c930e42 100644 --- a/lib/conf2.c +++ b/lib/conf2.c @@ -15,6 +15,7 @@ #include "lib/fastbuf.h" #include "lib/chartype.h" #include "lib/lfs.h" +#include "lib/stkstring.h" #include #include @@ -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(©_buf, start_copy + l + 1); strcpy(copy_buf.ptr + start_copy, tmp); diff --git a/lib/conf2.t b/lib/conf2.t index 95216e13..9ffc82cc 100644 --- a/lib/conf2.t +++ b/lib/conf2.t @@ -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?