]> mj.ucw.cz Git - libucw.git/commitdiff
Renamed lib/ff-utf8.* to lib/ff-unicode.*
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Mon, 10 Dec 2007 10:12:49 +0000 (11:12 +0100)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Mon, 10 Dec 2007 10:12:49 +0000 (11:12 +0100)
lib/Makefile
lib/ff-unicode.c [new file with mode: 0644]
lib/ff-unicode.h [new file with mode: 0644]
lib/ff-utf8.c [deleted file]
lib/ff-utf8.h [deleted file]
sherlock/xml/xml.c

index 52751e11e95035c8e88d4631824df3b12f09e7c7..ed6a3a7972fa70afafa5538fa7a14f5ad65c220e 100644 (file)
@@ -17,7 +17,7 @@ LIBUCW_MODS= \
        conf-alloc conf-dump conf-input conf-intr conf-journal conf-parse conf-section \
        ipaccess \
        profile \
-       fastbuf ff-binary ff-string ff-printf ff-utf8 \
+       fastbuf ff-binary ff-string ff-printf ff-unicode \
        fb-file carefulio fb-mem fb-temp fb-mmap fb-limfd fb-buffer fb-grow fb-pool fb-atomic fb-param \
        str_ctype str_upper str_lower unicode-utf8 stkstring \
        wildmatch wordsplit ctmatch patimatch patmatch regex \
@@ -49,7 +49,7 @@ LIBUCW_INCLUDES= \
        bitops.h \
        conf.h getopt.h ipaccess.h \
        profile.h \
-       fastbuf.h lfs.h ff-utf8.h ff-binary.h \
+       fastbuf.h lfs.h ff-unicode.h ff-binary.h \
        chartype.h unicode.h stkstring.h \
        wildmatch.h patmatch.h \
        db.h \
diff --git a/lib/ff-unicode.c b/lib/ff-unicode.c
new file mode 100644 (file)
index 0000000..7f46aaa
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ *     UCW Library: Reading and writing of UTF-8 on Fastbuf Streams
+ *
+ *     (c) 2001--2004 Martin Mares <mj@ucw.cz>
+ *     (c) 2004 Robert Spalek <robert@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
+ */
+
+#include "lib/lib.h"
+#include "lib/fastbuf.h"
+#include "lib/unicode.h"
+#include "lib/ff-unicode.h"
+
+int
+bget_utf8_slow(struct fastbuf *b)
+{
+  int c = bgetc(b);
+  int code;
+
+  if (c < 0x80)                                /* Includes EOF */
+    return c;
+  if (c < 0xc0)                                /* Incorrect combination */
+    return UNI_REPLACEMENT;
+  if (c >= 0xf0)                       /* Too large, skip it */
+    {
+      while ((c = bgetc(b)) >= 0x80 && c < 0xc0)
+       ;
+      goto wrong;
+    }
+  if (c >= 0xe0)                       /* 3 bytes */
+    {
+      code = c & 0x0f;
+      if ((c = bgetc(b)) < 0x80 || c >= 0xc0)
+       goto wrong;
+      code = (code << 6) | (c & 0x3f);
+      if ((c = bgetc(b)) < 0x80 || c >= 0xc0)
+       goto wrong;
+      code = (code << 6) | (c & 0x3f);
+    }
+  else                                 /* 2 bytes */
+    {
+      code = c & 0x1f;
+      if ((c = bgetc(b)) < 0x80 || c >= 0xc0)
+       goto wrong;
+      code = (code << 6) | (c & 0x3f);
+    }
+  return code;
+
+ wrong:
+  if (c >= 0)
+    bungetc(b);
+  return UNI_REPLACEMENT;
+}
+
+int
+bget_utf8_32_slow(struct fastbuf *b)
+{
+  int c = bgetc(b);
+  int code;
+  int nr;
+
+  if (c < 0x80)                                /* Includes EOF */
+    return c;
+  if (c < 0xc0)                                /* Incorrect combination */
+    return UNI_REPLACEMENT;
+  if (c < 0xe0)
+    {
+      code = c & 0x1f;
+      nr = 1;
+    }
+  else if (c < 0xf0)
+    {
+      code = c & 0x0f;
+      nr = 2;
+    }
+  else if (c < 0xf8)
+    {
+      code = c & 0x07;
+      nr = 3;
+    }
+  else if (c < 0xfc)
+    {
+      code = c & 0x03;
+      nr = 4;
+    }
+  else if (c < 0xfe)
+    {
+      code = c & 0x01;
+      nr = 5;
+    }
+  else                                 /* Too large, skip it */
+    {
+      while ((c = bgetc(b)) >= 0x80 && c < 0xc0)
+       ;
+      goto wrong;
+    }
+  while (nr-- > 0)
+    {
+      if ((c = bgetc(b)) < 0x80 || c >= 0xc0)
+       goto wrong;
+      code = (code << 6) | (c & 0x3f);
+    }
+  return code;
+
+ wrong:
+  if (c >= 0)
+    bungetc(b);
+  return UNI_REPLACEMENT;
+}
+
+void
+bput_utf8_slow(struct fastbuf *b, uns u)
+{
+  ASSERT(u < 65536);
+  if (u < 0x80)
+    bputc(b, u);
+  else
+    {
+      if (u < 0x800)
+       bputc(b, 0xc0 | (u >> 6));
+      else
+       {
+         bputc(b, 0xe0 | (u >> 12));
+         bputc(b, 0x80 | ((u >> 6) & 0x3f));
+       }
+      bputc(b, 0x80 | (u & 0x3f));
+    }
+}
+
+void
+bput_utf8_32_slow(struct fastbuf *b, uns u)
+{
+  ASSERT(u < (1U<<31));
+  if (u < 0x80)
+    bputc(b, u);
+  else
+    {
+      if (u < 0x800)
+       bputc(b, 0xc0 | (u >> 6));
+      else
+       {
+         if (u < (1<<16))
+           bputc(b, 0xe0 | (u >> 12));
+         else
+           {
+             if (u < (1<<21))
+               bputc(b, 0xf0 | (u >> 18));
+             else
+               {
+                 if (u < (1<<26))
+                   bputc(b, 0xf8 | (u >> 24));
+                 else
+                   {
+                     bputc(b, 0xfc | (u >> 30));
+                     bputc(b, 0x80 | ((u >> 24) & 0x3f));
+                   }
+                 bputc(b, 0x80 | ((u >> 18) & 0x3f));
+               }
+             bputc(b, 0x80 | ((u >> 12) & 0x3f));
+           }
+         bputc(b, 0x80 | ((u >> 6) & 0x3f));
+       }
+      bputc(b, 0x80 | (u & 0x3f));
+    }
+}
diff --git a/lib/ff-unicode.h b/lib/ff-unicode.h
new file mode 100644 (file)
index 0000000..31510ff
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ *     UCW Library: Reading and writing of UTF-8 on Fastbuf Streams
+ *
+ *     (c) 2001--2004 Martin Mares <mj@ucw.cz>
+ *     (c) 2004 Robert Spalek <robert@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
+ */
+
+#ifndef _UCW_FF_UTF8_H
+#define _UCW_FF_UTF8_H
+
+#include "lib/fastbuf.h"
+#include "lib/unicode.h"
+
+int bget_utf8_slow(struct fastbuf *b);
+int bget_utf8_32_slow(struct fastbuf *b);
+void bput_utf8_slow(struct fastbuf *b, uns u);
+void bput_utf8_32_slow(struct fastbuf *b, uns u);
+
+static inline int
+bget_utf8(struct fastbuf *b)
+{
+  uns u;
+
+  if (bavailr(b) >= 3)
+    {
+      GET_UTF8(b->bptr, u);
+      return u;
+    }
+  else
+    return bget_utf8_slow(b);
+}
+
+static inline void
+bput_utf8(struct fastbuf *b, uns u)
+{
+  ASSERT(u < 65536);
+  if (bavailw(b) >= 3)
+    PUT_UTF8(b->bptr, u);
+  else
+    bput_utf8_slow(b, u);
+}
+
+static inline int
+bget_utf8_32(struct fastbuf *b)
+{
+  uns u;
+
+  if (bavailr(b) >= 6)
+    {
+      GET_UTF8_32(b->bptr, u);
+      return u;
+    }
+  else
+    return bget_utf8_32_slow(b);
+}
+
+static inline void
+bput_utf8_32(struct fastbuf *b, uns u)
+{
+  ASSERT(u < (1U<<31));
+  if (bavailw(b) >= 6)
+    PUT_UTF8_32(b->bptr, u);
+  else
+    bput_utf8_32_slow(b, u);
+}
+
+#endif
diff --git a/lib/ff-utf8.c b/lib/ff-utf8.c
deleted file mode 100644 (file)
index a7e40d3..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- *     UCW Library: Reading and writing of UTF-8 on Fastbuf Streams
- *
- *     (c) 2001--2004 Martin Mares <mj@ucw.cz>
- *     (c) 2004 Robert Spalek <robert@ucw.cz>
- *
- *     This software may be freely distributed and used according to the terms
- *     of the GNU Lesser General Public License.
- */
-
-#include "lib/lib.h"
-#include "lib/fastbuf.h"
-#include "lib/unicode.h"
-#include "lib/ff-utf8.h"
-
-int
-bget_utf8_slow(struct fastbuf *b)
-{
-  int c = bgetc(b);
-  int code;
-
-  if (c < 0x80)                                /* Includes EOF */
-    return c;
-  if (c < 0xc0)                                /* Incorrect combination */
-    return UNI_REPLACEMENT;
-  if (c >= 0xf0)                       /* Too large, skip it */
-    {
-      while ((c = bgetc(b)) >= 0x80 && c < 0xc0)
-       ;
-      goto wrong;
-    }
-  if (c >= 0xe0)                       /* 3 bytes */
-    {
-      code = c & 0x0f;
-      if ((c = bgetc(b)) < 0x80 || c >= 0xc0)
-       goto wrong;
-      code = (code << 6) | (c & 0x3f);
-      if ((c = bgetc(b)) < 0x80 || c >= 0xc0)
-       goto wrong;
-      code = (code << 6) | (c & 0x3f);
-    }
-  else                                 /* 2 bytes */
-    {
-      code = c & 0x1f;
-      if ((c = bgetc(b)) < 0x80 || c >= 0xc0)
-       goto wrong;
-      code = (code << 6) | (c & 0x3f);
-    }
-  return code;
-
- wrong:
-  if (c >= 0)
-    bungetc(b);
-  return UNI_REPLACEMENT;
-}
-
-int
-bget_utf8_32_slow(struct fastbuf *b)
-{
-  int c = bgetc(b);
-  int code;
-  int nr;
-
-  if (c < 0x80)                                /* Includes EOF */
-    return c;
-  if (c < 0xc0)                                /* Incorrect combination */
-    return UNI_REPLACEMENT;
-  if (c < 0xe0)
-    {
-      code = c & 0x1f;
-      nr = 1;
-    }
-  else if (c < 0xf0)
-    {
-      code = c & 0x0f;
-      nr = 2;
-    }
-  else if (c < 0xf8)
-    {
-      code = c & 0x07;
-      nr = 3;
-    }
-  else if (c < 0xfc)
-    {
-      code = c & 0x03;
-      nr = 4;
-    }
-  else if (c < 0xfe)
-    {
-      code = c & 0x01;
-      nr = 5;
-    }
-  else                                 /* Too large, skip it */
-    {
-      while ((c = bgetc(b)) >= 0x80 && c < 0xc0)
-       ;
-      goto wrong;
-    }
-  while (nr-- > 0)
-    {
-      if ((c = bgetc(b)) < 0x80 || c >= 0xc0)
-       goto wrong;
-      code = (code << 6) | (c & 0x3f);
-    }
-  return code;
-
- wrong:
-  if (c >= 0)
-    bungetc(b);
-  return UNI_REPLACEMENT;
-}
-
-void
-bput_utf8_slow(struct fastbuf *b, uns u)
-{
-  ASSERT(u < 65536);
-  if (u < 0x80)
-    bputc(b, u);
-  else
-    {
-      if (u < 0x800)
-       bputc(b, 0xc0 | (u >> 6));
-      else
-       {
-         bputc(b, 0xe0 | (u >> 12));
-         bputc(b, 0x80 | ((u >> 6) & 0x3f));
-       }
-      bputc(b, 0x80 | (u & 0x3f));
-    }
-}
-
-void
-bput_utf8_32_slow(struct fastbuf *b, uns u)
-{
-  ASSERT(u < (1U<<31));
-  if (u < 0x80)
-    bputc(b, u);
-  else
-    {
-      if (u < 0x800)
-       bputc(b, 0xc0 | (u >> 6));
-      else
-       {
-         if (u < (1<<16))
-           bputc(b, 0xe0 | (u >> 12));
-         else
-           {
-             if (u < (1<<21))
-               bputc(b, 0xf0 | (u >> 18));
-             else
-               {
-                 if (u < (1<<26))
-                   bputc(b, 0xf8 | (u >> 24));
-                 else
-                   {
-                     bputc(b, 0xfc | (u >> 30));
-                     bputc(b, 0x80 | ((u >> 24) & 0x3f));
-                   }
-                 bputc(b, 0x80 | ((u >> 18) & 0x3f));
-               }
-             bputc(b, 0x80 | ((u >> 12) & 0x3f));
-           }
-         bputc(b, 0x80 | ((u >> 6) & 0x3f));
-       }
-      bputc(b, 0x80 | (u & 0x3f));
-    }
-}
diff --git a/lib/ff-utf8.h b/lib/ff-utf8.h
deleted file mode 100644 (file)
index 31510ff..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- *     UCW Library: Reading and writing of UTF-8 on Fastbuf Streams
- *
- *     (c) 2001--2004 Martin Mares <mj@ucw.cz>
- *     (c) 2004 Robert Spalek <robert@ucw.cz>
- *
- *     This software may be freely distributed and used according to the terms
- *     of the GNU Lesser General Public License.
- */
-
-#ifndef _UCW_FF_UTF8_H
-#define _UCW_FF_UTF8_H
-
-#include "lib/fastbuf.h"
-#include "lib/unicode.h"
-
-int bget_utf8_slow(struct fastbuf *b);
-int bget_utf8_32_slow(struct fastbuf *b);
-void bput_utf8_slow(struct fastbuf *b, uns u);
-void bput_utf8_32_slow(struct fastbuf *b, uns u);
-
-static inline int
-bget_utf8(struct fastbuf *b)
-{
-  uns u;
-
-  if (bavailr(b) >= 3)
-    {
-      GET_UTF8(b->bptr, u);
-      return u;
-    }
-  else
-    return bget_utf8_slow(b);
-}
-
-static inline void
-bput_utf8(struct fastbuf *b, uns u)
-{
-  ASSERT(u < 65536);
-  if (bavailw(b) >= 3)
-    PUT_UTF8(b->bptr, u);
-  else
-    bput_utf8_slow(b, u);
-}
-
-static inline int
-bget_utf8_32(struct fastbuf *b)
-{
-  uns u;
-
-  if (bavailr(b) >= 6)
-    {
-      GET_UTF8_32(b->bptr, u);
-      return u;
-    }
-  else
-    return bget_utf8_32_slow(b);
-}
-
-static inline void
-bput_utf8_32(struct fastbuf *b, uns u)
-{
-  ASSERT(u < (1U<<31));
-  if (bavailw(b) >= 6)
-    PUT_UTF8_32(b->bptr, u);
-  else
-    bput_utf8_32_slow(b, u);
-}
-
-#endif
index 27ff8249e3641a2d611d9a84a1a7cd6a639a1645..c5d5c5af5c6b6446c3db6fc1e96b80f206336a26 100644 (file)
@@ -17,7 +17,7 @@
 #include "lib/lib.h"
 #include "lib/mempool.h"
 #include "lib/fastbuf.h"
-#include "lib/ff-utf8.h"
+#include "lib/ff-unicode.h"
 #include "lib/ff-binary.h"
 #include "lib/chartype.h"
 #include "lib/unicode.h"