summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane2017-09-22 15:00:58 +0000
committerTom Lane2017-09-22 15:00:58 +0000
commit85feb77aa09cda9ff3e12cf95c757c499dc25343 (patch)
tree313b8bb0eb9cf4cff63a92dd5345d9d5c51b3b3a /src/backend
parente6023ee7fa73a2d9a2d7524f63584844b2291def (diff)
Assume wcstombs(), towlower(), and sibling functions are always present.
These functions are required by SUS v2, which is our minimum baseline for Unix platforms, and are present on all interesting Windows versions as well. Even our oldest buildfarm members have them. Thus, we were not testing the "!USE_WIDE_UPPER_LOWER" code paths, which explains why the bug fixed in commit e6023ee7f escaped detection. Per discussion, there seems to be no more real-world value in maintaining this option. Hence, remove the configure-time tests for wcstombs() and towlower(), remove the USE_WIDE_UPPER_LOWER symbol, and remove all the !USE_WIDE_UPPER_LOWER code. There's not actually all that much of the latter, but simplifying the #if nests is a win in itself. Discussion: https://postgr.es/m/20170921052928.GA188913@rfd.leadboat.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/regex/regc_pg_locale.c46
-rw-r--r--src/backend/tsearch/regis.c5
-rw-r--r--src/backend/tsearch/ts_locale.c9
-rw-r--r--src/backend/tsearch/wparser_def.c40
-rw-r--r--src/backend/utils/adt/formatting.c6
-rw-r--r--src/backend/utils/adt/pg_locale.c5
6 files changed, 12 insertions, 99 deletions
diff --git a/src/backend/regex/regc_pg_locale.c b/src/backend/regex/regc_pg_locale.c
index 6982879688b..b2122e9e8fa 100644
--- a/src/backend/regex/regc_pg_locale.c
+++ b/src/backend/regex/regc_pg_locale.c
@@ -268,7 +268,6 @@ pg_set_regex_collation(Oid collation)
pg_regex_strategy = PG_REGEX_LOCALE_ICU;
else
#endif
-#ifdef USE_WIDE_UPPER_LOWER
if (GetDatabaseEncoding() == PG_UTF8)
{
if (pg_regex_locale)
@@ -277,7 +276,6 @@ pg_set_regex_collation(Oid collation)
pg_regex_strategy = PG_REGEX_LOCALE_WIDE;
}
else
-#endif /* USE_WIDE_UPPER_LOWER */
{
if (pg_regex_locale)
pg_regex_strategy = PG_REGEX_LOCALE_1BYTE_L;
@@ -298,16 +296,14 @@ pg_wc_isdigit(pg_wchar c)
return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISDIGIT));
case PG_REGEX_LOCALE_WIDE:
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswdigit((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX &&
isdigit((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswdigit_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -336,16 +332,14 @@ pg_wc_isalpha(pg_wchar c)
return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISALPHA));
case PG_REGEX_LOCALE_WIDE:
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswalpha((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX &&
isalpha((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswalpha_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -374,16 +368,14 @@ pg_wc_isalnum(pg_wchar c)
return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISALNUM));
case PG_REGEX_LOCALE_WIDE:
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswalnum((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX &&
isalnum((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswalnum_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -412,16 +404,14 @@ pg_wc_isupper(pg_wchar c)
return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISUPPER));
case PG_REGEX_LOCALE_WIDE:
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswupper((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX &&
isupper((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswupper_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -450,16 +440,14 @@ pg_wc_islower(pg_wchar c)
return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISLOWER));
case PG_REGEX_LOCALE_WIDE:
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswlower((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX &&
islower((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswlower_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -488,16 +476,14 @@ pg_wc_isgraph(pg_wchar c)
return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISGRAPH));
case PG_REGEX_LOCALE_WIDE:
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswgraph((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX &&
isgraph((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswgraph_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -526,16 +512,14 @@ pg_wc_isprint(pg_wchar c)
return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISPRINT));
case PG_REGEX_LOCALE_WIDE:
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswprint((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX &&
isprint((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswprint_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -564,16 +548,14 @@ pg_wc_ispunct(pg_wchar c)
return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISPUNCT));
case PG_REGEX_LOCALE_WIDE:
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswpunct((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX &&
ispunct((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswpunct_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -602,16 +584,14 @@ pg_wc_isspace(pg_wchar c)
return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISSPACE));
case PG_REGEX_LOCALE_WIDE:
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswspace((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX &&
isspace((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswspace_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -644,10 +624,8 @@ pg_wc_toupper(pg_wchar c)
/* force C behavior for ASCII characters, per comments above */
if (c <= (pg_wchar) 127)
return pg_ascii_toupper((unsigned char) c);
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return towupper((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
/* force C behavior for ASCII characters, per comments above */
@@ -657,7 +635,7 @@ pg_wc_toupper(pg_wchar c)
return toupper((unsigned char) c);
return c;
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return towupper_l((wint_t) c, pg_regex_locale->info.lt);
#endif
@@ -690,10 +668,8 @@ pg_wc_tolower(pg_wchar c)
/* force C behavior for ASCII characters, per comments above */
if (c <= (pg_wchar) 127)
return pg_ascii_tolower((unsigned char) c);
-#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return towlower((wint_t) c);
-#endif
/* FALL THRU */
case PG_REGEX_LOCALE_1BYTE:
/* force C behavior for ASCII characters, per comments above */
@@ -703,7 +679,7 @@ pg_wc_tolower(pg_wchar c)
return tolower((unsigned char) c);
return c;
case PG_REGEX_LOCALE_WIDE_L:
-#if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER)
+#ifdef HAVE_LOCALE_T
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return towlower_l((wint_t) c, pg_regex_locale->info.lt);
#endif
diff --git a/src/backend/tsearch/regis.c b/src/backend/tsearch/regis.c
index 2b89f596f08..4a799f25859 100644
--- a/src/backend/tsearch/regis.c
+++ b/src/backend/tsearch/regis.c
@@ -178,7 +178,6 @@ RS_free(Regis *r)
r->node = NULL;
}
-#ifdef USE_WIDE_UPPER_LOWER
static bool
mb_strchr(char *str, char *c)
{
@@ -209,10 +208,6 @@ mb_strchr(char *str, char *c)
return res;
}
-#else
-#define mb_strchr(s,c) ( (strchr((s),*(c)) == NULL) ? false : true )
-#endif
-
bool
RS_execute(Regis *r, char *str)
diff --git a/src/backend/tsearch/ts_locale.c b/src/backend/tsearch/ts_locale.c
index 1aa3e237338..7a6f0bc7221 100644
--- a/src/backend/tsearch/ts_locale.c
+++ b/src/backend/tsearch/ts_locale.c
@@ -21,8 +21,6 @@
static void tsearch_readline_callback(void *arg);
-#ifdef USE_WIDE_UPPER_LOWER
-
int
t_isdigit(const char *ptr)
{
@@ -86,7 +84,6 @@ t_isprint(const char *ptr)
return iswprint((wint_t) character[0]);
}
-#endif /* USE_WIDE_UPPER_LOWER */
/*
@@ -244,17 +241,12 @@ char *
lowerstr_with_len(const char *str, int len)
{
char *out;
-
-#ifdef USE_WIDE_UPPER_LOWER
Oid collation = DEFAULT_COLLATION_OID; /* TODO */
pg_locale_t mylocale = 0; /* TODO */
-#endif
if (len == 0)
return pstrdup("");
-#ifdef USE_WIDE_UPPER_LOWER
-
/*
* Use wide char code only when max encoding length > 1 and ctype != C.
* Some operating systems fail with multi-byte encodings and a C locale.
@@ -300,7 +292,6 @@ lowerstr_with_len(const char *str, int len)
Assert(wlen < len);
}
else
-#endif /* USE_WIDE_UPPER_LOWER */
{
const char *ptr = str;
char *outptr;
diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c
index e841a1ccf0e..c118357336d 100644
--- a/src/backend/tsearch/wparser_def.c
+++ b/src/backend/tsearch/wparser_def.c
@@ -241,11 +241,9 @@ typedef struct TParser
/* string and position information */
char *str; /* multibyte string */
int lenstr; /* length of mbstring */
-#ifdef USE_WIDE_UPPER_LOWER
wchar_t *wstr; /* wide character string */
pg_wchar *pgwstr; /* wide character string for C-locale */
bool usewide;
-#endif
/* State of parse */
int charmaxlen;
@@ -294,8 +292,6 @@ TParserInit(char *str, int len)
prs->str = str;
prs->lenstr = len;
-#ifdef USE_WIDE_UPPER_LOWER
-
/*
* Use wide char code only when max encoding length > 1.
*/
@@ -323,7 +319,6 @@ TParserInit(char *str, int len)
}
else
prs->usewide = false;
-#endif
prs->state = newTParserPosition(NULL);
prs->state->state = TPS_Base;
@@ -360,15 +355,12 @@ TParserCopyInit(const TParser *orig)
prs->charmaxlen = orig->charmaxlen;
prs->str = orig->str + orig->state->posbyte;
prs->lenstr = orig->lenstr - orig->state->posbyte;
-
-#ifdef USE_WIDE_UPPER_LOWER
prs->usewide = orig->usewide;
if (orig->pgwstr)
prs->pgwstr = orig->pgwstr + orig->state->poschar;
if (orig->wstr)
prs->wstr = orig->wstr + orig->state->poschar;
-#endif
prs->state = newTParserPosition(NULL);
prs->state->state = TPS_Base;
@@ -393,12 +385,10 @@ TParserClose(TParser *prs)
prs->state = ptr;
}
-#ifdef USE_WIDE_UPPER_LOWER
if (prs->wstr)
pfree(prs->wstr);
if (prs->pgwstr)
pfree(prs->pgwstr);
-#endif
#ifdef WPARSER_TRACE
fprintf(stderr, "closing parser\n");
@@ -437,8 +427,6 @@ TParserCopyClose(TParser *prs)
* - if locale is C then we use pgwstr instead of wstr.
*/
-#ifdef USE_WIDE_UPPER_LOWER
-
#define p_iswhat(type) \
static int \
p_is##type(TParser *prs) { \
@@ -536,31 +524,6 @@ p_iseq(TParser *prs, char c)
Assert(prs->state);
return ((prs->state->charlen == 1 && *(prs->str + prs->state->posbyte) == c)) ? 1 : 0;
}
-#else /* USE_WIDE_UPPER_LOWER */
-
-#define p_iswhat(type) \
-static int \
-p_is##type(TParser *prs) { \
- Assert( prs->state ); \
- return is##type( (unsigned char)*( prs->str + prs->state->posbyte ) ); \
-} \
- \
-static int \
-p_isnot##type(TParser *prs) { \
- return !p_is##type(prs); \
-}
-
-
-static int
-p_iseq(TParser *prs, char c)
-{
- Assert(prs->state);
- return (*(prs->str + prs->state->posbyte) == c) ? 1 : 0;
-}
-
-p_iswhat(alnum)
-p_iswhat(alpha)
-#endif /* USE_WIDE_UPPER_LOWER */
p_iswhat(digit)
p_iswhat(lower)
@@ -785,8 +748,6 @@ p_isspecial(TParser *prs)
if (pg_dsplen(prs->str + prs->state->posbyte) == 0)
return 1;
-#ifdef USE_WIDE_UPPER_LOWER
-
/*
* Unicode Characters in the 'Mark, Spacing Combining' Category That
* characters are not alpha although they are not breakers of word too.
@@ -1050,7 +1011,6 @@ p_isspecial(TParser *prs)
StopHigh = StopMiddle;
}
}
-#endif
return 0;
}
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index 2bf484cda31..7877af2d6be 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1565,7 +1565,6 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
else
#endif
{
-#ifdef USE_WIDE_UPPER_LOWER
if (pg_database_encoding_max_length() > 1)
{
wchar_t *workspace;
@@ -1604,7 +1603,6 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
pfree(workspace);
}
else
-#endif /* USE_WIDE_UPPER_LOWER */
{
char *p;
@@ -1689,7 +1687,6 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
else
#endif
{
-#ifdef USE_WIDE_UPPER_LOWER
if (pg_database_encoding_max_length() > 1)
{
wchar_t *workspace;
@@ -1728,7 +1725,6 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
pfree(workspace);
}
else
-#endif /* USE_WIDE_UPPER_LOWER */
{
char *p;
@@ -1814,7 +1810,6 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
else
#endif
{
-#ifdef USE_WIDE_UPPER_LOWER
if (pg_database_encoding_max_length() > 1)
{
wchar_t *workspace;
@@ -1865,7 +1860,6 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
pfree(workspace);
}
else
-#endif /* USE_WIDE_UPPER_LOWER */
{
char *p;
diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 3d3d8aa4b65..5ad75efb7a2 100644
--- a/src/backend/utils/adt/pg_locale.c
+++ b/src/backend/utils/adt/pg_locale.c
@@ -1587,6 +1587,7 @@ icu_from_uchar(char **result, const UChar *buff_uchar, int32_t len_uchar)
return len_result;
}
+
#endif /* USE_ICU */
/*
@@ -1594,8 +1595,6 @@ icu_from_uchar(char **result, const UChar *buff_uchar, int32_t len_uchar)
* Therefore we keep them here rather than with the mbutils code.
*/
-#ifdef USE_WIDE_UPPER_LOWER
-
/*
* wchar2char --- convert wide characters to multibyte format
*
@@ -1762,5 +1761,3 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen,
return result;
}
-
-#endif /* USE_WIDE_UPPER_LOWER */