]> mj.ucw.cz Git - libucw.git/commitdiff
Fix: .h indentation and ifdef names; some comments; stk-conv enlarges
authorPavel Charvat <pchar@camellia.ms.mff.cuni.cz>
Sat, 4 Mar 2006 19:45:08 +0000 (20:45 +0100)
committerPavel Charvat <pchar@camellia.ms.mff.cuni.cz>
Sat, 4 Mar 2006 19:45:08 +0000 (20:45 +0100)
string 3 times; warning in string_table generator.

charset/charconv.h
charset/misc/gen-charconv
charset/mp-charconv.c
charset/mp-charconv.h
charset/stk-charconv.c
charset/stk-charconv.h
charset/unicat.h

index d14493c16b8c241f27aa90280e15865cc2dd8024..ed775b137b0e26cf27c2fa893f87452aedbaf1f1 100644 (file)
@@ -7,8 +7,8 @@
  *     of the GNU Lesser General Public License.
  */
 
-#ifndef _CHARCONV_H
-#define _CHARCONV_H
+#ifndef _CHARSET_CHARCONV_H
+#define _CHARSET_CHARCONV_H
 
 struct conv_context {
 
index ab22b1563d0465be597d5f40f9e1b17caff1a910..a731d9ab0a4b80c2968eae5c0c4aa734dc9a7aa6 100755 (executable)
@@ -182,6 +182,9 @@ print "static unsigned char string_table[] = {\n";
 $i = 256;
 while ($i < $pstr) {
        $w = $strval{$i};
+       if (length($w) > 3) {
+               print STDERR "Warning: Entries should have at most 3 characters, see charset/stk-charconv.c\n";
+       }
        print length $w, ",";
        foreach $x (unpack("C256", $w)) {
                print " $x,";
index 731d591ef126fcc80aab9b1253660af77ead6db8..0235ae7693257fd00037d38ea06f78a2902f8b4f 100644 (file)
@@ -8,7 +8,6 @@
 #include "lib/mempool.h"
 #include "charset/mp-charconv.h"
 #include "charset/stk-charconv.h"
-#include <string.h>
 
 byte *
 mp_conv(struct mempool *mp, byte *s, uns in_cs, uns out_cs)
index 6519535a38504bdf86d5ad10adb542119cc39b91..f3d7bd232016375eaf93c1059fde0a4a1b788e26 100644 (file)
@@ -4,14 +4,13 @@
  *     (c) 2006 Pavel Charvat <pchar@ucw.cz>
  */
 
-#ifndef _MP_CHARCONV_H
-#define _MP_CHARCONV_H
+#ifndef _CHARSET_MP_CHARCONV_H
+#define _CHARSET_MP_CHARCONV_H
 
 #include "lib/mempool.h"
 #include "charset/charconv.h"
 
-byte *
-mp_conv(struct mempool *mp, byte *s, uns cs_in, uns cs_out);
+byte *mp_conv(struct mempool *mp, byte *s, uns cs_in, uns cs_out);
 
 static inline byte *
 mp_conv_to_utf8(struct mempool *mp, byte *s, uns cs_in) 
index 6550ea351b6cdd7f25ec91da9d36d3b7f7ac01ce..3fbc07bb420d362590fc9d2756d8afd3ec940515 100644 (file)
@@ -26,7 +26,7 @@ stk_conv_internal(struct conv_context *c, byte *s, uns in_cs, uns out_cs)
   c->source_end = s + l + 1;
 
   /* Resulting string can be longer after the conversion.
-   * The following constatnt must be at least 4 for conversion to UTF-8
+   * The following constant must be at least 3 for conversion to UTF-8
    * and at least the maximum length of the strings in string_table for other charsets. */
-  return 4 * l + 1;
+  return 3 * l + 1;
 }
index c0d8568f0f43341192579e9b04294fb7ed05346a..d63ba746efcd143527936e086545cb10ad79b57f 100644 (file)
@@ -4,12 +4,16 @@
  *     (c) 2006 Pavel Charvat <pchar@ucw.cz>
  */
 
-#ifndef _STK_CHARCONV_H
-#define _STK_CHARCONV_H
+#ifndef _CHARSET_STK_CHARCONV_H
+#define _CHARSET_STK_CHARCONV_H
 
 #include "charset/charconv.h"
 #include <alloca.h>
 
+/* The following macros convert strings between given charsets (CONV_CHARSET_x).
+ * The resulting string is allocated on the stack with the exception of cs_in == cs_out, 
+ * when the pointer to the input string is returned. */
+
 #define stk_conv(s, cs_in, cs_out) \
     ({ struct conv_context _c; uns _l=stk_conv_internal(&_c, (s), (cs_in), (cs_out)); \
     if (_l) { _c.dest=_c.dest_start=alloca(_l); _c.dest_end=_c.dest+_l; conv_run(&_c); } \
@@ -18,6 +22,6 @@
 #define stk_conv_to_utf8(s, cs_in) stk_conv(s, cs_in, CONV_CHARSET_UTF8)
 #define stk_conv_from_utf8(s, cs_out) stk_conv(s, CONV_CHARSET_UTF8, cs_out)
     
-uns stk_conv_internal(struct conv_context *, byte *, uns, uns);
+uns stk_conv_internal(struct conv_context *c, byte *s, uns cs_in, uns cs_out);
 
 #endif
index 1ddfb8e62fd818e3be642f948bfa24f6f133fa61..021ec5c2eb4106b950fa257fc2bf2ca62d7867fc 100644 (file)
@@ -7,8 +7,8 @@
  *     of the GNU Lesser General Public License.
  */
 
-#ifndef _UNICAT_H
-#define _UNICAT_H
+#ifndef _CHARSET_UNICAT_H
+#define _CHARSET_UNICAT_H
 
 extern const byte *_U_cat[];
 extern const word *_U_upper[], *_U_lower[], *_U_unaccent[];