]> code.citadel.org Git - citadel.git/blobdiff - libcitadel/lib/stringbuf.c
add missing var definition *ups*
[citadel.git] / libcitadel / lib / stringbuf.c
index f3cd8c54364d289cc17a13f6637d900476c29630..273c09ecb2d320f28a5c8f0aa3e31cf5eaf9a387 100644 (file)
@@ -2141,6 +2141,7 @@ long StrECMAEscAppend(StrBuf *Target, const StrBuf *Source, const char *PlainIn)
        const char *aptr, *eiptr;
        char *bptr, *eptr;
        long len;
+       int IsUtf8Sequence;
 
        if (((Source == NULL) && (PlainIn == NULL)) || (Target == NULL) )
                return -1;
@@ -3328,14 +3329,16 @@ void StrBuf_RFC822_2_Utf8(StrBuf *Target,
  */
 static inline int Ctdl_GetUtf8SequenceLength(const char *CharS, const char *CharE)
 {
-       int n = 1;
-        char test = (1<<7);
+       int n = 0;
+        unsigned char test = (1<<7);
 
-       if ((*CharS & 0xC0) == 0) 
+       if ((*CharS & 0xC0) != 0xC0) 
                return 1;
 
-       while ((n < 8) && ((test & *CharS) != 0)) {
-               test = test << 1;
+       while ((n < 8) && 
+              ((test & ((unsigned char)*CharS)) != 0)) 
+       {
+               test = test >> 1;
                n ++;
        }
        if ((n > 6) || ((CharE - CharS) < n))
@@ -3352,7 +3355,7 @@ static inline int Ctdl_GetUtf8SequenceLength(const char *CharS, const char *Char
 static inline int Ctdl_IsUtf8SequenceStart(const char Char)
 {
 /** 11??.???? indicates an UTF8 Sequence. */
-       return ((Char & 0xC0) != 0);
+       return ((Char & 0xC0) == 0xC0);
 }
 
 /**