R-brio/0001-Fix-return-type-of-fge...

32 lines
941 B
Diff

From 6beb3df583413a7084a9b2f6ffa6de3ea9817368 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Mon, 7 Sep 2020 23:52:27 -0400
Subject: [PATCH] Fix return type of fgetc.
On x86, this seems to work by fluke, but on other systems, it does not
work because `(char)EOF` never equals `EOF`, causing an infinite loop.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
src/file_line_endings.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/file_line_endings.c b/src/file_line_endings.c
index 4587994..e8c8709 100644
--- a/src/file_line_endings.c
+++ b/src/file_line_endings.c
@@ -14,8 +14,8 @@ SEXP brio_file_line_endings(SEXP path) {
error("Could not open file: %s", path_c);
}
- char c;
- char prev_c = '\0';
+ int c;
+ int prev_c = '\0';
while ((c = fgetc(fp)) != EOF) {
if (c == '\n') {
if (prev_c == '\r') {
--
2.26.2