package info parser: allow escaping of new lines
So we can break long lines without changing the semantics.
This commit is contained in:
@@ -105,15 +105,20 @@ BPackageInfo::Parser::ParseVersion(const BString& versionString,
|
|||||||
BPackageInfo::Parser::Token
|
BPackageInfo::Parser::Token
|
||||||
BPackageInfo::Parser::_NextToken()
|
BPackageInfo::Parser::_NextToken()
|
||||||
{
|
{
|
||||||
// Eat any whitespace or comments. Also eat ';' -- they have the same
|
// Eat any whitespace, comments, or escaped new lines. Also eat ';' -- they
|
||||||
// function as newlines. We remember the last encountered ';' or '\n' and
|
// have the same function as newlines. We remember the last encountered ';'
|
||||||
// return it as a token afterwards.
|
// or '\n' and return it as a token afterwards.
|
||||||
const char* itemSeparatorPos = NULL;
|
const char* itemSeparatorPos = NULL;
|
||||||
bool inComment = false;
|
bool inComment = false;
|
||||||
while ((inComment && *fPos != '\0') || isspace(*fPos) || *fPos == ';'
|
while ((inComment && *fPos != '\0') || isspace(*fPos) || *fPos == ';'
|
||||||
|| *fPos == '#') {
|
|| *fPos == '#' || *fPos == '\\') {
|
||||||
if (*fPos == '#') {
|
if (*fPos == '#') {
|
||||||
inComment = true;
|
inComment = true;
|
||||||
|
} else if (!inComment && *fPos == '\\') {
|
||||||
|
if (fPos[1] != '\n')
|
||||||
|
break;
|
||||||
|
// ignore escaped line breaks
|
||||||
|
fPos++;
|
||||||
} else if (*fPos == '\n') {
|
} else if (*fPos == '\n') {
|
||||||
itemSeparatorPos = fPos;
|
itemSeparatorPos = fPos;
|
||||||
inComment = false;
|
inComment = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user