fix: build without HAVE_CHARSET

This commit is contained in:
Ilia Maslakov 2009-04-20 05:51:32 +00:00
parent a4b354f99c
commit 9d855b3253
5 changed files with 21 additions and 6 deletions

View File

@ -277,9 +277,10 @@ edit_load_file_fast (WEdit *edit, const char *filename)
edit->curs2 = edit->last_byte; edit->curs2 = edit->last_byte;
buf2 = edit->curs2 >> S_EDIT_BUF_SIZE; buf2 = edit->curs2 >> S_EDIT_BUF_SIZE;
edit->utf8 = 0; edit->utf8 = 0;
#ifdef HAVE_CHARSET
if ( get_codepage_id( source_codepage ) ) if ( get_codepage_id( source_codepage ) )
edit->utf8 = str_isutf8 (get_codepage_id( source_codepage )); edit->utf8 = str_isutf8 (get_codepage_id( source_codepage ));
#endif
if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) { if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) {
GString *errmsg = g_string_new(NULL); GString *errmsg = g_string_new(NULL);
g_string_sprintf(errmsg, _(" Cannot open %s for reading "), filename); g_string_sprintf(errmsg, _(" Cannot open %s for reading "), filename);

View File

@ -102,7 +102,7 @@ static void status_string (WEdit * edit, char *s, int w)
/* The field lengths just prevent the status line from shortening too much */ /* The field lengths just prevent the status line from shortening too much */
g_snprintf (s, w, g_snprintf (s, w,
"[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb)= %s cp:%s", "[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb)= %s %s",
edit->mark1 != edit->mark2 ? ( column_highlighting ? 'C' : 'B') : '-', edit->mark1 != edit->mark2 ? ( column_highlighting ? 'C' : 'B') : '-',
edit->modified ? 'M' : '-', edit->modified ? 'M' : '-',
edit->macro_i < 0 ? '-' : 'R', edit->macro_i < 0 ? '-' : 'R',
@ -117,7 +117,12 @@ static void status_string (WEdit * edit, char *s, int w)
edit->curs1, edit->curs1,
edit->last_byte, edit->last_byte,
byte_str, byte_str,
#ifdef HAVE_CHARSET
get_codepage_id ( source_codepage ) get_codepage_id ( source_codepage )
#else
""
#endif
); );
} }
@ -432,6 +437,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
} }
/* fallthrough */ /* fallthrough */
default: default:
#ifdef HAVE_CHARSET
if ( utf8_display ) { if ( utf8_display ) {
if ( !edit->utf8 ) { if ( !edit->utf8 ) {
c = convert_from_8bit_to_utf_c ((unsigned char) c); c = convert_from_8bit_to_utf_c ((unsigned char) c);
@ -440,9 +446,12 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
if ( edit->utf8 ) { if ( edit->utf8 ) {
c = convert_from_utf_to_current_c (c); c = convert_from_utf_to_current_c (c);
} else { } else {
#endif
c = convert_to_display_c (c); c = convert_to_display_c (c);
#ifdef HAVE_CHARSET
} }
} }
#endif
/* Caret notation for control characters */ /* Caret notation for control characters */
if (c < 32) { if (c < 32) {
p->ch = '^'; p->ch = '^';

View File

@ -247,6 +247,7 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
/* an ordinary insertable character */ /* an ordinary insertable character */
if (x_key < 256 && !extmod) { if (x_key < 256 && !extmod) {
#ifdef HAVE_CHARSET
if ( edit->charpoint >= 4 ) { if ( edit->charpoint >= 4 ) {
edit->charpoint = 0; edit->charpoint = 0;
edit->charbuf[edit->charpoint] = '\0'; edit->charbuf[edit->charpoint] = '\0';
@ -260,11 +261,13 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
if ( !utf8_display ) { if ( !utf8_display ) {
/* source in 8-bit codeset */ /* source in 8-bit codeset */
if (!edit->utf8) { if (!edit->utf8) {
#endif
c = convert_from_input_c (x_key); c = convert_from_input_c (x_key);
if (is_printable (c)) { if (is_printable (c)) {
char_for_insertion = c; char_for_insertion = c;
goto fin; goto fin;
} }
#ifdef HAVE_CHARSET
} else { } else {
//FIXME: need more think about //FIXME: need more think about
//must be return multibyte char but this func return 8bit char //must be return multibyte char but this func return 8bit char
@ -317,6 +320,7 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
} }
} }
} }
#endif
} }
/* Commands specific to the key emulation */ /* Commands specific to the key emulation */

View File

@ -1423,10 +1423,10 @@ set_panel_encoding (WPanel *panel)
char *encoding = NULL; char *encoding = NULL;
char *cd_path; char *cd_path;
#ifdef HAVE_CHARSET
do_select_codepage (); do_select_codepage ();
encoding = g_strdup( get_codepage_id ( source_codepage ) ); encoding = g_strdup( get_codepage_id ( source_codepage ) );
#endif
if (encoding) { if (encoding) {
cd_path = add_encoding_to_path (panel->cwd, encoding); cd_path = add_encoding_to_path (panel->cwd, encoding);
if (!do_panel_cd (MENU_PANEL, cd_path, 0)) if (!do_panel_cd (MENU_PANEL, cd_path, 0))

View File

@ -3657,10 +3657,11 @@ view_select_encoding (WView *view)
GIConv conv; GIConv conv;
struct cache_line *line; struct cache_line *line;
#ifdef HAVE_CHARSET
do_select_codepage (); do_select_codepage ();
enc = g_strdup( get_codepage_id ( source_codepage ) ); enc = g_strdup( get_codepage_id ( source_codepage ) );
if (enc != NULL) { #endif
if ( enc ) {
conv = str_crt_conv_from (enc); conv = str_crt_conv_from (enc);
if (conv != INVALID_CONV) { if (conv != INVALID_CONV) {
if (view->converter != str_cnv_from_term) if (view->converter != str_cnv_from_term)