From 72f030fd8e2d206049cf1fbb1d719d42af9d47f3 Mon Sep 17 00:00:00 2001 From: Dav999-v Date: Thu, 29 Dec 2022 05:02:09 +0100 Subject: [PATCH] Support underscore (_) in VFormat arg name This is needed for the limits check in the translator menu. This commit is part of rewritten history of the localization branch. The original (unsquashed) commit history can be found here: https://github.com/Dav999-v/VVVVVV/tree/localization-orig --- desktop_version/src/VFormat.c | 3 ++- desktop_version/src/VFormat.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/VFormat.c b/desktop_version/src/VFormat.c index f71766ea..ae8eff90 100644 --- a/desktop_version/src/VFormat.c +++ b/desktop_version/src/VFormat.c @@ -245,7 +245,8 @@ void vformat_cb_valist( trim_whitespace(&arg_name, &arg_name_len); trim_whitespace(&arg_type, &arg_type_len); - match = (arg_name_len == name_len && SDL_memcmp(arg_name, name, name_len) == 0); + match = (arg_name_len == name_len && SDL_memcmp(arg_name, name, name_len) == 0) + || (arg_name_len == 1 && arg_name[0] == '_'); if (arg_type_len == 3 && SDL_memcmp(arg_type, "int", 3) == 0) { diff --git a/desktop_version/src/VFormat.h b/desktop_version/src/VFormat.h index 3723524b..c2a826f1 100644 --- a/desktop_version/src/VFormat.h +++ b/desktop_version/src/VFormat.h @@ -45,6 +45,9 @@ * - str const char* * - but Controller button icon * + * Special case: if an argument name is a single underscore (_), it matches + * any name not found earlier in the list. This should normally not be needed. + * * Full example: * * char buffer[100];