New issue
Advanced search Search tips

Issue 794908 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug-Regression



Sign in to add a comment

New RC.exe in v64 keep indentation spaces in multiline LTEXT elements

Project Member Reported by yn...@vivaldi.com, Dec 14 2017

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.97 Safari/537.36 Vivaldi/1.94.1008.36

Steps to reproduce the problem:
1. Create a dialog in an rc file (e.g. setup.rc)
2. Add LTEXT string element that is broken across two or more lines using the backslash line continuation method, and indent the lines of the string so that the text string of all parts of the string starts at the same line position
3. Build the executable with the new rc.exe in v64

pseudo code:

IDD_DIALOG1 DIALOGEX 0, 0, 360, 290
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Foo"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    LTEXT           "First part of string. \
                     Second part of string. There should only be a single space in front of this part of the string.", IDC_STATIC_INFO, 32, 185, 305, 25, SS_LEFT
END

What is the expected behavior?
Visual Studio 2017 rc.exe will ignore all indentation on the second line of the continued string, and just use the whitespace *before* the backslash, and continue with the text when encountering the first non-whitespace character of the string.

What went wrong?
When building an rc file with such an LTEXT element, Chromium 64 rc.exe will keep the spaces in the indentation. 

Since VS rc.exe will not keep the indentation, the following binary compare of the two results will fail due to the different strings, and the build will fail.

If the resulting file had been used in an executable, the dialog element would have contained a large space section in the middle of the displayed string.

Did this work before? Yes 63.0.3239.84

Chrome version: 64.0.3282.2  Channel: dev
OS Version: 10.0
Flash Version: 

Vivaldi is presently using a dialog in its installer with an LTEXT element formatted this way.

At present we are overriding the use of chromium 64's rc.exe for this file, using VS 2017 instead, mostly due to another issue https://bugs.chromium.org/p/chromium/issues/detail?id=794598 . Once that is solved, provided this issue is not fixed before then, we will likely use one of the workarounds discussed below.

This way of breaking up and formatting a string is used to 1) avoid long lines of text by continuing the text across several lines instead of one long line, and 2) indent the text to make the source more readable.

It is possible to avoid the problem by using either one long line, or by not indenting the text. Both of these methods produce less readable code.
 

Comment 1 by thakis@chromium.org, Dec 14 2017

Owner: thakis@chromium.org
Status: Available (was: Unconfirmed)
Thanks for the report. This is definitely something where rc.py is incompatible with rc.exe, which isn't great (but the auto-comparer found it, which is...something).

I am however a bit hesitant about fixing this for the following reason: removing a \ followed by a newline into nothing is the responsibility of the preprocessor (well, technically it's phase 2 of translation in http://en.cppreference.com/w/cpp/language/translation_phases and the preprocessor usually handles 1-4). If you do

  const char foo[] = "Hello \
                      world";

in C, you also end up with that run of spaces. rc.py currently invokes a vanilla preprocessor with -E and then pipes the output of that into a small resource compiler program that knows nothing about preprocessing.

Fixing this would require one of:

a) adding a whole custom preprocessor to the resource compiler
b) giving clang a dedicated "preprocess but delete whitespace after \\\\n" mode and using that
c) in rc.py, using a regex to do this transformation before calling clang -E

(c) is probably the most workable, but it's still pretty ugly. So I think it'd be best if you changed your code if that's an option at all. Do you have many instances of this, or just one? (I'm sympathetic to the "it's less readable", but on the other hand you get behavior that's consistent with C, and thus while less readable, arguably also maybe less surprising".

But let's keep this open and if others run into this problem, please make yourself heard.

Comment 2 by yn...@vivaldi.com, Dec 14 2017

We currently only have that single instance.

Most of our application UI is made using other functionality, but those can't be used for the installer setup application.

BTW, One issue with the compare operation is that it is rather difficult (though not impossible) to discover what is causing the differences between the results.

Comment 3 by thakis@chromium.org, Dec 14 2017

Yeah :-/ I usually load both files in `gvim -d` and then pipe both sides through xxd. This requires being fairly familiar with the binary .res format. If you have a suggestion on how to make this easier, please do tell :-) 

Comment 4 by yn...@vivaldi.com, Dec 14 2017

Unfortunately I don't; I tried my diff util with no luck, and found my problems by comparing hex views ...

One thing that could be helpful would be to be provided info about where in the files the differences are, at least where they start diverging
Status: Assigned (was: Available)

Sign in to add a comment