From 8507ee602303ac11fcc12cc0e340da2821ceb9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sat, 14 Mar 2020 12:55:09 +0200 Subject: [PATCH] windres-wrapper: Do the format name comparisons case insensitively --- wrappers/native-wrapper.h | 9 +++++++++ wrappers/windres-wrapper.c | 10 +++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/wrappers/native-wrapper.h b/wrappers/native-wrapper.h index 7a16174..7b0c16f 100644 --- a/wrappers/native-wrapper.h +++ b/wrappers/native-wrapper.h @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN @@ -94,6 +95,14 @@ static inline int _tspawnvp_escape(int mode, const TCHAR *filename, const TCHAR escaped_argv[num_args] = NULL; return _tspawnvp(mode, filename, escaped_argv); } +#else +static inline int _tcsicmp(const TCHAR *a, const TCHAR *b) { + while (*a && tolower(*a) == tolower(*b)) { + a++; + b++; + } + return *a - *b; +} #endif static inline TCHAR *concat(const TCHAR *prefix, const TCHAR *suffix) { diff --git a/wrappers/windres-wrapper.c b/wrappers/windres-wrapper.c index 2caf526..d3417d3 100644 --- a/wrappers/windres-wrapper.c +++ b/wrappers/windres-wrapper.c @@ -292,7 +292,7 @@ int _tmain(int argc, TCHAR* argv[]) { const TCHAR **exec_argv = malloc((max_arg + 1) * sizeof(*exec_argv)); int arg = 0; - if (!_tcscmp(input_format, _T("rc"))) { + if (!_tcsicmp(input_format, _T("rc"))) { exec_argv[arg++] = concat(dir, CC); exec_argv[arg++] = _T("-E"); for (int i = 0; i < nb_cpp_options; i++) @@ -327,7 +327,7 @@ int _tmain(int argc, TCHAR* argv[]) { exec_argv[arg++] = _T("-c"); exec_argv[arg++] = codepage; exec_argv[arg++] = _T("-fo"); - if (!_tcscmp(output_format, _T("res"))) + if (!_tcsicmp(output_format, _T("res"))) exec_argv[arg++] = output; else exec_argv[arg++] = res; @@ -348,9 +348,9 @@ int _tmain(int argc, TCHAR* argv[]) { return ret; } - if (!_tcscmp(output_format, _T("res"))) { + if (!_tcsicmp(output_format, _T("res"))) { // All done - } else if (!_tcscmp(output_format, _T("coff"))) { + } else if (!_tcsicmp(output_format, _T("coff"))) { arg = 0; exec_argv[arg++] = concat(dir, _T("llvm-cvtres")); exec_argv[arg++] = res; @@ -374,7 +374,7 @@ int _tmain(int argc, TCHAR* argv[]) { } else { error(basename, _T("invalid output format: `"TS"'"), output_format); } - } else if (!_tcscmp(input_format, _T("res"))) { + } else if (!_tcsicmp(input_format, _T("res"))) { exec_argv[arg++] = concat(dir, _T("llvm-cvtres")); exec_argv[arg++] = input; exec_argv[arg++] = concat(_T("-machine:"), machine);