1491
1491
/* C/POSIX collations use this path regardless of database encoding */
1492
1492
if (lc_ctype_is_c(collid))
1496
result = pnstrdup(buff, nbytes);
1498
for (p = result; *p; p++)
1499
*p = pg_ascii_tolower((unsigned char) *p);
1494
result = asc_tolower(buff, nbytes);
1501
1496
#ifdef USE_WIDE_UPPER_LOWER
1502
1497
else if (pg_database_encoding_max_length() > 1)
1612
1607
/* C/POSIX collations use this path regardless of database encoding */
1613
1608
if (lc_ctype_is_c(collid))
1617
result = pnstrdup(buff, nbytes);
1619
for (p = result; *p; p++)
1620
*p = pg_ascii_toupper((unsigned char) *p);
1610
result = asc_toupper(buff, nbytes);
1622
1612
#ifdef USE_WIDE_UPPER_LOWER
1623
1613
else if (pg_database_encoding_max_length() > 1)
1734
1724
/* C/POSIX collations use this path regardless of database encoding */
1735
1725
if (lc_ctype_is_c(collid))
1739
result = pnstrdup(buff, nbytes);
1741
for (p = result; *p; p++)
1746
*p = c = pg_ascii_tolower((unsigned char) *p);
1748
*p = c = pg_ascii_toupper((unsigned char) *p);
1749
/* we don't trust isalnum() here */
1750
wasalnum = ((c >= 'A' && c <= 'Z') ||
1751
(c >= 'a' && c <= 'z') ||
1752
(c >= '0' && c <= '9'));
1727
result = asc_initcap(buff, nbytes);
1755
1729
#ifdef USE_WIDE_UPPER_LOWER
1756
1730
else if (pg_database_encoding_max_length() > 1)
1851
* ASCII-only lower function
1853
* We pass the number of bytes so we can pass varlena and char*
1854
* to this function. The result is a palloc'd, null-terminated string.
1857
asc_tolower(const char *buff, size_t nbytes)
1865
result = pnstrdup(buff, nbytes);
1867
for (p = result; *p; p++)
1868
*p = pg_ascii_tolower((unsigned char) *p);
1874
* ASCII-only upper function
1876
* We pass the number of bytes so we can pass varlena and char*
1877
* to this function. The result is a palloc'd, null-terminated string.
1880
asc_toupper(const char *buff, size_t nbytes)
1888
result = pnstrdup(buff, nbytes);
1890
for (p = result; *p; p++)
1891
*p = pg_ascii_toupper((unsigned char) *p);
1897
* ASCII-only initcap function
1899
* We pass the number of bytes so we can pass varlena and char*
1900
* to this function. The result is a palloc'd, null-terminated string.
1903
asc_initcap(const char *buff, size_t nbytes)
1907
int wasalnum = false;
1912
result = pnstrdup(buff, nbytes);
1914
for (p = result; *p; p++)
1919
*p = c = pg_ascii_tolower((unsigned char) *p);
1921
*p = c = pg_ascii_toupper((unsigned char) *p);
1922
/* we don't trust isalnum() here */
1923
wasalnum = ((c >= 'A' && c <= 'Z') ||
1924
(c >= 'a' && c <= 'z') ||
1925
(c >= '0' && c <= '9'));
1876
1931
/* convenience routines for when the input is null-terminated */
1893
1948
return str_initcap(buff, strlen(buff), collid);
1952
asc_tolower_z(const char *buff)
1954
return asc_tolower(buff, strlen(buff));
1958
asc_toupper_z(const char *buff)
1960
return asc_toupper(buff, strlen(buff));
1963
/* asc_initcap_z is not currently needed */
1898
1967
* Skip TM / th in FROM_CHAR
2427
2497
strcpy(s, str_toupper_z(localized_full_months[tm->tm_mon - 1], collid));
2429
2499
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9,
2430
str_toupper_z(months_full[tm->tm_mon - 1], collid));
2500
asc_toupper_z(months_full[tm->tm_mon - 1]));
2431
2501
s += strlen(s);
2433
2503
case DCH_Month:
2437
2507
if (S_TM(n->suffix))
2438
2508
strcpy(s, str_initcap_z(localized_full_months[tm->tm_mon - 1], collid));
2440
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, months_full[tm->tm_mon - 1]);
2510
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9,
2511
months_full[tm->tm_mon - 1]);
2441
2512
s += strlen(s);
2443
2514
case DCH_month:
2447
2518
if (S_TM(n->suffix))
2448
2519
strcpy(s, str_tolower_z(localized_full_months[tm->tm_mon - 1], collid));
2451
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, months_full[tm->tm_mon - 1]);
2452
*s = pg_tolower((unsigned char) *s);
2521
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9,
2522
asc_tolower_z(months_full[tm->tm_mon - 1]));
2454
2523
s += strlen(s);
2460
2529
if (S_TM(n->suffix))
2461
2530
strcpy(s, str_toupper_z(localized_abbrev_months[tm->tm_mon - 1], collid));
2463
strcpy(s, str_toupper_z(months[tm->tm_mon - 1], collid));
2532
strcpy(s, asc_toupper_z(months[tm->tm_mon - 1]));
2464
2533
s += strlen(s);
2480
2549
if (S_TM(n->suffix))
2481
2550
strcpy(s, str_tolower_z(localized_abbrev_months[tm->tm_mon - 1], collid));
2484
strcpy(s, months[tm->tm_mon - 1]);
2485
*s = pg_tolower((unsigned char) *s);
2552
strcpy(s, asc_tolower_z(months[tm->tm_mon - 1]));
2487
2553
s += strlen(s);
2498
2564
strcpy(s, str_toupper_z(localized_full_days[tm->tm_wday], collid));
2500
2566
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9,
2501
str_toupper_z(days[tm->tm_wday], collid));
2567
asc_toupper_z(days[tm->tm_wday]));
2502
2568
s += strlen(s);
2506
2572
if (S_TM(n->suffix))
2507
2573
strcpy(s, str_initcap_z(localized_full_days[tm->tm_wday], collid));
2509
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, days[tm->tm_wday]);
2575
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9,
2510
2577
s += strlen(s);
2514
2581
if (S_TM(n->suffix))
2515
2582
strcpy(s, str_tolower_z(localized_full_days[tm->tm_wday], collid));
2518
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9, days[tm->tm_wday]);
2519
*s = pg_tolower((unsigned char) *s);
2584
sprintf(s, "%*s", S_FM(n->suffix) ? 0 : -9,
2585
asc_tolower_z(days[tm->tm_wday]));
2521
2586
s += strlen(s);
2525
2590
if (S_TM(n->suffix))
2526
2591
strcpy(s, str_toupper_z(localized_abbrev_days[tm->tm_wday], collid));
2528
strcpy(s, str_toupper_z(days_short[tm->tm_wday], collid));
2593
strcpy(s, asc_toupper_z(days_short[tm->tm_wday]));
2529
2594
s += strlen(s);
2541
2606
if (S_TM(n->suffix))
2542
2607
strcpy(s, str_tolower_z(localized_abbrev_days[tm->tm_wday], collid));
2545
strcpy(s, days_short[tm->tm_wday]);
2546
*s = pg_tolower((unsigned char) *s);
2609
strcpy(s, asc_tolower_z(days_short[tm->tm_wday]));
2548
2610
s += strlen(s);
4652
4714
if (IS_FILLMODE(Np->Num))
4654
strcpy(Np->inout_p, str_tolower_z(Np->number_p, collid));
4716
strcpy(Np->inout_p, asc_tolower_z(Np->number_p));
4655
4717
Np->inout_p += strlen(Np->inout_p) - 1;
4659
sprintf(Np->inout_p, "%15s", str_tolower_z(Np->number_p, collid));
4721
sprintf(Np->inout_p, "%15s", asc_tolower_z(Np->number_p));
4660
4722
Np->inout_p += strlen(Np->inout_p) - 1;