Skip to content

Fix some recently implemented comparisons of token strings - #6452

Merged
kimkulling merged 2 commits into
assimp:masterfrom
nickykitchingman:bugfix/fix_obj_mtl_token_comparisons
Jan 22, 2026
Merged

kimkulling merged 2 commits into
assimp:masterfrom
nickykitchingman:bugfix/fix_obj_mtl_token_comparisons

Conversation

@nickykitchingman

@nickykitchingman nickykitchingman commented Jan 21, 2026 •

Copy link
Copy Markdown
Contributor

Previously, the keyword included the following space along with the token, which broke the string comparison using the equality operator.
This is an addition to 709fe3c which (partly) addressed issues #6253 and #5635.

Summary by CodeRabbit

  • Refactor
    • Internal parsing for OBJ/MTL import was reworked to clarify token boundary detection vs. advancement. This improves consistency across keyword and texture parsing paths, reducing ambiguity in how keywords and their arguments are interpreted while preserving existing behavior and public interfaces.

✏️ Tip: You can customize this high-level summary in your review settings.

…y, the `keyword` included the following space along with the token, which broke the string comparison using the equality operator.
@coderabbitai

coderabbitai Bot commented Jan 21, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Reworked token parsing in ObjFileMtlImporter to use a delimiter-first approach: introduce getNextDelimiter() to locate token boundaries, then advance to the next word with getNextWord(). Adjusted keyword handling (including map*) to use the new boundary semantics without public API changes.

Changes

Cohort / File(s) Summary
Obj MTL Importer
code/AssetLib/Obj/ObjFileMtlImporter.cpp
Replaced direct getNextToken(...) usages with getNextDelimiter(...) and then m_DataIt = getNextWord(tokenEnd, m_DataItEnd) across multiple material parsing branches (m, r, a, s, c, etc.). For map* keywords, reset m_DataIt to tokenStart before calling getTexture().
Token Utilities
code/AssetLib/Obj/ObjTools.h
Added inline getNextDelimiter(...) to return the delimiter position. Kept getNextToken(...) as a wrapper that calls getNextDelimiter(...) then getNextWord(...). Updated inline docs to reflect delimiter vs. token-after-delimiter semantics.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble tokens, sniff the end,
I mark the gap where words suspend,
Then hop ahead to fetch the next,
A tidy trail of tiny text,
Hooray — parsing bounds transcend! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes a bug fix for token string comparisons, which directly aligns with the main change: correcting token extraction in OBJ/MTL parsing to fix equality comparison failures.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@code/AssetLib/Obj/ObjTools.h`:
- Around line 88-115: Update the getEndOfToken documentation to state it returns
a pointer to the first delimiter (space/newline) or pEnd (i.e., an end-exclusive
iterator), not the last character of the token; mention that callers should use
the returned pointer as the end for substring ranges (e.g., [start,
getEndOfToken(...)) so behavior is clear, and ensure the doc for getNextToken
remains consistent since it calls getEndOfToken and getNextWord.

Comment thread code/AssetLib/Obj/ObjTools.h Resolved

@kimkulling kimkulling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine for me.

@sonarqubecloud

Copy link
Copy Markdown

@kullingk kullingk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine for me.

@kimkulling
kimkulling merged commit d5091bb into assimp:master Jan 22, 2026
@kimkulling

Copy link
Copy Markdown
Member

Merged, thank you for the contribution.

@kimkulling kimkulling added Wavefront-Obj Bugs related to the wavefront format Bug Global flag to mark a deviation from expected behaviour labels Jan 22, 2026
@nickykitchingman
nickykitchingman deleted the bugfix/fix_obj_mtl_token_comparisons branch January 22, 2026 10:42
kimkulling pushed a commit that referenced this pull request Jul 1, 2026
* Fix some recently implemented comparisons of token strings. Previously, the `keyword` included the following space along with the token, which broke the string comparison using the equality operator.

* Rename `getEndOfToken` -> `getNextDelimiter`, to reflect the actual usage
tkluge-fender pushed a commit to cclsoftware/assimp that referenced this pull request Jul 28, 2026
* Fix some recently implemented comparisons of token strings. Previously, the `keyword` included the following space along with the token, which broke the string comparison using the equality operator.

* Rename `getEndOfToken` -> `getNextDelimiter`, to reflect the actual usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Global flag to mark a deviation from expected behaviour Wavefront-Obj Bugs related to the wavefront format

Projects

Development

Successfully merging this pull request may close these issues.

3 participants