ObjFW  Diff

Differences From Artifact [f8d1ab3b42]:

To Artifact [7f7b9ed83b]:


231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257

258
259
260
261
262
263
264

265
266
267
268
269
270
271

	if (str->is_utf8)
		is_utf8 = YES;

	return self;
}

- appendWithFormat: (OFString*)fmt, ...
{
	id ret;
	va_list args;

	va_start(args, fmt);
	ret = [self appendWithFormat: fmt
			   arguments: args];
	va_end(args);

	return ret;
}

- appendWithFormat: (OFString*)fmt
	 arguments: (va_list)args
{
	char *t;

	if (fmt == NULL)
		@throw [OFInvalidFormatException newWithClass: isa];


	if ((vasprintf(&t, [fmt cString], args)) == -1)
		/*
		 * This is only the most likely error to happen. Unfortunately,
		 * there is no good way to check what really happened.
		 */
		@throw [OFOutOfMemoryException newWithClass: isa];


	@try {
		[self appendCString: t];
	} @finally {
		free(t);
	}








|





|
|





|
|



|
|
>

|





>







231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273

	if (str->is_utf8)
		is_utf8 = YES;

	return self;
}

- appendFormat: (OFString*)fmt, ...
{
	id ret;
	va_list args;

	va_start(args, fmt);
	ret = [self appendFormat: fmt
		   withArguments: args];
	va_end(args);

	return ret;
}

-  appendFormat: (OFString*)fmt
  withArguments: (va_list)args
{
	char *t;

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

	if ((vasprintf(&t, [fmt cString], args)) == -1) {
		/*
		 * This is only the most likely error to happen. Unfortunately,
		 * there is no good way to check what really happened.
		 */
		@throw [OFOutOfMemoryException newWithClass: isa];
	}

	@try {
		[self appendCString: t];
	} @finally {
		free(t);
	}