X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=libs%2Fweb%2Fsrc%2Ftemplate_parser.c;h=fe324cedc85d4929b817da29b0c413cbaef5d8d5;hp=58de5bb77471292c3122862f408cf40c676f5c55;hb=67150c34a103fe89a0e32d16169f958e2758ca56;hpb=80a2dd2cc27e2fc0c55f03f01a1d460a91954ab6 diff --git a/libs/web/src/template_parser.c b/libs/web/src/template_parser.c index 58de5bb77..fe324cedc 100644 --- a/libs/web/src/template_parser.c +++ b/libs/web/src/template_parser.c @@ -21,12 +21,12 @@ /* leading and trailing code for different types */ const char * gen_code[6][2] = { - { "write(\"", "\")" }, - { NULL, NULL }, - { "write(tostring(", "))" }, - { "include(\"", "\")" }, - { "write(translate(\"", "\"))" }, - { NULL, " " } + { "write(\"", "\")" }, + { NULL, NULL }, + { "write(tostring(", " or \"\"))" }, + { "include(\"", "\")" }, + { "write(translate(\"", "\"))" }, + { NULL, " " } }; /* Simple strstr() like function that takes len arguments for both haystack and needle. */ @@ -58,12 +58,12 @@ static char *strfind(char *haystack, int hslen, const char *needle, int ndlen) return NULL; } -/* - * Inspect current read buffer and find the number of "vague" characters at the end +/* + * Inspect current read buffer and find the number of "vague" characters at the end * which could indicate an opening token. Returns the number of "vague" chars. * The last continuous sequence of whitespace, optionally followed by a "<" is * treated as "vague" because whitespace may be discarded if the upcoming opening - * token indicates pre-whitespace-removal ("<%-"). A single remaining "<" char + * token indicates pre-whitespace-removal ("<%-"). A single remaining "<" char * can't be differentiated from an opening token ("<%"), so it's kept to be processed * in the next cycle. */ @@ -186,8 +186,8 @@ static const char * generate_expression(struct template_parser *data, size_t *sz } } - /* Found whitespace in i18n expression, raise flag */ - else if( isspace(data->out[i]) && (data->type == T_TYPE_I18N) ) + /* Found first whitespace in i18n expression, raise flag */ + else if( isspace(data->out[i]) && (data->type == T_TYPE_I18N) && (i18n_hasdef == 0) ) { i18n_hasdef = 1; }