Skip to content

Conversation

@smoe
Copy link
Collaborator

@smoe smoe commented Feb 1, 2026

The strtok function is not reentrant. It has an internal static char* memorizing where the function has last split the string when it is called again. As a consequence, its calls cannot be nested (as in an outer and inner loop) and also it cannot be used at the same time within two different threads.

The strtok_r function expects the programmer to take care of that internal variable, instead. This is what this patch is all about. The remnant strtok usage of LinuxCNC are for the binaries that implement remote access to LinuxCNC. Those would be more intrusive to transition to strtok_r and are not expected to be of immediate relevance, so this is not addressed in this stable branch.

@BsAtHome
Copy link
Contributor

BsAtHome commented Feb 1, 2026

Pedantic mode enable: isn't it "saveptr" and not "safeptr" (v verses f)?

@smoe
Copy link
Collaborator Author

smoe commented Feb 1, 2026

Pedantic mode enable: isn't it "saveptr" and not "safeptr" (v verses f)?

Addressed. Thank you!

@smoe smoe mentioned this pull request Feb 1, 2026
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.

4 participants