Skip to content

Commit

Permalink
[libiodata] Fix regexp used for parsing hex values
Browse files Browse the repository at this point in the history
The function iodata::output::prepare(...) replaces certain
characters with hex values, like \x22 for a quotation mark.
The function is called when data is saved to a file,
see iodata::output::output_record(...).

However, the regexp used for reading saved data from a file
looked for hex values encoded as \x{22}, which is incorrect,
causing hex values of form \x22 be interpreted as stray
backslashes instead, which aborts the parsing process.
  • Loading branch information
Petri M. Gerdt committed Apr 2, 2014
1 parent 48734b2 commit fb45844
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/datalang.l
Expand Up @@ -83,8 +83,8 @@ DECNUM ([1-9]{DEC}*)|0
<STRING_LIT>"\\t" *yylval->str += (char)'\t' ;
<STRING_LIT>"\\\\" *yylval->str += (char)'\\' ;
<STRING_LIT>"\\\"" *yylval->str += (char)'\"' ;
<STRING_LIT>"\\x{"{HEX}{HEX}"}" {
char x[2]={ (char)strtoll(STR(3,1).c_str(), NULL, 16), 0} ;
<STRING_LIT>"\\x"{HEX}{HEX} {
char x[2]={ (char)strtoll(STR(2,0).c_str(), NULL, 16), 0} ;
*yylval->str += x ;
}
<STRING_LIT>"\"" BEGIN(INITIAL) ; return TSTRING ;
Expand Down

0 comments on commit fb45844

Please sign in to comment.