ObjFW  Diff

Differences From Artifact [e1e1de1e89]:

To Artifact [31524fd43b]:


284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
		}

		@try {
			id object;

			if ((object = va_arg(ctx->arguments, id)) != nil)
				tmpLen = asprintf(&tmp, ctx->subformat,
				    [[object description] cString]);
			else
				tmpLen = asprintf(&tmp, ctx->subformat,
				    "(nil)");
		} @catch (id e) {
			free(ctx->buffer);
			@throw e;
		} @finally {







|







284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
		}

		@try {
			id object;

			if ((object = va_arg(ctx->arguments, id)) != nil)
				tmpLen = asprintf(&tmp, ctx->subformat,
				    [[object description] UTF8String]);
			else
				tmpLen = asprintf(&tmp, ctx->subformat,
				    "(nil)");
		} @catch (id e) {
			free(ctx->buffer);
			@throw e;
		} @finally {
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
	formatFlagsState,
	formatFieldWidthState,
	formatLengthModifierState,
	formatConversionSpecifierState
};

int
of_vasprintf(char **cString, const char *format, va_list arguments)
{
	struct context ctx;

	ctx.format = format;
	ctx.formatLen = strlen(format);
	memset(ctx.subformat, 0, MAX_SUBFORMAT_LEN + 1);
	ctx.subformatLen = 0;







|







510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
	formatFlagsState,
	formatFieldWidthState,
	formatLengthModifierState,
	formatConversionSpecifierState
};

int
of_vasprintf(char **UTF8String, const char *format, va_list arguments)
{
	struct context ctx;

	ctx.format = format;
	ctx.formatLen = strlen(format);
	memset(ctx.subformat, 0, MAX_SUBFORMAT_LEN + 1);
	ctx.subformatLen = 0;
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
	    ctx.formatLen - ctx.last)) {
		free(ctx.buffer);
		return -1;
	}

	ctx.buffer[ctx.bufferLen] = 0;

	*cString = ctx.buffer;
	return (ctx.bufferLen <= INT_MAX ? (int)ctx.bufferLen : -1);
}

int
of_asprintf(char **cString, const char *format, ...)
{
	va_list arguments;
	int ret;

	va_start(arguments, format);
	ret = of_vasprintf(cString, format, arguments);
	va_end(arguments);

	return ret;
}







|




|





|




547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
	    ctx.formatLen - ctx.last)) {
		free(ctx.buffer);
		return -1;
	}

	ctx.buffer[ctx.bufferLen] = 0;

	*UTF8String = ctx.buffer;
	return (ctx.bufferLen <= INT_MAX ? (int)ctx.bufferLen : -1);
}

int
of_asprintf(char **UTF8String, const char *format, ...)
{
	va_list arguments;
	int ret;

	va_start(arguments, format);
	ret = of_vasprintf(UTF8String, format, arguments);
	va_end(arguments);

	return ret;
}