ObjFW  Diff

Differences From Artifact [d31bdbf69b]:

To Artifact [e24ed84b06]:


15
16
17
18
19
20
21

22
23
24
25
26
27
28
#include <unistd.h>

#import "OFXMLParser.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFXMLAttribute.h"

#import "OFFile.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

typedef void (*state_function)(id, SEL, const char*, size_t*, size_t*);
static SEL selectors[OF_XMLPARSER_NUM_STATES];







>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <unistd.h>

#import "OFXMLParser.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFXMLAttribute.h"
#import "OFStream.h"
#import "OFFile.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "macros.h"

typedef void (*state_function)(id, SEL, const char*, size_t*, size_t*);
static SEL selectors[OF_XMLPARSER_NUM_STATES];
204
205
206
207
208
209
210

















211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
}

- (void)parseString: (OFString*)str
{
	[self parseBuffer: [str cString]
		 withSize: [str cStringLength]];
}


















- (void)parseFile: (OFString*)path
{
	OFFile *file = [[OFFile alloc] initWithPath: path
					       mode: @"rb"];

	@try {
		char *buf = [self allocMemoryWithSize: of_pagesize];

		@try {
			while (![file isAtEndOfStream]) {
				size_t size;

				size = [file readNBytes: of_pagesize
					     intoBuffer: buf];
				[self parseBuffer: buf
					 withSize: size];
			}
		} @finally {
			[self freeMemory: buf];
		}
	} @finally {
		[file release];
	}
}

/*
 * The following methods handle the different states of the parser. They are







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







<
<
<
<
<
<
<
<
|
<
<
<
<
<







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235








236





237
238
239
240
241
242
243
}

- (void)parseString: (OFString*)str
{
	[self parseBuffer: [str cString]
		 withSize: [str cStringLength]];
}

- (void)parseStream: (OFStream*)stream
{
	char *buf = [self allocMemoryWithSize: of_pagesize];

	@try {
		while (![stream isAtEndOfStream]) {
			size_t len = [stream readNBytes: of_pagesize
					     intoBuffer: buf];

			[self parseBuffer: buf
				 withSize: len];
		}
	} @finally {
		[self freeMemory: buf];
	}
}

- (void)parseFile: (OFString*)path
{
	OFFile *file = [[OFFile alloc] initWithPath: path
					       mode: @"rb"];

	@try {








		[self parseStream: file];





	} @finally {
		[file release];
	}
}

/*
 * The following methods handle the different states of the parser. They are