Commit bd041d82 authored by Bruce Momjian's avatar Bruce Momjian

multi-byte fix from Tatsuo Ishii

parent d73f73af
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.40 1998/09/25 01:46:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.41 1998/09/25 15:51:02 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -147,14 +147,7 @@ bpchar(char *s, int32 len) ...@@ -147,14 +147,7 @@ bpchar(char *s, int32 len)
if ((len == -1) || (len == VARSIZE(s))) if ((len == -1) || (len == VARSIZE(s)))
return s; return s;
#ifdef MULTIBYTE
/* truncate multi-byte string in a way not to break
multi-byte boundary */
rlen = pg_mbcliplen(VARDATA(s), len - VARHDRSZ, len - VARHDRSZ);
len = rlen + VARHDRSZ;
#else
rlen = len - VARHDRSZ; rlen = len - VARHDRSZ;
#endif
if (rlen > 4096) if (rlen > 4096)
elog(ERROR, "bpchar: length of char() must be less than 4096"); elog(ERROR, "bpchar: length of char() must be less than 4096");
...@@ -167,7 +160,13 @@ bpchar(char *s, int32 len) ...@@ -167,7 +160,13 @@ bpchar(char *s, int32 len)
result = (char *) palloc(len); result = (char *) palloc(len);
VARSIZE(result) = len; VARSIZE(result) = len;
r = VARDATA(result); r = VARDATA(result);
#ifdef MULTIBYTE
/* truncate multi-byte string in a way not to break
multi-byte boundary */
slen = pg_mbcliplen(VARDATA(s), rlen, rlen);
#else
slen = VARSIZE(s) - VARHDRSZ; slen = VARSIZE(s) - VARHDRSZ;
#endif
s = VARDATA(s); s = VARDATA(s);
#ifdef STRINGDEBUG #ifdef STRINGDEBUG
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment