Skip to content

chore: update inih to 577ae2d and raise INI_MAX_LINE to 2048 - #24

Merged
michvllni merged 1 commit into
masterfrom
feat/increase-max-lines
Sep 21, 2026
Merged

michvllni merged 1 commit into
masterfrom
feat/increase-max-lines

Conversation

@michvllni

@michvllni michvllni commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Replaces source/libs/inih/ini.{c,h} with upstream benhoyt/inih 577ae2d (2026-01-30), byte for byte, and raises INI_MAX_LINE from 1024 to 2048 in BUILD_FLAGS. A pasted Token= is an OAuth access token and Google's run past a kilobyte.

Keeping the two files identical to upstream means the next resync is a two-file copy with no patch to re-apply, so inih's compile-time options stay in the Makefile. source/libs/inih/INIReader/ is untouched — it is a local fork, and GetValues() (which getConfiguredSyncPaths() depends on) has no upstream equivalent.

Why this update is worth taking

It fixes an error misattribution this project actually hits. Given a token longer than the buffer, the old parser cut the line and parsed its tail as the next line, so ParseError() named the line after the offending one — debugConfigSummary() would report syntax error on line 3, that line was ignored while pointing at a perfectly valid Path=. Upstream now discards the overflow and reports the real line number.

Validation

Everything below was run against the vendored copy, not upstream's tree.

  • Clean 3DS build from scratch: zero warnings, all artifacts produced (.3dsx, .3ds, .cia, zip). ini.c and INIReader.cpp are also clean under devkitARM at -Wall -Wextra -Wpedantic.
  • Host test suite: 115 passed, 0 failed. (These never touched inih, hence the extra work below.)
  • Upstream's own test matrix: all 15 configurations match their baselines — multiline, heap, realloc, custom allocator, INI_HANDLER_LINENO=1, and the rest.
  • Old-vs-new differential over a 17-file corpus of README-shaped configs (1.1 KB token, inline comments, multiline continuations, BOM, CRLF, unterminated sections, over-long section/key names, no trailing newline). Only two changes, both improvements: the line numbering above, and inline comments now stripped from continuation lines (inert here — a continuation value would already be broken as a filesystem path).
  • Invariants re-checked per AGENTS.md: INI_HANDLER_LINENO still defaults to 0, so INIReader::ValueHandler's four-argument form is still correct; ini_parse/ini_parse_string signatures are unchanged apart from the no-op INI_API; the renamed statics (rstrip → ini_rstrip and friends) were all file-local, so nothing outside ini.c referenced them.

One upstream quirk, left unpatched

A line whose content is exactly INI_MAX_LINE - 1 bytes and ends in a newline parses completely, value intact, yet is still flagged as a syntax error. Reproduced standalone against ini.c alone at INI_MAX_LINE=20, so it is upstream's off-by-one rather than a bad copy.

At 2048 this needs a 2047-byte config line; main() only bails on ParseError() < 0 so a sync still runs, and the symptom is a debug-only message claiming a line was ignored when it was not. Not worth breaking the byte-identical invariant for — better filed upstream.

Notes, no action needed

The new assert()s on NULL arguments are live (NDEBUG is unset, __assert_func links in) but unreachable through INIReader — ini_parse only calls through after a successful fopen. And since INI_USE_STACK=1, the 1024 → 2048 bump grew ini_parse_stream's frame to 2196 bytes; it is called from main(), so there is ample stack.

🤖 Generated with Claude Code

adresses #14

source/libs/inih/ini.{c,h} are replaced with upstream benhoyt/inih 577ae2d
(2026-01-30), byte for byte, so the next resync stays a two-file copy with no
patch to re-apply.  INI_MAX_LINE moves from 1024 to 2048 in BUILD_FLAGS: a
pasted "Token=" is an OAuth access token and Google's run past a kilobyte.

The update fixes a misattributed error this project actually hits.  Given a
token longer than the buffer, the old parser cut the line and parsed its tail
as the next line, so ParseError() named the line *after* the offending one --
debugConfigSummary() would report "syntax error on line 3, that line was
ignored" while pointing at a perfectly valid Path=.  Upstream now discards the
overflow and reports the real line number.

Validated against the vendored copy rather than upstream's tree: all 15 of
upstream's test configurations match their baselines, and an old-vs-new diff
over a corpus of README-shaped configs (1.1 KB token, inline comments,
multiline continuations, BOM, CRLF, unterminated sections, over-long
section/key names, no trailing newline) shows only two changes, both
improvements -- the line numbering above, and inline comments now being
stripped from continuation lines.

One upstream quirk came out of the boundary probe and is left unpatched: a line
whose content is exactly INI_MAX_LINE-1 bytes and ends in a newline parses
completely, value intact, yet is still flagged as a syntax error.  At 2048 that
needs a 2047-byte line, main() only bails on ParseError() < 0 so a sync still
runs, and the symptom is a debug-only message claiming a line was ignored when
it was not -- not worth breaking the byte-identical invariant for.

INI_HANDLER_LINENO still defaults to 0, keeping INIReader::ValueHandler's
four-argument form correct, and the renamed statics (rstrip -> ini_rstrip and
friends) were all file-local, so nothing outside ini.c referenced them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@michvllni
michvllni merged commit d0cf566 into master Sep 21, 2026
5 checks passed
@michvllni
michvllni deleted the feat/increase-max-lines branch September 21, 2026 07:45
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.

1 participant