@@ -62,19 +62,16 @@ static OFString* transformString(OFXMLParser *parser, OFDataArray *buffer, size_t cut, bool unescape) { - char *items; - size_t i, length; + char *items = [buffer items]; + size_t length = [buffer count] - cut; bool hasEntities = false; OFString *ret; - items = [buffer items]; - length = [buffer count] - cut; - - for (i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { if (items[i] == '\r') { if (i + 1 < length && items[i + 1] == '\n') { [buffer removeItemAtIndex: i]; items = [buffer items]; @@ -104,19 +101,18 @@ static OFString* namespaceForPrefix(OFString *prefix, OFArray *namespaces) { OFDictionary *const *objects = [namespaces objects]; size_t count = [namespaces count]; - ssize_t i; if (prefix == nil) prefix = @""; if (count - 1 > SSIZE_MAX) @throw [OFOutOfRangeException exception]; - for (i = count - 1; i >= 0; i--) { + for (ssize_t i = count - 1; i >= 0; i--) { OFString *tmp; if ((tmp = [objects[i] objectForKey: prefix]) != nil) return tmp; } @@ -148,12 +144,10 @@ @implementation OFXMLParser @synthesize delegate = _delegate, depthLimit = _depthLimit; + (void)initialize { - size_t i; - const SEL selectors_[OF_XMLPARSER_NUM_STATES] = { @selector(OF_inByteOrderMarkState), @selector(OF_outsideTagState), @selector(OF_tagOpenedState), @selector(OF_inProcessingInstructionsState), @@ -174,11 +168,11 @@ @selector(OF_inCommentState2), @selector(OF_inDOCTYPEState) }; memcpy(selectors, selectors_, sizeof(selectors_)); - for (i = 0; i < OF_XMLPARSER_NUM_STATES; i++) { + for (size_t i = 0; i < OF_XMLPARSER_NUM_STATES; i++) { if (![self instancesRespondToSelector: selectors[i]]) @throw [OFInitializationFailedException exceptionWithClass: self]; lookupTable[i] = (state_function_t) @@ -397,11 +391,11 @@ /* */ - (bool)OF_parseXMLProcessingInstructions: (OFString*)pi { const char *cString; - size_t i, last, length; + size_t length, last; int PIState = 0; OFString *attribute = nil; OFMutableString *value = nil; char piDelimiter = 0; bool hasVersion = false; @@ -415,11 +409,12 @@ pi = [pi stringByDeletingEnclosingWhitespaces]; cString = [pi UTF8String]; length = [pi UTF8StringLength]; - for (i = last = 0; i < length; i++) { + last = 0; + for (size_t i = 0; i < length; i++) { switch (PIState) { case 0: if (cString[i] == ' ' || cString[i] == '\t' || cString[i] == '\r' || cString[i] == '\n') continue; @@ -690,11 +685,11 @@ - (void)OF_inTagState { void *pool; OFString *namespace; OFXMLAttribute *const *attributesObjects; - size_t j, attributesCount; + size_t attributesCount; if (_data[_i] != '>' && _data[_i] != '/') { if (_data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r') { _last = _i; @@ -712,11 +707,11 @@ if (_prefix != nil && namespace == nil) @throw [OFUnboundPrefixException exceptionWithPrefix: _prefix parser: self]; - for (j = 0; j < attributesCount; j++) + for (size_t j = 0; j < attributesCount; j++) resolveAttributeNamespace(attributesObjects[j], _namespaces, self); pool = objc_autoreleasePoolPush();