mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[llvm-rc] Allow specifying language with a leading 0x prefix
This option is always interpreted strictly as a hexadecimal string, even if it has no prefix that indicates the number format, hence the existing call to StringRef::getAsInteger(16, ...). StringRef::getAsInteger(0, ...) consumes a leading "0x" prefix is present, but when the radix is specified, the radix shouldn't be included. Both MS rc.exe and GNU windres accept the language with that prefix. Also allow specifying the codepage to llvm-windres with a different radix, as GNU windres allows that (but MS rc.exe doesn't). This fixes https://llvm.org/PR51295. Differential Revision: https://reviews.llvm.org/D107263 (cherry picked from commit 46020f6f0c8aa134002208b2ecf0593b04c46d08)
This commit is contained in:
parent
910de616a4
commit
7563d8dfe5
@ -4,6 +4,8 @@
|
||||
; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check-prefix=UTF8
|
||||
; RUN: llvm-windres --no-preprocess --codepage 65001 %p/Inputs/utf8.rc %t.utf8.res
|
||||
; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check-prefix=UTF8
|
||||
; RUN: llvm-windres --no-preprocess --codepage 0xfde9 %p/Inputs/utf8.rc %t.utf8.res
|
||||
; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check-prefix=UTF8
|
||||
|
||||
; UTF8: Resource type (int): STRINGTABLE (ID 6)
|
||||
; UTF8-NEXT: Resource name (int): 1
|
||||
|
@ -6,6 +6,8 @@
|
||||
; RUN: llvm-readobj %t.res | FileCheck %s
|
||||
; RUN: llvm-windres --no-preprocess --language 40A %p/Inputs/language.rc %t.res
|
||||
; RUN: llvm-readobj %t.res | FileCheck %s
|
||||
; RUN: llvm-windres --no-preprocess -l 0x40A %p/Inputs/language.rc %t.res
|
||||
; RUN: llvm-readobj %t.res | FileCheck %s
|
||||
|
||||
; CHECK: Resource name (int): 1
|
||||
; CHECK-NEXT: Data version:
|
||||
|
@ -476,13 +476,14 @@ RcOptions parseWindresOptions(ArrayRef<const char *> ArgsArr,
|
||||
Opts.Params.CodePage = CpWin1252; // Different default
|
||||
if (InputArgs.hasArg(WINDRES_codepage)) {
|
||||
if (InputArgs.getLastArgValue(WINDRES_codepage)
|
||||
.getAsInteger(10, Opts.Params.CodePage))
|
||||
.getAsInteger(0, Opts.Params.CodePage))
|
||||
fatalError("Invalid code page: " +
|
||||
InputArgs.getLastArgValue(WINDRES_codepage));
|
||||
}
|
||||
if (InputArgs.hasArg(WINDRES_language)) {
|
||||
if (InputArgs.getLastArgValue(WINDRES_language)
|
||||
.getAsInteger(16, Opts.LangId))
|
||||
StringRef Val = InputArgs.getLastArgValue(WINDRES_language);
|
||||
Val.consume_front_insensitive("0x");
|
||||
if (Val.getAsInteger(16, Opts.LangId))
|
||||
fatalError("Invalid language id: " +
|
||||
InputArgs.getLastArgValue(WINDRES_language));
|
||||
}
|
||||
@ -565,7 +566,9 @@ RcOptions parseRcOptions(ArrayRef<const char *> ArgsArr,
|
||||
}
|
||||
Opts.AppendNull = InputArgs.hasArg(OPT_add_null);
|
||||
if (InputArgs.hasArg(OPT_lang_id)) {
|
||||
if (InputArgs.getLastArgValue(OPT_lang_id).getAsInteger(16, Opts.LangId))
|
||||
StringRef Val = InputArgs.getLastArgValue(OPT_lang_id);
|
||||
Val.consume_front_insensitive("0x");
|
||||
if (Val.getAsInteger(16, Opts.LangId))
|
||||
fatalError("Invalid language id: " +
|
||||
InputArgs.getLastArgValue(OPT_lang_id));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user