[llvm-rc] Implement escape sequences in .rc files.
authorZachary Turner <zturner@google.com>
Fri, 6 Oct 2017 22:05:15 +0000 (22:05 +0000)
committerZachary Turner <zturner@google.com>
Fri, 6 Oct 2017 22:05:15 +0000 (22:05 +0000)
commita92eb33ad59e3d01bd832f9c19a03d011f393a92
treef22d4e1130854f98ad16609ddff84856c380c599
parent9d8b358a49bec7cbd225062962d7959854d04338
[llvm-rc] Implement escape sequences in .rc files.

This allows the escape sequences (\a, \n, \r, \t, \\, \x[0-9a-f]*,
\[0-7]*, "") to appear in .rc scripts. These are parsed and output in
the same way as it's done in original MS implementation.

The way these sequences are processed depends on the type of the
resource it resides in, and on whether the user declared the string to
be "wide" or "narrow".

I tried to maintain the maximum compatibility with the original tool
(and fail in some erroneous situations that are accepted by .rc).
However, there are some (extremely rare) cases where Microsoft tool
outputs nonsense. I found it infeasible to detect such casses.

Patch by Marek Sokolowski

Differential Revision: https://reviews.llvm.org/D38426

llvm-svn: 315118
llvm/test/tools/llvm-rc/Inputs/tag-escape.rc [new file with mode: 0644]
llvm/test/tools/llvm-rc/tag-escape.test [new file with mode: 0644]
llvm/tools/llvm-rc/ResourceFileWriter.cpp
llvm/tools/llvm-rc/ResourceScriptToken.cpp