aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>1999-11-24 03:45:12 +0000
committerTatsuo Ishii <ishii@postgresql.org>1999-11-24 03:45:12 +0000
commit61a93ed2da5adbacc57cc3b4b00805a7e3c868df (patch)
treed228530973a2c2988d01866afd523dae4d053d29
parent95997e159b6d7a1e70b02b387a30dd27b421f0a3 (diff)
downloadpostgresql-61a93ed2da5adbacc57cc3b4b00805a7e3c868df.tar.gz
postgresql-61a93ed2da5adbacc57cc3b4b00805a7e3c868df.zip
Add multi-byte support to lztextlen()
-rw-r--r--src/backend/utils/adt/lztext.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/backend/utils/adt/lztext.c b/src/backend/utils/adt/lztext.c
index a07ddebcf19..6ff128515b6 100644
--- a/src/backend/utils/adt/lztext.c
+++ b/src/backend/utils/adt/lztext.c
@@ -1,7 +1,7 @@
/* ----------
* 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;
-
-
}