diff --git a/src/ChangeLog b/src/ChangeLog index c978256ad..2f62212e5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2001-06-07 Andrew V. Samoilov + + * charsets.h: Define CHARSETS_INDEX without leading LIBDIR. + + * charsets.c (translate_character): Warning fix. + (init_translation_table): Don't deal with printable. + This one is initialized by init_printable_table (). + (load_codepages_list): Use CHARSETS_INDEX. + + * selcodepage.c (do_select_codepage): Messages marked for i18n. + * setup.c (load_setup): Eliminate errbuf. Fix error message. + 2001-06-07 Pavel Roskin * setup.c (load_setup): Call init_printable_table() and diff --git a/src/charsets.c b/src/charsets.c index ed1def8d0..6a284823a 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -27,7 +27,7 @@ int load_codepages_list() char * default_codepage = NULL; strcpy ( buf, mc_home ); - strcat ( buf, "/mc.charsets" ); + strcat ( buf, "/" CHARSETS_INDEX ); if ( !( f = fopen( buf, "r" ) ) ) return -1; @@ -104,7 +104,7 @@ static char translate_character( iconv_t cd, char c ) char outbuf[4], *obuf; size_t ibuflen, obuflen, count; - char *ibuf = &c; + const char *ibuf = &c; obuf = outbuf; ibuflen = 1; obuflen = 4; @@ -126,17 +126,14 @@ char errbuf[255]; char* init_printable_table( int cpdisplay ) { int i; - uchar ch; + uchar ch = (cpdisplay == CP_ASCII) ? 0 : 1; /* Fill printable characters table */ for (i=0; i<=127; ++i) printable[i] = (i > 31 && i != 127); - ch = (cpdisplay == CP_ASCII) ? 0 : 1; - for (i=128; i<=255; ++i) { printable[i] = 1; - printable[i] = (i > 31 && i != 127); } return NULL; @@ -155,7 +152,6 @@ char* init_translation_table( int cpsource, int cpdisplay ) for (i=0; i<=255; ++i) { conv_displ[i] = i; conv_input[i] = i; - printable[i] = (i > 31 && i != 127); } return NULL; } @@ -163,7 +159,6 @@ char* init_translation_table( int cpsource, int cpdisplay ) for (i=0; i<=127; ++i) { conv_displ[i] = i; conv_input[i] = i; - printable[i] = (i > 31 && i != 127); } cpsour = codepages[ cpsource ].id; @@ -193,7 +188,6 @@ char* init_translation_table( int cpsource, int cpdisplay ) for (i=128; i<=255; ++i) { ch = translate_character( cd, i ); conv_input[i] = (ch == UNKNCHAR) ? i : ch; - printable[i] = 1; } iconv_close( cd ); diff --git a/src/charsets.h b/src/charsets.h index b59dddb19..d8eb8fde3 100644 --- a/src/charsets.h +++ b/src/charsets.h @@ -4,7 +4,7 @@ #define UNKNCHAR '\001' -#define CHARSETS_INDEX LIBDIR "mc.charsets" +#define CHARSETS_INDEX "mc.charsets" typedef unsigned char uchar; diff --git a/src/selcodepage.c b/src/selcodepage.c index 33fa440c2..ef4fdc313 100644 --- a/src/selcodepage.c +++ b/src/selcodepage.c @@ -68,29 +68,29 @@ int select_charset( int current_charset, int seldisplay ) int do_select_codepage() { - char *errmsg; - #ifndef HAVE_ICONV message( 1, _(" Warning "), - "Midnight Commander was compiled without iconv support,\n" - "so charsets recoding feature is not available!" ); + _("Midnight Commander was compiled without iconv support,\n" + "so charsets recoding feature is not available!" )); return -1; #else + char *errmsg; + if (display_codepage > 0) { source_codepage = select_charset( source_codepage, 0 ); errmsg = init_translation_table( source_codepage, display_codepage ); if (errmsg) { - message( 1, _(" Error "), errmsg ); + message( 1, MSG_ERROR, "%s", errmsg ); return -1; } } else { message( 1, _(" Warning "), - "To use this feature select your codepage in\n" + _("To use this feature select your codepage in\n" "Setup / Display Bits dialog!\n" - "Do not forget to save options." ); + "Do not forget to save options." )); return -1; } return 0; diff --git a/src/setup.c b/src/setup.c index 0cf52041a..7fa038947 100644 --- a/src/setup.c +++ b/src/setup.c @@ -639,9 +639,7 @@ load_setup (void) #ifdef HAVE_CHARSET if ( load_codepages_list() <= 0 ) { - char errmsg[256]; - sprintf( errmsg, _("Can't load %s"), CHARSETS_INDEX ); - message( 1, MSG_ERROR, "%s", errmsg ); + message( 1, MSG_ERROR, _("Can't load %s/%s"), mc_home, CHARSETS_INDEX ); } else { char cpname[128]; load_string( "Misc", "display_codepage", "", @@ -708,10 +706,11 @@ load_keys_from_section (char *terminal, char *profile_name) while (profile_keys){ profile_keys = profile_iterator_next (profile_keys, &key, &value); key_code = lookup_key (key); - valcopy = convert_controls (value); - if (key_code) + if (key_code){ + valcopy = convert_controls (value); define_sequence (key_code, valcopy, MCKEY_NOACTION); - g_free (valcopy); + g_free (valcopy); + } } g_free (section_name); return;