1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-22 21:53:06 +03:00

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

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;
}