Bug 1411480 (attempt 2) - Inline and remove the parser's pref_DoCallback() function. r=glandium.
Preferences.cpp has two functions named pref_DoCallback(). One of them has a single use in the parser. This patch inlines that single use to remove the name duplication. MozReview-Commit-ID: HnyteQ0N5M1
This commit is contained in:
@@ -1499,49 +1499,6 @@ pref_ReportParseProblem(PrefParseState& aPS,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is called when a complete pref name-value pair has been
|
|
||||||
// extracted from the input data.
|
|
||||||
//
|
|
||||||
// @param aPS
|
|
||||||
// parse state instance
|
|
||||||
//
|
|
||||||
// @return false to indicate a fatal error.
|
|
||||||
static bool
|
|
||||||
pref_DoCallback(PrefParseState* aPS)
|
|
||||||
{
|
|
||||||
PrefValue value;
|
|
||||||
|
|
||||||
switch (aPS->mVtype) {
|
|
||||||
case PrefType::String:
|
|
||||||
value.mStringVal = aPS->mVb;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PrefType::Int:
|
|
||||||
if ((aPS->mVb[0] == '-' || aPS->mVb[0] == '+') && aPS->mVb[1] == '\0') {
|
|
||||||
pref_ReportParseProblem(*aPS, "invalid integer value", 0, true);
|
|
||||||
NS_WARNING("malformed integer value");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
value.mIntVal = atoi(aPS->mVb);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PrefType::Bool:
|
|
||||||
value.mBoolVal = (aPS->mVb == kTrue);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*aPS->mReader)(aPS->mClosure,
|
|
||||||
aPS->mLb,
|
|
||||||
value,
|
|
||||||
aPS->mVtype,
|
|
||||||
aPS->mIsDefault,
|
|
||||||
aPS->mIsStickyDefault);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize a PrefParseState instance.
|
// Initialize a PrefParseState instance.
|
||||||
//
|
//
|
||||||
// |aPS| is the PrefParseState instance.
|
// |aPS| is the PrefParseState instance.
|
||||||
@@ -1986,9 +1943,40 @@ PREF_ParseBuf(PrefParseState* aPS, const char* aBuf, int aBufLen)
|
|||||||
case PREF_PARSE_UNTIL_SEMICOLON:
|
case PREF_PARSE_UNTIL_SEMICOLON:
|
||||||
// tolerate only whitespace and embedded comments
|
// tolerate only whitespace and embedded comments
|
||||||
if (c == ';') {
|
if (c == ';') {
|
||||||
if (!pref_DoCallback(aPS)) {
|
|
||||||
return false;
|
PrefValue value;
|
||||||
|
|
||||||
|
switch (aPS->mVtype) {
|
||||||
|
case PrefType::String:
|
||||||
|
value.mStringVal = aPS->mVb;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PrefType::Int:
|
||||||
|
if ((aPS->mVb[0] == '-' || aPS->mVb[0] == '+') &&
|
||||||
|
aPS->mVb[1] == '\0') {
|
||||||
|
pref_ReportParseProblem(*aPS, "invalid integer value", 0, true);
|
||||||
|
NS_WARNING("malformed integer value");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
value.mIntVal = atoi(aPS->mVb);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PrefType::Bool:
|
||||||
|
value.mBoolVal = (aPS->mVb == kTrue);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We've extracted a complete name/value pair.
|
||||||
|
aPS->mReader(aPS->mClosure,
|
||||||
|
aPS->mLb,
|
||||||
|
value,
|
||||||
|
aPS->mVtype,
|
||||||
|
aPS->mIsDefault,
|
||||||
|
aPS->mIsStickyDefault);
|
||||||
|
|
||||||
state = PREF_PARSE_INIT;
|
state = PREF_PARSE_INIT;
|
||||||
} else if (c == '/') {
|
} else if (c == '/') {
|
||||||
aPS->mNextState = state; // return here when done with comment
|
aPS->mNextState = state; // return here when done with comment
|
||||||
|
|||||||
Reference in New Issue
Block a user