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
This commit is contained in:
Tom Lane 2017-09-22 11:00:58 -04:00
parent e6023ee7fa
commit 85feb77aa0
13 changed files with 18 additions and 139 deletions

2
configure vendored
View File

@ -12970,7 +12970,7 @@ fi
LIBS_including_readline="$LIBS" LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'` LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
for ac_func in cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range towlower utime utimes wcstombs wcstombs_l for ac_func in cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range utime utimes wcstombs_l
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

View File

@ -1399,7 +1399,7 @@ PGAC_FUNC_WCSTOMBS_L
LIBS_including_readline="$LIBS" LIBS_including_readline="$LIBS"
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'` LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
AC_CHECK_FUNCS([cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range towlower utime utimes wcstombs wcstombs_l]) AC_CHECK_FUNCS([cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range utime utimes wcstombs_l])
AC_REPLACE_FUNCS(fseeko) AC_REPLACE_FUNCS(fseeko)
case $host_os in case $host_os in

View File

@ -268,7 +268,6 @@ pg_set_regex_collation(Oid collation)
pg_regex_strategy = PG_REGEX_LOCALE_ICU; pg_regex_strategy = PG_REGEX_LOCALE_ICU;
else else
#endif #endif
#ifdef USE_WIDE_UPPER_LOWER
if (GetDatabaseEncoding() == PG_UTF8) if (GetDatabaseEncoding() == PG_UTF8)
{ {
if (pg_regex_locale) if (pg_regex_locale)
@ -277,7 +276,6 @@ pg_set_regex_collation(Oid collation)
pg_regex_strategy = PG_REGEX_LOCALE_WIDE; pg_regex_strategy = PG_REGEX_LOCALE_WIDE;
} }
else else
#endif /* USE_WIDE_UPPER_LOWER */
{ {
if (pg_regex_locale) if (pg_regex_locale)
pg_regex_strategy = PG_REGEX_LOCALE_1BYTE_L; pg_regex_strategy = PG_REGEX_LOCALE_1BYTE_L;
@ -298,16 +296,14 @@ pg_wc_isdigit(pg_wchar c)
return (c <= (pg_wchar) 127 && return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISDIGIT)); (pg_char_properties[c] & PG_ISDIGIT));
case PG_REGEX_LOCALE_WIDE: case PG_REGEX_LOCALE_WIDE:
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswdigit((wint_t) c); return iswdigit((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX && return (c <= (pg_wchar) UCHAR_MAX &&
isdigit((unsigned char) c)); isdigit((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswdigit_l((wint_t) c, pg_regex_locale->info.lt); return iswdigit_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -336,16 +332,14 @@ pg_wc_isalpha(pg_wchar c)
return (c <= (pg_wchar) 127 && return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISALPHA)); (pg_char_properties[c] & PG_ISALPHA));
case PG_REGEX_LOCALE_WIDE: case PG_REGEX_LOCALE_WIDE:
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswalpha((wint_t) c); return iswalpha((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX && return (c <= (pg_wchar) UCHAR_MAX &&
isalpha((unsigned char) c)); isalpha((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswalpha_l((wint_t) c, pg_regex_locale->info.lt); return iswalpha_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -374,16 +368,14 @@ pg_wc_isalnum(pg_wchar c)
return (c <= (pg_wchar) 127 && return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISALNUM)); (pg_char_properties[c] & PG_ISALNUM));
case PG_REGEX_LOCALE_WIDE: case PG_REGEX_LOCALE_WIDE:
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswalnum((wint_t) c); return iswalnum((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX && return (c <= (pg_wchar) UCHAR_MAX &&
isalnum((unsigned char) c)); isalnum((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswalnum_l((wint_t) c, pg_regex_locale->info.lt); return iswalnum_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -412,16 +404,14 @@ pg_wc_isupper(pg_wchar c)
return (c <= (pg_wchar) 127 && return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISUPPER)); (pg_char_properties[c] & PG_ISUPPER));
case PG_REGEX_LOCALE_WIDE: case PG_REGEX_LOCALE_WIDE:
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswupper((wint_t) c); return iswupper((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX && return (c <= (pg_wchar) UCHAR_MAX &&
isupper((unsigned char) c)); isupper((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswupper_l((wint_t) c, pg_regex_locale->info.lt); return iswupper_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -450,16 +440,14 @@ pg_wc_islower(pg_wchar c)
return (c <= (pg_wchar) 127 && return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISLOWER)); (pg_char_properties[c] & PG_ISLOWER));
case PG_REGEX_LOCALE_WIDE: case PG_REGEX_LOCALE_WIDE:
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswlower((wint_t) c); return iswlower((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX && return (c <= (pg_wchar) UCHAR_MAX &&
islower((unsigned char) c)); islower((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswlower_l((wint_t) c, pg_regex_locale->info.lt); return iswlower_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -488,16 +476,14 @@ pg_wc_isgraph(pg_wchar c)
return (c <= (pg_wchar) 127 && return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISGRAPH)); (pg_char_properties[c] & PG_ISGRAPH));
case PG_REGEX_LOCALE_WIDE: case PG_REGEX_LOCALE_WIDE:
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswgraph((wint_t) c); return iswgraph((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX && return (c <= (pg_wchar) UCHAR_MAX &&
isgraph((unsigned char) c)); isgraph((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswgraph_l((wint_t) c, pg_regex_locale->info.lt); return iswgraph_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -526,16 +512,14 @@ pg_wc_isprint(pg_wchar c)
return (c <= (pg_wchar) 127 && return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISPRINT)); (pg_char_properties[c] & PG_ISPRINT));
case PG_REGEX_LOCALE_WIDE: case PG_REGEX_LOCALE_WIDE:
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswprint((wint_t) c); return iswprint((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX && return (c <= (pg_wchar) UCHAR_MAX &&
isprint((unsigned char) c)); isprint((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswprint_l((wint_t) c, pg_regex_locale->info.lt); return iswprint_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -564,16 +548,14 @@ pg_wc_ispunct(pg_wchar c)
return (c <= (pg_wchar) 127 && return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISPUNCT)); (pg_char_properties[c] & PG_ISPUNCT));
case PG_REGEX_LOCALE_WIDE: case PG_REGEX_LOCALE_WIDE:
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswpunct((wint_t) c); return iswpunct((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX && return (c <= (pg_wchar) UCHAR_MAX &&
ispunct((unsigned char) c)); ispunct((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswpunct_l((wint_t) c, pg_regex_locale->info.lt); return iswpunct_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -602,16 +584,14 @@ pg_wc_isspace(pg_wchar c)
return (c <= (pg_wchar) 127 && return (c <= (pg_wchar) 127 &&
(pg_char_properties[c] & PG_ISSPACE)); (pg_char_properties[c] & PG_ISSPACE));
case PG_REGEX_LOCALE_WIDE: case PG_REGEX_LOCALE_WIDE:
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswspace((wint_t) c); return iswspace((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
return (c <= (pg_wchar) UCHAR_MAX && return (c <= (pg_wchar) UCHAR_MAX &&
isspace((unsigned char) c)); isspace((unsigned char) c));
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return iswspace_l((wint_t) c, pg_regex_locale->info.lt); return iswspace_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -644,10 +624,8 @@ pg_wc_toupper(pg_wchar c)
/* force C behavior for ASCII characters, per comments above */ /* force C behavior for ASCII characters, per comments above */
if (c <= (pg_wchar) 127) if (c <= (pg_wchar) 127)
return pg_ascii_toupper((unsigned char) c); return pg_ascii_toupper((unsigned char) c);
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return towupper((wint_t) c); return towupper((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
/* force C behavior for ASCII characters, per comments above */ /* 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 toupper((unsigned char) c);
return c; return c;
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return towupper_l((wint_t) c, pg_regex_locale->info.lt); return towupper_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif
@ -690,10 +668,8 @@ pg_wc_tolower(pg_wchar c)
/* force C behavior for ASCII characters, per comments above */ /* force C behavior for ASCII characters, per comments above */
if (c <= (pg_wchar) 127) if (c <= (pg_wchar) 127)
return pg_ascii_tolower((unsigned char) c); return pg_ascii_tolower((unsigned char) c);
#ifdef USE_WIDE_UPPER_LOWER
if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return towlower((wint_t) c); return towlower((wint_t) c);
#endif
/* FALL THRU */ /* FALL THRU */
case PG_REGEX_LOCALE_1BYTE: case PG_REGEX_LOCALE_1BYTE:
/* force C behavior for ASCII characters, per comments above */ /* 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 tolower((unsigned char) c);
return c; return c;
case PG_REGEX_LOCALE_WIDE_L: 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) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF)
return towlower_l((wint_t) c, pg_regex_locale->info.lt); return towlower_l((wint_t) c, pg_regex_locale->info.lt);
#endif #endif

View File

@ -178,7 +178,6 @@ RS_free(Regis *r)
r->node = NULL; r->node = NULL;
} }
#ifdef USE_WIDE_UPPER_LOWER
static bool static bool
mb_strchr(char *str, char *c) mb_strchr(char *str, char *c)
{ {
@ -209,10 +208,6 @@ mb_strchr(char *str, char *c)
return res; return res;
} }
#else
#define mb_strchr(s,c) ( (strchr((s),*(c)) == NULL) ? false : true )
#endif
bool bool
RS_execute(Regis *r, char *str) RS_execute(Regis *r, char *str)

View File

@ -21,8 +21,6 @@
static void tsearch_readline_callback(void *arg); static void tsearch_readline_callback(void *arg);
#ifdef USE_WIDE_UPPER_LOWER
int int
t_isdigit(const char *ptr) t_isdigit(const char *ptr)
{ {
@ -86,7 +84,6 @@ t_isprint(const char *ptr)
return iswprint((wint_t) character[0]); return iswprint((wint_t) character[0]);
} }
#endif /* USE_WIDE_UPPER_LOWER */
/* /*
@ -244,17 +241,12 @@ char *
lowerstr_with_len(const char *str, int len) lowerstr_with_len(const char *str, int len)
{ {
char *out; char *out;
#ifdef USE_WIDE_UPPER_LOWER
Oid collation = DEFAULT_COLLATION_OID; /* TODO */ Oid collation = DEFAULT_COLLATION_OID; /* TODO */
pg_locale_t mylocale = 0; /* TODO */ pg_locale_t mylocale = 0; /* TODO */
#endif
if (len == 0) if (len == 0)
return pstrdup(""); return pstrdup("");
#ifdef USE_WIDE_UPPER_LOWER
/* /*
* Use wide char code only when max encoding length > 1 and ctype != C. * 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. * 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); Assert(wlen < len);
} }
else else
#endif /* USE_WIDE_UPPER_LOWER */
{ {
const char *ptr = str; const char *ptr = str;
char *outptr; char *outptr;

View File

@ -241,11 +241,9 @@ typedef struct TParser
/* string and position information */ /* string and position information */
char *str; /* multibyte string */ char *str; /* multibyte string */
int lenstr; /* length of mbstring */ int lenstr; /* length of mbstring */
#ifdef USE_WIDE_UPPER_LOWER
wchar_t *wstr; /* wide character string */ wchar_t *wstr; /* wide character string */
pg_wchar *pgwstr; /* wide character string for C-locale */ pg_wchar *pgwstr; /* wide character string for C-locale */
bool usewide; bool usewide;
#endif
/* State of parse */ /* State of parse */
int charmaxlen; int charmaxlen;
@ -294,8 +292,6 @@ TParserInit(char *str, int len)
prs->str = str; prs->str = str;
prs->lenstr = len; prs->lenstr = len;
#ifdef USE_WIDE_UPPER_LOWER
/* /*
* Use wide char code only when max encoding length > 1. * Use wide char code only when max encoding length > 1.
*/ */
@ -323,7 +319,6 @@ TParserInit(char *str, int len)
} }
else else
prs->usewide = false; prs->usewide = false;
#endif
prs->state = newTParserPosition(NULL); prs->state = newTParserPosition(NULL);
prs->state->state = TPS_Base; prs->state->state = TPS_Base;
@ -360,15 +355,12 @@ TParserCopyInit(const TParser *orig)
prs->charmaxlen = orig->charmaxlen; prs->charmaxlen = orig->charmaxlen;
prs->str = orig->str + orig->state->posbyte; prs->str = orig->str + orig->state->posbyte;
prs->lenstr = orig->lenstr - orig->state->posbyte; prs->lenstr = orig->lenstr - orig->state->posbyte;
#ifdef USE_WIDE_UPPER_LOWER
prs->usewide = orig->usewide; prs->usewide = orig->usewide;
if (orig->pgwstr) if (orig->pgwstr)
prs->pgwstr = orig->pgwstr + orig->state->poschar; prs->pgwstr = orig->pgwstr + orig->state->poschar;
if (orig->wstr) if (orig->wstr)
prs->wstr = orig->wstr + orig->state->poschar; prs->wstr = orig->wstr + orig->state->poschar;
#endif
prs->state = newTParserPosition(NULL); prs->state = newTParserPosition(NULL);
prs->state->state = TPS_Base; prs->state->state = TPS_Base;
@ -393,12 +385,10 @@ TParserClose(TParser *prs)
prs->state = ptr; prs->state = ptr;
} }
#ifdef USE_WIDE_UPPER_LOWER
if (prs->wstr) if (prs->wstr)
pfree(prs->wstr); pfree(prs->wstr);
if (prs->pgwstr) if (prs->pgwstr)
pfree(prs->pgwstr); pfree(prs->pgwstr);
#endif
#ifdef WPARSER_TRACE #ifdef WPARSER_TRACE
fprintf(stderr, "closing parser\n"); fprintf(stderr, "closing parser\n");
@ -437,8 +427,6 @@ TParserCopyClose(TParser *prs)
* - if locale is C then we use pgwstr instead of wstr. * - if locale is C then we use pgwstr instead of wstr.
*/ */
#ifdef USE_WIDE_UPPER_LOWER
#define p_iswhat(type) \ #define p_iswhat(type) \
static int \ static int \
p_is##type(TParser *prs) { \ p_is##type(TParser *prs) { \
@ -536,31 +524,6 @@ p_iseq(TParser *prs, char c)
Assert(prs->state); Assert(prs->state);
return ((prs->state->charlen == 1 && *(prs->str + prs->state->posbyte) == c)) ? 1 : 0; 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(digit)
p_iswhat(lower) p_iswhat(lower)
@ -785,8 +748,6 @@ p_isspecial(TParser *prs)
if (pg_dsplen(prs->str + prs->state->posbyte) == 0) if (pg_dsplen(prs->str + prs->state->posbyte) == 0)
return 1; return 1;
#ifdef USE_WIDE_UPPER_LOWER
/* /*
* Unicode Characters in the 'Mark, Spacing Combining' Category That * Unicode Characters in the 'Mark, Spacing Combining' Category That
* characters are not alpha although they are not breakers of word too. * characters are not alpha although they are not breakers of word too.
@ -1050,7 +1011,6 @@ p_isspecial(TParser *prs)
StopHigh = StopMiddle; StopHigh = StopMiddle;
} }
} }
#endif
return 0; return 0;
} }

View File

@ -1565,7 +1565,6 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
else else
#endif #endif
{ {
#ifdef USE_WIDE_UPPER_LOWER
if (pg_database_encoding_max_length() > 1) if (pg_database_encoding_max_length() > 1)
{ {
wchar_t *workspace; wchar_t *workspace;
@ -1604,7 +1603,6 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
pfree(workspace); pfree(workspace);
} }
else else
#endif /* USE_WIDE_UPPER_LOWER */
{ {
char *p; char *p;
@ -1689,7 +1687,6 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
else else
#endif #endif
{ {
#ifdef USE_WIDE_UPPER_LOWER
if (pg_database_encoding_max_length() > 1) if (pg_database_encoding_max_length() > 1)
{ {
wchar_t *workspace; wchar_t *workspace;
@ -1728,7 +1725,6 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
pfree(workspace); pfree(workspace);
} }
else else
#endif /* USE_WIDE_UPPER_LOWER */
{ {
char *p; char *p;
@ -1814,7 +1810,6 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
else else
#endif #endif
{ {
#ifdef USE_WIDE_UPPER_LOWER
if (pg_database_encoding_max_length() > 1) if (pg_database_encoding_max_length() > 1)
{ {
wchar_t *workspace; wchar_t *workspace;
@ -1865,7 +1860,6 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
pfree(workspace); pfree(workspace);
} }
else else
#endif /* USE_WIDE_UPPER_LOWER */
{ {
char *p; char *p;

View File

@ -1587,6 +1587,7 @@ icu_from_uchar(char **result, const UChar *buff_uchar, int32_t len_uchar)
return len_result; return len_result;
} }
#endif /* USE_ICU */ #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. * Therefore we keep them here rather than with the mbutils code.
*/ */
#ifdef USE_WIDE_UPPER_LOWER
/* /*
* wchar2char --- convert wide characters to multibyte format * 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; return result;
} }
#endif /* USE_WIDE_UPPER_LOWER */

View File

@ -1095,14 +1095,6 @@ extern int fdatasync(int fildes);
#define HAVE_STRTOULL 1 #define HAVE_STRTOULL 1
#endif #endif
/*
* We assume if we have these two functions, we have their friends too, and
* can use the wide-character functions.
*/
#if defined(HAVE_WCSTOMBS) && defined(HAVE_TOWLOWER)
#define USE_WIDE_UPPER_LOWER
#endif
/* EXEC_BACKEND defines */ /* EXEC_BACKEND defines */
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
#define NON_EXEC_STATIC #define NON_EXEC_STATIC

View File

@ -593,9 +593,6 @@
`HAVE_STRUCT_TM_TM_ZONE' instead. */ `HAVE_STRUCT_TM_TM_ZONE' instead. */
#undef HAVE_TM_ZONE #undef HAVE_TM_ZONE
/* Define to 1 if you have the `towlower' function. */
#undef HAVE_TOWLOWER
/* Define to 1 if your compiler understands `typeof' or something similar. */ /* Define to 1 if your compiler understands `typeof' or something similar. */
#undef HAVE_TYPEOF #undef HAVE_TYPEOF
@ -659,9 +656,6 @@
/* Define to 1 if you have the <wchar.h> header file. */ /* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H #undef HAVE_WCHAR_H
/* Define to 1 if you have the `wcstombs' function. */
#undef HAVE_WCSTOMBS
/* Define to 1 if you have the `wcstombs_l' function. */ /* Define to 1 if you have the `wcstombs_l' function. */
#undef HAVE_WCSTOMBS_L #undef HAVE_WCSTOMBS_L

View File

@ -442,9 +442,6 @@
`HAVE_STRUCT_TM_TM_ZONE' instead. */ `HAVE_STRUCT_TM_TM_ZONE' instead. */
/* #undef HAVE_TM_ZONE */ /* #undef HAVE_TM_ZONE */
/* Define to 1 if you have the `towlower' function. */
#define HAVE_TOWLOWER 1
/* Define to 1 if your compiler understands `typeof' or something similar. */ /* Define to 1 if your compiler understands `typeof' or something similar. */
/* #undef HAVE_TYPEOF */ /* #undef HAVE_TYPEOF */
@ -484,9 +481,6 @@
/* Define to 1 if you have the <wchar.h> header file. */ /* Define to 1 if you have the <wchar.h> header file. */
#define HAVE_WCHAR_H 1 #define HAVE_WCHAR_H 1
/* Define to 1 if you have the `wcstombs' function. */
#define HAVE_WCSTOMBS 1
/* Define to 1 if you have the `wcstombs_l' function. */ /* Define to 1 if you have the `wcstombs_l' function. */
#define HAVE_WCSTOMBS_L 1 #define HAVE_WCSTOMBS_L 1

View File

@ -41,28 +41,16 @@ typedef struct
#define TOUCHAR(x) (*((const unsigned char *) (x))) #define TOUCHAR(x) (*((const unsigned char *) (x)))
#ifdef USE_WIDE_UPPER_LOWER /* The second argument of t_iseq() must be a plain ASCII character */
#define t_iseq(x,c) (TOUCHAR(x) == (unsigned char) (c))
#define COPYCHAR(d,s) memcpy(d, s, pg_mblen(s))
extern int t_isdigit(const char *ptr); extern int t_isdigit(const char *ptr);
extern int t_isspace(const char *ptr); extern int t_isspace(const char *ptr);
extern int t_isalpha(const char *ptr); extern int t_isalpha(const char *ptr);
extern int t_isprint(const char *ptr); extern int t_isprint(const char *ptr);
/* The second argument of t_iseq() must be a plain ASCII character */
#define t_iseq(x,c) (TOUCHAR(x) == (unsigned char) (c))
#define COPYCHAR(d,s) memcpy(d, s, pg_mblen(s))
#else /* not USE_WIDE_UPPER_LOWER */
#define t_isdigit(x) isdigit(TOUCHAR(x))
#define t_isspace(x) isspace(TOUCHAR(x))
#define t_isalpha(x) isalpha(TOUCHAR(x))
#define t_isprint(x) isprint(TOUCHAR(x))
#define t_iseq(x,c) (TOUCHAR(x) == (unsigned char) (c))
#define COPYCHAR(d,s) (*((unsigned char *) (d)) = TOUCHAR(s))
#endif /* USE_WIDE_UPPER_LOWER */
extern char *lowerstr(const char *str); extern char *lowerstr(const char *str);
extern char *lowerstr_with_len(const char *str, int len); extern char *lowerstr_with_len(const char *str, int len);

View File

@ -110,11 +110,9 @@ extern int32_t icu_from_uchar(char **result, const UChar *buff_uchar, int32_t le
#endif #endif
/* These functions convert from/to libc's wchar_t, *not* pg_wchar_t */ /* These functions convert from/to libc's wchar_t, *not* pg_wchar_t */
#ifdef USE_WIDE_UPPER_LOWER
extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen, extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen,
pg_locale_t locale); pg_locale_t locale);
extern size_t char2wchar(wchar_t *to, size_t tolen, extern size_t char2wchar(wchar_t *to, size_t tolen,
const char *from, size_t fromlen, pg_locale_t locale); const char *from, size_t fromlen, pg_locale_t locale);
#endif
#endif /* _PG_LOCALE_ */ #endif /* _PG_LOCALE_ */