From 433593db485806f3632a4d93f8b9661060398888 Mon Sep 17 00:00:00 2001 From: Elias Batek Date: Thu, 13 Feb 2025 06:29:05 +0100 Subject: [PATCH] Fix known bug with line-folding keys or sections --- ini.d | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ini.d b/ini.d index 10c5d30..686af1c 100644 --- a/ini.d +++ b/ini.d @@ -993,14 +993,12 @@ struct IniParser( case '\r': const idxAfterNext = idxNext + 1; - // CRLF? if (idxAfterNext < _source.length) { if (_source[idxAfterNext] == '\n') { return 3; } } - return 2; default: @@ -1014,7 +1012,7 @@ struct IniParser( if (foldingCount > 0) { static if (operatingMode!string == OperatingMode.nonDestructive) { idx += (foldingCount - 1); - idxLastText = idx; + idxCutoff = idx; } static if (operatingMode!string == OperatingMode.destructive) { _source.splice(idx, foldingCount); @@ -1073,7 +1071,7 @@ struct IniParser( } } - const idxNextToken = (idxCutoff >= 0) ? idxCutoff : idxEOT; + const idxNextToken = (idxCutoff >= idxLastText) ? idxCutoff : idxEOT; _source = _source[idxNextToken .. $]; if (inQuotedString != QuotedString.none) { @@ -1946,12 +1944,7 @@ key \= = value { parser.popFront(); assert(!parser.empty); - // FIXME: Line folding does not interact properly with keys. - version (none) { - assert(parser.front.data == "key"); - } else { - assert(parser.front.data == "key "); // bug - } + assert(parser.front.data == "key"); parser.popFront(); assert(!parser.empty);