ObjFW  Diff

Differences From Artifact [096a7db2b7]:

To Artifact [c0ebec1591]:


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
	} lengthModifier;
	bool useLocale;
};

#ifdef HAVE_ASPRINTF_L
static locale_t cLocale;

static void __attribute__((init))
init(void)
{
	if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL)
		@throw [OFInitializationFailedException exception];
}
#endif








|







78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
	} lengthModifier;
	bool useLocale;
};

#ifdef HAVE_ASPRINTF_L
static locale_t cLocale;

static void __attribute__((constructor))
init(void)
{
	if ((cLocale = newlocale(LC_ALL_MASK, "C", NULL)) == NULL)
		@throw [OFInitializationFailedException exception];
}
#endif

510
511
512
513
514
515
516
517
518
519
520
521
522
523



524
525
526
527

528
529
530
531
532
533
534
535
536
537
538

539

540
541
542
543

544
545
546
547
548
549
550

551
552
553
554
555
556
557
	case 'F':
	case 'e':
	case 'E':
	case 'g':
	case 'G':
	case 'a':
	case 'A':
#ifdef HAVE_ASPRINTF_L
		{
			locale_t locale = (ctx->useLocale ? NULL : cLocale);

			switch (ctx->lengthModifier) {
			case LENGTH_MODIFIER_NONE:
			case LENGTH_MODIFIER_L:



				tmpLen = asprintf(&tmp, ctx->subformat,
				    va_arg(ctx->arguments, double), locale);
				break;
			case LENGTH_MODIFIER_CAPITAL_L:

				tmpLen = asprintf(&tmp, ctx->subformat,
				    va_arg(ctx->arguments, long double),
				    locale);
				break;
			default:
				return false;
			}
		}
#else
		switch (ctx->lengthModifier) {
		case LENGTH_MODIFIER_NONE:

		case LENGTH_MODIFIER_L:

			tmpLen = asprintf(&tmp, ctx->subformat,
			    va_arg(ctx->arguments, double));
			break;
		case LENGTH_MODIFIER_CAPITAL_L:

			tmpLen = asprintf(&tmp, ctx->subformat,
			    va_arg(ctx->arguments, long double));
			break;
		default:
			return false;
		}


		/*
		 * If there's no asprintf_l, we have no other choice than to
		 * use this ugly hack to replace the locale's decimal point
		 * back to ".".
		 */
		if (!ctx->useLocale) {
			void *pool = objc_autoreleasePoolPush();







<
<
<
<
|
|
|
>
>
>
|
|
|
<
>

|
<
|
<
<
<
<
<
<
|
>
|
>
|
|
|
<
>
|
|





>







510
511
512
513
514
515
516




517
518
519
520
521
522
523
524
525

526
527
528

529






530
531
532
533
534
535
536

537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
	case 'F':
	case 'e':
	case 'E':
	case 'g':
	case 'G':
	case 'a':
	case 'A':




		switch (ctx->lengthModifier) {
		case LENGTH_MODIFIER_NONE:
		case LENGTH_MODIFIER_L:
#ifdef HAVE_ASPRINTF_L
			if (!ctx->useLocale)
				tmpLen = asprintf_l(&tmp, cLocale,
				    ctx->subformat,
				    va_arg(ctx->arguments, double));
			else

#endif
				tmpLen = asprintf(&tmp, ctx->subformat,
				    va_arg(ctx->arguments, double));

			break;






		case LENGTH_MODIFIER_CAPITAL_L:
#ifdef HAVE_ASPRINTF_L
			if (!ctx->useLocale)
				tmpLen = asprintf_l(&tmp, cLocale,
				    ctx->subformat,
				    va_arg(ctx->arguments, long double));
			else

#endif
				tmpLen = asprintf(&tmp, ctx->subformat,
				    va_arg(ctx->arguments, long double));
			break;
		default:
			return false;
		}

#ifndef HAVE_ASPRINTF_L
		/*
		 * If there's no asprintf_l, we have no other choice than to
		 * use this ugly hack to replace the locale's decimal point
		 * back to ".".
		 */
		if (!ctx->useLocale) {
			void *pool = objc_autoreleasePoolPush();