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

Commit 61a93ed

Browse files
committed
Add multi-byte support to lztextlen()
1 parent 95997e1 commit 61a93ed

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/backend/utils/adt/lztext.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ----------
22
* lztext.c -
33
*
4-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.2 1999/11/17 22:18:45 wieck Exp $
4+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.3 1999/11/24 03:45:12 ishii Exp $
55
*
66
* Text type with internal LZ compressed representation. Uses the
77
* standard PostgreSQL compression method.
@@ -21,7 +21,9 @@
2121
#include "utils/builtins.h"
2222
#include "utils/palloc.h"
2323
#include "utils/pg_lzcompress.h"
24-
24+
#ifdef MULTIBYTE
25+
#include "mb/pg_wchar.h"
26+
#endif
2527

2628
/* ----------
2729
* lztextin -
@@ -134,18 +136,39 @@ lztextout(lztext *lz)
134136
int32
135137
lztextlen(lztext *lz)
136138
{
139+
#ifdef MULTIBYTE
140+
unsigned char *s1,*s2;
141+
int len;
142+
int l;
143+
int wl;
144+
#endif
137145
/* ----------
138146
* Handle NULL
139147
* ----------
140148
*/
141149
if (lz == NULL)
142150
return 0;
143151

152+
#ifdef MULTIBYTE
153+
len = 0;
154+
s1 = s2 = (unsigned char *)lztextout(lz);
155+
l = PGLZ_RAW_SIZE(lz);
156+
while (l > 0)
157+
{
158+
wl = pg_mblen(s1);
159+
l -= wl;
160+
s1 += wl;
161+
len++;
162+
}
163+
pfree((char *)s2);
164+
return (len);
165+
#else
144166
/* ----------
145167
* without multibyte support, it's the remembered rawsize
146168
* ----------
147169
*/
148170
return PGLZ_RAW_SIZE(lz);
171+
#endif
149172
}
150173

151174

@@ -228,8 +251,6 @@ text_lztext(text *txt)
228251
}
229252

230253
return result;
231-
232-
233254
}
234255

235256

0 commit comments

Comments
 (0)