mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 18:11:19 +00:00
[llvm-rc] Allow -1 for menu item IDs
This seems to be used in some resource files, e.g.f3217573d7/include/wx/msw/wx.rc (L28)
. MSVC rc.exe and GNU windres both allow any value here, and silently just truncate to uint16_t range. This just explicitly allows the -1 value and errors out on others - the same was done for control IDs in dialogs inc1a67857ba
. Differential Revision: https://reviews.llvm.org/D76951
This commit is contained in:
parent
8c1dbd5c1e
commit
8330dcadb8
@ -54,7 +54,7 @@ BEGIN
|
||||
MENUITEM "a&bcde", 2
|
||||
MENUITEM "ab&cde", 3
|
||||
MENUITEM "abc&de", 4
|
||||
MENUITEM "abcd&e", 5
|
||||
MENUITEM "abcd&e", -1
|
||||
}
|
||||
END
|
||||
|
||||
|
@ -69,7 +69,7 @@
|
||||
; MENU-NEXT: 0060: 61002600 62006300 64006500 00000000 |a.&.b.c.d.e.....|
|
||||
; MENU-NEXT: 0070: 03006100 62002600 63006400 65000000 |..a.b.&.c.d.e...|
|
||||
; MENU-NEXT: 0080: 00000400 61006200 63002600 64006500 |....a.b.c.&.d.e.|
|
||||
; MENU-NEXT: 0090: 00008000 05006100 62006300 64002600 |......a.b.c.d.&.|
|
||||
; MENU-NEXT: 0090: 00008000 FFFF6100 62006300 64002600 |......a.b.c.d.&.|
|
||||
; MENU-NEXT: 00A0: 65000000 |e...|
|
||||
; MENU-NEXT: )
|
||||
|
||||
|
@ -1180,8 +1180,10 @@ Error ResourceFileWriter::writeMenuDefinition(
|
||||
|
||||
if (auto *MenuItemPtr = dyn_cast<MenuItem>(DefPtr)) {
|
||||
writeInt<uint16_t>(Flags);
|
||||
RETURN_IF_ERROR(
|
||||
checkNumberFits<uint16_t>(MenuItemPtr->Id, "MENUITEM action ID"));
|
||||
// Some resource files use -1, i.e. UINT32_MAX, for empty menu items.
|
||||
if (MenuItemPtr->Id != static_cast<uint32_t>(-1))
|
||||
RETURN_IF_ERROR(
|
||||
checkNumberFits<uint16_t>(MenuItemPtr->Id, "MENUITEM action ID"));
|
||||
writeInt<uint16_t>(MenuItemPtr->Id);
|
||||
RETURN_IF_ERROR(writeCString(MenuItemPtr->Name));
|
||||
return Error::success();
|
||||
|
Loading…
Reference in New Issue
Block a user