ObjFW  Diff

Differences From Artifact [3a4097c573]:

To Artifact [89405889ad]:


27
28
29
30
31
32
33

34
35
36
37
38
39
40

/* Reference for static linking */
int _OFString_URLEncoding_reference;

@implementation OFString (URLEncoding)
- (OFString*)stringByURLEncoding
{

	const char *string = [self UTF8String];
	char *retCString;
	size_t i;
	OFString *ret;

	/*
	 * Worst case: 3 times longer than before.







>







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

/* Reference for static linking */
int _OFString_URLEncoding_reference;

@implementation OFString (URLEncoding)
- (OFString*)stringByURLEncoding
{
	void *pool = objc_autoreleasePoolPush();
	const char *string = [self UTF8String];
	char *retCString;
	size_t i;
	OFString *ret;

	/*
	 * Worst case: 3 times longer than before.
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
			retCString[i++] =
			    (high > 9 ? high - 10 + 'A' : high + '0');
			retCString[i++] =
			    (low  > 9 ? low  - 10 + 'A' : low  + '0');
		}
	}



	@try {
		ret = [OFString stringWithUTF8String: retCString
					      length: i];
	} @finally {
		free(retCString);
	}

	return ret;
}

- (OFString*)stringByURLDecoding
{

	OFString *ret;
	const char *string = [self UTF8String];
	char *retCString;
	char byte = 0;
	int state = 0;
	size_t i;








>
>












>







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
			retCString[i++] =
			    (high > 9 ? high - 10 + 'A' : high + '0');
			retCString[i++] =
			    (low  > 9 ? low  - 10 + 'A' : low  + '0');
		}
	}

	objc_autoreleasePoolPop(pool);

	@try {
		ret = [OFString stringWithUTF8String: retCString
					      length: i];
	} @finally {
		free(retCString);
	}

	return ret;
}

- (OFString*)stringByURLDecoding
{
	void *pool = objc_autoreleasePoolPush();
	OFString *ret;
	const char *string = [self UTF8String];
	char *retCString;
	char byte = 0;
	int state = 0;
	size_t i;

124
125
126
127
128
129
130


131
132
133
134
135
136
137
				byte = 0;
			}

			break;
		}
	}
	retCString[i] = '\0';



	if (state != 0) {
		free(retCString);
		@throw [OFInvalidFormatException exception];
	}

	@try {







>
>







128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
				byte = 0;
			}

			break;
		}
	}
	retCString[i] = '\0';

	objc_autoreleasePoolPop(pool);

	if (state != 0) {
		free(retCString);
		@throw [OFInvalidFormatException exception];
	}

	@try {