ObjFW  Check-in [5085342127]

Overview
Comment:More style improvements.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 50853421279570ab85430089234a07a25f52e2106ec7802504163fd77c20e91b
User & Date: js on 2011-04-23 17:52:36
Other Links: manifest | tags
Context
2011-04-23
21:19
Get rid of useless variables. check-in: 01f12ed5e2 user: js tags: trunk
17:52
More style improvements. check-in: 5085342127 user: js tags: trunk
14:46
Add -[uppercaseString] and -[lowercaseString] to OFString. check-in: becb4c9b86 user: js tags: trunk
Changes

Modified configure.ac from [a558c04623] to [013094e60d].

533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
])

AS_IF([test x"$cross_compiling" = x"yes"], [
	AC_SUBST(BIN_PREFIX, "$host-")

	case "$host" in
		*-*-mingw*)
			AC_CHECK_PROG(WINE, wine)

			AS_IF([test x"$WINE" != x""], [
				AC_SUBST(TESTS, "tests")
				AC_SUBST(TEST_LAUNCHER, "$WINE")
			])
			;;
	esac







|







533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
])

AS_IF([test x"$cross_compiling" = x"yes"], [
	AC_SUBST(BIN_PREFIX, "$host-")

	case "$host" in
		*-*-mingw*)
			AC_CHECK_PROG(WINE, wine, wine)

			AS_IF([test x"$WINE" != x""], [
				AC_SUBST(TESTS, "tests")
				AC_SUBST(TEST_LAUNCHER, "$WINE")
			])
			;;
	esac

Modified src/OFArray.h from [d4a064a71c] to [acc0282c12].

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
 * Initializes an OFArray with the specified object and a va_list.
 *
 * \param firstObject The first object
 * \param arguments A va_list
 * \return An initialized OFArray
 */
- initWithObject: (id)firstObject
    argumentList: (va_list)arguments;

/**
 * Initializes an OFArray with the objects from the specified C array.
 *
 * \param objects A C array of objects, terminated with nil
 * \return An initialized OFArray
 */







|







99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
 * Initializes an OFArray with the specified object and a va_list.
 *
 * \param firstObject The first object
 * \param arguments A va_list
 * \return An initialized OFArray
 */
- initWithObject: (id)firstObject
       arguments: (va_list)arguments;

/**
 * Initializes an OFArray with the objects from the specified C array.
 *
 * \param objects A C array of objects, terminated with nil
 * \return An initialized OFArray
 */

Modified src/OFArray.m from [b8875e845f] to [52d24426fd].

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+ arrayWithObjects: (id)firstObject, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstObject);
	ret = [[[self alloc] initWithObject: firstObject
			       argumentList: arguments] autorelease];
	va_end(arguments);

	return ret;
}

+ arrayWithCArray: (id*)objects
{







|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
+ arrayWithObjects: (id)firstObject, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstObject);
	ret = [[[self alloc] initWithObject: firstObject
				  arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

+ arrayWithCArray: (id*)objects
{
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
- initWithObjects: (id)firstObject, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstObject);
	ret = [self initWithObject: firstObject
		      argumentList: arguments];
	va_end(arguments);

	return ret;
}

- initWithObject: (id)firstObject
    argumentList: (va_list)arguments
{
	self = [self init];

	@try {
		id object;

		[array addItem: &firstObject];







|






|







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
- initWithObjects: (id)firstObject, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstObject);
	ret = [self initWithObject: firstObject
			 arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithObject: (id)firstObject
       arguments: (va_list)arguments
{
	self = [self init];

	@try {
		id object;

		[array addItem: &firstObject];

Modified src/OFDictionary.h from [e6a40ac98c] to [21642e8123].

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
 * Initializes an already allocated OFDictionary with the specified key and
 * va_list.
 *
 * \param firstKey The first key
 * \param arguments A va_list of the other arguments
 * \return A new initialized OFDictionary
 */
-  initWithKey: (id <OFCopying>)firstKey
  argumentList: (va_list)arguments;

/**
 * Returns the object for the given key or nil if the key was not found.
 *
 * The returned object is <i>not</i> retained and autoreleased for performance
 * reasons!
 *







|
|







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
 * Initializes an already allocated OFDictionary with the specified key and
 * va_list.
 *
 * \param firstKey The first key
 * \param arguments A va_list of the other arguments
 * \return A new initialized OFDictionary
 */
- initWithKey: (id <OFCopying>)firstKey
    arguments: (va_list)arguments;

/**
 * Returns the object for the given key or nil if the key was not found.
 *
 * The returned object is <i>not</i> retained and autoreleased for performance
 * reasons!
 *

Modified src/OFDictionary.m from [d2ad80013b] to [188b37a1ab].

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+ dictionaryWithKeysAndObjects: (id <OFCopying>)firstKey, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstKey);
	ret = [[[self alloc] initWithKey: firstKey
			    argumentList: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init
{







|







62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
+ dictionaryWithKeysAndObjects: (id <OFCopying>)firstKey, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstKey);
	ret = [[[self alloc] initWithKey: firstKey
			       arguments: arguments] autorelease];
	va_end(arguments);

	return ret;
}

- init
{
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331


332
333
334
335
336
337
338
- initWithKeysAndObjects: (id <OFCopying>)firstKey, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstKey);
	ret = [self initWithKey: firstKey
		   argumentList: arguments];
	va_end(arguments);

	return ret;
}

-  initWithKey: (id <OFCopying>)key
  argumentList: (va_list)arguments
{
	self = [super init];

	@try {
		id object;
		uint32_t i, j, hash, newSize;
		va_list argumentsCopy;
		struct of_dictionary_bucket *bucket;

		va_copy(argumentsCopy, arguments);

		if (key == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];



		if ((object = va_arg(arguments, id)) == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		count = 1;
		for (; va_arg(argumentsCopy, id) != nil; count++);







|





|
|




|






|


>
>







303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
- initWithKeysAndObjects: (id <OFCopying>)firstKey, ...
{
	id ret;
	va_list arguments;

	va_start(arguments, firstKey);
	ret = [self initWithKey: firstKey
		      arguments: arguments];
	va_end(arguments);

	return ret;
}

- initWithKey: (id <OFCopying>)firstKey
    arguments: (va_list)arguments
{
	self = [super init];

	@try {
		id key, object;
		uint32_t i, j, hash, newSize;
		va_list argumentsCopy;
		struct of_dictionary_bucket *bucket;

		va_copy(argumentsCopy, arguments);

		if (firstKey == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		key = firstKey;

		if ((object = va_arg(arguments, id)) == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		count = 1;
		for (; va_arg(argumentsCopy, id) != nil; count++);

Modified src/OFString+XMLEscaping.m from [bbfbe023ae] to [0113b63029].

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
int _OFString_XMLEscaping_reference;

@implementation OFString (XMLEscaping)
- (OFString*)stringByXMLEscaping
{
	char *retCString;
	const char *append;
	size_t retLength, appendLength;
	size_t i, j;
	OFString *ret;

	j = 0;
	retLength = length;

	/*
	 * We can't use allocMemoryWithSize: here as it might be a @"" literal
	 */
	if ((retCString = malloc(retLength)) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: retLength];

	for (i = 0; i < length; i++) {
		switch (string[i]) {
			case '<':
				append = "&lt;";
				appendLength = 4;
				break;
			case '>':
				append = "&gt;";
				appendLength = 4;
				break;
			case '"':
				append = "&quot;";
				appendLength = 6;
				break;
			case '\'':
				append = "&apos;";
				appendLength = 6;
				break;
			case '&':
				append = "&amp;";
				appendLength = 5;
				break;
			default:
				append = NULL;
				appendLength = 0;
		}

		if (append != NULL) {
			char *newRetCString;

			if ((newRetCString = realloc(retCString,
			    retLength + appendLength)) == NULL) {
				free(retCString);
				@throw [OFOutOfMemoryException
				     newWithClass: isa
				    requestedSize: retLength + appendLength];
			}
			retCString = newRetCString;
			retLength += appendLength - 1;

			memcpy(retCString + j, append, appendLength);
			j += appendLength;
		} else
			retCString[j++] = string[i];
	}

	assert(j == retLength);

	@try {







|

















|



|



|



|



|



|






|



|


|

|
|







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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
int _OFString_XMLEscaping_reference;

@implementation OFString (XMLEscaping)
- (OFString*)stringByXMLEscaping
{
	char *retCString;
	const char *append;
	size_t retLength, appendLen;
	size_t i, j;
	OFString *ret;

	j = 0;
	retLength = length;

	/*
	 * We can't use allocMemoryWithSize: here as it might be a @"" literal
	 */
	if ((retCString = malloc(retLength)) == NULL)
		@throw [OFOutOfMemoryException newWithClass: isa
					      requestedSize: retLength];

	for (i = 0; i < length; i++) {
		switch (string[i]) {
			case '<':
				append = "&lt;";
				appendLen = 4;
				break;
			case '>':
				append = "&gt;";
				appendLen = 4;
				break;
			case '"':
				append = "&quot;";
				appendLen = 6;
				break;
			case '\'':
				append = "&apos;";
				appendLen = 6;
				break;
			case '&':
				append = "&amp;";
				appendLen = 5;
				break;
			default:
				append = NULL;
				appendLen = 0;
		}

		if (append != NULL) {
			char *newRetCString;

			if ((newRetCString = realloc(retCString,
			    retLength + appendLen)) == NULL) {
				free(retCString);
				@throw [OFOutOfMemoryException
				     newWithClass: isa
				    requestedSize: retLength + appendLen];
			}
			retCString = newRetCString;
			retLength += appendLen - 1;

			memcpy(retCString + j, append, appendLen);
			j += appendLen;
		} else
			retCString[j++] = string[i];
	}

	assert(j == retLength);

	@try {