]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Allow building sources with mixed LF/CRLF line-endings.
authorMike Pall <mike>
Tue, 21 Feb 2023 15:49:51 +0000 (16:49 +0100)
committerMike Pall <mike>
Tue, 21 Feb 2023 15:49:51 +0000 (16:49 +0100)
Reported by mgood7123.

src/host/buildvm_lib.c

index a9829d0d139498c3229fcfe987b956f30e492385..47195fd4ee333a1e58e7018df34d40142fbda8b8 100644 (file)
@@ -319,12 +319,18 @@ void emit_lib(BuildCtx *ctx)
       char *p;
       /* Simplistic pre-processor. Only handles top-level #if/#endif. */
       if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') {
-       int ok = 1;
-       if (!strcmp(buf, "#if LJ_52\n"))
+       int ok = 1, len = strlen(buf);
+       if (buf[len-1] == '\n') {
+         buf[len-1] = 0;
+         if (buf[len-2] == '\r') {
+           buf[len-2] = 0;
+         }
+       }
+       if (!strcmp(buf, "#if LJ_52"))
          ok = LJ_52;
-       else if (!strcmp(buf, "#if LJ_HASJIT\n"))
+       else if (!strcmp(buf, "#if LJ_HASJIT"))
          ok = LJ_HASJIT;
-       else if (!strcmp(buf, "#if LJ_HASFFI\n"))
+       else if (!strcmp(buf, "#if LJ_HASFFI"))
          ok = LJ_HASFFI;
        if (!ok) {
          int lvl = 1;