ObjFW  Check-in [a81bd93b41]

Overview
Comment:Fix OFXMLParser so it passes indexes relative to Unicode characters.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a81bd93b414b4192b222f58c835dd8daf1d5a11556db8e08db0f228a914dfed8
User & Date: js on 2009-10-03 21:24:26
Other Links: manifest | tags
Context
2009-10-04
12:45
Add of_unichar_t type. check-in: 8b162c7122 user: js tags: trunk
2009-10-03
21:24
Fix OFXMLParser so it passes indexes relative to Unicode characters. check-in: a81bd93b41 user: js tags: trunk
21:18
Add -[length] to OFString. check-in: 0fcb47fb59 user: js tags: trunk
Changes

Modified src/OFXMLParser.m from [50080689c1] to [3bf4893784].

456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
			break;
		case OF_XMLPARSER_IN_COMMENT_4:
			if (buf[i] == '-') {
				size_t cache_len;

				[cache appendCString: buf + last
					  withLength: i - last];
				cache_len = [cache cStringLength];

				pool = [[OFAutoreleasePool alloc] init];
				[cache removeCharactersFromIndex: cache_len - 1
							 toIndex: cache_len];
				[cache removeLeadingAndTrailingWhitespaces];
				[delegate xmlParser: self
				       foundComment: cache];







|







456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
			break;
		case OF_XMLPARSER_IN_COMMENT_4:
			if (buf[i] == '-') {
				size_t cache_len;

				[cache appendCString: buf + last
					  withLength: i - last];
				cache_len = [cache length];

				pool = [[OFAutoreleasePool alloc] init];
				[cache removeCharactersFromIndex: cache_len - 1
							 toIndex: cache_len];
				[cache removeLeadingAndTrailingWhitespaces];
				[delegate xmlParser: self
				       foundComment: cache];

Modified tests/xmlparser.m from [50ad7436fa] to [6b442cb340].

102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
		break;
	case 10:
		/* FIXME: Namespace */
		TEST(msg, et == TAG_END && [name isEqual: @"bar"] &&
		    [prefix isEqual: @"foo"] && ns == nil)
		break;
	case 11:
		TEST(msg, et == COMMENT && [comment isEqual: @"foo bar-baz"])
		break;
	default:
		TEST(msg, NO)
		break;
	}
}








|







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
		break;
	case 10:
		/* FIXME: Namespace */
		TEST(msg, et == TAG_END && [name isEqual: @"bar"] &&
		    [prefix isEqual: @"foo"] && ns == nil)
		break;
	case 11:
		TEST(msg, et == COMMENT && [comment isEqual: @"foo bär-baz"])
		break;
	default:
		TEST(msg, NO)
		break;
	}
}

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
void
xmlparser_tests()
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLParser *parser;
	const char *str = "bar<foo:bar  bar='b&amp;az'  qux:qux=\" quux \">\r\n"
	    "foo&lt;bar<qux  >bar <baz name='' test='&foo;'/>  quxbar\r\n</qux>"
	    "</foo:bar><!-- foo bar-baz -->";
	size_t j, len;

	TEST(@"+[xmlParser]", (parser = [OFXMLParser xmlParser]))

	TEST(@"-[setDelegate:]",
	    [parser setDelegate: [[[ParserDelegate alloc] init] autorelease]])








|







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
void
xmlparser_tests()
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLParser *parser;
	const char *str = "bar<foo:bar  bar='b&amp;az'  qux:qux=\" quux \">\r\n"
	    "foo&lt;bar<qux  >bar <baz name='' test='&foo;'/>  quxbar\r\n</qux>"
	    "</foo:bar><!-- foo bär-baz -->";
	size_t j, len;

	TEST(@"+[xmlParser]", (parser = [OFXMLParser xmlParser]))

	TEST(@"-[setDelegate:]",
	    [parser setDelegate: [[[ParserDelegate alloc] init] autorelease]])