ObjFW  Check-in [164d9d84f2]

Overview
Comment:Remove leading and trailing whitespaces in XML data.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 164d9d84f276ad55db131fbc47ed3b3372c60af7924d57739c0ac7e87a27d2d6
User & Date: js on 2009-08-14 01:14:27
Other Links: manifest | tags
Context
2009-08-16
13:28
Add OF{Link,Symlink}FailedException. check-in: 35d9dbcd6f user: js tags: trunk
2009-08-14
01:14
Remove leading and trailing whitespaces in XML data. check-in: 164d9d84f2 user: js tags: trunk
01:01
Treat \n and \r as whitespaces in whitespace removing methods. check-in: a5aed6da30 user: js tags: trunk
Changes

Modified src/OFXMLParser.m from [eb5533890d] to [841823e28f].

15
16
17
18
19
20
21









22
23
24
25
26
27
28

#import "OFXMLParser.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

int _OFXMLParser_reference;










static OF_INLINE OFString*
parse_numeric_entity(const char *entity, size_t length)
{
	uint32_t c;
	size_t i;
	char buf[4];







>
>
>
>
>
>
>
>
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

#import "OFXMLParser.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

int _OFXMLParser_reference;

static OF_INLINE OFString*
transform_string(OFString *cache, OFObject <OFXMLUnescapingDelegate> *handler)
{
	/* TODO: Support for xml:space */

	[cache removeLeadingAndTrailingWhitespaces];
	return [cache stringByXMLUnescapingWithHandler: handler];
}

static OF_INLINE OFString*
parse_numeric_entity(const char *entity, size_t length)
{
	uint32_t c;
	size_t i;
	char buf[4];
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
					[cache appendCString: buf + last
						  withLength: len];

				if ([cache length] > 0) {
					OFString *str;

					pool = [[OFAutoreleasePool alloc] init];
					str = [cache
					    stringByXMLUnescapingWithHandler:
					    self];

					[delegate xmlParser: self
						foundString: str];

					[pool release];
				}

				[cache setToCString: ""];







<
<
<
|







147
148
149
150
151
152
153



154
155
156
157
158
159
160
161
					[cache appendCString: buf + last
						  withLength: len];

				if ([cache length] > 0) {
					OFString *str;

					pool = [[OFAutoreleasePool alloc] init];



					str = transform_string(cache, self);
					[delegate xmlParser: self
						foundString: str];

					[pool release];
				}

				[cache setToCString: ""];

Modified tests/OFXMLParser/OFXMLParser.m from [7476e2d4e0] to [b1e1d76dd2].

82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
	return nil;
}
@end

int
main()
{
	const char *foo = "bar<foo:bar  bar='b&amp;az'  qux:qux=\"quux\">"
	    "foo&lt;bar<qux  >bar<baz name='' test='&foo;'/>quxbar</qux>"
	    "</foo:bar>";
	size_t len = strlen(foo);
	size_t i;
	OFXMLParser *parser = [OFXMLParser xmlParser];

	[parser setDelegate: [[ParserDelegate alloc] init]];








|
|







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
	return nil;
}
@end

int
main()
{
	const char *foo = "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>";
	size_t len = strlen(foo);
	size_t i;
	OFXMLParser *parser = [OFXMLParser xmlParser];

	[parser setDelegate: [[ParserDelegate alloc] init]];