Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bd041d8

Browse files
committed
multi-byte fix from Tatsuo Ishii
1 parent d73f73a commit bd041d8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/backend/utils/adt/varchar.c

+7-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.40 1998/09/25 01:46:21 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.41 1998/09/25 15:51:02 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -147,14 +147,7 @@ bpchar(char *s, int32 len)
147147
if ((len == -1) || (len == VARSIZE(s)))
148148
return s;
149149

150-
#ifdef MULTIBYTE
151-
/* truncate multi-byte string in a way not to break
152-
multi-byte boundary */
153-
rlen = pg_mbcliplen(VARDATA(s), len - VARHDRSZ, len - VARHDRSZ);
154-
len = rlen + VARHDRSZ;
155-
#else
156150
rlen = len - VARHDRSZ;
157-
#endif
158151

159152
if (rlen > 4096)
160153
elog(ERROR, "bpchar: length of char() must be less than 4096");
@@ -167,7 +160,13 @@ bpchar(char *s, int32 len)
167160
result = (char *) palloc(len);
168161
VARSIZE(result) = len;
169162
r = VARDATA(result);
163+
#ifdef MULTIBYTE
164+
/* truncate multi-byte string in a way not to break
165+
multi-byte boundary */
166+
slen = pg_mbcliplen(VARDATA(s), rlen, rlen);
167+
#else
170168
slen = VARSIZE(s) - VARHDRSZ;
169+
#endif
171170
s = VARDATA(s);
172171

173172
#ifdef STRINGDEBUG

0 commit comments

Comments
 (0)