ObjFW  Diff

Differences From Artifact [5fed7eca62]:

To Artifact [dbcbcc49c8]:


12
13
14
15
16
17
18
19
20
21
22
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
12
13
14
15
16
17
18

19
20
21
22
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







-















-
+












-
+







#import "config.h"

#include <stdarg.h>
#include <stdlib.h>
#include <string.h>

#import "OFString.h"
#import "OFMutableString.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "OFMacros.h"

@implementation OFString
+ string
{
	return [[[OFMutableString alloc] init] autorelease];
}

+ stringWithCString: (const char*)str
{
	return [[[OFMutableString alloc] initWithCString: str] autorelease];
}

+ stringWithFormat: (const char*)fmt, ...
+ stringWithFormat: (OFString*)fmt, ...
{
	id ret;
	va_list args;

	va_start(args, fmt);
	ret = [[[OFMutableString alloc] initWithFormat: fmt
					  andArguments: args] autorelease];
	va_end(args);

	return ret;
}

+ stringWithFormat: (const char*)fmt
+ stringWithFormat: (OFString*)fmt
      andArguments: (va_list)args
{
	return [[[OFMutableString alloc] initWithFormat: fmt
					   andArguments: args] autorelease];
}

- init
123
124
125
126
127
128
129
130

131
132
133
134
135
136
137


138
139
140
141
142
143
144
122
123
124
125
126
127
128

129
130
131
132
133
134


135
136
137
138
139
140
141
142
143







-
+





-
-
+
+








- appendCString: (const char*)str
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- appendWithFormatCString: (const char*)fmt, ...
- appendWithFormat: (OFString*)fmt, ...
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- appendWithFormatCString: (const char*)fmt
	     andArguments: (va_list)args
- appendWithFormat: (OFString*)fmt
      andArguments: (va_list)args
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- reverse
{
154
155
156
157
158
159
160
161

162
163
164

165

166
167
168
169
170
171
172

173
174
175
176
177
178
179
153
154
155
156
157
158
159

160
161
162
163
164

165
166
167
168
169
170
171

172
173
174
175
176
177
178
179







-
+



+
-
+






-
+








- lower
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- (OFArray*)splitWithDelimiter: (const char*)delimiter
- (OFArray*)splitWithDelimiter: (OFString*)delimiter
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFArray *array = nil;
	const char *delim = [delimiter cString];
	size_t delim_len = strlen(delimiter);
	size_t delim_len = [delimiter length];
	size_t i, last;

	array = [OFArray array];

	for (i = 0, last = 0; i <= length; i++) {
		if (OF_UNLIKELY(i == length ||
		    !memcmp(string + i, delimiter, delim_len))) {
		    !memcmp(string + i, delim, delim_len))) {
			OFString *str;
			char *tmp;

			/*
			 * We can't use [self allocWithSize:] here as
			 * self might be a @""-literal.
			 */