aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2023-02-21 16:49:51 +0100
committerMike Pall <mike>2023-02-21 16:49:51 +0100
commit126526ab936a1b5c5015d31ab5d3bdac4ad0b19d (patch)
treed89575a81dd51e84163b745d30e2e9385212dc3c
parent8a5e398c52c7f8ca3e1a0e574cc2ba38224b759b (diff)
downloadluajit-126526ab936a1b5c5015d31ab5d3bdac4ad0b19d.tar.gz
luajit-126526ab936a1b5c5015d31ab5d3bdac4ad0b19d.tar.bz2
luajit-126526ab936a1b5c5015d31ab5d3bdac4ad0b19d.zip
Allow building sources with mixed LF/CRLF line-endings.
Reported by mgood7123.
-rw-r--r--src/host/buildvm_lib.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/host/buildvm_lib.c b/src/host/buildvm_lib.c
index a9829d0d..47195fd4 100644
--- a/src/host/buildvm_lib.c
+++ b/src/host/buildvm_lib.c
@@ -319,12 +319,18 @@ void emit_lib(BuildCtx *ctx)
319 char *p; 319 char *p;
320 /* Simplistic pre-processor. Only handles top-level #if/#endif. */ 320 /* Simplistic pre-processor. Only handles top-level #if/#endif. */
321 if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') { 321 if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') {
322 int ok = 1; 322 int ok = 1, len = strlen(buf);
323 if (!strcmp(buf, "#if LJ_52\n")) 323 if (buf[len-1] == '\n') {
324 buf[len-1] = 0;
325 if (buf[len-2] == '\r') {
326 buf[len-2] = 0;
327 }
328 }
329 if (!strcmp(buf, "#if LJ_52"))
324 ok = LJ_52; 330 ok = LJ_52;
325 else if (!strcmp(buf, "#if LJ_HASJIT\n")) 331 else if (!strcmp(buf, "#if LJ_HASJIT"))
326 ok = LJ_HASJIT; 332 ok = LJ_HASJIT;
327 else if (!strcmp(buf, "#if LJ_HASFFI\n")) 333 else if (!strcmp(buf, "#if LJ_HASFFI"))
328 ok = LJ_HASFFI; 334 ok = LJ_HASFFI;
329 if (!ok) { 335 if (!ok) {
330 int lvl = 1; 336 int lvl = 1;