ObjFW  Check-in [1248c00475]

Overview
Comment:OFINIFile: Always use \r\n
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1248c00475ab79234c05b9f875e1767558f944195e7bdb59b02c785b56606c2a
User & Date: js on 2017-07-24 20:29:17
Other Links: manifest | tags
Context
2017-07-24
20:33
runtime: Don't depend on platform.h in ObjFW-RT.h check-in: 636098dbdd user: js tags: trunk
20:29
OFINIFile: Always use \r\n check-in: 1248c00475 user: js tags: trunk
20:10
OFData: Add casts to make 32 bit Clang happy check-in: 8da165721c user: js tags: trunk
Changes

Modified src/OFINICategory.m from [4c38694599] to [77ec98f4c0].

493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
		encoding: (of_string_encoding_t)encoding
		   first: (bool)first
{
	if ([_lines count] == 0)
		return false;

	if (first)
		[stream writeFormat: @"[%@]\n", _name];
	else
		[stream writeFormat: @"\n[%@]\n", _name];

	for (id line in _lines) {
		if ([line isKindOfClass: [OFINICategory_Comment class]]) {
			OFINICategory_Comment *comment = line;
			[stream writeLine: comment->_comment];
		} else if ([line isKindOfClass: [OFINICategory_Pair class]]) {
			OFINICategory_Pair *pair = line;
			OFString *key = escapeString(pair->_key);
			OFString *value = escapeString(pair->_value);
			OFString *line = [OFString
			    stringWithFormat: @"%@=%@\n", key, value];

			[stream writeString: line
				   encoding: encoding];
		} else
			@throw [OFInvalidArgumentException exception];
	}








|

|




|





|







493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
		encoding: (of_string_encoding_t)encoding
		   first: (bool)first
{
	if ([_lines count] == 0)
		return false;

	if (first)
		[stream writeFormat: @"[%@]\r\n", _name];
	else
		[stream writeFormat: @"\r\n[%@]\r\n", _name];

	for (id line in _lines) {
		if ([line isKindOfClass: [OFINICategory_Comment class]]) {
			OFINICategory_Comment *comment = line;
			[stream writeFormat: @"%@\r\n", comment->_comment];
		} else if ([line isKindOfClass: [OFINICategory_Pair class]]) {
			OFINICategory_Pair *pair = line;
			OFString *key = escapeString(pair->_key);
			OFString *value = escapeString(pair->_value);
			OFString *line = [OFString
			    stringWithFormat: @"%@=%@\r\n", key, value];

			[stream writeString: line
				   encoding: encoding];
		} else
			@throw [OFInvalidArgumentException exception];
	}

Modified tests/OFINIFileTests.m from [2d74cdc476] to [71a1ded6ce].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
#import "OFDictionary.h"
#import "OFFile.h"
#import "OFFileManager.h"
#import "OFAutoreleasePool.h"

#import "TestsAppDelegate.h"

#if defined(OF_WINDOWS) || defined(OF_MSDOS)
# define NL @"\r\n"
#else
# define NL @"\n"
#endif

static OFString *module = @"OFINIFile";

@implementation TestsAppDelegate (OFINIFileTests)
- (void)INIFileTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFString *output = @"[tests]" NL
	    @"foo=baz" NL
	    @"foobar=baz" NL
	    @";comment" NL
	    @"new=new" NL
	    NL

	    @"[foobar]" NL
	    @";foobarcomment" NL
	    @"qux=\" asd\"" NL
	    @"quxquxqux=\"hello\\\"wörld\"" NL
	    @"qux2=\"a\\f\"" NL
	    @"qux3=a\fb" NL
	    NL

	    @"[types]" NL
	    @"integer=16" NL
	    @"bool=false" NL
	    @"float=0.25" NL
	    @"array1=foo" NL
	    @"array1=bar" NL
	    @"double=0.75" NL;
	OFINIFile *file;
	OFINICategory *tests, *foobar, *types;
	OFArray *array;
#ifndef OF_NINTENDO_DS
	OFString *writePath;
#endif








<
<
<
<
<
<






|
|
|
|
|
<
>
|
|
|
|
|
|
<
>
|
|
|
|
|
|
|







23
24
25
26
27
28
29






30
31
32
33
34
35
36
37
38
39
40

41
42
43
44
45
46
47

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#import "OFDictionary.h"
#import "OFFile.h"
#import "OFFileManager.h"
#import "OFAutoreleasePool.h"

#import "TestsAppDelegate.h"







static OFString *module = @"OFINIFile";

@implementation TestsAppDelegate (OFINIFileTests)
- (void)INIFileTests
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFString *output = @"[tests]\r\n"
	    @"foo=baz\r\n"
	    @"foobar=baz\r\n"
	    @";comment\r\n"
	    @"new=new\r\n"

	    @"\r\n"
	    @"[foobar]\r\n"
	    @";foobarcomment\r\n"
	    @"qux=\" asd\"\r\n"
	    @"quxquxqux=\"hello\\\"wörld\"\r\n"
	    @"qux2=\"a\\f\"\r\n"
	    @"qux3=a\fb\r\n"

	    @"\r\n"
	    @"[types]\r\n"
	    @"integer=16\r\n"
	    @"bool=false\r\n"
	    @"float=0.25\r\n"
	    @"array1=foo\r\n"
	    @"array1=bar\r\n"
	    @"double=0.75\r\n";
	OFINIFile *file;
	OFINICategory *tests, *foobar, *types;
	OFArray *array;
#ifndef OF_NINTENDO_DS
	OFString *writePath;
#endif

Modified tests/testfile.ini from [828829461b] to [70f0fff498].