From a98dd49a6b8f7a267dbbade3694ec88072785f5e Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 25 May 2013 01:10:25 +0200 Subject: [PATCH] package info parser: allow escaping of new lines So we can break long lines without changing the semantics. --- src/kits/package/PackageInfoParser.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/kits/package/PackageInfoParser.cpp b/src/kits/package/PackageInfoParser.cpp index 9d0e0ec89a..aaa37b9d5c 100644 --- a/src/kits/package/PackageInfoParser.cpp +++ b/src/kits/package/PackageInfoParser.cpp @@ -105,15 +105,20 @@ BPackageInfo::Parser::ParseVersion(const BString& versionString, BPackageInfo::Parser::Token BPackageInfo::Parser::_NextToken() { - // Eat any whitespace or comments. Also eat ';' -- they have the same - // function as newlines. We remember the last encountered ';' or '\n' and - // return it as a token afterwards. + // Eat any whitespace, comments, or escaped new lines. Also eat ';' -- they + // have the same function as newlines. We remember the last encountered ';' + // or '\n' and return it as a token afterwards. const char* itemSeparatorPos = NULL; bool inComment = false; while ((inComment && *fPos != '\0') || isspace(*fPos) || *fPos == ';' - || *fPos == '#') { + || *fPos == '#' || *fPos == '\\') { if (*fPos == '#') { inComment = true; + } else if (!inComment && *fPos == '\\') { + if (fPos[1] != '\n') + break; + // ignore escaped line breaks + fPos++; } else if (*fPos == '\n') { itemSeparatorPos = fPos; inComment = false;