Skip to content

Commit 45fdcc2

Browse files
committed
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]".
1 parent b465531 commit 45fdcc2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Source/Modules/swigmain.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static void merge_options_files(int *argc, char ***argv) {
163163
i = 1;
164164
while (i < new_argc) {
165165
if (new_argv[i] && new_argv[i][0] == '@' && (f = fopen(&new_argv[i][1], "r"))) {
166-
char c;
166+
int ci;
167167
char *b;
168168
char *be = &buffer[BUFFER_SIZE];
169169
int quote = 0;
@@ -174,7 +174,8 @@ static void merge_options_files(int *argc, char ***argv) {
174174
insert = i;
175175
b = buffer;
176176

177-
while ((c = fgetc(f)) != EOF) {
177+
while ((ci = fgetc(f)) != EOF) {
178+
const char c = static_cast<char>(ci);
178179
if (escape) {
179180
if (b != be) {
180181
*b = c;

0 commit comments

Comments
 (0)