Commit 4c803fb1

4c803fb1d7c0Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified

Description

Fix require-modifier detection for CRLF line endings

The trailing-modifier check added for require 'x' rescue nil treated a carriage return as a modifier: on Windows (CRLF sources) the byte after require 'x' is \r, so every plain require was misread as having a modifier and replaced with nil instead of being inlined, breaking any require that pulls in real definitions (windows-mingw CI went red).

Treat \r as a statement boundary alongside \n, ;, #, and EOF so CRLF sources keep the normal inlining path.

Fixes #1285

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
4c803fb1d7c0
Parent
ce6995665306

spinel_parse.cmodifiedView file

@@ -1688,7 +1688,11 @@
16881688 {
16891689 char *trail = end + 1;
16901690 while (*trail == ' ' || *trail == '\t') trail++;
1691- if (*trail != '\n' && *trail != ';' && *trail != '\0' && *trail != '#') {
1691+ /* `\r` is part of a CRLF line ending, not a modifier: treat it as a
1692+ statement boundary so Windows sources keep the normal inlining
1693+ path. */
1694+ if (*trail != '\n' && *trail != '\r' && *trail != ';' &&
1695+ *trail != '\0' && *trail != '#') {
16921696 free(content);
16931697 size_t rl_len = (size_t)((end + 1) - pos); /* the `require 'x'` span */
16941698 size_t result_len = strlen(result);