ObjFW  Diff

Differences From Artifact [7a9c826b78]:

To Artifact [983a2f4cc6]:


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
17
18
19
20
21
22
23

24
25
26
27
28
29
30







-







#include "config.h"

#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdbool.h>
#include <limits.h>
#include <wchar.h>

#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "asprintf.h"

#define MAX_SUBFMT_LEN 64
393
394
395
396
397
398
399
400

401
402
403


404
405
406

407
408
409

410
411
412


413
414
415

416
417
418
419
420
421


422
423
424
425
426
427
428
392
393
394
395
396
397
398

399
400
401

402
403
404
405

406
407
408

409
410
411

412
413
414
415

416
417
418
419
420
421

422
423
424
425
426
427
428
429
430







-
+


-
+
+


-
+


-
+


-
+
+


-
+





-
+
+








		tmp_len = asprintf(&tmp, ctx->subfmt, va_arg(ctx->args, void*));

		break;
	case 'n':
		switch (ctx->len_mod) {
		case LENGTH_MODIFIER_NONE:
			*va_arg(ctx->args, int*) = ctx->buf_len;
			*va_arg(ctx->args, int*) = (int)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_HH:
			*va_arg(ctx->args, signed char*) = ctx->buf_len;
			*va_arg(ctx->args, signed char*) =
			    (signed char)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_H:
			*va_arg(ctx->args, short*) = ctx->buf_len;
			*va_arg(ctx->args, short*) = (short)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_L:
			*va_arg(ctx->args, long*) = ctx->buf_len;
			*va_arg(ctx->args, long*) = (long)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_LL:
			*va_arg(ctx->args, long long*) = ctx->buf_len;
			*va_arg(ctx->args, long long*) =
			    (long long)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_J:
			*va_arg(ctx->args, intmax_t*) = ctx->buf_len;
			*va_arg(ctx->args, intmax_t*) = (intmax_t)ctx->buf_len;
			break;
		case LENGTH_MODIFIER_Z:
			*va_arg(ctx->args, size_t*) = ctx->buf_len;
			break;
		case LENGTH_MODIFIER_T:
			*va_arg(ctx->args, ptrdiff_t*) = ctx->buf_len;
			*va_arg(ctx->args, ptrdiff_t*) =
			    (ptrdiff_t)ctx->buf_len;
			break;
		default:
			return false;
		}

		break;
	case '%':
501
502
503
504
505
506
507
508

509
510
511
512
513
514
515
503
504
505
506
507
508
509

510
511
512
513
514
515
516
517







-
+







		free(ctx.buf);
		return -1;
	}

	ctx.buf[ctx.buf_len] = 0;

	*ret = ctx.buf;
	return ctx.buf_len;
	return (ctx.buf_len <= INT_MAX ? (int)ctx.buf_len : INT_MAX);
}

int
of_asprintf(char **ret, const char *fmt, ...)
{
	va_list args;
	int r;