mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Fixed issue when the string is escaped with a newline
This commit is contained in:
parent
9f42da4686
commit
b02abb1f18
1 changed files with 18 additions and 16 deletions
|
@ -92,43 +92,45 @@ static void TextEscapeValue( char *str, size_t len )
|
||||||
{
|
{
|
||||||
if( *str == '\\' )
|
if( *str == '\\' )
|
||||||
{
|
{
|
||||||
len--;
|
if( len == 1 )
|
||||||
|
|
||||||
if( !len )
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
str++;
|
if( str[1] == 'n' )
|
||||||
if( *str == 'n' )
|
|
||||||
{
|
{
|
||||||
*to = '\n';
|
*to = '\n';
|
||||||
|
to++;
|
||||||
}
|
}
|
||||||
else if( *str == 't' )
|
else if( str[1] == 't' )
|
||||||
{
|
{
|
||||||
*to = '\t';
|
*to = '\t';
|
||||||
|
to++;
|
||||||
}
|
}
|
||||||
else if( *str == '"' )
|
else if( str[1] == '"' )
|
||||||
{
|
{
|
||||||
*to = '\"';
|
*to = '\"';
|
||||||
|
to++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*to = *str;
|
*to = str[1];
|
||||||
|
to++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
len -= 2;
|
||||||
|
str += 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*to = *str;
|
*to = *str;
|
||||||
|
to++;
|
||||||
|
len--;
|
||||||
|
str++;
|
||||||
}
|
}
|
||||||
|
|
||||||
len--;
|
|
||||||
str++;
|
|
||||||
to++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*to = 0;
|
*to = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void TextValue( char *str, size_t len )
|
static void TextValue( char *str, size_t len )
|
||||||
{
|
{
|
||||||
char* s = parsetree_malloc(len + 1);
|
char* s = parsetree_malloc(len + 1);
|
||||||
|
@ -186,7 +188,7 @@ static bool UseField( void )
|
||||||
%x VARIABLES
|
%x VARIABLES
|
||||||
%x IDENTIFIER
|
%x IDENTIFIER
|
||||||
|
|
||||||
string ([^\\\"]|\\.)*
|
string ([^\\\"\r\n]|\\.)*
|
||||||
identifier [^\{\}\(\)\[\]\r\n\,:; \t]
|
identifier [^\{\}\(\)\[\]\r\n\,:; \t]
|
||||||
alphanum [a-zA-Z0-9_]+
|
alphanum [a-zA-Z0-9_]+
|
||||||
varname [a-zA-Z0-9_\"]+
|
varname [a-zA-Z0-9_\"]+
|
||||||
|
@ -219,8 +221,8 @@ varname [a-zA-Z0-9_\"]+
|
||||||
unput(yytext[yyleng - 1]);
|
unput(yytext[yyleng - 1]);
|
||||||
yyreducepos(1);
|
yyreducepos(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
\"{string}\" { TextEscapeValue( yytext + 1, strlen( yytext ) - 2 ); YYLEX( TOKEN_STRING ); }
|
\"{string}\" { TextEscapeValue( yytext + 1, yyleng - 2 ); YYLEX( TOKEN_STRING ); }
|
||||||
|
|
||||||
|
|
||||||
"?" { YYLEX( TOKEN_TERNARY ); }
|
"?" { YYLEX( TOKEN_TERNARY ); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue