diff --git a/res/rc.cc b/res/rc.cc index c5ec200..8fcbb90 100644 --- a/res/rc.cc +++ b/res/rc.cc @@ -12,7 +12,6 @@ bit-for-bit equal to what Microsoft rc.exe produces. It's ok if this program rejects some inputs that Microsoft rc.exe accepts. Missing for chromium: -- real string literal parser (L"\0") - preprocessor (but see pptest next to this; `pptest file | rc` kinda works) Also missing, but not yet for chromium: @@ -1867,13 +1866,25 @@ bool Parser::ParseRawData(std::vector* data) { } bool is_text_token = Is(Token::kString); if (is_text_token) { + bool is_wide = cur_token().value_[0] == 'L'; + std::string_view value_val = StringContents(Consume()); - // FIXME: 1-byte strings for "asdf", 2-byte for L"asdf". - for (size_t j = 0; j < value_val.size(); ++j) { - // FIXME: Real UTF16 support. - data->push_back(value_val[j]); + if (is_wide) { + C16string value_val_utf16; + if (!ToUTF16(&value_val_utf16, value_val, encoding_, &err_)) + return false; + + for (size_t j = 0; j < value_val_utf16.size(); ++j) { + // FIXME: This is gross and assumes little-endian-ness. + data->push_back(value_val_utf16[j] & 0xFF); + data->push_back(value_val_utf16[j] >> 8); + } + } else { + for (size_t j = 0; j < value_val.size(); ++j) + data->push_back(value_val[j]); } + // No implicit \0-termination in raw blocks. } else { // FIXME: The Is(Token::kInt) should probably be IsIntExprStart diff --git a/res/test/custom_inline.rc b/res/test/custom_inline.rc index 1e3824e..46a3190 100644 --- a/res/test/custom_inline.rc +++ b/res/test/custom_inline.rc @@ -1,4 +1,6 @@ 1 CUSTOM { "foo" } +1 CUSTOM { L"foo" } +1 CUSTOM { L"foo" "bar" L"baz" } 1 CSTOM { "foo" "b" } // No trailing \0! 1 CUOM { "foo" "ba" } 1 CUS { "foo" "bar" } @@ -14,8 +16,6 @@ 9 CUSTOM { 8 "val1", 9 } 10 CUSTOM { 8, "val1", 9 } -// FIXME: -//1 CUSTOM { L"foo" } 11 CUSTOM { 4L, 2L } // 32 12 CUSTOM { 4l, 2L } // 32 diff --git a/res/test/custom_inline.res b/res/test/custom_inline.res index 018d6d7..461d243 100644 Binary files a/res/test/custom_inline.res and b/res/test/custom_inline.res differ diff --git a/res/test/html_inline.rc b/res/test/html_inline.rc index 6acee36..cd765ee 100644 --- a/res/test/html_inline.rc +++ b/res/test/html_inline.rc @@ -1,4 +1,5 @@ 1 HTML { "foo" } +1 HTML { L"foo" } 1 HTML { "foo" "b" } // No trailing \0! 1 HTML { "foo" "ba" } 1 HTML { "foo" "bar" } @@ -14,9 +15,6 @@ 9 HTML { 8 "val1", 9 } 10 HTML { 8, "val1", 9 } -// FIXME: -//1 HTML { L"foo" } - 11 HTML { 4L, 2L } // 32 12 HTML { 4l, 2L } // 32 13 HTML { 4labdf, 2L } // 32 diff --git a/res/test/html_inline.res b/res/test/html_inline.res index ed5e701..eba2643 100644 Binary files a/res/test/html_inline.res and b/res/test/html_inline.res differ diff --git a/res/test/rcdata_inline.rc b/res/test/rcdata_inline.rc index 8575be8..e7035bf 100644 --- a/res/test/rcdata_inline.rc +++ b/res/test/rcdata_inline.rc @@ -1,4 +1,5 @@ 1 RCDATA { "foo" } +1 RCDATA { L"foo" } 1 RCDATA { "foo" "b" } // No trailing \0! 1 RCDATA { "foo" "ba" } 1 RCDATA { "foo" "bar" } @@ -14,9 +15,6 @@ 9 RCDATA { 8 "val1", 9 } 10 RCDATA { 8, "val1", 9 } -// FIXME: -//1 RCDATA { L"foo" } - 11 RCDATA { 4L, 2L } // 32 12 RCDATA { 4l, 2L } // 32 13 RCDATA { 4labdf, 2L } // 32 diff --git a/res/test/rcdata_inline.res b/res/test/rcdata_inline.res index a31cda2..40f86d6 100644 Binary files a/res/test/rcdata_inline.res and b/res/test/rcdata_inline.res differ