Alvaro Herrera wrote:
> Bruce Momjian wrote:
>
> > I moved str_initcap() over into oracle_compat.c and then had initcap()
> > convert to/from TEXT to call it. The code is a little weird because
> > str_initcap() needs to convert to text to use texttowcs(), so in
> > multibyte encodings initcap converts the string to text, then to char,
> > then to text to call texttowcs(). I didn't see a cleaner way to do
> > this.
>
> Why not use wchar2char? It seems there's room for extra cleanup here.
>
> Also, the prototype of str_initcap in builtins.h looks out of place.
I talked to Alvaro on IM, and there is certainly much more cleanup to do
in this area. I will work from the bottom up. First, is moving the
USE_WIDE_UPPER_LOWER define to c.h, and removing TS_USE_WIDE and using
USE_WIDE_UPPER_LOWER instead. Patch attached and applied.
--
Bruce Momjian <[EMAIL PROTECTED]>http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Index: src/backend/tsearch/regis.c
===
RCS file: /cvsroot/pgsql/src/backend/tsearch/regis.c,v
retrieving revision 1.4
diff -c -c -r1.4 regis.c
*** src/backend/tsearch/regis.c 21 Jan 2008 02:46:10 - 1.4
--- src/backend/tsearch/regis.c 17 Jun 2008 16:06:54 -
***
*** 178,184
r->node = NULL;
}
! #ifdef TS_USE_WIDE
static bool
mb_strchr(char *str, char *c)
{
--- 178,184
r->node = NULL;
}
! #ifdef USE_WIDE_UPPER_LOWER
static bool
mb_strchr(char *str, char *c)
{
Index: src/backend/tsearch/ts_locale.c
===
RCS file: /cvsroot/pgsql/src/backend/tsearch/ts_locale.c,v
retrieving revision 1.7
diff -c -c -r1.7 ts_locale.c
*** src/backend/tsearch/ts_locale.c 1 Jan 2008 19:45:52 - 1.7
--- src/backend/tsearch/ts_locale.c 17 Jun 2008 16:06:54 -
***
*** 17,23
#include "tsearch/ts_public.h"
! #ifdef TS_USE_WIDE
/*
* wchar2char --- convert wide characters to multibyte format
--- 17,23
#include "tsearch/ts_public.h"
! #ifdef USE_WIDE_UPPER_LOWER
/*
* wchar2char --- convert wide characters to multibyte format
***
*** 190,196
return iswprint((wint_t) character[0]);
}
! #endif /* TS_USE_WIDE */
/*
--- 190,196
return iswprint((wint_t) character[0]);
}
! #endif /* USE_WIDE_UPPER_LOWER */
/*
***
*** 260,266
if (len == 0)
return pstrdup("");
! #ifdef TS_USE_WIDE
/*
* Use wide char code only when max encoding length > 1 and ctype != C.
--- 260,266
if (len == 0)
return pstrdup("");
! #ifdef USE_WIDE_UPPER_LOWER
/*
* Use wide char code only when max encoding length > 1 and ctype != C.
***
*** 307,313
Assert(wlen < len);
}
else
! #endif /* TS_USE_WIDE */
{
const char *ptr = str;
char *outptr;
--- 307,313
Assert(wlen < len);
}
else
! #endif /* USE_WIDE_UPPER_LOWER */
{
const char *ptr = str;
char *outptr;
Index: src/backend/tsearch/wparser_def.c
===
RCS file: /cvsroot/pgsql/src/backend/tsearch/wparser_def.c,v
retrieving revision 1.14
diff -c -c -r1.14 wparser_def.c
*** src/backend/tsearch/wparser_def.c 1 Jan 2008 19:45:52 - 1.14
--- src/backend/tsearch/wparser_def.c 17 Jun 2008 16:06:54 -
***
*** 238,244
/* string and position information */
char *str; /* multibyte string */
int lenstr; /* length of mbstring */
! #ifdef TS_USE_WIDE
wchar_t*wstr; /* wide character string */
int lenwstr; /* length of wsting */
#endif
--- 238,244
/* string and position information */
char *str; /* multibyte string */
int lenstr; /* length of mbstring */
! #ifdef USE_WIDE_UPPER_LOWER
wchar_t*wstr; /* wide character string */
int lenwstr; /* length of wsting */
#endif
***
*** 291,297
prs->str = str;
prs->lenstr = len;
! #ifdef TS_USE_WIDE
/*
* Use wide char code only when max encoding length > 1.
--- 291,297
prs->str = str;
prs->lenstr = len;
! #ifdef USE_WIDE_UPPER_LOWER
/*
* Use wide char code only when max encoding length > 1.
***
*** 328,334
prs->state = ptr;
}
! #ifdef TS_USE_WIDE
if (prs->wstr)
pfree(prs->wstr);
#endif
--- 328,334
prs->state = ptr;
}
! #ifdef USE_WIDE_UPPER_LOWER
if (prs->wstr)
pfree(prs->wstr);
#endif
***
*** 344,350
* often are used for Asian languages
*/
! #ifdef TS_USE_WIDE
#define p_iswhat(type) \
static int \
--- 344,350
* often are used for Asian languages
*/
! #ifdef USE_WIDE_UPPER_LOWER
#define p_iswhat(type)