vile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vile] strange 9.7 vile behavior under FreeBSD


From: Thomas Dickey
Subject: Re: [vile] strange 9.7 vile behavior under FreeBSD
Date: Sun, 22 Jun 2008 18:59:43 -0400
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

On Sun, Jun 22, 2008 at 10:09:28AM -0400, Thomas Dickey wrote:
> On Sun, 22 Jun 2008, Gary Jennejohn wrote:
...
>> It may very well be a) something specific to 8-current or b) a side-
>> effect of some other port which I have installed.  The way in which
>> port dependencies interact is pretty much impossible to analyze.  And
>> since I only have 8-current installed I can't evaluate it any better.
>>
>> OBTW the problem disappears for me too when I link against iconv.  I
>
> thanks - I didn't pick out that detail (was thinking that it was _with_  
> iconv).  I'll look closer at
>
>       --with-locale
>       --without-iconv
>
> ....which would only be vile + ctype

I guess it helps to look in the right place - here's what I did to
eightbit.c (seems to work).  Will have 9.7a in a day or so (was working
on some of the non-locale bugs, e.g., in syntax highlighting).

===================================================================
RCS file: RCS/eightbit.c,v
retrieving revision 1.43
diff -u -b -r1.43 eightbit.c
--- eightbit.c  2008/05/06 00:58:40     1.43
+++ eightbit.c  2008/06/22 16:29:12
@@ -1,5 +1,5 @@
 /*
- * $Id: eightbit.c,v 1.43 2008/05/06 00:58:40 Mark.Robinson Exp $
+ * $Id: eightbit.c,v 1.44 2008/06/22 16:29:12 tom Exp $
  *
  * Maintain "8bit" file-encoding mode by converting incoming UTF-8 to single
  * bytes, and providing a function that tells vile whether a given Unicode
@@ -647,10 +647,10 @@
 void
 vl_init_8bit(const char *wide, const char *narrow)
 {
+    int fixup, fixed_up;
     int n;
 
     TRACE((T_CALLED "vl_init_8bit(%s, %s)\n", NonNull(wide), NonNull(narrow)));
-#if OPT_ICONV_FUNCS
     if (wide == 0 || narrow == 0) {
        TRACE(("setup POSIX-locale\n"));
        vl_encoding = enc_POSIX;
@@ -677,6 +677,7 @@
         * If the wide/narrow encodings do not differ, that is probably because
         * the narrow encoding is really a wide-encoding.
         */
+#if OPT_ICONV_FUNCS
        if (vl_narrow_enc.encoding != 0
            && vl_wide_enc.encoding != 0
            && strcmp(vl_narrow_enc.encoding, vl_wide_enc.encoding)) {
@@ -690,32 +691,32 @@
             */
            open_encoding(vl_wide_enc.encoding, vl_narrow_enc.encoding);
        }
+#endif
     } else {
        TRACE(("setup narrow-locale(%s)\n", narrow));
        vl_encoding = enc_8BIT;
        vl_wide_enc.locale = 0;
        vl_narrow_enc.locale = StrMalloc(narrow);
        vl_get_encoding(&vl_narrow_enc.encoding, narrow);
+#if OPT_ICONV_FUNCS
        if (try_encoding(vl_narrow_enc.encoding, "UTF-8")) {
            initialize_table_8bit_utf8();
            close_encoding();
        }
+#endif
     }
-#else
-    TRACE(("setup %s-locale(%s)\n",
-          isEmpty(wide) ? "narrow" : "mixed",
-          NonNull(narrow)));
-    vl_wide_enc.locale = wide ? StrMalloc(wide) : 0;
-    vl_narrow_enc.locale = narrow ? StrMalloc(narrow) : 0;
-    vl_get_encoding(&vl_narrow_enc.encoding, narrow);
-#endif /* OPT_ICONV_FUNCS */
 
     /*
      * Even if we do not have iconv, we can still convert between the narrow
      * encoding (if it happens to be ISO-8859-1) and UTF-8.
      */
     if (vl_is_latin1_encoding(vl_narrow_enc.encoding)) {
-       for (n = 0; n < N_chars; ++n) {
+       fixup = N_chars;
+    } else {
+       /* if nothing else, still accept POSIX characters */
+       fixup = 128;
+    }
+    for (n = 0, fixed_up = 0; n < fixup; ++n) {
            if (table_8bit_utf8[n].text == 0) {
                char temp[10];
                int len = vl_conv_to_utf8((UCHAR *) temp, n, sizeof(temp));
@@ -723,9 +724,11 @@
                temp[len] = EOS;
                table_8bit_utf8[n].code = n;
                table_8bit_utf8[n].text = strmalloc(temp);
+           if (len)
+               ++fixed_up;
            }
        }
-    }
+    TRACE(("fixed-up %d of %d 8bit/utf8 mappings\n", fixed_up, fixup));
 
     /*
      * Build reverse-index.
@@ -957,6 +960,7 @@
        if ((ch = save_getch()) < 0)
            break;
        *ip++ = ch;
+       *ip = EOS;
        ch = vl_conv_to_utf32(&result, input, ip - input);
        if (ch == 0) {
            ch = -1;

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]