win32_localize_menu - get rid of direct strcpy/strcat calls

This commit is contained in:
twinaphex 2021-05-18 18:53:30 +02:00
parent a04fe66032
commit e4a8f42ad1

View File

@ -1909,15 +1909,15 @@ static void win32_localize_menu(HMENU menu)
{ {
int len; int len;
#ifndef LEGACY_WIN32 #ifndef LEGACY_WIN32
wchar_t* newLabel_unicode; wchar_t* newLabel_unicode = NULL;
#else #else
char* newLabel_ansi; char* newLabel_ansi = NULL;
#endif #endif
const char* newLabel = msg_hash_to_str(label_enum); const char* newLabel = msg_hash_to_str(label_enum);
unsigned int metaKey = menu_id_to_meta_key(menuItemInfo.wID); unsigned int metaKey = menu_id_to_meta_key(menuItemInfo.wID);
const char* metaKeyName = meta_key_to_name(metaKey); const char* newLabel2 = newLabel;
const char* newLabel2 = newLabel; const char* metaKeyName = NULL;
char* newLabelText = NULL; char* newLabelText = NULL;
/* specific replacements: /* specific replacements:
Load Content = "Ctrl+O" Load Content = "Ctrl+O"
@ -1928,6 +1928,8 @@ static void win32_localize_menu(HMENU menu)
else if (label_enum == else if (label_enum ==
MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY) MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY)
metaKeyName = "Alt+Enter"; metaKeyName = "Alt+Enter";
else
metaKeyName = meta_key_to_name(metaKey);
/* Append localized name, tab character, and Shortcut Key */ /* Append localized name, tab character, and Shortcut Key */
if (metaKeyName && 0 != strcmp(metaKeyName, "nul")) if (metaKeyName && 0 != strcmp(metaKeyName, "nul"))
@ -1939,10 +1941,8 @@ static void win32_localize_menu(HMENU menu)
if (newLabelText) if (newLabelText)
{ {
newLabel2 = newLabelText; newLabel2 = newLabelText;
strcpy(newLabelText, newLabel); snprintf(newLabelText, bufSize, "%s\t%s", newLabel, metaKeyName);
strcat(newLabelText, "\t");
strcat(newLabelText, metaKeyName);
/* Make first character of shortcut name uppercase */ /* Make first character of shortcut name uppercase */
newLabelText[len1 + 1] = toupper(newLabelText[len1 + 1]); newLabelText[len1 + 1] = toupper(newLabelText[len1 + 1]);
} }