summaryrefslogtreecommitdiff
path: root/yacc
diff options
context:
space:
mode:
authorDavid Allsopp <david.allsopp@metastack.com>2017-02-15 13:02:11 +0000
committerDavid Allsopp <david.allsopp@metastack.com>2017-02-15 13:02:11 +0000
commitfffde17d52ecd43e3e09475db2a95105c65e735b (patch)
treecc88c22ba51429e81327259c1e3d664920e12aeb /yacc
parentc1828b92b64a5826a51312e117c2968b5d8bfa9a (diff)
downloadocaml-fffde17d52ecd43e3e09475db2a95105c65e735b.tar.gz
Make ocamlyacc and make_opcodes ignore \r on Unix
ocamlyacc doesn't correctly handle \r on Unix meaning that long strings with escaped newlines cause unterminated string warnings. Similarly, the make_opcodes script in the build system cannot cope with a CRLF checkout of the header files.
Diffstat (limited to 'yacc')
-rw-r--r--yacc/reader.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/yacc/reader.c b/yacc/reader.c
index 85ee63ead5..3e99e8c8eb 100644
--- a/yacc/reader.c
+++ b/yacc/reader.c
@@ -102,7 +102,12 @@ void get_line(void)
line = REALLOC(line, linesize);
if (line == 0) no_space();
}
- if (c == '\n') { line[i] = '\0'; cptr = line; return; }
+ if (c == '\n') {
+ if (i >= 2 && line[i-2] == '\r') {
+ line[i-2] = '\n'; i--;
+ }
+ line[i] = '\0'; cptr = line; return;
+ }
c = getc(f);
if (c == EOF) { saw_eof = 1; c = '\n'; }
}