From 45fdcc2feccd45a2ad1c5a60e7edf48ad5e024a1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 16 Feb 2020 17:03:14 +0100 Subject: [PATCH] Fix reading options files on platforms with unsigned char This fixes EOF detection on platforms where char is unsigned, as comparing it with EOF could never return true there. Thanks gcc for the warning "comparison is always true due to limited range of data type [-Wtype-limits]". --- Source/Modules/swigmain.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 8d52af194..84ac74294 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -163,7 +163,7 @@ static void merge_options_files(int *argc, char ***argv) { i = 1; while (i < new_argc) { if (new_argv[i] && new_argv[i][0] == '@' && (f = fopen(&new_argv[i][1], "r"))) { - char c; + int ci; char *b; char *be = &buffer[BUFFER_SIZE]; int quote = 0; @@ -174,7 +174,8 @@ static void merge_options_files(int *argc, char ***argv) { insert = i; b = buffer; - while ((c = fgetc(f)) != EOF) { + while ((ci = fgetc(f)) != EOF) { + const char c = static_cast(ci); if (escape) { if (b != be) { *b = c;