MCPcopy Create free account
hub / github.com/apache/cloudberry / setDecimalLocale

Function setDecimalLocale

src/fe_utils/print.c:3519–3552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3517}
3518
3519void
3520setDecimalLocale(void)
3521{
3522 struct lconv *extlconv;
3523
3524 extlconv = localeconv();
3525
3526 /* Don't accept an empty decimal_point string */
3527 if (*extlconv->decimal_point)
3528 decimal_point = pg_strdup(extlconv->decimal_point);
3529 else
3530 decimal_point = "."; /* SQL output standard */
3531
3532 /*
3533 * Although the Open Group standard allows locales to supply more than one
3534 * group width, we consider only the first one, and we ignore any attempt
3535 * to suppress grouping by specifying CHAR_MAX. As in the backend's
3536 * cash.c, we must apply a range check to avoid being fooled by variant
3537 * CHAR_MAX values.
3538 */
3539 groupdigits = *extlconv->grouping;
3540 if (groupdigits <= 0 || groupdigits > 6)
3541 groupdigits = 3; /* most common */
3542
3543 /* Don't accept an empty thousands_sep string, either */
3544 /* similar code exists in formatting.c */
3545 if (*extlconv->thousands_sep)
3546 thousands_sep = pg_strdup(extlconv->thousands_sep);
3547 /* Make sure thousands separator doesn't match decimal point symbol. */
3548 else if (strcmp(decimal_point, ",") != 0)
3549 thousands_sep = ",";
3550 else
3551 thousands_sep = ".";
3552}
3553
3554/* get selected or default line style */
3555const printTextFormat *

Callers 1

mainFunction · 0.85

Calls 1

pg_strdupFunction · 0.85

Tested by

no test coverage detected