Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d9a9f0

Browse files
committed
All supported systems have locale_t.
locale_t is defined by POSIX.1-2008 and SUSv4, and available on alltargeted systems. For Windows, win32_port.h redirects to a partialimplementation called _locale_t. We can now remove a lot ofcompile-time tests for HAVE_LOCALE_T, and associated comments and deadcode branches that were needed for older computers.Since configure + MinGW builds didn't detect locale_t but now we assumethat all systems have it, further inconsistencies among the 3 Windows buildsystems were revealed. With this commit, we no longer defineHAVE_WCSTOMBS_L and HAVE_MBSTOWCS_L on any Windows build system, butwe have logic to deal with that so that replacements are available whereappropriate.Reviewed-by: Noah Misch <noah@leadboat.com>Reviewed-by: Tristan Partin <tristan@neon.tech>Reviewed-by: Peter Eisentraut <peter@eisentraut.org>Discussion:https://postgr.es/m/CA%2BhUKGLg7_T2GKwZFAkEf0V7vbnur-NfCjZPKZb%3DZfAXSV1ORw%40mail.gmail.com
1 parente9f15bc commit8d9a9f0

File tree

12 files changed

+46
-169
lines changed

12 files changed

+46
-169
lines changed

‎config/c-library.m4

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ AC_DEFUN([PGAC_STRUCT_SOCKADDR_SA_LEN],
8686
# PGAC_TYPE_LOCALE_T
8787
# ------------------
8888
# Check for the locale_t type and find the right header file. macOS
89-
# needs xlocale.h; standard is locale.h, but glibc alsohas an
90-
# xlocale.h file that we should not use.
91-
#
89+
# needs xlocale.h; standard is locale.h, but glibc<= 2.25alsohad an
90+
# xlocale.h file that we should not use, so we check the standard
91+
# header first.
9292
AC_DEFUN([PGAC_TYPE_LOCALE_T],
9393
[AC_CACHE_CHECK([for locale_t],pgac_cv_type_locale_t,
9494
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
@@ -102,10 +102,6 @@ locale_t x;],
102102
[])],
103103
[pgac_cv_type_locale_t='yes (in xlocale.h)'],
104104
[pgac_cv_type_locale_t=no])])])
105-
if test "$pgac_cv_type_locale_t" != no; then
106-
AC_DEFINE(HAVE_LOCALE_T,1,
107-
[Define to 1 if the system has the type `locale_t'.])
108-
fi
109105
if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
110106
AC_DEFINE(LOCALE_T_IN_XLOCALE,1,
111107
[Define to 1 if `locale_t' requires <xlocale.h>.])

‎configure

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15120,11 +15120,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1512015120
fi
1512115121
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_type_locale_t" >&5
1512215122
$as_echo "$pgac_cv_type_locale_t" >&6; }
15123-
if test "$pgac_cv_type_locale_t" != no; then
15124-
15125-
$as_echo "#define HAVE_LOCALE_T 1" >>confdefs.h
15126-
15127-
fi
1512815123
if test "$pgac_cv_type_locale_t" = 'yes (in xlocale.h)'; then
1512915124

1513015125
$as_echo "#define LOCALE_T_IN_XLOCALE 1" >>confdefs.h

‎meson.build

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,17 +2283,13 @@ else
22832283
cdata.set('STRERROR_R_INT',false)
22842284
endif
22852285

2286-
# Check for the locale_t type and find the right header file. macOS
2287-
# needs xlocale.h; standard is locale.h, but glibc also has an
2288-
# xlocale.h file that we should not use. MSVC has a replacement
2289-
# defined in src/include/port/win32_port.h.
2290-
if cc.has_type('locale_t',prefix:'#include <locale.h>')
2291-
cdata.set('HAVE_LOCALE_T',1)
2292-
elif cc.has_type('locale_t',prefix:'#include <xlocale.h>')
2293-
cdata.set('HAVE_LOCALE_T',1)
2286+
# Find the right header file for the locale_t type. macOS needs xlocale.h;
2287+
# standard is locale.h, but glibc <= 2.25 also had an xlocale.h file that
2288+
# we should not use so we check the standard header first. MSVC has a
2289+
# replacement defined in src/include/port/win32_port.h.
2290+
ifnot cc.has_type('locale_t',prefix:'#include <locale.h>')and \
2291+
cc.has_type('locale_t',prefix:'#include <xlocale.h>')
22942292
cdata.set('LOCALE_T_IN_XLOCALE',1)
2295-
elif cc.get_id()=='msvc'
2296-
cdata.set('HAVE_LOCALE_T',1)
22972293
endif
22982294

22992295
# Check if the C compiler understands typeof or a variant. Define
@@ -2489,13 +2485,6 @@ if cc.has_function('syslog', args: test_c_args) and \
24892485
endif
24902486

24912487

2492-
# MSVC has replacements defined in src/include/port/win32_port.h.
2493-
if cc.get_id()=='msvc'
2494-
cdata.set('HAVE_WCSTOMBS_L',1)
2495-
cdata.set('HAVE_MBSTOWCS_L',1)
2496-
endif
2497-
2498-
24992488
# if prerequisites for unnamed posix semas aren't fulfilled, fall back to sysv
25002489
# semaphores
25012490
if sema_kind=='unnamed_posix'and \

‎src/backend/commands/collationcmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
534534

535535

536536
/* will we use "locale -a" in pg_import_system_collations? */
537-
#ifdefined(HAVE_LOCALE_T)&&!defined(WIN32)
537+
#if !defined(WIN32)
538538
#defineREAD_LOCALE_A_OUTPUT
539539
#endif
540540

‎src/backend/regex/regc_pg_locale.c

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
* the platform's wchar_t representation matches what we do in pg_wchar
4545
* conversions.
4646
*
47-
* 3. Other collations are only supported on platforms that HAVE_LOCALE_T.
48-
* Here, we use the locale_t-extended forms of the <wctype.h> and <ctype.h>
47+
* 3. Here, we use the locale_t-extended forms of the <wctype.h> and <ctype.h>
4948
* functions, under exactly the same cases as #2.
5049
*
5150
* There is one notable difference between cases 2 and 3: in the "default"
@@ -252,11 +251,6 @@ pg_set_regex_collation(Oid collation)
252251
}
253252
else
254253
{
255-
/*
256-
* NB: pg_newlocale_from_collation will fail if not HAVE_LOCALE_T; the
257-
* case of pg_regex_locale != 0 but not HAVE_LOCALE_T does not have to
258-
* be considered below.
259-
*/
260254
pg_regex_locale=pg_newlocale_from_collation(collation);
261255

262256
if (!pg_locale_deterministic(pg_regex_locale))
@@ -304,16 +298,12 @@ pg_wc_isdigit(pg_wchar c)
304298
return (c <= (pg_wchar)UCHAR_MAX&&
305299
isdigit((unsignedchar)c));
306300
casePG_REGEX_LOCALE_WIDE_L:
307-
#ifdefHAVE_LOCALE_T
308301
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
309302
returniswdigit_l((wint_t)c,pg_regex_locale->info.lt);
310-
#endif
311303
/* FALL THRU */
312304
casePG_REGEX_LOCALE_1BYTE_L:
313-
#ifdefHAVE_LOCALE_T
314305
return (c <= (pg_wchar)UCHAR_MAX&&
315306
isdigit_l((unsignedchar)c,pg_regex_locale->info.lt));
316-
#endif
317307
break;
318308
casePG_REGEX_LOCALE_ICU:
319309
#ifdefUSE_ICU
@@ -340,16 +330,12 @@ pg_wc_isalpha(pg_wchar c)
340330
return (c <= (pg_wchar)UCHAR_MAX&&
341331
isalpha((unsignedchar)c));
342332
casePG_REGEX_LOCALE_WIDE_L:
343-
#ifdefHAVE_LOCALE_T
344333
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
345334
returniswalpha_l((wint_t)c,pg_regex_locale->info.lt);
346-
#endif
347335
/* FALL THRU */
348336
casePG_REGEX_LOCALE_1BYTE_L:
349-
#ifdefHAVE_LOCALE_T
350337
return (c <= (pg_wchar)UCHAR_MAX&&
351338
isalpha_l((unsignedchar)c,pg_regex_locale->info.lt));
352-
#endif
353339
break;
354340
casePG_REGEX_LOCALE_ICU:
355341
#ifdefUSE_ICU
@@ -376,16 +362,12 @@ pg_wc_isalnum(pg_wchar c)
376362
return (c <= (pg_wchar)UCHAR_MAX&&
377363
isalnum((unsignedchar)c));
378364
casePG_REGEX_LOCALE_WIDE_L:
379-
#ifdefHAVE_LOCALE_T
380365
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
381366
returniswalnum_l((wint_t)c,pg_regex_locale->info.lt);
382-
#endif
383367
/* FALL THRU */
384368
casePG_REGEX_LOCALE_1BYTE_L:
385-
#ifdefHAVE_LOCALE_T
386369
return (c <= (pg_wchar)UCHAR_MAX&&
387370
isalnum_l((unsignedchar)c,pg_regex_locale->info.lt));
388-
#endif
389371
break;
390372
casePG_REGEX_LOCALE_ICU:
391373
#ifdefUSE_ICU
@@ -421,16 +403,12 @@ pg_wc_isupper(pg_wchar c)
421403
return (c <= (pg_wchar)UCHAR_MAX&&
422404
isupper((unsignedchar)c));
423405
casePG_REGEX_LOCALE_WIDE_L:
424-
#ifdefHAVE_LOCALE_T
425406
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
426407
returniswupper_l((wint_t)c,pg_regex_locale->info.lt);
427-
#endif
428408
/* FALL THRU */
429409
casePG_REGEX_LOCALE_1BYTE_L:
430-
#ifdefHAVE_LOCALE_T
431410
return (c <= (pg_wchar)UCHAR_MAX&&
432411
isupper_l((unsignedchar)c,pg_regex_locale->info.lt));
433-
#endif
434412
break;
435413
casePG_REGEX_LOCALE_ICU:
436414
#ifdefUSE_ICU
@@ -457,16 +435,12 @@ pg_wc_islower(pg_wchar c)
457435
return (c <= (pg_wchar)UCHAR_MAX&&
458436
islower((unsignedchar)c));
459437
casePG_REGEX_LOCALE_WIDE_L:
460-
#ifdefHAVE_LOCALE_T
461438
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
462439
returniswlower_l((wint_t)c,pg_regex_locale->info.lt);
463-
#endif
464440
/* FALL THRU */
465441
casePG_REGEX_LOCALE_1BYTE_L:
466-
#ifdefHAVE_LOCALE_T
467442
return (c <= (pg_wchar)UCHAR_MAX&&
468443
islower_l((unsignedchar)c,pg_regex_locale->info.lt));
469-
#endif
470444
break;
471445
casePG_REGEX_LOCALE_ICU:
472446
#ifdefUSE_ICU
@@ -493,16 +467,12 @@ pg_wc_isgraph(pg_wchar c)
493467
return (c <= (pg_wchar)UCHAR_MAX&&
494468
isgraph((unsignedchar)c));
495469
casePG_REGEX_LOCALE_WIDE_L:
496-
#ifdefHAVE_LOCALE_T
497470
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
498471
returniswgraph_l((wint_t)c,pg_regex_locale->info.lt);
499-
#endif
500472
/* FALL THRU */
501473
casePG_REGEX_LOCALE_1BYTE_L:
502-
#ifdefHAVE_LOCALE_T
503474
return (c <= (pg_wchar)UCHAR_MAX&&
504475
isgraph_l((unsignedchar)c,pg_regex_locale->info.lt));
505-
#endif
506476
break;
507477
casePG_REGEX_LOCALE_ICU:
508478
#ifdefUSE_ICU
@@ -529,16 +499,12 @@ pg_wc_isprint(pg_wchar c)
529499
return (c <= (pg_wchar)UCHAR_MAX&&
530500
isprint((unsignedchar)c));
531501
casePG_REGEX_LOCALE_WIDE_L:
532-
#ifdefHAVE_LOCALE_T
533502
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
534503
returniswprint_l((wint_t)c,pg_regex_locale->info.lt);
535-
#endif
536504
/* FALL THRU */
537505
casePG_REGEX_LOCALE_1BYTE_L:
538-
#ifdefHAVE_LOCALE_T
539506
return (c <= (pg_wchar)UCHAR_MAX&&
540507
isprint_l((unsignedchar)c,pg_regex_locale->info.lt));
541-
#endif
542508
break;
543509
casePG_REGEX_LOCALE_ICU:
544510
#ifdefUSE_ICU
@@ -565,16 +531,12 @@ pg_wc_ispunct(pg_wchar c)
565531
return (c <= (pg_wchar)UCHAR_MAX&&
566532
ispunct((unsignedchar)c));
567533
casePG_REGEX_LOCALE_WIDE_L:
568-
#ifdefHAVE_LOCALE_T
569534
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
570535
returniswpunct_l((wint_t)c,pg_regex_locale->info.lt);
571-
#endif
572536
/* FALL THRU */
573537
casePG_REGEX_LOCALE_1BYTE_L:
574-
#ifdefHAVE_LOCALE_T
575538
return (c <= (pg_wchar)UCHAR_MAX&&
576539
ispunct_l((unsignedchar)c,pg_regex_locale->info.lt));
577-
#endif
578540
break;
579541
casePG_REGEX_LOCALE_ICU:
580542
#ifdefUSE_ICU
@@ -601,16 +563,12 @@ pg_wc_isspace(pg_wchar c)
601563
return (c <= (pg_wchar)UCHAR_MAX&&
602564
isspace((unsignedchar)c));
603565
casePG_REGEX_LOCALE_WIDE_L:
604-
#ifdefHAVE_LOCALE_T
605566
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
606567
returniswspace_l((wint_t)c,pg_regex_locale->info.lt);
607-
#endif
608568
/* FALL THRU */
609569
casePG_REGEX_LOCALE_1BYTE_L:
610-
#ifdefHAVE_LOCALE_T
611570
return (c <= (pg_wchar)UCHAR_MAX&&
612571
isspace_l((unsignedchar)c,pg_regex_locale->info.lt));
613-
#endif
614572
break;
615573
casePG_REGEX_LOCALE_ICU:
616574
#ifdefUSE_ICU
@@ -645,16 +603,12 @@ pg_wc_toupper(pg_wchar c)
645603
returntoupper((unsignedchar)c);
646604
returnc;
647605
casePG_REGEX_LOCALE_WIDE_L:
648-
#ifdefHAVE_LOCALE_T
649606
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
650607
returntowupper_l((wint_t)c,pg_regex_locale->info.lt);
651-
#endif
652608
/* FALL THRU */
653609
casePG_REGEX_LOCALE_1BYTE_L:
654-
#ifdefHAVE_LOCALE_T
655610
if (c <= (pg_wchar)UCHAR_MAX)
656611
returntoupper_l((unsignedchar)c,pg_regex_locale->info.lt);
657-
#endif
658612
returnc;
659613
casePG_REGEX_LOCALE_ICU:
660614
#ifdefUSE_ICU
@@ -689,16 +643,12 @@ pg_wc_tolower(pg_wchar c)
689643
returntolower((unsignedchar)c);
690644
returnc;
691645
casePG_REGEX_LOCALE_WIDE_L:
692-
#ifdefHAVE_LOCALE_T
693646
if (sizeof(wchar_t) >=4||c <= (pg_wchar)0xFFFF)
694647
returntowlower_l((wint_t)c,pg_regex_locale->info.lt);
695-
#endif
696648
/* FALL THRU */
697649
casePG_REGEX_LOCALE_1BYTE_L:
698-
#ifdefHAVE_LOCALE_T
699650
if (c <= (pg_wchar)UCHAR_MAX)
700651
returntolower_l((unsignedchar)c,pg_regex_locale->info.lt);
701-
#endif
702652
returnc;
703653
casePG_REGEX_LOCALE_ICU:
704654
#ifdefUSE_ICU

‎src/backend/utils/adt/formatting.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,12 +1613,6 @@ u_strToTitle_default_BI(UChar *dest, int32_t destCapacity,
16131613
* in multibyte character sets. Note that in either case we are effectively
16141614
* assuming that the database character encoding matches the encoding implied
16151615
* by LC_CTYPE.
1616-
*
1617-
* If the system provides locale_t and associated functions (which are
1618-
* standardized by Open Group's XBD), we can support collations that are
1619-
* neither default nor C. The code is written to handle both combinations
1620-
* of have-wide-characters and have-locale_t, though it's rather unlikely
1621-
* a platform would have the latter without the former.
16221616
*/
16231617

16241618
/*
@@ -1696,11 +1690,9 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
16961690

16971691
for (curr_char=0;workspace[curr_char]!=0;curr_char++)
16981692
{
1699-
#ifdefHAVE_LOCALE_T
17001693
if (mylocale)
17011694
workspace[curr_char]=towlower_l(workspace[curr_char],mylocale->info.lt);
17021695
else
1703-
#endif
17041696
workspace[curr_char]=towlower(workspace[curr_char]);
17051697
}
17061698

@@ -1729,11 +1721,9 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
17291721
*/
17301722
for (p=result;*p;p++)
17311723
{
1732-
#ifdefHAVE_LOCALE_T
17331724
if (mylocale)
17341725
*p=tolower_l((unsignedchar)*p,mylocale->info.lt);
17351726
else
1736-
#endif
17371727
*p=pg_tolower((unsignedchar)*p);
17381728
}
17391729
}
@@ -1818,11 +1808,9 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
18181808

18191809
for (curr_char=0;workspace[curr_char]!=0;curr_char++)
18201810
{
1821-
#ifdefHAVE_LOCALE_T
18221811
if (mylocale)
18231812
workspace[curr_char]=towupper_l(workspace[curr_char],mylocale->info.lt);
18241813
else
1825-
#endif
18261814
workspace[curr_char]=towupper(workspace[curr_char]);
18271815
}
18281816

@@ -1851,11 +1839,9 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
18511839
*/
18521840
for (p=result;*p;p++)
18531841
{
1854-
#ifdefHAVE_LOCALE_T
18551842
if (mylocale)
18561843
*p=toupper_l((unsignedchar)*p,mylocale->info.lt);
18571844
else
1858-
#endif
18591845
*p=pg_toupper((unsignedchar)*p);
18601846
}
18611847
}
@@ -1941,7 +1927,6 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
19411927

19421928
for (curr_char=0;workspace[curr_char]!=0;curr_char++)
19431929
{
1944-
#ifdefHAVE_LOCALE_T
19451930
if (mylocale)
19461931
{
19471932
if (wasalnum)
@@ -1951,7 +1936,6 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
19511936
wasalnum=iswalnum_l(workspace[curr_char],mylocale->info.lt);
19521937
}
19531938
else
1954-
#endif
19551939
{
19561940
if (wasalnum)
19571941
workspace[curr_char]=towlower(workspace[curr_char]);
@@ -1986,7 +1970,6 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
19861970
*/
19871971
for (p=result;*p;p++)
19881972
{
1989-
#ifdefHAVE_LOCALE_T
19901973
if (mylocale)
19911974
{
19921975
if (wasalnum)
@@ -1996,7 +1979,6 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
19961979
wasalnum=isalnum_l((unsignedchar)*p,mylocale->info.lt);
19971980
}
19981981
else
1999-
#endif
20001982
{
20011983
if (wasalnum)
20021984
*p=pg_tolower((unsignedchar)*p);

‎src/backend/utils/adt/like.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ SB_lower_char(unsigned char c, pg_locale_t locale, bool locale_is_c)
9595
{
9696
if (locale_is_c)
9797
returnpg_ascii_tolower(c);
98-
#ifdefHAVE_LOCALE_T
9998
elseif (locale)
10099
returntolower_l(c,locale->info.lt);
101-
#endif
102100
else
103101
returnpg_tolower(c);
104102
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp