/** * Check for a modifier flag of the following forms: * "flag" (same as "true") * "flag=yes|true|1" * "flag="no|false|0" * @param aFlag The flag to compare. * @param aData The tokenized data to check; this is lowercased * before being passed in. * @param aResult If the flag is found, the value is assigned here. * @return Whether the flag was handled. */ static bool CheckFlag(const nsSubstring& aFlag, const nsSubstring& aData, bool& aResult) { if (!StringBeginsWith(aData, aFlag)) { return false; } if (aFlag.Length() == aData.Length()) { // the data is simply "flag", which is the same as "flag=yes" aResult = true; return true; } if (aData.CharAt(aFlag.Length()) != '=') { // the data is "flag2=", which is not anything we care about return false; } if (aData.Length() == aFlag.Length() + 1) { aResult = false; return true; } switch (aData.CharAt(aFlag.Length() + 1)) { case '1': case 't': //true case 'y': //yes aResult = true; return true; case '0': case 'f': //false case 'n': //no aResult = false; return true; } return false; }
// This is to fix characters that the spellchecker may not like static void NormalizeWord(const nsSubstring& aInput, int32_t aPos, int32_t aLen, nsAString& aOutput) { aOutput.Truncate(); for (int32_t i = 0; i < aLen; i++) { PRUnichar ch = aInput.CharAt(i + aPos); // remove ignorable characters from the word if (IsIgnorableCharacter(ch)) continue; // the spellchecker doesn't handle curly apostrophes in all languages if (ch == 0x2019) { // RIGHT SINGLE QUOTATION MARK ch = '\''; } aOutput.Append(ch); } }