static bool parseHTMLNonNegativeIntegerInternal(const CharacterType* position, const CharacterType* end, unsigned& value) { // Step 3 while (position < end) { if (!isHTMLSpace<CharacterType>(*position)) break; ++position; } // Step 4 if (position == end) return false; ASSERT(position < end); // Step 5 if (*position == '+') ++position; // Step 6 if (position == end) return false; ASSERT(position < end); // Step 7 if (!isASCIIDigit(*position)) return false; // Step 8 StringBuilder digits; while (position < end) { if (!isASCIIDigit(*position)) break; digits.append(*position++); } // Step 9 bool ok; if (digits.is8Bit()) value = charactersToUIntStrict(digits.characters8(), digits.length(), &ok); else value = charactersToUIntStrict(digits.characters16(), digits.length(), &ok); return ok; }
// http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-negative-integers bool parseHTMLNonNegativeInteger(const String& input, unsigned int& value) { // Step 1 // Step 2 const UChar* position = input.characters(); const UChar* end = position + input.length(); // Step 3 while (position < end) { if (!isHTMLSpace(*position)) break; ++position; } // Step 4 if (position == end) return false; ASSERT(position < end); // Step 5 if (*position == '+') ++position; // Step 6 if (position == end) return false; ASSERT(position < end); // Step 7 if (!isASCIIDigit(*position)) return false; // Step 8 StringBuilder digits; while (position < end) { if (!isASCIIDigit(*position)) break; digits.append(*position++); } // Step 9 bool ok; value = charactersToUIntStrict(digits.characters(), digits.length(), &ok); return ok; }
unsigned StringImpl::toUIntStrict(bool* ok, int base) { return charactersToUIntStrict(m_data, m_length, ok, base); }