Force package names and versions to lower case
This commit is contained in:
@@ -82,7 +82,8 @@ private:
|
|||||||
void _ParseList(ListElementParser& elementParser,
|
void _ParseList(ListElementParser& elementParser,
|
||||||
bool allowSingleNonListElement);
|
bool allowSingleNonListElement);
|
||||||
void _ParseStringList(BObjectList<BString>* value,
|
void _ParseStringList(BObjectList<BString>* value,
|
||||||
bool allowQuotedStrings = true);
|
bool allowQuotedStrings = true,
|
||||||
|
bool convertToLowerCase = false);
|
||||||
void _ParseResolvableList(
|
void _ParseResolvableList(
|
||||||
BObjectList<BPackageResolvable>* value);
|
BObjectList<BPackageResolvable>* value);
|
||||||
void _ParseResolvableExprList(
|
void _ParseResolvableExprList(
|
||||||
@@ -449,16 +450,19 @@ BPackageInfo::Parser::_ParseList(ListElementParser& elementParser,
|
|||||||
|
|
||||||
void
|
void
|
||||||
BPackageInfo::Parser::_ParseStringList(BObjectList<BString>* value,
|
BPackageInfo::Parser::_ParseStringList(BObjectList<BString>* value,
|
||||||
bool allowQuotedStrings)
|
bool allowQuotedStrings, bool convertToLowerCase)
|
||||||
{
|
{
|
||||||
struct StringParser : public ListElementParser {
|
struct StringParser : public ListElementParser {
|
||||||
BObjectList<BString>* value;
|
BObjectList<BString>* value;
|
||||||
bool allowQuotedStrings;
|
bool allowQuotedStrings;
|
||||||
|
bool convertToLowerCase;
|
||||||
|
|
||||||
StringParser(BObjectList<BString>* value, bool allowQuotedStrings)
|
StringParser(BObjectList<BString>* value, bool allowQuotedStrings,
|
||||||
|
bool convertToLowerCase)
|
||||||
:
|
:
|
||||||
value(value),
|
value(value),
|
||||||
allowQuotedStrings(allowQuotedStrings)
|
allowQuotedStrings(allowQuotedStrings),
|
||||||
|
convertToLowerCase(convertToLowerCase)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,9 +479,13 @@ BPackageInfo::Parser::_ParseStringList(BObjectList<BString>* value,
|
|||||||
throw ParseError("expected word", token.pos);
|
throw ParseError("expected word", token.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
value->AddItem(new BString(token.text));
|
BString* element = new BString(token.text);
|
||||||
|
if (convertToLowerCase)
|
||||||
|
element->ToLower();
|
||||||
|
|
||||||
|
value->AddItem(element);
|
||||||
}
|
}
|
||||||
} stringParser(value, allowQuotedStrings);
|
} stringParser(value, allowQuotedStrings, convertToLowerCase);
|
||||||
|
|
||||||
_ParseList(stringParser, true);
|
_ParseList(stringParser, true);
|
||||||
}
|
}
|
||||||
@@ -688,8 +696,12 @@ BPackageInfo::Parser::_Parse(BPackageInfo* packageInfo)
|
|||||||
|
|
||||||
switch (attribute) {
|
switch (attribute) {
|
||||||
case B_PACKAGE_INFO_NAME:
|
case B_PACKAGE_INFO_NAME:
|
||||||
_ParseStringValue(&packageInfo->fName);
|
{
|
||||||
|
BString name;
|
||||||
|
_ParseStringValue(&name);
|
||||||
|
packageInfo->SetName(name);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case B_PACKAGE_INFO_SUMMARY:
|
case B_PACKAGE_INFO_SUMMARY:
|
||||||
{
|
{
|
||||||
@@ -758,7 +770,7 @@ BPackageInfo::Parser::_Parse(BPackageInfo* packageInfo)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PACKAGE_INFO_REPLACES:
|
case B_PACKAGE_INFO_REPLACES:
|
||||||
_ParseStringList(&packageInfo->fReplacesList, false);
|
_ParseStringList(&packageInfo->fReplacesList, false, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PACKAGE_INFO_FLAGS:
|
case B_PACKAGE_INFO_FLAGS:
|
||||||
@@ -1051,6 +1063,7 @@ void
|
|||||||
BPackageInfo::SetName(const BString& name)
|
BPackageInfo::SetName(const BString& name)
|
||||||
{
|
{
|
||||||
fName = name;
|
fName = name;
|
||||||
|
fName.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1298,6 +1311,7 @@ BPackageInfo::AddReplaces(const BString& replaces)
|
|||||||
if (newReplaces == NULL)
|
if (newReplaces == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
newReplaces->ToLower();
|
||||||
return fReplacesList.AddItem(newReplaces) ? B_OK : B_ERROR;
|
return fReplacesList.AddItem(newReplaces) ? B_OK : B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ BPackageResolvable::BPackageResolvable(const BString& name,
|
|||||||
fVersion(version),
|
fVersion(version),
|
||||||
fCompatibleVersion(compatibleVersion)
|
fCompatibleVersion(compatibleVersion)
|
||||||
{
|
{
|
||||||
|
fName.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -110,6 +111,8 @@ BPackageResolvable::SetTo(const BString& name, BPackageResolvableType type,
|
|||||||
fType = type;
|
fType = type;
|
||||||
fVersion = version;
|
fVersion = version;
|
||||||
fCompatibleVersion = compatibleVersion;
|
fCompatibleVersion = compatibleVersion;
|
||||||
|
|
||||||
|
fName.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ BPackageResolvableExpression::BPackageResolvableExpression(
|
|||||||
fOperator(data.op),
|
fOperator(data.op),
|
||||||
fVersion(data.version)
|
fVersion(data.version)
|
||||||
{
|
{
|
||||||
|
fName.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@ BPackageResolvableExpression::BPackageResolvableExpression(const BString& name,
|
|||||||
fOperator(_operator),
|
fOperator(_operator),
|
||||||
fVersion(version)
|
fVersion(version)
|
||||||
{
|
{
|
||||||
|
fName.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,6 +108,8 @@ BPackageResolvableExpression::SetTo(const BString& name,
|
|||||||
fName = name;
|
fName = name;
|
||||||
fOperator = _operator;
|
fOperator = _operator;
|
||||||
fVersion = version;
|
fVersion = version;
|
||||||
|
|
||||||
|
fName.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,25 +25,15 @@ BPackageVersion::BPackageVersion()
|
|||||||
|
|
||||||
|
|
||||||
BPackageVersion::BPackageVersion(const BPackageVersionData& data)
|
BPackageVersion::BPackageVersion(const BPackageVersionData& data)
|
||||||
:
|
|
||||||
fMajor(data.major),
|
|
||||||
fMinor(data.minor),
|
|
||||||
fMicro(data.micro),
|
|
||||||
fPreRelease(data.preRelease),
|
|
||||||
fRelease(data.release)
|
|
||||||
{
|
{
|
||||||
|
SetTo(data.major, data.minor, data.micro, data.preRelease, data.release);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BPackageVersion::BPackageVersion(const BString& major, const BString& minor,
|
BPackageVersion::BPackageVersion(const BString& major, const BString& minor,
|
||||||
const BString& micro, const BString& preRelease, uint8 release)
|
const BString& micro, const BString& preRelease, uint8 release)
|
||||||
:
|
|
||||||
fMajor(major),
|
|
||||||
fMinor(minor),
|
|
||||||
fMicro(micro),
|
|
||||||
fPreRelease(preRelease),
|
|
||||||
fRelease(release)
|
|
||||||
{
|
{
|
||||||
|
SetTo(major, minor, micro, preRelease, release);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -153,6 +143,11 @@ BPackageVersion::SetTo(const BString& major, const BString& minor,
|
|||||||
fMicro = micro;
|
fMicro = micro;
|
||||||
fPreRelease = preRelease;
|
fPreRelease = preRelease;
|
||||||
fRelease = release;
|
fRelease = release;
|
||||||
|
|
||||||
|
fMajor.ToLower();
|
||||||
|
fMinor.ToLower();
|
||||||
|
fMicro.ToLower();
|
||||||
|
fPreRelease.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user