Commit 61a93ed2 authored by Tatsuo Ishii's avatar Tatsuo Ishii

Add multi-byte support to lztextlen()

parent 95997e15
/* ----------
* lztext.c -
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.2 1999/11/17 22:18:45 wieck Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/lztext.c,v 1.3 1999/11/24 03:45:12 ishii Exp $
*
* Text type with internal LZ compressed representation. Uses the
* standard PostgreSQL compression method.
......@@ -21,7 +21,9 @@
#include "utils/builtins.h"
#include "utils/palloc.h"
#include "utils/pg_lzcompress.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
/* ----------
* lztextin -
......@@ -134,6 +136,12 @@ lztextout(lztext *lz)
int32
lztextlen(lztext *lz)
{
#ifdef MULTIBYTE
unsigned char *s1,*s2;
int len;
int l;
int wl;
#endif
/* ----------
* Handle NULL
* ----------
......@@ -141,11 +149,26 @@ lztextlen(lztext *lz)
if (lz == NULL)
return 0;
#ifdef MULTIBYTE
len = 0;
s1 = s2 = (unsigned char *)lztextout(lz);
l = PGLZ_RAW_SIZE(lz);
while (l > 0)
{
wl = pg_mblen(s1);
l -= wl;
s1 += wl;
len++;
}
pfree((char *)s2);
return (len);
#else
/* ----------
* without multibyte support, it's the remembered rawsize
* ----------
*/
return PGLZ_RAW_SIZE(lz);
#endif
}
......@@ -228,8 +251,6 @@ text_lztext(text *txt)
}
return result;
}
......
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