Unprintable characters with --enable-charset

Andrew V. Samoilov kai at cmail.ru
Tue Feb 5 08:40:19 UTC 2002


Hello!
> 
> >    I want to continue discussion about displaying unprintable
> > characters.
> >    The problem has arised when I tried to use new experimental
> > feature "Support for charset selection and
> > conversion" (--enable-charset). I set c_y_r_i_l_l_i_c input encodings
> > and decided to view any binary file. After few strokes on PgDn MC screen
> > was completely crashed and I saw invitation to search strange regex.
> 
> I guess that it's exactly the problem that I noticed immediately in the
> charset patch.  It relies on charset conversion doing filtering of
> unprintable characters.
> 
> That's precisely the reason why the charset patch is experimental and is
> disabled by default.
> 
> I promise to look into that before releasing the next version (unless the
> release is forced by security issues).
> 
> >  #ifdef HAVE_CHARSET
> > -    if (display_codepage < 0) {
> > +/* Because of broken printable[] in charset.c            */
> > +/* we still need in filtering characters #127 and #155       */
> 
> Exactly!

I applied patch below to CVS:

ChangeLog:

* util.c [HAVE_CHARSET] (is_printable): Eliminate printable.
* setup.c [HAVE_CHARSET] (load_setup): Don't use
init_printable_table().

* charset.c (printable): Removed.
(init_printable_table): Removed.
Index: util.c
===================================================================
RCS file: /cvs/gnome/mc/src/util.c,v
retrieving revision 1.57
diff -u -p -r1.57 util.c
--- util.c 2002/01/17 07:17:54 1.57
+++ util.c 2002/02/04 17:48:13
@@ -78,13 +78,10 @@ int is_printable (int c)
 
     c &= 0xff;
 #ifdef HAVE_CHARSET
-    if (display_codepage < 0) {
- if (xterm_flag)
-     return xterm_printable[c];
- else
-     return (c > 31 && c != 127 && c != 155);
-    } else
- return printable[ c ];
+    if (xterm_flag)
+ return xterm_printable[c];
+    else
+ return (c > 31 && c != 127 && c != 155);
 #else
     if (eight_bit_clean){
         if (full_eight_bits){
Index: charsets.c
===================================================================
RCS file: /cvs/gnome/mc/src/charsets.c,v
retrieving revision 1.12
diff -u -p -r1.12 charsets.c
--- charsets.c 2002/01/29 15:10:00 1.12
+++ charsets.c 2002/02/04 17:48:14
@@ -15,7 +15,6 @@ struct codepage_desc *codepages;
 
 uchar conv_displ[256];
 uchar conv_input[256];
-uchar printable[256];
 
 int load_codepages_list(void)
 {
@@ -142,21 +141,6 @@ char errbuf[255];
  * in mc.charsets
  */
 #define CP_ASCII 0
-
-char* init_printable_table( int cpdisplay )
-{
-    int i;
-
-    /* Fill printable characters table */
-    for (i=0; i<=127; ++i)
- printable[i] = (i > 31 && i != 127);
-
-    for (i=128; i<=255; ++i) {
- printable[i] = 1;
-    }
-
-    return NULL;
-}
 
 char* init_translation_table( int cpsource, int cpdisplay )
 {
Index: setup.c
===================================================================
RCS file: /cvs/gnome/mc/src/setup.c,v
retrieving revision 1.57
diff -u -p -r1.57 setup.c
--- setup.c 2002/01/17 07:17:54 1.57
+++ setup.c 2002/02/04 17:48:15
@@ -573,7 +573,6 @@ load_setup (void)
      display_codepage = get_codepage_index( cpname );
     }
 
-    init_printable_table( display_codepage );
     init_translation_table( source_codepage, display_codepage );
 #endif /* HAVE_CHARSET */
 }





More information about the mc-devel mailing list