]> mj.ucw.cz Git - libucw.git/commitdiff
Functions working with tagged characters moved from index.h to a new
authorMartin Mares <mj@ucw.cz>
Wed, 11 Jun 2003 13:50:09 +0000 (13:50 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 11 Jun 2003 13:50:09 +0000 (13:50 +0000)
header file tagged-text.h. This also revealed a couple of unintentional
indirect includes.

lib/finger.c
lib/index.h
lib/tagged-text.h [new file with mode: 0644]

index 585678a0119d0f56a231f2442cf86ba6dc618be7..b2e0460a87f96c0c5a18859f3aacbce757bda5ba 100644 (file)
@@ -26,6 +26,8 @@
 #include "lib/index.h"
 #include "lib/md5.h"
 
+#include <string.h>
+
 void
 fingerprint(byte *string, struct fingerprint *fp)
 {
index 8ee0b51ebf1f6d20af357a46807048fff1d847e9..ccb4b360f53b8a8abeae8b8e243500cd52a27ecd 100644 (file)
@@ -7,9 +7,7 @@
 #ifndef _SHERLOCK_INDEX_H
 #define _SHERLOCK_INDEX_H
 
-#include "lib/fastbuf.h"
 #include SHERLOCK_CUSTOM
-#include "charset/unistream.h"
 
 #define INDEX_VERSION (0x32240100+sizeof(struct card_attr))    /* Increase with each incompatible change in index format */
 
@@ -113,73 +111,6 @@ fp_hash(struct fingerprint *fp)
 byte *url_key(byte *url, byte *buf);
 void url_fingerprint(byte *url, struct fingerprint *fp);
 
-/* Reading of tagged text (Unicode values, tags mapped to 0x80000000 and higher) */
-
-#define GET_TAGGED_CHAR(p,u) do {                              \
-  u = *p;                                                      \
-  if (u >= 0xc0)                                               \
-    GET_UTF8_CHAR(p,u);                                                \
-  else if (u >= 0x80)                                          \
-    {                                                          \
-      p++;                                                     \
-      if (u >= 0xb0)                                           \
-        {                                                      \
-         ASSERT(u == 0xb0);                                    \
-         u += 0x80020000;                                      \
-        }                                                      \
-      else if (u >= 0xa0)                                      \
-        {                                                      \
-         ASSERT(*p >= 0x80 && *p <= 0xbf);                     \
-         u = 0x80010000 + ((u & 0x0f) << 6) + (*p++ & 0x3f);   \
-        }                                                      \
-      else                                                     \
-       u += 0x80000000;                                        \
-    }                                                          \
-  else                                                         \
-    p++;                                                       \
-} while (0)
-
-#define SKIP_TAGGED_CHAR(p) do {                               \
-  if (*p >= 0x80 && *p < 0xc0)                                 \
-    {                                                          \
-      uns u = *p++;                                            \
-      if (u >= 0xa0 && u < 0xb0 && *p >= 0x80 && *p < 0xc0)    \
-       p++;                                                    \
-    }                                                          \
-  else                                                         \
-    UTF8_SKIP(p);                                              \
-} while (0)
-
-static inline uns
-bget_tagged_char(struct fastbuf *f)
-{
-  uns u = bgetc(f);
-  if ((int)u < 0x80)
-    ;
-  else if (u < 0xc0)
-    {
-      if (u >= 0xb0)
-       {
-         ASSERT(u == 0xb0);
-         u += 0x80020000;
-       }
-      else if (u >= 0xa0)
-       {
-         uns v = bgetc(f);
-         ASSERT(v >= 0x80 && v <= 0xbf);
-         u = 0x80010000 + ((u & 0x0f) << 6) + (v & 0x3f);
-       }
-      else
-       u += 0x80000000;
-    }
-  else
-    {
-      bungetc(f);
-      u = bget_utf8(f);
-    }
-  return u;
-}
-
 /* Conversion of document age from seconds to our internal units */
 
 static inline int
diff --git a/lib/tagged-text.h b/lib/tagged-text.h
new file mode 100644 (file)
index 0000000..97c07ee
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ *     Sherlock: Processing of tagged characters
+ *
+ *     (c) 2001--2003 Martin Mares <mj@ucw.cz>
+ */
+
+#ifndef _SHERLOCK_TAGGED_TEXT_H
+#define _SHERLOCK_TAGGED_TEXT_H
+
+#include "lib/fastbuf.h"
+#include "charset/unistream.h"
+
+/* Reading of tagged text (Unicode values, tags mapped to 0x80000000 and higher) */
+
+#define GET_TAGGED_CHAR(p,u) do {                              \
+  u = *p;                                                      \
+  if (u >= 0xc0)                                               \
+    GET_UTF8_CHAR(p,u);                                                \
+  else if (u >= 0x80)                                          \
+    {                                                          \
+      p++;                                                     \
+      if (u >= 0xb0)                                           \
+        {                                                      \
+         ASSERT(u == 0xb0);                                    \
+         u += 0x80020000;                                      \
+        }                                                      \
+      else if (u >= 0xa0)                                      \
+        {                                                      \
+         ASSERT(*p >= 0x80 && *p <= 0xbf);                     \
+         u = 0x80010000 + ((u & 0x0f) << 6) + (*p++ & 0x3f);   \
+        }                                                      \
+      else                                                     \
+       u += 0x80000000;                                        \
+    }                                                          \
+  else                                                         \
+    p++;                                                       \
+} while (0)
+
+#define SKIP_TAGGED_CHAR(p) do {                               \
+  if (*p >= 0x80 && *p < 0xc0)                                 \
+    {                                                          \
+      uns u = *p++;                                            \
+      if (u >= 0xa0 && u < 0xb0 && *p >= 0x80 && *p < 0xc0)    \
+       p++;                                                    \
+    }                                                          \
+  else                                                         \
+    UTF8_SKIP(p);                                              \
+} while (0)
+
+static inline uns
+bget_tagged_char(struct fastbuf *f)
+{
+  uns u = bgetc(f);
+  if ((int)u < 0x80)
+    ;
+  else if (u < 0xc0)
+    {
+      if (u >= 0xb0)
+       {
+         ASSERT(u == 0xb0);
+         u += 0x80020000;
+       }
+      else if (u >= 0xa0)
+       {
+         uns v = bgetc(f);
+         ASSERT(v >= 0x80 && v <= 0xbf);
+         u = 0x80010000 + ((u & 0x0f) << 6) + (v & 0x3f);
+       }
+      else
+       u += 0x80000000;
+    }
+  else
+    {
+      bungetc(f);
+      u = bget_utf8(f);
+    }
+  return u;
+}
+
+#endif