Skip to content

Commit

Permalink
Merge pull request #223 from fe-dagostino/fix_escaping
Browse files Browse the repository at this point in the history
add \a \b \v for correct escaping
  • Loading branch information
hyperrealm authored Dec 26, 2023
2 parents 5242916 + 94d1084 commit f9404f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/libconfig.texi
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ Boolean values may have one of the following values: @samp{true},
String values consist of arbitrary text delimited by double
quotes. Literal double quotes can be escaped by preceding them with a
backslash: @samp{\"}. The escape sequences @samp{\\}, @samp{\f},
@samp{\n}, @samp{\r}, and @samp{\t} are also recognized, and have the
@samp{\n}, @samp{\r}, @samp{\a}, @samp{\b}, @samp{\v} and @samp{\t} are also recognized, and have the
usual meaning.

In addition, the @samp{\x} escape sequence is supported; this sequence
Expand Down
5 changes: 4 additions & 1 deletion lib/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ include_open ^[ \t]*@include[ \t]+\"

\" { BEGIN STRING; }
<STRING>[^\"\\]+ { libconfig_scanctx_append_string(yyextra, yytext); }
<STRING>\\a { libconfig_scanctx_append_char(yyextra, '\a'); }
<STRING>\\b { libconfig_scanctx_append_char(yyextra, '\b'); }
<STRING>\\n { libconfig_scanctx_append_char(yyextra, '\n'); }
<STRING>\\r { libconfig_scanctx_append_char(yyextra, '\r'); }
<STRING>\\t { libconfig_scanctx_append_char(yyextra, '\t'); }
<STRING>\\v { libconfig_scanctx_append_char(yyextra, '\v'); }
<STRING>\\f { libconfig_scanctx_append_char(yyextra, '\f'); }
<STRING>\\\\ { libconfig_scanctx_append_char(yyextra, '\\'); }
<STRING>\\\" { libconfig_scanctx_append_char(yyextra, '\"'); }
Expand Down Expand Up @@ -125,7 +128,7 @@ include_open ^[ \t]*@include[ \t]+\"
BEGIN INITIAL;
}

\n|\r|\f { /* ignore */ }
\n|\r|\f|\a|\b|\v { /* ignore */ }
[ \t]+ { /* ignore */ }

\=|\: { return(TOK_EQUALS); }
Expand Down

0 comments on commit f9404f6

Please sign in to comment.