Skip to content

Commit

Permalink
windres-wrapper: Do the format name comparisons case insensitively
Browse files Browse the repository at this point in the history
  • Loading branch information
mstorsjo committed Mar 14, 2020
1 parent 96b149e commit 8507ee6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions wrappers/native-wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions wrappers/windres-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 8507ee6

Please sign in to comment.