ObjFW  Check-in [151463e32a]

Overview
Comment:of_vasprintf: Preserve exceptions that happen in -[description].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 151463e32a84f035d835800eabde0a31a11bd31c87596fb4e1a4c5644ab4b5e5
User & Date: js on 2011-02-07 21:05:16
Other Links: manifest | tags
Context
2011-02-08
12:11
Use xmlns if there is no prefix for the namespace. check-in: 783ccbbad8 user: js tags: trunk
2011-02-07
21:05
of_vasprintf: Preserve exceptions that happen in -[description]. check-in: 151463e32a user: js tags: trunk
19:22
Add -[containsObject(IdenticalTo):] to OFCollection. check-in: 0a6e073938 user: js tags: trunk
Changes

Modified src/OFMutableString.m from [751ced34bb] to [e762638600].

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
	int len;

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

	if ((len = of_vasprintf(&t, [fmt cString], args)) == -1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

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







|
<







235
236
237
238
239
240
241
242

243
244
245
246
247
248
249
	int len;

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

	if ((len = of_vasprintf(&t, [fmt cString], args)) == -1)
		@throw [OFInvalidFormatException newWithClass: isa];


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

Modified src/OFStream.m from [5a1ab363d9] to [df8ed55ecd].

682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
	int len;

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

	if ((len = of_vasprintf(&t, [fmt cString], args)) == -1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	@try {
		return [self writeNBytes: len
			      fromBuffer: t];
	} @finally {
		free(t);
	}







|
<







682
683
684
685
686
687
688
689

690
691
692
693
694
695
696
	int len;

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

	if ((len = of_vasprintf(&t, [fmt cString], args)) == -1)
		@throw [OFInvalidFormatException newWithClass: isa];


	@try {
		return [self writeNBytes: len
			      fromBuffer: t];
	} @finally {
		free(t);
	}

Modified src/OFString.m from [5a7d886f0b] to [877ceb4ed7].

484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
		int len;

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

		if ((len = of_vasprintf(&string, [fmt cString], args)) == -1)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		@try {
			length = len;

			switch (of_string_check_utf8(string, length)) {
			case 1:
				isUTF8 = YES;







|
<







484
485
486
487
488
489
490
491

492
493
494
495
496
497
498
		int len;

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

		if ((len = of_vasprintf(&string, [fmt cString], args)) == -1)
			@throw [OFInvalidFormatException newWithClass: isa];


		@try {
			length = len;

			switch (of_string_check_utf8(string, length)) {
			case 1:
				isUTF8 = YES;

Modified src/of_asprintf.m from [0c6c3ac0b6] to [ca529b4e62].

249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
			if ((obj = va_arg(ctx->args, id)) != nil)
				tmp_len = asprintf(&tmp, ctx->subfmt,
				    [[obj description] cString]);
			else
				if (!append_str(ctx, "(nil)", 5))
					return false;
		} @catch (id e) {
			[e release];
			return false;
		} @finally {
			[pool release];
		}

		break;
	case 'd':
	case 'i':







|
|







249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
			if ((obj = va_arg(ctx->args, id)) != nil)
				tmp_len = asprintf(&tmp, ctx->subfmt,
				    [[obj description] cString]);
			else
				if (!append_str(ctx, "(nil)", 5))
					return false;
		} @catch (id e) {
			free(ctx->buf);
			@throw e;
		} @finally {
			[pool release];
		}

		break;
	case 'd':
	case 'i':
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
	ctx.len_mod = LENGTH_MODIFIER_NONE;

	if ((ctx.buf = malloc(1)) == NULL)
		return -1;

	for (ctx.i = 0; ctx.i < ctx.fmt_len; ctx.i++) {
		if (!states[ctx.state](&ctx)) {
			if (ctx.buf != NULL)
				free(ctx.buf);

			return -1;
		}
	}

	if (ctx.state != STATE_STRING) {
		if (ctx.buf != NULL)
			free(ctx.buf);

		return -1;
	}

	if (!append_str(&ctx, ctx.fmt + ctx.last, ctx.fmt_len - ctx.last)) {
		free(ctx.buf);
		return -1;
	}







<

<





<

<







484
485
486
487
488
489
490

491

492
493
494
495
496

497

498
499
500
501
502
503
504
	ctx.len_mod = LENGTH_MODIFIER_NONE;

	if ((ctx.buf = malloc(1)) == NULL)
		return -1;

	for (ctx.i = 0; ctx.i < ctx.fmt_len; ctx.i++) {
		if (!states[ctx.state](&ctx)) {

				free(ctx.buf);

			return -1;
		}
	}

	if (ctx.state != STATE_STRING) {

			free(ctx.buf);

		return -1;
	}

	if (!append_str(&ctx, ctx.fmt + ctx.last, ctx.fmt_len - ctx.last)) {
		free(ctx.buf);
		return -1;
	}