Skip to content

GCodeLoader: Fix parsing of files with CRLF line endings. - #35171

Merged
Mugen87 merged 4 commits into
mrdoob:devfrom
L4XB:gcodeloader-crlf
Oct 23, 2026
Merged

Mugen87 merged 4 commits into
mrdoob:devfrom
L4XB:gcodeloader-crlf

Conversation

@L4XB

@L4XB L4XB commented Oct 22, 2026

Copy link
Copy Markdown

Related issue: -

Description

GCodeLoader splits the file at \n and each line at spaces. With CRLF line endings, a command without arguments keeps the \r ('G91\r') and matches none of the command checks. As a result, G90, G91, M82 and M83 are ignored. Take this program:

G90
M82
G1 Z0.2 F1200
G1 X10 Y0 E1
G91
G1 X10 Y0 E1
G1 X0 Y10 E1
LF    extrusion: 0,0 → 10,0; 10,0 → 20,0; 20,0 → 20,10 | travel: 0,0 → 0,0
CRLF  extrusion: 0,0 → 10,0 | travel: 0,0 → 0,0; 10,0 → 10,0; 10,0 → 0,10

With CRLF, the moves after G91 go to absolute positions. They also stop extruding, because E1 is now read as an absolute value.

The loader now trims each line and splits it at any whitespace. With this change, both line endings give the LF result above.

test/unit/addons/loaders/GCodeLoader.tests.js is new. It parses the program with LF and with CRLF line endings and compares the extruded toolpaths, and it fails with the current code. ESLint passes on the changed files.

L4XB and others added 4 commits October 23, 2026 00:21
Lines were split at spaces only, so a command without arguments kept the \r of a CRLF line ending and matched none of the checks. G90, G91, M82 and M83 were ignored. Trim each line and split it at any whitespace.
@Mugen87 Mugen87 added this to the r187 milestone Oct 23, 2026
@Mugen87
Mugen87 merged commit c8f537f into mrdoob:dev Oct 23, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants