From e0ce0b02cf278352adb913a70e674b72a45676e2 Mon Sep 17 00:00:00 2001 From: Jindrich Novy Date: Fri, 31 Jul 2009 18:40:04 +0000 Subject: [PATCH] - update to latest GIT mc - forwardport prompt fix and exit patch, keep IPv6 patch and drop the others --- .cvsignore | 2 +- mc-4.6.2-utf8.patch | 7017 ------------------------- mc-64bit.patch | 54 - mc-cedit-configurable-highlight.patch | 363 -- mc-cedit.patch | 16 - mc-delcheck.patch | 15 - mc-edit-segv.patch | 11 - mc-etcmc.patch | 356 -- mc-exit.patch | 17 +- mc-extensions.patch | 272 - mc-hintchk.patch | 15 - mc-lzma.patch | 182 - mc-ministatus.patch | 11 - mc-newlinedir.patch | 12 - mc-oldrpmtags.patch | 14 - mc-prompt.patch | 87 +- mc-refresh.patch | 14 - mc-shellcwd.patch | 13 - mc-showfree.patch | 310 -- mc-spaceprompt.patch | 30 - mc-userhost.patch | 115 - mc.spec | 159 +- sources | 2 +- 23 files changed, 82 insertions(+), 9005 deletions(-) delete mode 100644 mc-4.6.2-utf8.patch delete mode 100644 mc-64bit.patch delete mode 100644 mc-cedit-configurable-highlight.patch delete mode 100644 mc-cedit.patch delete mode 100644 mc-delcheck.patch delete mode 100644 mc-edit-segv.patch delete mode 100644 mc-etcmc.patch delete mode 100644 mc-extensions.patch delete mode 100644 mc-hintchk.patch delete mode 100644 mc-lzma.patch delete mode 100644 mc-ministatus.patch delete mode 100644 mc-newlinedir.patch delete mode 100644 mc-oldrpmtags.patch delete mode 100644 mc-refresh.patch delete mode 100644 mc-shellcwd.patch delete mode 100644 mc-showfree.patch delete mode 100644 mc-spaceprompt.patch delete mode 100644 mc-userhost.patch diff --git a/.cvsignore b/.cvsignore index cbe4b3f..0718c5c 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1 @@ -mc-4.6.2.tar.gz +mc-4.6.99-20090731git.tar.bz2 diff --git a/mc-4.6.2-utf8.patch b/mc-4.6.2-utf8.patch deleted file mode 100644 index 66472af..0000000 --- a/mc-4.6.2-utf8.patch +++ /dev/null @@ -1,7017 +0,0 @@ -diff --git a/acinclude.m4 b/acinclude.m4 -index f4c0e3b..f7f4fd4 100644 ---- a/acinclude.m4 -+++ b/acinclude.m4 -@@ -399,14 +399,14 @@ AC_DEFUN([MC_WITH_SLANG], [ - fi - - dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks -- if test x$with_screen = xslang; then -- : -- m4_if([$1], strict, , -- [AC_CHECK_LIB([slang], [SLsmg_write_nwchars], -- [AC_MSG_WARN([Rejecting S-Lang with UTF-8 support, \ --it's not fully supported yet]) -- with_screen=mcslang])]) -- fi -+dnl if test x$with_screen = xslang; then -+dnl : -+dnl m4_if([$1], strict, , -+dnl [AC_CHECK_LIB([slang], [SLsmg_write_nwchars], -+dnl [AC_MSG_WARN([Rejecting S-Lang with UTF-8 support, \ -+dnl it's not fully supported yet]) -+dnl with_screen=mcslang])]) -+dnl fi - - if test x$with_screen = xslang; then - AC_DEFINE(HAVE_SYSTEM_SLANG, 1, -diff --git a/edit/edit-widget.h b/edit/edit-widget.h -index ab55764..fd51aaa 100644 ---- a/edit/edit-widget.h -+++ b/edit/edit-widget.h -@@ -30,6 +30,11 @@ typedef struct edit_key_map_type { - long command; - } edit_key_map_type; - -+struct action { -+ mc_wchar_t ch; -+ long flags; -+}; -+ - struct WEdit { - Widget widget; - -@@ -42,8 +47,17 @@ struct WEdit { - /* dynamic buffers and cursor position for editor: */ - long curs1; /* position of the cursor from the beginning of the file. */ - long curs2; /* position from the end of the file */ -+#ifndef UTF8 - unsigned char *buffers1[MAXBUFF + 1]; /* all data up to curs1 */ - unsigned char *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */ -+#else /* UTF8 */ -+ mc_wchar_t *buffers1[MAXBUFF + 1]; /* all data up to curs1 */ -+ mc_wchar_t *buffers2[MAXBUFF + 1]; /* all data from end of file down to curs2 */ -+ -+ unsigned char charbuf[MB_LEN_MAX]; -+ int charpoint; -+#endif /* UTF8 */ -+ - - /* search variables */ - long search_start; /* First character to start searching from */ -@@ -87,7 +101,7 @@ struct WEdit { - - /* undo stack and pointers */ - unsigned long stack_pointer; -- long *undo_stack; -+ struct action *undo_stack; - unsigned long stack_size; - unsigned long stack_size_mask; - unsigned long stack_bottom; -diff --git a/edit/edit.c b/edit/edit.c -index bec84d7..8df473b 100644 ---- a/edit/edit.c -+++ b/edit/edit.c -@@ -105,7 +105,11 @@ char *option_backup_ext = NULL; - - static void user_menu (WEdit *edit); - -+#ifndef UTF8 - int edit_get_byte (WEdit * edit, long byte_index) -+#else -+mc_wchar_t edit_get_byte (WEdit * edit, long byte_index) -+#endif - { - unsigned long p; - if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0) -@@ -134,7 +138,7 @@ edit_init_buffers (WEdit *edit) - - edit->curs1 = 0; - edit->curs2 = 0; -- edit->buffers2[0] = g_malloc (EDIT_BUF_SIZE); -+ edit->buffers2[0] = g_malloc (EDIT_BUF_SIZE * sizeof(mc_wchar_t)); - } - - /* -@@ -159,7 +163,7 @@ edit_load_file_fast (WEdit *edit, const char *filename) - } - - if (!edit->buffers2[buf2]) -- edit->buffers2[buf2] = g_malloc (EDIT_BUF_SIZE); -+ edit->buffers2[buf2] = g_malloc (EDIT_BUF_SIZE * sizeof(mc_wchar_t)); - - mc_read (file, - (char *) edit->buffers2[buf2] + EDIT_BUF_SIZE - -@@ -169,7 +173,7 @@ edit_load_file_fast (WEdit *edit, const char *filename) - for (buf = buf2 - 1; buf >= 0; buf--) { - /* edit->buffers2[0] is already allocated */ - if (!edit->buffers2[buf]) -- edit->buffers2[buf] = g_malloc (EDIT_BUF_SIZE); -+ edit->buffers2[buf] = g_malloc (EDIT_BUF_SIZE * sizeof(mc_wchar_t)); - mc_read (file, (char *) edit->buffers2[buf], EDIT_BUF_SIZE); - } - -@@ -242,9 +246,44 @@ edit_insert_stream (WEdit * edit, FILE * f) - { - int c; - long i = 0; -- while ((c = fgetc (f)) >= 0) { -+#ifndef UTF8 -+ while ((c = fgetc (f)) != EOF) { - edit_insert (edit, c); - i++; -+#else /* UTF8 */ -+ unsigned char buf[MB_LEN_MAX]; -+ int charpos = 0; -+ mbstate_t mbs; -+ -+ while ((c = fgetc (f)) != EOF) { -+ mc_wchar_t wc; -+ int size; -+ int j; -+ -+ buf[charpos++] = c; -+ -+ memset (&mbs, 0, sizeof (mbs)); -+ size = mbrtowc(&wc, (char *)buf, charpos, &mbs); -+ -+ if (size == -2) -+ continue; /* incomplete */ -+ -+ else if (size >= 0) { -+ edit_insert (edit, wc); -+ i++; -+ charpos = 0; -+ continue; -+ } -+ else { -+ -+ /* invalid */ -+#ifdef __STDC_ISO_10646__ -+ for (j=0; jlast_byte; i++) - if (fputc (edit_get_byte (edit, i), f) < 0) - break; -+#else /* UTF8 */ -+ for (i = 0; i < edit->last_byte; i++) { -+ mc_wchar_t wc = edit_get_byte (edit, i); -+ int res; -+ char tmpbuf[MB_LEN_MAX]; -+ mbstate_t mbs; -+ -+ memset (&mbs, 0, sizeof (mbs)); -+ -+#ifdef __STDC_ISO_10646__ -+ if (wc >= BINARY_CHAR_OFFSET && wc < (BINARY_CHAR_OFFSET + 256)) { -+ res = 1; -+ tmpbuf[0] = (char) (wc - BINARY_CHAR_OFFSET); -+ } else -+#endif -+ res = wcrtomb(tmpbuf, wc, &mbs); -+ if (res > 0) { -+ if (fwrite(tmpbuf, res, 1, f) != 1) -+ break; -+ } -+ } -+#endif /* UTF8 */ - return i; - } - -@@ -293,12 +355,46 @@ edit_insert_file (WEdit *edit, const char *filename) - int i, file, blocklen; - long current = edit->curs1; - unsigned char *buf; -+#ifdef UTF8 -+ mbstate_t mbs; -+ int bufstart = 0; -+ -+ memset (&mbs, 0, sizeof (mbs)); -+#endif /* UTF8 */ - if ((file = mc_open (filename, O_RDONLY | O_BINARY)) == -1) - return 0; - buf = g_malloc (TEMP_BUF_LEN); -+#ifndef UTF8 - while ((blocklen = mc_read (file, (char *) buf, TEMP_BUF_LEN)) > 0) { - for (i = 0; i < blocklen; i++) - edit_insert (edit, buf[i]); -+#else /* UTF8 */ -+ while ((blocklen = mc_read (file, (char *) buf + bufstart, TEMP_BUF_LEN - bufstart)) > 0) { -+ blocklen += bufstart; -+ bufstart = 0; -+ for (i = 0; i < blocklen; ) { -+ mc_wchar_t wc; -+ int j; -+ int size = mbrtowc(&wc, (char *)buf + i, blocklen - i, &mbs); -+ if (size == -2) { /*incomplete char*/ -+ bufstart = blocklen - i; -+ memcpy(buf, buf+i, bufstart); -+ i = blocklen; -+ memset (&mbs, 0, sizeof (mbs)); -+ } -+ else if (size <= 0) { -+#ifdef __STDC_ISO_10646__ -+ edit_insert (edit, BINARY_CHAR_OFFSET + (mc_wchar_t)buf[i]); -+#endif -+ memset (&mbs, 0, sizeof (mbs)); -+ i++; /* skip broken char */ -+ } -+ else { -+ edit_insert (edit, wc); -+ i+=size; -+ } -+ } -+#endif /* UTF8 */ - } - edit_cursor_move (edit, current - edit->curs1); - g_free (buf); -@@ -388,7 +484,11 @@ cleanup: - static int - edit_load_file (WEdit *edit) - { -+#ifndef UTF8 - int fast_load = 1; -+#else /* UTF8 */ -+ int fast_load = 0; /* can't be used with multibyte characters */ -+#endif /* UTF8 */ - - /* Cannot do fast load if a filter is used */ - if (edit_find_filter (edit->filename) >= 0) -@@ -454,6 +554,7 @@ edit_load_position (WEdit *edit) - edit->prev_col = column; - edit_move_to_prev_col (edit, edit_bol (edit, edit->curs1)); - edit_move_display (edit, line - (edit->num_widget_lines / 2)); -+ edit->charpoint = 0; - } - - /* Save cursor position in the file */ -@@ -537,7 +638,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename, - edit_set_filename (edit, filename); - edit->stack_size = START_STACK_SIZE; - edit->stack_size_mask = START_STACK_SIZE - 1; -- edit->undo_stack = g_malloc ((edit->stack_size + 10) * sizeof (long)); -+ edit->undo_stack = g_malloc ((edit->stack_size + 10) * sizeof (struct action)); - if (edit_load_file (edit)) { - /* edit_load_file already gives an error message */ - if (to_free) -@@ -692,14 +793,23 @@ void edit_push_action (WEdit * edit, long c,...) - { - unsigned long sp = edit->stack_pointer; - unsigned long spm1; -- long *t; -+ -+ struct action *t; -+ mc_wchar_t ch = 0; -+ -+ if (c == CHAR_INSERT || c == CHAR_INSERT_AHEAD) { -+ va_list ap; -+ va_start (ap, c); -+ ch = va_arg (ap, mc_wint_t); -+ va_end (ap); -+ } - - /* first enlarge the stack if necessary */ - if (sp > edit->stack_size - 10) { /* say */ - if (option_max_undo < 256) - option_max_undo = 256; - if (edit->stack_size < (unsigned long) option_max_undo) { -- t = g_realloc (edit->undo_stack, (edit->stack_size * 2 + 10) * sizeof (long)); -+ t = g_realloc (edit->undo_stack, (edit->stack_size * 2 + 10) * sizeof (struct action)); - if (t) { - edit->undo_stack = t; - edit->stack_size <<= 1; -@@ -714,7 +824,7 @@ void edit_push_action (WEdit * edit, long c,...) - #ifdef FAST_MOVE_CURSOR - if (c == CURS_LEFT_LOTS || c == CURS_RIGHT_LOTS) { - va_list ap; -- edit->undo_stack[sp] = c == CURS_LEFT_LOTS ? CURS_LEFT : CURS_RIGHT; -+ edit->undo_stack[sp].flags = c == CURS_LEFT_LOTS ? CURS_LEFT : CURS_RIGHT; - edit->stack_pointer = (edit->stack_pointer + 1) & edit->stack_size_mask; - va_start (ap, c); - c = -(va_arg (ap, int)); -@@ -725,12 +835,14 @@ void edit_push_action (WEdit * edit, long c,...) - && spm1 != edit->stack_bottom - && ((sp - 2) & edit->stack_size_mask) != edit->stack_bottom) { - int d; -- if (edit->undo_stack[spm1] < 0) { -- d = edit->undo_stack[(sp - 2) & edit->stack_size_mask]; -- if (d == c) { -- if (edit->undo_stack[spm1] > -1000000000) { -+ mc_wchar_t d_ch; -+ if (edit->undo_stack[spm1].flags < 0) { -+ d = edit->undo_stack[(sp - 2) & edit->stack_size_mask].flags; -+ d_ch = edit->undo_stack[(sp - 2) & edit->stack_size_mask].ch; -+ if (d == c && d_ch == ch) { -+ if (edit->undo_stack[spm1].flags > -1000000000) { - if (c < KEY_PRESS) /* --> no need to push multiple do-nothings */ -- edit->undo_stack[spm1]--; -+ edit->undo_stack[spm1].flags--; - return; - } - } -@@ -738,19 +850,20 @@ void edit_push_action (WEdit * edit, long c,...) - #ifndef NO_STACK_CURSMOVE_ANIHILATION - else if ((c == CURS_LEFT && d == CURS_RIGHT) - || (c == CURS_RIGHT && d == CURS_LEFT)) { /* a left then a right anihilate each other */ -- if (edit->undo_stack[spm1] == -2) -+ if (edit->undo_stack[spm1].flags == -2) - edit->stack_pointer = spm1; - else -- edit->undo_stack[spm1]++; -+ edit->undo_stack[spm1].flags++; - return; - } - #endif - } else { -- d = edit->undo_stack[spm1]; -- if (d == c) { -+ d = edit->undo_stack[spm1].flags; -+ d_ch = edit->undo_stack[spm1].ch; -+ if (d == c && d_ch == ch) { - if (c >= KEY_PRESS) - return; /* --> no need to push multiple do-nothings */ -- edit->undo_stack[sp] = -2; -+ edit->undo_stack[sp].flags = -2; - goto check_bottom; - } - #ifndef NO_STACK_CURSMOVE_ANIHILATION -@@ -762,7 +875,9 @@ void edit_push_action (WEdit * edit, long c,...) - #endif - } - } -- edit->undo_stack[sp] = c; -+ edit->undo_stack[sp].flags = c; -+ edit->undo_stack[sp].ch = ch; -+ - check_bottom: - - edit->stack_pointer = (edit->stack_pointer + 1) & edit->stack_size_mask; -@@ -775,10 +890,10 @@ void edit_push_action (WEdit * edit, long c,...) - (((unsigned long) c + 1) & edit->stack_size_mask) == edit->stack_bottom) - do { - edit->stack_bottom = (edit->stack_bottom + 1) & edit->stack_size_mask; -- } while (edit->undo_stack[edit->stack_bottom] < KEY_PRESS && edit->stack_bottom != edit->stack_pointer); -+ } while (edit->undo_stack[edit->stack_bottom].flags < KEY_PRESS && edit->stack_bottom != edit->stack_pointer); - - /*If a single key produced enough pushes to wrap all the way round then we would notice that the [stack_bottom] does not contain KEY_PRESS. The stack is then initialised: */ -- if (edit->stack_pointer != edit->stack_bottom && edit->undo_stack[edit->stack_bottom] < KEY_PRESS) -+ if (edit->stack_pointer != edit->stack_bottom && edit->undo_stack[edit->stack_bottom].flags < KEY_PRESS) - edit->stack_bottom = edit->stack_pointer = 0; - } - -@@ -787,30 +902,30 @@ void edit_push_action (WEdit * edit, long c,...) - then the file should be as it was when he loaded up. Then set edit->modified to 0. - */ - static long --pop_action (WEdit * edit) -+pop_action (WEdit * edit, struct action *c) - { -- long c; - unsigned long sp = edit->stack_pointer; - if (sp == edit->stack_bottom) { -- return STACK_BOTTOM; -+ c->flags = STACK_BOTTOM; -+ return c->flags; - } - sp = (sp - 1) & edit->stack_size_mask; -- if ((c = edit->undo_stack[sp]) >= 0) { --/* edit->undo_stack[sp] = '@'; */ -+ *c = edit->undo_stack[sp]; -+ if (edit->undo_stack[sp].flags >= 0) { - edit->stack_pointer = (edit->stack_pointer - 1) & edit->stack_size_mask; -- return c; -+ return c->flags; - } - if (sp == edit->stack_bottom) { - return STACK_BOTTOM; - } -- c = edit->undo_stack[(sp - 1) & edit->stack_size_mask]; -- if (edit->undo_stack[sp] == -2) { --/* edit->undo_stack[sp] = '@'; */ -+ *c = edit->undo_stack[(sp - 1) & edit->stack_size_mask]; -+ -+ if (edit->undo_stack[sp].flags == -2) { - edit->stack_pointer = sp; - } else -- edit->undo_stack[sp]++; -+ edit->undo_stack[sp].flags++; - -- return c; -+ return c->flags; - } - - /* is called whenever a modification is made by one of the four routines below */ -@@ -831,7 +946,7 @@ static inline void edit_modification (WEdit * edit) - */ - - void --edit_insert (WEdit *edit, int c) -+edit_insert (WEdit *edit, mc_wchar_t c) - { - /* check if file has grown to large */ - if (edit->last_byte >= SIZE_LIMIT) -@@ -869,12 +984,11 @@ edit_insert (WEdit *edit, int c) - /* add a new buffer if we've reached the end of the last one */ - if (!(edit->curs1 & M_EDIT_BUF_SIZE)) - edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = -- g_malloc (EDIT_BUF_SIZE); -+ g_malloc (EDIT_BUF_SIZE * sizeof(mc_wchar_t)); - - /* perform the insertion */ -- edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE][edit-> -- curs1 & M_EDIT_BUF_SIZE] -- = (unsigned char) c; -+ edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] -+ [edit->curs1 & M_EDIT_BUF_SIZE] = c; - - /* update file length */ - edit->last_byte++; -@@ -885,7 +999,7 @@ edit_insert (WEdit *edit, int c) - - - /* same as edit_insert and move left */ --void edit_insert_ahead (WEdit * edit, int c) -+void edit_insert_ahead (WEdit * edit, mc_wchar_t c) - { - if (edit->last_byte >= SIZE_LIMIT) - return; -@@ -908,7 +1022,7 @@ void edit_insert_ahead (WEdit * edit, int c) - edit->last_get_rule += (edit->last_get_rule >= edit->curs1); - - if (!((edit->curs2 + 1) & M_EDIT_BUF_SIZE)) -- edit->buffers2[(edit->curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE); -+ edit->buffers2[(edit->curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE * sizeof(mc_wchar_t)); - edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - (edit->curs2 & M_EDIT_BUF_SIZE) - 1] = c; - - edit->last_byte++; -@@ -918,7 +1032,7 @@ void edit_insert_ahead (WEdit * edit, int c) - - int edit_delete (WEdit * edit) - { -- int p; -+ mc_wint_t p; - if (!edit->curs2) - return 0; - -@@ -942,7 +1056,7 @@ int edit_delete (WEdit * edit) - edit->total_lines--; - edit->force |= REDRAW_AFTER_CURSOR; - } -- edit_push_action (edit, p + 256); -+ edit_push_action (edit, CHAR_INSERT_AHEAD, p); - if (edit->curs1 < edit->start_display) { - edit->start_display--; - if (p == '\n') -@@ -956,7 +1070,7 @@ int edit_delete (WEdit * edit) - static int - edit_backspace (WEdit * edit) - { -- int p; -+ mc_wint_t p; - if (!edit->curs1) - return 0; - -@@ -980,7 +1094,7 @@ edit_backspace (WEdit * edit) - edit->total_lines--; - edit->force |= REDRAW_AFTER_CURSOR; - } -- edit_push_action (edit, p); -+ edit_push_action (edit, CHAR_INSERT, p); - - if (edit->curs1 < edit->start_display) { - edit->start_display--; -@@ -993,10 +1107,18 @@ edit_backspace (WEdit * edit) - - #ifdef FAST_MOVE_CURSOR - --static void memqcpy (WEdit * edit, unsigned char *dest, unsigned char *src, int n) -+static void memqcpy (WEdit * edit, mc_wchar_t *dest, mc_wchar_t *src, int n) - { - unsigned long next; -+#ifndef UTF8 - while ((next = (unsigned long) memccpy (dest, src, '\n', n))) { -+#else /* UTF8 */ -+ while (n) { -+ next = 0; -+ while (next < n && src[next]!='\n') next++; -+ if (next < n) next++; -+ wmemcpy (dest, src, next) -+#endif /* UTF8 */ - edit->curs_line--; - next -= (unsigned long) dest; - n -= next; -@@ -1009,7 +1131,7 @@ int - edit_move_backward_lots (WEdit *edit, long increment) - { - int r, s, t; -- unsigned char *p; -+ mc_wchar_t *p; - - if (increment > edit->curs1) - increment = edit->curs1; -@@ -1049,7 +1171,7 @@ edit_move_backward_lots (WEdit *edit, long increment) - edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = p; - else - edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = -- g_malloc (EDIT_BUF_SIZE); -+ g_malloc (EDIT_BUF_SIZE * sizeof(mc_wchar_t)); - } else { - g_free (p); - } -@@ -1087,7 +1209,7 @@ edit_move_backward_lots (WEdit *edit, long increment) - edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = p; - else - edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE] = -- g_malloc (EDIT_BUF_SIZE); -+ g_malloc (EDIT_BUF_SIZE * sizeof(mc_wchar_t)); - } else { - g_free (p); - } -@@ -1120,7 +1242,7 @@ void edit_cursor_move (WEdit * edit, long increment) - - c = edit_get_byte (edit, edit->curs1 - 1); - if (!((edit->curs2 + 1) & M_EDIT_BUF_SIZE)) -- edit->buffers2[(edit->curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE); -+ edit->buffers2[(edit->curs2 + 1) >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE * sizeof(mc_wchar_t)); - edit->buffers2[edit->curs2 >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - (edit->curs2 & M_EDIT_BUF_SIZE) - 1] = c; - edit->curs2++; - c = edit->buffers1[(edit->curs1 - 1) >> S_EDIT_BUF_SIZE][(edit->curs1 - 1) & M_EDIT_BUF_SIZE]; -@@ -1144,7 +1266,7 @@ void edit_cursor_move (WEdit * edit, long increment) - - c = edit_get_byte (edit, edit->curs1); - if (!(edit->curs1 & M_EDIT_BUF_SIZE)) -- edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE); -+ edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE] = g_malloc (EDIT_BUF_SIZE * sizeof(mc_wchar_t)); - edit->buffers1[edit->curs1 >> S_EDIT_BUF_SIZE][edit->curs1 & M_EDIT_BUF_SIZE] = c; - edit->curs1++; - c = edit->buffers2[(edit->curs2 - 1) >> S_EDIT_BUF_SIZE][EDIT_BUF_SIZE - ((edit->curs2 - 1) & M_EDIT_BUF_SIZE) - 1]; -@@ -1249,7 +1371,7 @@ long edit_move_forward3 (WEdit * edit, long current, int cols, long upto) - q = edit->last_byte + 2; - - for (col = 0, p = current; p < q; p++) { -- int c; -+ mc_wchar_t c; - if (cols != -10) { - if (col == cols) - return p; -@@ -1267,7 +1389,7 @@ long edit_move_forward3 (WEdit * edit, long current, int cols, long upto) - } else if (c < 32 || c == 127) - col += 2; /* Caret notation for control characters */ - else -- col++; -+ col += wcwidth(c); - } - return col; - } -@@ -1400,12 +1522,16 @@ static int - is_blank (WEdit *edit, long offset) - { - long s, f; -- int c; -+ mc_wchar_t c; - s = edit_bol (edit, offset); - f = edit_eol (edit, offset) - 1; - while (s <= f) { - c = edit_get_byte (edit, s++); -+#ifndef UTF8 - if (!isspace (c)) -+#else -+ if (!iswspace (c)) -+#endif /* UTF8 */ - return 0; - } - return 1; -@@ -1660,6 +1786,7 @@ my_type_of (int c) - return 2; - return 0x80000000UL; - } -+#ifndef UTF8 - if (isupper (c)) - c = 'A'; - else if (islower (c)) -@@ -1670,6 +1797,18 @@ my_type_of (int c) - c = '0'; - else if (isspace (c)) - c = ' '; -+#else -+ if (iswupper (c)) -+ c = 'A'; -+ else if (iswlower (c)) -+ c = 'a'; -+ else if (iswalpha (c)) -+ c = 'a'; -+ else if (iswdigit (c)) -+ c = '0'; -+ else if (iswspace (c)) -+ c = ' '; -+#endif /* UTF8 */ - q = strchr (option_chars_move_whole_word, c); - if (!q) - return 0xFFFFFFFFUL; -@@ -1694,10 +1833,18 @@ edit_left_word_move (WEdit *edit, int s) - c2 = edit_get_byte (edit, edit->curs1); - if (!(my_type_of (c1) & my_type_of (c2))) - break; -+#ifndef UTF8 - if (isspace (c1) && !isspace (c2)) -+#else -+ if (iswspace (c1) && !iswspace (c2)) -+#endif /* UTF8 */ - break; - if (s) -+#ifndef UTF8 - if (!isspace (c1) && isspace (c2)) -+#else -+ if (!iswspace (c1) && iswspace (c2)) -+#endif /* UTF8 */ - break; - } - } -@@ -1720,10 +1867,18 @@ edit_right_word_move (WEdit *edit, int s) - c2 = edit_get_byte (edit, edit->curs1); - if (!(my_type_of (c1) & my_type_of (c2))) - break; -+#ifndef UTF8 - if (isspace (c1) && !isspace (c2)) -+#else -+ if (iswspace (c1) && !iswspace (c2)) -+#endif /* UTF8 */ - break; - if (s) -+#ifndef UTF8 - if (!isspace (c1) && isspace (c2)) -+#else -+ if (!iswspace (c1) && iswspace (c2)) -+#endif /* UTF8 */ - break; - } - } -@@ -1743,7 +1898,11 @@ static void edit_right_delete_word (WEdit * edit) - break; - c1 = edit_delete (edit); - c2 = edit_get_byte (edit, edit->curs1); -+#ifndef UTF8 - if ((isspace (c1) == 0) != (isspace (c2) == 0)) -+#else -+ if ((iswspace (c1) == 0) != (iswspace (c2) == 0)) -+#endif /* UTF8 */ - break; - if (!(my_type_of (c1) & my_type_of (c2))) - break; -@@ -1758,7 +1917,11 @@ static void edit_left_delete_word (WEdit * edit) - break; - c1 = edit_backspace (edit); - c2 = edit_get_byte (edit, edit->curs1 - 1); -+#ifndef UTF8 - if ((isspace (c1) == 0) != (isspace (c2) == 0)) -+#else -+ if ((iswspace (c1) == 0) != (iswspace (c2) == 0)) -+#endif /* UTF8 */ - break; - if (!(my_type_of (c1) & my_type_of (c2))) - break; -@@ -1772,13 +1935,13 @@ static void edit_left_delete_word (WEdit * edit) - static void - edit_do_undo (WEdit * edit) - { -- long ac; -+ struct action ac; - long count = 0; - - edit->stack_disable = 1; /* don't record undo's onto undo stack! */ - -- while ((ac = pop_action (edit)) < KEY_PRESS) { -- switch ((int) ac) { -+ while (pop_action (edit, &ac) < KEY_PRESS) { -+ switch ((int) ac.flags) { - case STACK_BOTTOM: - goto done_undo; - case CURS_RIGHT: -@@ -1799,31 +1962,33 @@ edit_do_undo (WEdit * edit) - case COLUMN_OFF: - column_highlighting = 0; - break; -+ case CHAR_INSERT: -+ edit_insert (edit, ac.ch); -+ break; -+ case CHAR_INSERT_AHEAD: -+ edit_insert_ahead (edit, ac.ch); -+ break; - } -- if (ac >= 256 && ac < 512) -- edit_insert_ahead (edit, ac - 256); -- if (ac >= 0 && ac < 256) -- edit_insert (edit, ac); - -- if (ac >= MARK_1 - 2 && ac < MARK_2 - 2) { -- edit->mark1 = ac - MARK_1; -+ if (ac.flags >= MARK_1 - 2 && ac.flags < MARK_2 - 2) { -+ edit->mark1 = ac.flags - MARK_1; - edit->column1 = edit_move_forward3 (edit, edit_bol (edit, edit->mark1), 0, edit->mark1); -- } else if (ac >= MARK_2 - 2 && ac < KEY_PRESS) { -- edit->mark2 = ac - MARK_2; -+ } else if (ac.flags >= MARK_2 - 2 && ac.flags < KEY_PRESS) { -+ edit->mark2 = ac.flags - MARK_2; - edit->column2 = edit_move_forward3 (edit, edit_bol (edit, edit->mark2), 0, edit->mark2); - } - if (count++) - edit->force |= REDRAW_PAGE; /* more than one pop usually means something big */ - } - -- if (edit->start_display > ac - KEY_PRESS) { -- edit->start_line -= edit_count_lines (edit, ac - KEY_PRESS, edit->start_display); -+ if (edit->start_display > ac.flags - KEY_PRESS) { -+ edit->start_line -= edit_count_lines (edit, ac.flags - KEY_PRESS, edit->start_display); - edit->force |= REDRAW_PAGE; -- } else if (edit->start_display < ac - KEY_PRESS) { -- edit->start_line += edit_count_lines (edit, edit->start_display, ac - KEY_PRESS); -+ } else if (edit->start_display < ac.flags - KEY_PRESS) { -+ edit->start_line += edit_count_lines (edit, edit->start_display, ac.flags - KEY_PRESS); - edit->force |= REDRAW_PAGE; - } -- edit->start_display = ac - KEY_PRESS; /* see push and pop above */ -+ edit->start_display = ac.flags - KEY_PRESS; /* see push and pop above */ - edit_update_curs_row (edit); - - done_undo:; -@@ -2103,7 +2268,7 @@ static void edit_goto_matching_bracket (WEdit *edit) - * passed as -1. Commands are executed, and char_for_insertion is - * inserted at the cursor. - */ --void edit_execute_key_command (WEdit *edit, int command, int char_for_insertion) -+void edit_execute_key_command (WEdit *edit, int command, mc_wint_t char_for_insertion) - { - if (command == CK_Begin_Record_Macro) { - edit->macro_i = 0; -@@ -2138,7 +2303,7 @@ static const char * const shell_cmd[] = SHELL_COMMANDS_i; - all of them. It also does not check for the Undo command. - */ - void --edit_execute_cmd (WEdit *edit, int command, int char_for_insertion) -+edit_execute_cmd (WEdit *edit, int command, mc_wint_t char_for_insertion) - { - edit->force |= REDRAW_LINE; - -@@ -2171,7 +2336,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion) - } - - /* An ordinary key press */ -- if (char_for_insertion >= 0) { -+ if (char_for_insertion != (mc_wint_t) -1) { - if (edit->overwrite) { - if (edit_get_byte (edit, edit->curs1) != '\n') - edit_delete (edit); -diff --git a/edit/edit.h b/edit/edit.h -index 4a1c39b..672bf3d 100644 ---- a/edit/edit.h -+++ b/edit/edit.h -@@ -25,6 +25,27 @@ - - #include - -+#include "src/tty.h" -+ -+#ifdef UTF8 -+#include -+#include -+ -+#define mc_wchar_t wchar_t -+#define mc_wint_t wint_t -+ -+#else -+ -+#define mc_wchar_t unsigned char -+#define mc_wint_t int -+ -+#endif -+ -+ -+/* unicode private use area */ -+#define BINARY_CHAR_OFFSET 0xFFE00 -+ -+ - #define N_menus 5 - - #define SEARCH_DIALOG_OPTION_NO_SCANF (1 << 0) -@@ -86,6 +107,8 @@ - #define START_STACK_SIZE 32 - - /* Some codes that may be pushed onto or returned from the undo stack */ -+#define CHAR_INSERT 65 -+#define CHAR_INSERT_AHEAD 66 - #define CURS_LEFT 601 - #define CURS_RIGHT 602 - #define DELCHAR 603 -@@ -105,7 +128,7 @@ - - struct macro { - short command; -- short ch; -+ mc_wchar_t ch; - }; - - struct WEdit; -@@ -120,8 +143,12 @@ void edit_reload_menu (void); - void menu_save_mode_cmd (void); - int edit_raw_key_query (const char *heading, const char *query, int cancel); - int edit_file (const char *_file, int line); --int edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch); -+int edit_translate_key (WEdit *edit, long x_key, int *cmd, mc_wint_t *ch); -+#ifndef UTF8 - int edit_get_byte (WEdit * edit, long byte_index); -+#else /* UTF8 */ -+mc_wchar_t edit_get_byte (WEdit * edit, long byte_index); -+#endif /* UTF8 */ - int edit_count_lines (WEdit * edit, long current, int upto); - long edit_move_forward (WEdit * edit, long current, int lines, long upto); - long edit_move_forward3 (WEdit * edit, long current, int cols, long upto); -@@ -148,11 +175,11 @@ int edit_block_delete_cmd (WEdit * edit); - void edit_delete_line (WEdit * edit); - - int edit_delete (WEdit * edit); --void edit_insert (WEdit * edit, int c); -+void edit_insert (WEdit * edit, mc_wchar_t c); - void edit_cursor_move (WEdit * edit, long increment); - void edit_push_action (WEdit * edit, long c, ...); - void edit_push_key_press (WEdit * edit); --void edit_insert_ahead (WEdit * edit, int c); -+void edit_insert_ahead (WEdit * edit, mc_wchar_t c); - long edit_write_stream (WEdit * edit, FILE * f); - char *edit_get_write_filter (const char *writename, const char *filename); - int edit_save_confirm_cmd (WEdit * edit); -@@ -183,7 +210,7 @@ void edit_goto_cmd (WEdit * edit); - int eval_marks (WEdit * edit, long *start_mark, long *end_mark); - void edit_status (WEdit * edit); - void edit_execute_key_command (WEdit *edit, int command, -- int char_for_insertion); -+ mc_wint_t char_for_insertion); - void edit_update_screen (WEdit * edit); - int edit_print_string (WEdit * e, const char *s); - void edit_move_to_line (WEdit * e, long line); -@@ -233,7 +260,7 @@ void edit_mail_dialog (WEdit *edit); - void format_paragraph (WEdit *edit, int force); - - /* either command or char_for_insertion must be passed as -1 */ --void edit_execute_cmd (WEdit *edit, int command, int char_for_insertion); -+void edit_execute_cmd (WEdit *edit, int command, mc_wint_t char_for_insertion); - - #define get_sys_error(s) (s) - -diff --git a/edit/editcmd.c b/edit/editcmd.c -index d223c35..b85d9cd 100644 ---- a/edit/editcmd.c -+++ b/edit/editcmd.c -@@ -60,7 +60,7 @@ - #include "../src/selcodepage.h" - - struct selection { -- unsigned char * text; -+ mc_wchar_t *text; - int len; - }; - -@@ -83,21 +83,16 @@ int edit_confirm_save = 1; - #define MAX_REPL_LEN 1024 - - static int edit_save_cmd (WEdit *edit); --static unsigned char *edit_get_block (WEdit *edit, long start, -+static mc_wchar_t *edit_get_block (WEdit *edit, long start, - long finish, int *l); - --static inline int my_lower_case (int c) -+static inline mc_wchar_t my_lower_case (mc_wchar_t c) - { -+#ifndef UTF8 - return tolower(c & 0xFF); --} -- --static const char * --strcasechr (const char *s, int c) --{ -- for (c = my_lower_case (c); my_lower_case ((int) *s) != c; ++s) -- if (*s == '\0') -- return 0; -- return s; -+#else -+ return towlower(c); -+#endif - } - - #ifndef HAVE_MEMMOVE -@@ -123,11 +118,11 @@ static void *memmove (void *dest, const void *src, size_t n) - #endif /* !HAVE_MEMMOVE */ - - /* #define itoa MY_itoa <---- this line is now in edit.h */ --static char * -+static mc_wchar_t * - MY_itoa (int i) - { -- static char t[14]; -- char *s = t + 13; -+ static mc_wchar_t t[14]; -+ mc_wchar_t *s = t + 13; - int j = i; - *s-- = 0; - do { -@@ -212,6 +207,48 @@ void edit_refresh_cmd (WEdit * edit) - doupdate(); - } - -+#ifdef UTF8 -+ -+static size_t -+wchar_write(int fd, mc_wchar_t *buf, size_t len) -+{ -+ char *tmpbuf = g_malloc(len + MB_LEN_MAX); -+ mbstate_t mbs; -+ size_t i; -+ size_t outlen = 0; -+ size_t res; -+ -+ for (i = 0; i < len; i++) { -+ if (outlen >= len) { -+ if ((res = mc_write(fd, tmpbuf, outlen)) != outlen) { -+ g_free(tmpbuf); -+ return -1; -+ } -+ outlen = 0; -+ } -+ memset (&mbs, 0, sizeof (mbs)); -+#ifdef __STDC_ISO_10646__ -+ if (buf[i] >= BINARY_CHAR_OFFSET && buf[i] < (BINARY_CHAR_OFFSET + 256)) { -+ res = 1; -+ tmpbuf[outlen] = (char) (buf[i] - BINARY_CHAR_OFFSET); -+ -+ } else -+#endif -+ res = wcrtomb(tmpbuf + outlen, buf[i], &mbs); -+ if (res > 0) { -+ outlen += res; -+ } -+ } -+ if ((res = mc_write(fd, tmpbuf, outlen)) != outlen) { -+ g_free(tmpbuf); -+ return -1; -+ } -+ g_free(tmpbuf); -+ return len; -+} -+ -+#endif /* UTF8 */ -+ - /* If 0 (quick save) then a) create/truncate file, - b) save to ; - if 1 (safe save) then a) save to , -@@ -359,32 +396,48 @@ edit_save_file (WEdit *edit, const char *filename) - buf = 0; - filelen = edit->last_byte; - while (buf <= (edit->curs1 >> S_EDIT_BUF_SIZE) - 1) { -+#ifndef UTF8 - if (mc_write (fd, (char *) edit->buffers1[buf], EDIT_BUF_SIZE) -+#else /* UTF8 */ -+ if (wchar_write (fd, edit->buffers1[buf], EDIT_BUF_SIZE) -+#endif /* UTF8 */ - != EDIT_BUF_SIZE) { - mc_close (fd); - goto error_save; - } - buf++; - } -+#ifndef UTF8 - if (mc_write - (fd, (char *) edit->buffers1[buf], -+#else /* UTF8 */ -+ if (wchar_write -+ (fd, edit->buffers1[buf], -+#endif /* UTF8 */ - edit->curs1 & M_EDIT_BUF_SIZE) != - (edit->curs1 & M_EDIT_BUF_SIZE)) { - filelen = -1; - } else if (edit->curs2) { - edit->curs2--; - buf = (edit->curs2 >> S_EDIT_BUF_SIZE); -- if (mc_write -- (fd, -- (char *) edit->buffers2[buf] + EDIT_BUF_SIZE - -+#ifndef UTF8 -+ if (mc_write(fd, (char *) edit->buffers2[buf] + EDIT_BUF_SIZE - -+#else /* UTF8 */ -+ if (wchar_write(fd, edit->buffers2[buf] + EDIT_BUF_SIZE - -+#endif /* UTF8 */ - (edit->curs2 & M_EDIT_BUF_SIZE) - 1, - 1 + (edit->curs2 & M_EDIT_BUF_SIZE)) != - 1 + (edit->curs2 & M_EDIT_BUF_SIZE)) { - filelen = -1; - } else { - while (--buf >= 0) { -+#ifndef UTF8 - if (mc_write - (fd, (char *) edit->buffers2[buf], -+#else /* UTF8 */ -+ if (wchar_write -+ (fd, edit->buffers2[buf], -+#endif /* UTF8 */ - EDIT_BUF_SIZE) != EDIT_BUF_SIZE) { - filelen = -1; - break; -@@ -705,13 +758,21 @@ edit_delete_macro (WEdit * edit, int k) - if (!n || n == EOF) - break; - n = 0; -+#ifndef UTF8 - while (fscanf (f, "%hd %hd, ", ¯o[n].command, ¯o[n].ch)) -+#else /* UTF8 */ -+ while (fscanf (f, "%hd %lu, ", ¯o[n].command, ¯o[n].ch)) -+#endif /* UTF8 */ - n++; - fscanf (f, ";\n"); - if (s != k) { - fprintf (g, ("key '%d 0': "), s); - for (i = 0; i < n; i++) -+#ifndef UTF8 - fprintf (g, "%hd %hd, ", macro[i].command, macro[i].ch); -+#else /* UTF8 */ -+ fprintf (g, "%hd %lu, ", macro[i].command, macro[i].ch); -+#endif /* UTF8 */ - fprintf (g, ";\n"); - } - } -@@ -744,7 +805,11 @@ int edit_save_macro_cmd (WEdit * edit, struct macro macro[], int n) - if (f) { - fprintf (f, ("key '%d 0': "), s); - for (i = 0; i < n; i++) -+#ifndef UTF8 - fprintf (f, "%hd %hd, ", macro[i].command, macro[i].ch); -+#else /* UTF8 */ -+ fprintf (f, "%hd %lu, ", macro[i].command, macro[i].ch); -+#endif /* UTF8 */ - fprintf (f, ";\n"); - fclose (f); - if (saved_macros_loaded) { -@@ -794,10 +859,18 @@ int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k) - saved_macro[i++] = s; - if (!found) { - *n = 0; -+#ifndef UTF8 - while (*n < MAX_MACRO_LENGTH && 2 == fscanf (f, "%hd %hd, ", ¯o[*n].command, ¯o[*n].ch)) -+#else /* UTF8 */ -+ while (*n < MAX_MACRO_LENGTH && 2 == fscanf (f, "%hd %lu, ", ¯o[*n].command, ¯o[*n].ch)) -+#endif /* UTF8 */ - (*n)++; - } else { -+#ifndef UTF8 - while (2 == fscanf (f, "%hd %hd, ", &dummy.command, &dummy.ch)); -+#else /* UTF8 */ -+ while (2 == fscanf (f, "%hd %lu, ", &dummy.command, &dummy.ch)); -+#endif /* UTF8 */ - } - fscanf (f, ";\n"); - if (s == k) -@@ -945,7 +1018,7 @@ int eval_marks (WEdit * edit, long *start_mark, long *end_mark) - #define space_width 1 - - static void --edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width) -+edit_insert_column_of_text (WEdit * edit, mc_wchar_t *data, int size, int width) - { - long cursor; - int i, col; -@@ -993,7 +1066,7 @@ edit_block_copy_cmd (WEdit *edit) - { - long start_mark, end_mark, current = edit->curs1; - int size; -- unsigned char *copy_buf; -+ mc_wchar_t *copy_buf; - - edit_update_curs_col (edit); - if (eval_marks (edit, &start_mark, &end_mark)) -@@ -1033,7 +1106,7 @@ edit_block_move_cmd (WEdit *edit) - { - long count; - long current; -- unsigned char *copy_buf; -+ mc_wchar_t *copy_buf; - long start_mark, end_mark; - int deleted = 0; - int x = 0; -@@ -1094,7 +1167,7 @@ edit_block_move_cmd (WEdit *edit) - edit_push_action (edit, COLUMN_ON); - column_highlighting = 0; - } else { -- copy_buf = g_malloc (end_mark - start_mark); -+ copy_buf = g_malloc ((end_mark - start_mark) * sizeof(mc_wchar_t)); - edit_cursor_move (edit, start_mark - edit->curs1); - edit_scroll_screen_over_cursor (edit); - count = start_mark; -@@ -1433,7 +1506,11 @@ static long sargs[NUM_REPL_ARGS][256 / sizeof (long)]; - /* This function is a modification of mc-3.2.10/src/view.c:regexp_view_search() */ - /* returns -3 on error in pattern, -1 on not found, found_len = 0 if either */ - static int -+#ifndef UTF8 - string_regexp_search (char *pattern, char *string, int match_type, -+#else /* UTF8 */ -+string_regexp_search (char *pattern, mc_wchar_t *wstring, int match_type, -+#endif /* UTF8 */ - int match_bol, int icase, int *found_len, void *d) - { - static regex_t r; -@@ -1442,6 +1519,11 @@ string_regexp_search (char *pattern, char *string, int match_type, - regmatch_t *pmatch; - static regmatch_t s[1]; - -+#ifdef UTF8 -+ char *string; -+ int i; -+#endif /* UTF8 */ -+ - pmatch = (regmatch_t *) d; - if (!pmatch) - pmatch = s; -@@ -1462,13 +1544,51 @@ string_regexp_search (char *pattern, char *string, int match_type, - old_type = match_type; - old_icase = icase; - } -+ -+#ifdef UTF8 -+ string = wchar_to_mbstr(wstring); -+ if (string == NULL) -+ return -1; -+#endif /* UTF8 */ -+ - if (regexec - (&r, string, d ? NUM_REPL_ARGS : 1, pmatch, - ((match_bol - || match_type != match_normal) ? 0 : REG_NOTBOL)) != 0) { - *found_len = 0; -+ -+#ifdef UTF8 -+ g_free(string); -+#endif /* UTF8 */ -+ - return -1; - } -+ -+#ifdef UTF8 -+ for (i = 0; i < (d ? NUM_REPL_ARGS : 1); i++) { -+ char tmp; -+ int new_o; -+ -+ if (pmatch[i].rm_so < 0) -+ continue; -+ tmp = string[pmatch[i].rm_so]; -+ string[pmatch[i].rm_so] = 0; -+ new_o = mbstrlen(string); -+ string[pmatch[i].rm_so] = tmp; -+ pmatch[i].rm_so = new_o; -+ -+ if (pmatch[i].rm_eo < 0) -+ continue; -+ tmp = string[pmatch[i].rm_eo]; -+ string[pmatch[i].rm_eo] = 0; -+ new_o = mbstrlen(string); -+ string[pmatch[i].rm_eo] = tmp; -+ pmatch[i].rm_eo = new_o; -+ } -+ -+ g_free(string); -+#endif /* UTF8 */ -+ - *found_len = pmatch[0].rm_eo - pmatch[0].rm_so; - return (pmatch[0].rm_so); - } -@@ -1476,13 +1596,29 @@ string_regexp_search (char *pattern, char *string, int match_type, - /* thanks to Liviu Daia for getting this - (and the above) routines to work properly - paul */ - -+#ifndef UTF8 - typedef int (*edit_getbyte_fn) (WEdit *, long); -+#else /* UTF8 */ -+typedef mc_wchar_t (*edit_getbyte_fn) (WEdit *, long); -+#endif /* UTF8 */ - - static long -+#ifndef UTF8 - edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit_getbyte_fn get_byte, void *data, int once_only, void *d) -+#else /* UTF8 */ -+edit_find_string (long start, unsigned char *exp_mb, int *len, long last_byte, edit_getbyte_fn get_byte, void *data, int once_only, void *d) -+#endif /* UTF8 */ - { - long p, q = 0; -- long l = strlen ((char *) exp), f = 0; -+ long f = 0; -+ -+#ifndef UTF8 -+ long l = strlen ((char *) exp); -+#else /* UTF8 */ -+ mc_wchar_t *exp = mbstr_to_wchar((char *)exp_mb); -+ mc_wchar_t *exp_backup = exp; -+ long l = wcslen(exp); -+#endif /* UTF8 */ - int n = 0; - - for (p = 0; p < l; p++) /* count conversions... */ -@@ -1491,19 +1627,22 @@ edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit - n++; - - if (replace_scanf || replace_regexp) { -- int c; -- unsigned char *buf; -- unsigned char mbuf[MAX_REPL_LEN * 2 + 3]; -+ mc_wint_t c; -+ mc_wchar_t *buf; -+ mc_wchar_t mbuf[MAX_REPL_LEN * 2 + 3]; - - replace_scanf = (!replace_regexp); /* can't have both */ - - buf = mbuf; - - if (replace_scanf) { -- unsigned char e[MAX_REPL_LEN]; -- if (n >= NUM_REPL_ARGS) -- return -3; -- -+ mc_wchar_t e[MAX_REPL_LEN]; -+ if (n >= NUM_REPL_ARGS) { -+#ifdef UTF8 -+ g_free(exp_backup); -+#endif /* UTF8 */ -+ return -3; -+ } - if (replace_case) { - for (p = start; p < last_byte && p < start + MAX_REPL_LEN; p++) - buf[p - start] = (*get_byte) (data, p); -@@ -1517,20 +1656,36 @@ edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit - } - - buf[(q = p - start)] = 0; -+#ifndef UTF8 - strcpy ((char *) e, (char *) exp); - strcat ((char *) e, "%n"); -+#else /* UTF8 */ -+ wcscpy (e, exp); -+ wcscat (e, L"%n"); -+#endif /* UTF8 */ - exp = e; - - while (q) { - *((int *) sargs[n]) = 0; /* --> here was the problem - now fixed: good */ -+#ifndef UTF8 - if (n == sscanf ((char *) buf, (char *) exp, SCANF_ARGS)) { -+#else /* UTF8 */ -+ if (n == swscanf (buf, exp, SCANF_ARGS)) { -+#endif /* UTF8 */ - if (*((int *) sargs[n])) { - *len = *((int *) sargs[n]); -+#ifdef UTF8 -+ g_free(exp_backup); -+#endif /* UTF8 */ - return start; - } - } -- if (once_only) -+ if (once_only) { -+#ifdef UTF8 -+ g_free(exp_backup); -+#endif /* UTF8 */ - return -2; -+ } - if (q + start < last_byte) { - if (replace_case) { - buf[q] = (*get_byte) (data, q + start); -@@ -1544,7 +1699,11 @@ edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit - start++; - buf++; /* move the window along */ - if (buf == mbuf + MAX_REPL_LEN) { /* the window is about to go past the end of array, so... */ -+#ifndef UTF8 - memmove (mbuf, buf, strlen ((char *) buf) + 1); /* reset it */ -+#else /* UTF8 */ -+ wmemmove (mbuf, buf, (wcslen (buf) + 1)); /* reset it */ -+#endif /* UTF8 */ - buf = mbuf; - } - q--; -@@ -1571,10 +1730,16 @@ edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit - - buf = mbuf; - while (q) { -+#ifndef UTF8 - found_start = string_regexp_search ((char *) exp, (char *) buf, match_normal, match_bol, !replace_case, len, d); -- -+#else /* UTF8 */ -+ found_start = string_regexp_search ((char *) exp_mb, buf, match_normal, match_bol, !replace_case, len, d); -+#endif /* UTF8 */ - if (found_start <= -2) { /* regcomp/regexec error */ - *len = 0; -+#ifdef UTF8 -+ g_free (exp_backup); -+#endif /* UTF8 */ - return -3; - } - else if (found_start == -1) /* not found: try next line */ -@@ -1585,15 +1750,27 @@ edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit - match_bol = 0; - continue; - } -- else /* found */ -+ else { /* found */ -+#ifdef UTF8 -+ g_free(exp_backup); -+#endif /* UTF8 */ - return (start + offset - q + found_start); -+ } - } -- if (once_only) -+ if (once_only) { -+#ifdef UTF8 -+ g_free(exp_backup); -+#endif /* UTF8 */ - return -2; -+ } - - if (buf[q - 1] != '\n') { /* incomplete line: try to recover */ - buf = mbuf + MAX_REPL_LEN / 2; -+#ifndef UTF8 - q = strlen ((const char *) buf); -+#else /* UTF8 */ -+ q = wcslen (buf); -+#endif /* UTF8 */ - memmove (mbuf, buf, q); - p = start + q; - move_win = 1; -@@ -1603,36 +1780,59 @@ edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit - } - } - } else { -+#ifndef UTF8 - *len = strlen ((const char *) exp); -+#else /* UTF8 */ -+ *len = wcslen (exp); -+#endif /* UTF8 */ - if (replace_case) { - for (p = start; p <= last_byte - l; p++) { -- if ((*get_byte) (data, p) == (unsigned char)exp[0]) { /* check if first char matches */ -+ if ((*get_byte) (data, p) == exp[0]) { /* check if first char matches */ - for (f = 0, q = 0; q < l && f < 1; q++) -- if ((*get_byte) (data, q + p) != (unsigned char)exp[q]) -+ if ((*get_byte) (data, q + p) != exp[q]) - f = 1; -- if (f == 0) -+ if (f == 0) { -+#ifdef UTF8 -+ g_free (exp_backup); -+#endif /* UTF8 */ - return p; -+ } - } -- if (once_only) -+ if (once_only) { -+#ifdef UTF8 -+ g_free(exp_backup); -+#endif /* UTF8 */ - return -2; -+ } - } - } else { - for (p = 0; exp[p] != 0; p++) - exp[p] = my_lower_case (exp[p]); - - for (p = start; p <= last_byte - l; p++) { -- if (my_lower_case ((*get_byte) (data, p)) == (unsigned char)exp[0]) { -+ if (my_lower_case ((*get_byte) (data, p)) == exp[0]) { - for (f = 0, q = 0; q < l && f < 1; q++) -- if (my_lower_case ((*get_byte) (data, q + p)) != (unsigned char)exp[q]) -+ if (my_lower_case ((*get_byte) (data, q + p)) != exp[q]) - f = 1; -- if (f == 0) -+ if (f == 0) { -+#ifdef UTF8 -+ g_free (exp_backup); -+#endif /* UTF8 */ - return p; -+ } - } -- if (once_only) -+ if (once_only) { -+#ifdef UTF8 -+ g_free (exp_backup); -+#endif /* UTF8 */ - return -2; -+ } - } - } - } -+#ifdef UTF8 -+ g_free (exp_backup); -+#endif /* UTF8 */ - return -2; - } - -@@ -1646,9 +1846,14 @@ edit_find_forwards (long search_start, unsigned char *exp, int *len, long last_b - - while ((p = edit_find_string (p, exp, len, last_byte, get_byte, data, once_only, d)) >= 0) { - if (replace_whole) { -+#ifndef UTF8 - /*If the bordering chars are not in option_whole_chars_search then word is whole */ - if (!strcasechr (option_whole_chars_search, (*get_byte) (data, p - 1)) - && !strcasechr (option_whole_chars_search, (*get_byte) (data, p + *len))) -+#else /* UTF8 */ -+ if (!iswalnum((*get_byte) (data, p - 1)) -+ && !iswalnum((*get_byte) (data, p + *len))) -+#endif /* UTF8 */ - return p; - if (once_only) - return -2; -@@ -1680,6 +1885,7 @@ edit_find (long search_start, unsigned char *exp, int *len, long last_byte, edit - - #define is_digit(x) ((x) >= '0' && (x) <= '9') - -+#ifndef UTF8 - #define snprint(v) { \ - *p1++ = *p++; \ - *p1 = '\0'; \ -@@ -1687,33 +1893,48 @@ edit_find (long search_start, unsigned char *exp, int *len, long last_byte, edit - if (n >= (size_t) (e - s)) goto nospc; \ - s += n; \ - } -+#else /* UTF8 */ -+#define snprint(v) { \ -+ *p1++ = *p++; \ -+ *p1 = '\0'; \ -+ n = swprintf(s, e-s, q1,v); \ -+ if (n >= (size_t) (e - s)) goto nospc; \ -+ s += n; \ -+ } -+#endif /* UTF8 */ - - /* this function uses the sprintf command to do a vprintf */ - /* it takes pointers to arguments instead of the arguments themselves */ - /* The return value is the number of bytes written excluding '\0' - if successfull, -1 if the resulting string would be too long and - -2 if the format string is errorneous. */ --static int snprintf_p (char *str, size_t size, const char *fmt,...) -- __attribute__ ((format (printf, 3, 4))); -- --static int snprintf_p (char *str, size_t size, const char *fmt,...) -+static int snprintf_p (mc_wchar_t *str, size_t size, const mc_wchar_t *fmt,...) - { - va_list ap; - size_t n; -- const char *q, *p; -- char *s = str, *e = str + size; -- char q1[40]; -- char *p1; -+ const mc_wchar_t *q, *p; -+ mc_wchar_t *s = str, *e = str + size; -+ mc_wchar_t q1[40]; -+ -+ mc_wchar_t *p1; - int nargs = 0; - - va_start (ap, fmt); - p = q = fmt; - -+#ifndef UTF8 - while ((p = strchr (p, '%'))) { -+#else /* UTF8 */ -+ while ((p = wcschr (p, L'%'))) { -+#endif /* UTF8 */ - n = p - q; - if (n >= (size_t) (e - s)) - goto nospc; -+#ifndef UTF8 - memcpy (s, q, n); /* copy stuff between format specifiers */ -+#else /* UTF8 */ -+ wmemcpy (s, q, n); /* copy stuff between format specifiers */ -+#endif /* UTF8 */ - s += n; - q = p; - p1 = q1; -@@ -1741,45 +1962,78 @@ static int snprintf_p (char *str, size_t size, const char *fmt,...) - *p1++ = *p++; - if (*p == '*') { - p++; -+#ifndef UTF8 - strcpy (p1, MY_itoa (*va_arg (ap, int *))); /* replace field width with a number */ - p1 += strlen (p1); -+#else /* UTF8 */ -+ wcscpy (p1, MY_itoa (*va_arg (ap, int *))); /* replace field width with a number */ -+ p1 += wcslen (p1); -+#endif /* UTF8 */ - } else { -- while (is_digit (*p) && p1 < q1 + 20) -+#ifndef UTF8 -+ while (is_digit (*p) -+#else /* UTF8 */ -+ while (iswdigit (*p) -+#endif /* UTF8 */ -+ && p1 < q1 + 20) - *p1++ = *p++; -+#ifndef UTF8 - if (is_digit (*p)) -+#else /* UTF8 */ -+ if (iswdigit (*p)) -+#endif /* UTF8 */ - goto err; - } - if (*p == '.') - *p1++ = *p++; - if (*p == '*') { - p++; -+#ifndef UTF8 - strcpy (p1, MY_itoa (*va_arg (ap, int *))); /* replace precision with a number */ - p1 += strlen (p1); -+#else /* UTF8 */ -+ wcscpy (p1, MY_itoa (*va_arg (ap, int *))); /* replace precision with a number */ -+ p1 += wcslen (p1); -+#endif /* UTF8 */ - } else { -- while (is_digit (*p) && p1 < q1 + 32) -+#ifndef UTF8 -+ while (is_digit (*p) -+#else /* UTF8 */ -+ while (iswdigit (*p) -+#endif /* UTF8 */ -+ && p1 < q1 + 32) - *p1++ = *p++; -+#ifndef UTF8 - if (is_digit (*p)) -+#else /* UTF8 */ -+ if (iswdigit (*p)) -+#endif /* UTF8 */ - goto err; - } - /* flags done, now get argument */ - if (*p == 's') { -+#ifndef UTF8 - snprint (va_arg (ap, char *)); -+#else /* UTF8 */ -+ *p1++ = 'l'; -+ snprint (va_arg (ap, mc_wchar_t *)); -+#endif /* UTF8 */ - } else if (*p == 'h') { -- if (strchr ("diouxX", *p)) -+ if (*p < 128 && strchr ("diouxX", *p)) - snprint (*va_arg (ap, short *)); - } else if (*p == 'l') { - *p1++ = *p++; -- if (strchr ("diouxX", *p)) -+ if (*p < 128 && strchr ("diouxX", *p)) - snprint (*va_arg (ap, long *)); -- } else if (strchr ("cdiouxX", *p)) { -+ } else if (*p < 128 && strchr ("cdiouxX", *p)) { - snprint (*va_arg (ap, int *)); - } else if (*p == 'L') { - *p1++ = *p++; -- if (strchr ("EefgG", *p)) -+ if (*p < 128 && strchr ("EefgG", *p)) - snprint (*va_arg (ap, double *)); /* should be long double */ -- } else if (strchr ("EefgG", *p)) { -+ } else if (*p < 128 && strchr ("EefgG", *p)) { - snprint (*va_arg (ap, double *)); -- } else if (strchr ("DOU", *p)) { -+ } else if (*p < 128 && strchr ("DOU", *p)) { - snprint (*va_arg (ap, long *)); - } else if (*p == 'p') { - snprint (*va_arg (ap, void **)); -@@ -1788,10 +2042,17 @@ static int snprintf_p (char *str, size_t size, const char *fmt,...) - q = p; - } - va_end (ap); -+#ifndef UTF8 - n = strlen (q); - if (n >= (size_t) (e - s)) - return -1; - memcpy (s, q, n + 1); -+#else /* UTF8 */ -+ n = wcslen (q); -+ if (n >= (size_t) (e - s)) -+ return -1; -+ wmemcpy (s, q, n + 1); -+#endif /* UTF8 */ - return s + n - str; - nospc: - va_end (ap); -@@ -1970,8 +2231,11 @@ edit_replace_cmd (WEdit *edit, int again) - } - } - if (replace_yes) { /* delete then insert new */ -+#ifdef UTF8 -+ mc_wchar_t *winput2 = mbstr_to_wchar(input2); -+#endif /* UTF8 */ - if (replace_scanf) { -- char repl_str[MAX_REPL_LEN + 2]; -+ mc_wchar_t repl_str[MAX_REPL_LEN + 2]; - int ret = 0; - - /* we need to fill in sargs just like with scanf */ -@@ -1980,17 +2244,25 @@ edit_replace_cmd (WEdit *edit, int again) - for (k = 1; - k < NUM_REPL_ARGS && pmatch[k].rm_eo >= 0; - k++) { -+#ifndef UTF8 - unsigned char *t; -+#else /* UTF8 */ -+ mc_wchar_t *t; -+#endif - - if (pmatch[k].rm_eo - pmatch[k].rm_so > 255) { - ret = -1; - break; - } -+#ifndef UTF8 - t = (unsigned char *) &sargs[k - 1][0]; -+#else /* UTF8 */ -+ t = (mc_wchar_t *) &sargs[k - 1][0]; -+#endif /* UTF8 */ - for (j = 0; - j < pmatch[k].rm_eo - pmatch[k].rm_so - && j < 255; j++, t++) -- *t = (unsigned char) edit_get_byte (edit, -+ *t = edit_get_byte (edit, - edit-> - search_start - - -@@ -2008,14 +2280,23 @@ edit_replace_cmd (WEdit *edit, int again) - } - if (!ret) - ret = -+#ifndef UTF8 - snprintf_p (repl_str, MAX_REPL_LEN + 2, input2, -+#else /* UTF8 */ -+ snprintf_p (repl_str, MAX_REPL_LEN + 2, winput2, -+#endif /* UTF8 */ - PRINTF_ARGS); - if (ret >= 0) { - times_replaced++; - while (i--) - edit_delete (edit); -+#ifndef UTF8 - while (repl_str[++i]) - edit_insert (edit, repl_str[i]); -+#else /* UTF8 */ -+ while (winput2[++i]) -+ edit_insert (edit, winput2[i]); -+#endif /* UTF8 */ - } else { - edit_error_dialog (_(" Replace "), - ret == -@@ -2029,10 +2310,18 @@ edit_replace_cmd (WEdit *edit, int again) - times_replaced++; - while (i--) - edit_delete (edit); -+#ifndef UTF8 - while (input2[++i]) - edit_insert (edit, input2[i]); -+#else /* UTF8 */ -+ while (winput2[++i]) -+ edit_insert (edit, winput2[i]); -+#endif /* UTF8 */ - } - edit->found_len = i; -+#ifdef UTF8 -+ g_free (winput2); -+#endif /* UTF8 */ - } - /* so that we don't find the same string again */ - if (replace_backwards) { -@@ -2205,16 +2494,17 @@ edit_ok_to_exit (WEdit *edit) - #define TEMP_BUF_LEN 1024 - - /* Return a null terminated length of text. Result must be g_free'd */ --static unsigned char * -+static mc_wchar_t * - edit_get_block (WEdit *edit, long start, long finish, int *l) - { -- unsigned char *s, *r; -- r = s = g_malloc (finish - start + 1); -+ mc_wchar_t *s, *r; -+ r = s = g_malloc ((finish - start + 1) * sizeof(mc_wchar_t)); - if (column_highlighting) { - *l = 0; - /* copy from buffer, excluding chars that are out of the column 'margins' */ - while (start < finish) { -- int c, x; -+ mc_wchar_t c; -+ int x; - x = edit_move_forward3 (edit, edit_bol (edit, start), 0, - start); - c = edit_get_byte (edit, start); -@@ -2247,11 +2537,15 @@ edit_save_block (WEdit * edit, const char *filename, long start, - return 0; - - if (column_highlighting) { -- unsigned char *block, *p; -+ mc_wchar_t *block, *p; - int r; - p = block = edit_get_block (edit, start, finish, &len); - while (len) { -+#ifndef UTF8 - r = mc_write (file, p, len); -+#else /* UTF8 */ -+ r = wchar_write (file, p, len); -+#endif /* UTF8 */ - if (r < 0) - break; - p += r; -@@ -2259,15 +2553,19 @@ edit_save_block (WEdit * edit, const char *filename, long start, - } - g_free (block); - } else { -- unsigned char *buf; -+ mc_wchar_t *buf; - int i = start, end; - len = finish - start; -- buf = g_malloc (TEMP_BUF_LEN); -+ buf = g_malloc (TEMP_BUF_LEN * sizeof(mc_wchar_t)); - while (start != finish) { - end = min (finish, start + TEMP_BUF_LEN); - for (; i < end; i++) - buf[i - start] = edit_get_byte (edit, i); -+#ifndef UTF8 - len -= mc_write (file, (char *) buf, end - start); -+#else /* UTF8 */ -+ len -= wchar_write (file, buf, end - start); -+#endif /* UTF8 */ - start = end; - } - g_free (buf); -@@ -2609,17 +2907,20 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block) - - /* prints at the cursor */ - /* returns the number of chars printed */ -+#ifndef UTF8 - int edit_print_string (WEdit * e, const char *s) -+#else /* UTF8 */ -+int edit_print_wstring (WEdit * e, mc_wchar_t *s) -+#endif /* UTF8 */ - { - int i = 0; - while (s[i]) -- edit_execute_cmd (e, -1, (unsigned char) s[i++]); -+ edit_execute_cmd (e, -1, s[i++]); - e->force |= REDRAW_COMPLETELY; - edit_update_screen (e); - return i; - } - -- - static void pipe_mail (WEdit *edit, char *to, char *subject, char *cc) - { - FILE *p = 0; -@@ -2713,15 +3014,20 @@ void edit_mail_dialog (WEdit * edit) - /* find first character of current word */ - static int edit_find_word_start (WEdit *edit, long *word_start, int *word_len) - { -- int i, c, last; -+ int i; -+ mc_wint_t c, last; - - /* return if at begin of file */ - if (edit->curs1 <= 0) - return 0; - -- c = (unsigned char) edit_get_byte (edit, edit->curs1 - 1); -+ c = edit_get_byte (edit, edit->curs1 - 1); - /* return if not at end or in word */ -+#ifndef UTF8 - if (isspace (c) || !(isalnum (c) || c == '_')) -+#else /* UTF8 */ -+ if (iswspace (c) || !(iswalnum (c) || c == '_')) -+#endif /* UTF8 */ - return 0; - - /* search start of word to be completed */ -@@ -2731,11 +3037,19 @@ static int edit_find_word_start (WEdit *edit, long *word_start, int *word_len) - return 0; - - last = c; -- c = (unsigned char) edit_get_byte (edit, edit->curs1 - i); -+ c = edit_get_byte (edit, edit->curs1 - i); - -+#ifndef UTF8 - if (!(isalnum (c) || c == '_')) { -+#else /* UTF8 */ -+ if (!(iswalnum (c) || c == '_')) { -+#endif /* UTF8 */ - /* return if word starts with digit */ -+#ifndef UTF8 - if (isdigit (last)) -+#else /* UTF8 */ -+ if (iswdigit (last)) -+#endif /* UTF8 */ - return 0; - - *word_start = edit->curs1 - (i - 1); /* start found */ -@@ -2768,7 +3082,7 @@ edit_collect_completions (WEdit *edit, long start, int word_len, - int *num) - { - int len, max_len = 0, i, skip; -- unsigned char *bufpos; -+ mc_wchar_t *bufpos; - - /* collect max MAX_WORD_COMPLETIONS completions */ - while (*num < MAX_WORD_COMPLETIONS) { -@@ -2787,11 +3101,16 @@ edit_collect_completions (WEdit *edit, long start, int word_len, - buffers1[start >> S_EDIT_BUF_SIZE][start & M_EDIT_BUF_SIZE]; - skip = 0; - for (i = 0; i < *num; i++) { -+#ifndef UTF8 - if (strncmp - ((char *) &compl[i].text[word_len], -- (char *) &bufpos[word_len], max (len, -- compl[i].len) - -- word_len) == 0) { -+ (char *) &bufpos[word_len], -+#else /* UTF8 */ -+ if (wcsncmp -+ ((wchar_t *) &compl[i].text[word_len], -+ (wchar_t *) &bufpos[word_len], -+#endif /* UTF8 */ -+ max (len, compl[i].len) - word_len) == 0) { - skip = 1; - break; /* skip it, already added */ - } -@@ -2799,7 +3118,7 @@ edit_collect_completions (WEdit *edit, long start, int word_len, - if (skip) - continue; - -- compl[*num].text = g_malloc (len + 1); -+ compl[*num].text = g_malloc ((len + 1) * sizeof(mc_wchar_t)); - compl[*num].len = len; - for (i = 0; i < len; i++) - compl[*num].text[i] = *(bufpos + i); -@@ -2813,6 +3132,18 @@ edit_collect_completions (WEdit *edit, long start, int word_len, - return max_len; - } - -+#ifdef UTF8 -+int edit_print_string (WEdit * e, const char *s) -+{ -+ int i; -+ mc_wchar_t *ws = mbstr_to_wchar(s); -+ i = edit_print_wstring (e, ws); -+ g_free(ws); -+ return i; -+} -+ -+#endif /* UTF8 */ -+ - - /* let the user select its preferred completion */ - static void -@@ -2825,6 +3156,9 @@ edit_completion_dialog (WEdit * edit, int max_len, int word_len, - WListbox *compl_list; - int compl_dlg_h; /* completion dialog height */ - int compl_dlg_w; /* completion dialog width */ -+#ifdef UTF8 -+ char *mbtext; -+#endif /* UTF8 */ - - /* calculate the dialog metrics */ - compl_dlg_h = num_compl + 2; -@@ -2860,9 +3194,18 @@ edit_completion_dialog (WEdit * edit, int max_len, int word_len, - add_widget (compl_dlg, compl_list); - - /* fill the listbox with the completions */ -+#ifndef UTF8 - for (i = 0; i < num_compl; i++) - listbox_add_item (compl_list, LISTBOX_APPEND_AT_END, 0, - (char *) compl[i].text, NULL); -+#else /* UTF8 */ -+ for (i = 0; i < num_compl; i++) { -+ mbtext = wchar_to_mbstr(compl[i].text); -+ listbox_add_item (compl_list, LISTBOX_APPEND_AT_END, 0, -+ mbtext, NULL); -+ g_free(mbtext); -+ } -+#endif /* UTF8 */ - - /* pop up the dialog */ - run_dlg (compl_dlg); -@@ -2870,9 +3213,17 @@ edit_completion_dialog (WEdit * edit, int max_len, int word_len, - /* apply the choosen completion */ - if (compl_dlg->ret_value == B_ENTER) { - listbox_get_current (compl_list, &curr, NULL); -- if (curr) -+ if (curr){ -+#ifndef UTF8 - for (curr += word_len; *curr; curr++) - edit_insert (edit, *curr); -+#else /* UTF8 */ -+ mc_wchar_t *wc, *wccurr = mbstr_to_wchar(curr); -+ for (wc = wccurr + word_len; *wc; wc++) -+ edit_insert (edit, *wc); -+ g_free(wccurr); -+#endif /* UTF8 */ -+ } - } - - /* destroy dialog before return */ -@@ -2889,8 +3240,9 @@ edit_complete_word_cmd (WEdit *edit) - { - int word_len = 0, i, num_compl = 0, max_len; - long word_start = 0; -- unsigned char *bufpos; -- char *match_expr; -+ mc_wchar_t *bufpos; -+ mc_wchar_t *match_expr; -+ char *mbmatch_expr; - struct selection compl[MAX_WORD_COMPLETIONS]; /* completions */ - - /* don't want to disturb another search */ -@@ -2907,16 +3259,32 @@ edit_complete_word_cmd (WEdit *edit) - /* prepare match expression */ - bufpos = &edit->buffers1[word_start >> S_EDIT_BUF_SIZE] - [word_start & M_EDIT_BUF_SIZE]; -+ -+ match_expr = g_malloc((word_len + 14) * sizeof(mc_wchar_t)); -+#ifndef UTF8 - match_expr = g_strdup_printf ("%.*s[a-zA-Z_0-9]+", word_len, bufpos); -+#else /* UTF8 */ -+ wcsncpy (match_expr, bufpos, word_len); -+ match_expr[word_len] = '\0'; -+ wcscat (match_expr, L"[a-zA-Z_0-9]+"); -+#endif /* UTF8 */ - - /* init search: backward, regexp, whole word, case sensitive */ - edit_set_search_parameters (0, 1, 1, 1, 1); - - /* collect the possible completions */ - /* start search from curs1 down to begin of file */ -+#ifndef UTF8 - max_len = - edit_collect_completions (edit, word_start, word_len, match_expr, - (struct selection *) &compl, &num_compl); -+#else /* UTF8 */ -+ mbmatch_expr = wchar_to_mbstr(match_expr); -+ max_len = -+ edit_collect_completions (edit, word_start, word_len, mbmatch_expr, -+ (struct selection *) &compl, &num_compl); -+ g_free(mbmatch_expr); -+#endif /* UTF8 */ - - if (num_compl > 0) { - /* insert completed word if there is only one match */ -@@ -2951,7 +3319,7 @@ void - edit_select_codepage_cmd (WEdit *edit) - { - #ifdef HAVE_CHARSET -- do_select_codepage (); -+ do_select_codepage (_(" Choose codepage ")); - edit->force = REDRAW_COMPLETELY; - edit_refresh_cmd (edit); - #endif -diff --git a/edit/editdraw.c b/edit/editdraw.c -index 86ea3f9..654f0b3 100644 ---- a/edit/editdraw.c -+++ b/edit/editdraw.c -@@ -71,11 +71,26 @@ static void status_string (WEdit * edit, char *s, int w) - * as decimal and as hex. - */ - if (edit->curs1 < edit->last_byte) { -- unsigned char cur_byte = edit_get_byte (edit, edit->curs1); -+ mc_wchar_t cur_byte = edit_get_byte (edit, edit->curs1); -+ mc_wchar_t cur_byte2 = cur_byte; -+#ifndef UTF8 - g_snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X", - is_printable (cur_byte) ? cur_byte : '.', -- (int) cur_byte, -- (unsigned) cur_byte); -+#else /* UTF8 */ -+ /* In 8-bit locales show the byte itself instead of its Unicode value */ -+ if (MB_CUR_MAX == 1) { -+ unsigned char cur_8bit_byte; -+ mbstate_t mbs; -+ memset (&mbs, 0, sizeof (mbs)); -+ if (wcrtomb(&cur_8bit_byte, cur_byte, &mbs) == 1) { -+ cur_byte = cur_8bit_byte; -+ } -+ } -+ g_snprintf (byte_str, sizeof(byte_str), "%lc %3d 0x%02X", -+ iswprint(cur_byte2) ? cur_byte2 : '.', -+#endif /* UTF8 */ -+ (int) cur_byte, -+ (unsigned) cur_byte); - } else { - strcpy (byte_str, ""); - } -@@ -207,11 +222,16 @@ void edit_scroll_screen_over_cursor (WEdit * edit) - #define lowlevel_set_color(x) attrset(MY_COLOR_PAIR(color)) - #endif - -+struct line_s { -+ mc_wchar_t ch; -+ unsigned int style; -+}; -+ - static void - print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, -- long end_col, unsigned int line[]) -+ long end_col, struct line_s line[]) - { -- unsigned int *p; -+ struct line_s *p; - - int x = start_col_real + EDIT_TEXT_HORIZONTAL_OFFSET; - int x1 = start_col + EDIT_TEXT_HORIZONTAL_OFFSET; -@@ -225,9 +245,9 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, - edit_move (x1 + FONT_OFFSET_X, y + FONT_OFFSET_Y); - p = line; - -- while (*p) { -+ while (p->ch) { - int style; -- int textchar; -+ mc_wchar_t textchar; - int color; - - if (cols_to_skip) { -@@ -236,9 +256,9 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, - continue; - } - -- style = *p & 0xFF00; -- textchar = *p & 0xFF; -- color = *p >> 16; -+ style = p->style & 0xFF00; -+ textchar = p->ch; -+ color = p->style >> 16; - - if (style & MOD_ABNORMAL) { - /* Non-printable - use black background */ -@@ -267,8 +287,11 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, - lowlevel_set_color (color); - } - } -- -+#ifdef UTF8 -+ SLsmg_write_nwchars(&textchar, 1); -+#else - addch (textchar); -+#endif - p++; - } - } -@@ -280,11 +303,11 @@ static void - edit_draw_this_line (WEdit *edit, long b, long row, long start_col, - long end_col) - { -- static unsigned int line[MAX_LINE_LEN]; -- unsigned int *p = line; -+ struct line_s line[MAX_LINE_LEN]; -+ struct line_s *p = line; - long m1 = 0, m2 = 0, q, c1, c2; - int col, start_col_real; -- unsigned int c; -+ mc_wint_t c; - int color; - int i; - -@@ -309,62 +332,88 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col, - } - - while (col <= end_col - edit->start_col) { -- *p = 0; -+ p->ch = 0; -+ p->style = 0; - if (q == edit->curs1) -- *p |= MOD_CURSOR; -+ p->style |= MOD_CURSOR; - if (q >= m1 && q < m2) { - if (column_highlighting) { - int x; - x = edit_move_forward3 (edit, b, 0, q); - if (x >= c1 && x < c2) -- *p |= MOD_MARKED; -+ p->style |= MOD_MARKED; - } else -- *p |= MOD_MARKED; -+ p->style |= MOD_MARKED; - } - if (q == edit->bracket) -- *p |= MOD_BOLD; -+ p->style |= MOD_BOLD; - if (q >= edit->found_start - && q < edit->found_start + edit->found_len) -- *p |= MOD_BOLD; -+ p->style |= MOD_BOLD; - c = edit_get_byte (edit, q); - /* we don't use bg for mc - fg contains both */ - edit_get_syntax_color (edit, q, &color); -- *p |= color << 16; -+ p->style |= color << 16; - switch (c) { - case '\n': - col = end_col - edit->start_col + 1; /* quit */ -- *(p++) |= ' '; -+ p->ch = ' '; -+ p++; - break; - case '\t': - i = TAB_SIZE - ((int) col % TAB_SIZE); - col += i; - if (use_colors && visible_tabs) { -- c = (*p & ~MOD_CURSOR) | MOD_WHITESPACE; -+ c = (p->style & ~MOD_CURSOR) | MOD_WHITESPACE; - if (i > 2) { -- *(p++) |= '<' | MOD_WHITESPACE; -- while (--i > 1) -- *(p++) = c | '-'; -- *(p++) = c | '>'; -+ p->ch = '<'; -+ p->style |= MOD_WHITESPACE; -+ p++; -+ while (--i > 1) { -+ p->ch = '-'; -+ p->style = c; -+ p++; -+ } -+ p->ch = '>'; -+ p->style = c; -+ p++; - } else if (i > 1) { -- *(p++) |= '<' | MOD_WHITESPACE; -- *(p++) = c | '>'; -- } else -- *(p++) |= '>' | MOD_WHITESPACE; -+ p->ch = '<'; -+ p->style |= MOD_WHITESPACE; -+ p++; -+ p->ch = '>'; -+ p->style = c; -+ p++; -+ } else { -+ p->ch = '>'; -+ p->style |= MOD_WHITESPACE; -+ p++; -+ } - } else if (use_colors && visible_tws && q >= tws) { -- *p |= '.' | MOD_WHITESPACE; -- c = *(p++) & ~MOD_CURSOR; -- while (--i) -- *(p++) = c; -+ p->ch = '.'; -+ p->style |= MOD_WHITESPACE; -+ c = p->style & ~MOD_CURSOR; -+ p++; -+ while (--i) { -+ p->ch = '.'; -+ p->style = c; -+ p++; -+ } - } else { -- *p |= ' '; -- c = *(p++) & ~MOD_CURSOR; -- while (--i) -- *(p++) = c; -+ p->ch = ' '; -+ c = p->style & ~MOD_CURSOR; -+ p++; -+ while (--i) { -+ p->ch = ' '; p->style = c; -+ p++; -+ } - } - break; - case ' ': - if (use_colors && visible_tws && q >= tws) { -- *(p++) |= '.' | MOD_WHITESPACE; -+ p->ch = '.'; -+ p->style |= MOD_WHITESPACE; -+ p++; - col++; - break; - } -@@ -374,22 +423,47 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col, - - /* Caret notation for control characters */ - if (c < 32) { -- *(p++) = '^' | MOD_ABNORMAL; -- *(p++) = (c + 0x40) | MOD_ABNORMAL; -+ p->ch = '^'; -+ p->style = MOD_ABNORMAL; -+ p++; -+ p->ch = c + 0x40; -+ p->style = MOD_ABNORMAL; - col += 2; - break; - } - if (c == 127) { -- *(p++) = '^' | MOD_ABNORMAL; -- *(p++) = '?' | MOD_ABNORMAL; -+ p->ch = '^'; -+ p->style = MOD_ABNORMAL; -+ p++; -+ p->ch = '?'; -+ p->style = MOD_ABNORMAL; -+ p++; - col += 2; - break; - } - -- if (is_printable (c)) { -- *(p++) |= c; -+#ifndef UTF8 -+ if (is_printable (c) -+#else /* UTF8 */ -+ if (iswprint (c) -+#ifdef __STDC_ISO_10646__ -+ && (c < BINARY_CHAR_OFFSET || c >= (BINARY_CHAR_OFFSET + 256)) -+#endif -+#endif /* UTF8 */ -+ ) { -+ p->ch = c; -+ p++; -+ -+#ifdef UTF8 -+ i = wcwidth(c); -+ if (i > 1) { -+ col += i - 1; -+ } -+#endif /* UTF8 */ - } else { -- *(p++) = '.' | MOD_ABNORMAL; -+ p->ch = '.'; -+ p->style = MOD_ABNORMAL; -+ p++; - } - col++; - break; -@@ -400,7 +474,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col, - } else { - start_col_real = start_col = 0; - } -- *p = 0; -+ p->ch = 0; - - print_to_widget (edit, row, start_col, start_col_real, end_col, line); - } -diff --git a/edit/editkeys.c b/edit/editkeys.c -index 2cc6add..111d377 100644 ---- a/edit/editkeys.c -+++ b/edit/editkeys.c -@@ -183,10 +183,10 @@ static const edit_key_map_type common_key_map[] = { - * 'command' is one of the editor commands from editcmddef.h. - */ - int --edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch) -+edit_translate_key (WEdit *edit, long x_key, int *cmd, mc_wint_t *ch) - { - int command = CK_Insert_Char; -- int char_for_insertion = -1; -+ mc_wint_t char_for_insertion = -1; - int i = 0; - int extmod = 0; - const edit_key_map_type *key_map = NULL; -@@ -243,9 +243,30 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch) - /* an ordinary insertable character */ - if (x_key < 256 && !extmod) { - int c = convert_from_input_c (x_key); -+#ifdef UTF8 -+ mbstate_t mbs; -+ int res; -+ mc_wchar_t wc; - -+ memset (&mbs, 0, sizeof (mbs)); -+ -+ if (edit->charpoint >= MB_CUR_MAX) edit->charpoint = 0; -+ -+ edit->charbuf[edit->charpoint++] = c; -+ -+ res = mbrtowc(&wc, (char *)edit->charbuf, edit->charpoint, &mbs); -+ if (res < 0) { -+ if (res != -2) edit->charpoint = 0; /* broken multibyte char, skip */ -+ return 0; -+ } -+ edit->charpoint = 0; -+ -+ if (iswprint (wc)) { -+ char_for_insertion = wc; -+#else - if (is_printable (c)) { - char_for_insertion = c; -+#endif /* UTF8 */ - goto fin; - } - } -@@ -284,7 +305,7 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch) - *cmd = command; - *ch = char_for_insertion; - -- if (command == CK_Insert_Char && char_for_insertion == -1) { -+ if (command == CK_Insert_Char && char_for_insertion == (mc_wint_t)-1) { - /* unchanged, key has no function here */ - return 0; - } -diff --git a/edit/editwidget.c b/edit/editwidget.c -index 8ae8cf0..286a844 100644 ---- a/edit/editwidget.c -+++ b/edit/editwidget.c -@@ -333,7 +333,8 @@ edit_callback (Widget *w, widget_msg_t msg, int parm) - - case WIDGET_KEY: - { -- int cmd, ch; -+ int cmd; -+ mc_wint_t ch; - - /* The user may override the access-keys for the menu bar. */ - if (edit_translate_key (e, parm, &cmd, &ch)) { -diff --git a/edit/wordproc.c b/edit/wordproc.c -index fc16136..25a534e 100644 ---- a/edit/wordproc.c -+++ b/edit/wordproc.c -@@ -40,7 +40,12 @@ - - #define tab_width option_tab_spacing - -+#ifndef UTF8 - #define NO_FORMAT_CHARS_START "-+*\\,.;:&>" -+#else /* UTF8 */ -+#define NO_FORMAT_CHARS_START L"-+*\\,.;:&>" -+#endif /* UTF8 */ -+ - #define FONT_MEAN_WIDTH 1 - - static long -@@ -57,14 +62,21 @@ line_start (WEdit *edit, long line) - p = edit_move_forward (edit, p, line - l, 0); - - p = edit_bol (edit, p); -+ -+#ifndef UTF8 - while (strchr ("\t ", edit_get_byte (edit, p))) -+#else /* UTF8 */ -+ while (wcschr (L"\t ", edit_get_byte (edit, p))) -+#endif /* UTF8 */ -+ - p++; - return p; - } - - static int bad_line_start (WEdit * edit, long p) - { -- int c; -+ mc_wint_t c; -+ - c = edit_get_byte (edit, p); - if (c == '.') { /* `...' is acceptable */ - if (edit_get_byte (edit, p + 1) == '.') -@@ -78,7 +90,13 @@ static int bad_line_start (WEdit * edit, long p) - return 0; /* `---' is acceptable */ - return 1; - } -+ -+#ifndef UTF8 - if (strchr (NO_FORMAT_CHARS_START, c)) -+#else /* UTF8 */ -+ if (wcschr (NO_FORMAT_CHARS_START, c)) -+#endif /* UTF8 */ -+ - return 1; - return 0; - } -@@ -131,33 +149,37 @@ end_paragraph (WEdit *edit, int force) - i - edit->curs_line, 0)); - } - --static unsigned char * -+static mc_wchar_t * - get_paragraph (WEdit *edit, long p, long q, int indent, int *size) - { -- unsigned char *s, *t; -+ mc_wchar_t *s, *t; - #if 0 -- t = g_malloc ((q - p) + 2 * (q - p) / option_word_wrap_line_length + -- 10); -+ t = g_malloc (((q - p) + 2 * (q - p) / option_word_wrap_line_length + -+ 10) * sizeof(mc_wchar_t)); - #else -- t = g_malloc (2 * (q - p) + 100); -+ t = g_malloc ((2 * (q - p) + 100) * sizeof(mc_wchar_t)); - #endif - if (!t) - return 0; - for (s = t; p < q; p++, s++) { - if (indent) - if (edit_get_byte (edit, p - 1) == '\n') -+#ifndef UTF8 - while (strchr ("\t ", edit_get_byte (edit, p))) -+#else /* UTF8 */ -+ while (wcschr (L"\t ", edit_get_byte (edit, p))) -+#endif /* UTF8 */ - p++; - *s = edit_get_byte (edit, p); - } -- *size = (unsigned long) s - (unsigned long) t; -+ *size = s - t; - t[*size] = '\n'; - return t; - } - --static void strip_newlines (unsigned char *t, int size) -+static void strip_newlines (mc_wchar_t *t, int size) - { -- unsigned char *p = t; -+ mc_wchar_t *p = t; - while (size--) { - *p = *p == '\n' ? ' ' : *p; - p++; -@@ -174,7 +196,7 @@ static inline int next_tab_pos (int x) - { - return x += tab_width - x % tab_width; - } --static int line_pixel_length (unsigned char *t, long b, int l) -+static int line_pixel_length (mc_wchar_t *t, long b, int l) - { - int x = 0, c, xn = 0; - for (;;) { -@@ -198,7 +220,7 @@ static int line_pixel_length (unsigned char *t, long b, int l) - } - - static int --next_word_start (unsigned char *t, int q, int size) -+next_word_start (mc_wchar_t *t, int q, int size) - { - int i; - int saw_ws = 0; -@@ -222,7 +244,7 @@ next_word_start (unsigned char *t, int q, int size) - - /* find the start of a word */ - static int --word_start (unsigned char *t, int q, int size) -+word_start (mc_wchar_t *t, int q, int size) - { - int i = q; - if (t[q] == ' ' || t[q] == '\t') -@@ -241,7 +263,7 @@ word_start (unsigned char *t, int q, int size) - } - - /* replaces ' ' with '\n' to properly format a paragraph */ --static void format_this (unsigned char *t, int size, int indent) -+static void format_this (mc_wchar_t *t, int size, int indent) - { - int q = 0, ww; - strip_newlines (t, size); -@@ -269,7 +291,7 @@ static void format_this (unsigned char *t, int size, int indent) - } - } - --static void replace_at (WEdit * edit, long q, int c) -+static void replace_at (WEdit * edit, long q, mc_wint_t c) - { - edit_cursor_move (edit, q - edit->curs1); - edit_delete (edit); -@@ -278,18 +300,27 @@ static void replace_at (WEdit * edit, long q, int c) - - /* replaces a block of text */ - static void --put_paragraph (WEdit * edit, unsigned char *t, long p, int indent, int size) -+put_paragraph (WEdit * edit, mc_wchar_t *t, long p, int indent, int size) - { - long cursor; -- int i, c = 0; -+ int i; -+ mc_wchar_t c = 0; - cursor = edit->curs1; - if (indent) -+#ifndef UTF8 - while (strchr ("\t ", edit_get_byte (edit, p))) -+#else /* UTF8 */ -+ while (wcschr (L"\t ", edit_get_byte (edit, p))) -+#endif /* UTF8 */ - p++; - for (i = 0; i < size; i++, p++) { - if (i && indent) { - if (t[i - 1] == '\n' && c == '\n') { -+#ifndef UTF8 - while (strchr ("\t ", edit_get_byte (edit, p))) -+#else /* UTF8 */ -+ while (wcschr (L"\t ", edit_get_byte (edit, p))) -+#endif /* UTF8 */ - p++; - } else if (t[i - 1] == '\n') { - long curs; -@@ -301,7 +332,11 @@ put_paragraph (WEdit * edit, unsigned char *t, long p, int indent, int size) - p = edit->curs1; - } else if (c == '\n') { - edit_cursor_move (edit, p - edit->curs1); -+#ifndef UTF8 - while (strchr ("\t ", edit_get_byte (edit, p))) { -+#else /* UTF8 */ -+ while (wcschr (L"\t ", edit_get_byte (edit, p))) { -+#endif /* UTF8 */ - edit_delete (edit); - if (cursor > edit->curs1) - cursor--; -@@ -334,7 +369,7 @@ format_paragraph (WEdit *edit, int force) - { - long p, q; - int size; -- unsigned char *t; -+ mc_wchar_t *t; - int indent = 0; - if (option_word_wrap_line_length < 2) - return; -@@ -348,13 +383,21 @@ format_paragraph (WEdit *edit, int force) - return; - if (!force) { - int i; -+#ifndef UTF8 - if (strchr (NO_FORMAT_CHARS_START, *t)) { -+#else /* UTF8 */ -+ if (wcschr (NO_FORMAT_CHARS_START, *t)) { -+#endif /* UTF8 */ - g_free (t); - return; - } - for (i = 0; i < size - 1; i++) { - if (t[i] == '\n') { -+#ifndef UTF8 - if (strchr (NO_FORMAT_CHARS_START "\t ", t[i + 1])) { -+#else /* UTF8 */ -+ if (wcschr (NO_FORMAT_CHARS_START "\t", t[i + 1])) { -+#endif /* UTF8 */ - g_free (t); - return; - } -diff --git a/po/ru.po b/po/ru.po -index 5ee11d0..76c3a6b 100644 ---- a/po/ru.po -+++ b/po/ru.po -@@ -3650,5 +3650,30 @@ msgstr " - #~ " ÔÅÐÅÒØ ÈÒÁÎÑÔÓÑ × ËÁÔÁÌÏÇÅ ~/.mc, ÓÔÁÒÙÅ \n" - #~ " ÆÁÊÌÙ ÓÅÊÞÁÓ ÔÕÄÁ ÐÅÒÅÍÅÝÅÎÙ\n" - --#~ msgid "%s bytes in %d files" --#~ msgstr "%s ÂÁÊÔ × %d ÆÁÊÌÁÈ" -+#: messages for recode patch -+msgid "Panel &codepage" -+msgstr "ëÏÄÉÒÏ×ËÁ ÐÁÎÅÌÉ" -+ -+msgid " Choose codepage " -+msgstr " ÷ÙÂÅÒÉÔÅ ËÏÄÉÒÏ×ËÕ" -+ -+msgid " Choose panel codepage " -+msgstr " ÷ÙÂÅÒÉÔÅ ËÏÄÉÒÏ×ËÕ ÐÁÎÅÌÉ " -+ -+msgid " Choose default FTP codepage " -+msgstr " ÷ÙÂÅÒÉÔÅ ËÏÄÉÒÏ×ËÕ FTP ÐÏ ÕÍÏÌÞÁÎÉÀ " -+ -+msgid "FTP default codepage:" -+msgstr "ëÏÄÉÒÏ×ËÁ FTP ÐÏ ÕÍÏÌÞÁÎÉÀ:" -+ -+msgid "Recode file names:" -+msgstr "ðÅÒÅËÏÄÉÒÏ×ÁÔØ ÉÍÅÎÁ:" -+ -+msgid "Recoding works only with COPY/MOVE operation" -+msgstr "ðÅÒÅËÏÄÉÒÏ×ËÁ ÒÁÂÏÔÁÅÔ ÔÏÌØËÏ ÄÌÑ ÏÐÅÒÁÃÉÊ ËÏÐÉÒÏ×ÁÎÉÑ/ÐÅÒÅÍÅÝÅÎÉÑ" -+ -+msgid " Choose \"FROM\" codepage for COPY/MOVE operaion " -+msgstr" ÷ÙÂÅÒÉÔÅ ÎÁÞÁÌØÎÕÀ ËÏÄÉÒÏ×ËÕ ÄÌÑ ÏÐÅÒÁÃÉÉ ËÏÐÉÒÏ×ÁÎÉÑ/ÐÅÒÅÍÅÝÅÎÉÑ " -+ -+msgid " Choose \"TO\" codepage for COPY/MOVE operaion " -+msgstr" ÷ÙÂÅÒÉÔÅ ËÏÎÅÞÎÕÀ ËÏÄÉÒÏ×ËÕ ÄÌÑ ÏÐÅÒÁÃÉÉ ËÏÐÉÒÏ×ÁÎÉÑ/ÐÅÒÅÍÅÝÅÎÉÑ " -diff --git a/src/Makefile.am b/src/Makefile.am -index d43b198..90bd1b1 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -41,7 +41,8 @@ endif - mc_LDADD = $(EDITLIB) $(SLANGLIB) $(VFSLIB) \ - $(INTLLIBS) $(GLIB_LIBS) $(MCLIBS) $(LIBICONV) - --CHARSET_SRC = charsets.c charsets.h selcodepage.c selcodepage.h -+CHARSET_SRC = charsets.c charsets.h selcodepage.c selcodepage.h \ -+ recode.c recode.h - - SRCS = achown.c achown.h background.c background.h boxes.c boxes.h \ - chmod.c chmod.h chown.c chown.h cmd.c cmd.h color.c color.h \ -@@ -58,7 +59,7 @@ SRCS = achown.c achown.h background.c background.h boxes.c boxes.h \ - menu.c menu.h mountlist.c mountlist.h mouse.c mouse.h myslang.h \ - option.c option.h panel.h panelize.c panelize.h poptalloca.h \ - popt.c poptconfig.c popt.h popthelp.c poptint.h poptparse.c \ -- profile.c profile.h regex.c rxvt.c screen.c setup.c setup.h \ -+ profile.c profile.h regex.c rxvt.c screen.c screen.h setup.c setup.h \ - slint.c subshell.c subshell.h textconf.c textconf.h \ - tree.c tree.h treestore.c treestore.h timefmt.h tty.c tty.h user.c \ - user.h util.c util.h utilunix.c view.c view.h vfsdummy.h widget.c \ -diff --git a/src/achown.c b/src/achown.c -index 72ddcad..f1f3024 100644 ---- a/src/achown.c -+++ b/src/achown.c -@@ -585,6 +585,12 @@ init_chown_advanced (void) - b_att[2] = button_new (XTRACT (6)); - b_user = button_new (XTRACT (5)); - b_group = button_new (XTRACT (4)); -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) { -+ b_user->text = g_realloc (b_user->text, MB_CUR_MAX * 15 + 1); -+ b_group->text = g_realloc (b_group->text, MB_CUR_MAX * 15 + 1); -+ } -+#endif - - add_widget (ch_dlg, b_group); - add_widget (ch_dlg, b_user); -diff --git a/src/boxes.c b/src/boxes.c -index 0ff72d4..82a0e1b 100644 ---- a/src/boxes.c -+++ b/src/boxes.c -@@ -53,6 +53,7 @@ - #ifdef HAVE_CHARSET - #include "charsets.h" - #include "selcodepage.h" -+#include "recode.h" - #endif - - #ifdef USE_NETCODE -@@ -154,23 +155,23 @@ display_init (int radio_sel, char *init_text, int _check_status, - display_title = _(display_title); - for (i = 0; i < LIST_TYPES; i++) { - displays[i] = _(displays[i]); -- if ((l = strlen (displays[i])) > maxlen) -+ if ((l = mbstrlen (displays[i])) > maxlen) - maxlen = l; - } - -- i = strlen (ok_button) + 5; -- l = strlen (cancel_button) + 3; -+ i = mbstrlen (ok_button) + 5; -+ l = mbstrlen (cancel_button) + 3; - l = max (i, l); - - i = maxlen + l + 16; - if (i > DISPLAY_X) - DISPLAY_X = i; - -- i = strlen (user_mini_status) + 13; -+ i = mbstrlen (user_mini_status) + 13; - if (i > DISPLAY_X) - DISPLAY_X = i; - -- i = strlen (display_title) + 10; -+ i = mbstrlen (display_title) + 10; - if (i > DISPLAY_X) - DISPLAY_X = i; - -@@ -290,20 +291,20 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive, int *exec_first) - int maxlen = 0; - for (i = SORT_TYPES - 1; i >= 0; i--) { - sort_orders_names[i] = _(sort_orders[i].sort_name); -- r = strlen (sort_orders_names[i]); -+ r = mbstrlen (sort_orders_names[i]); - if (r > maxlen) - maxlen = r; - } - - check_pos = maxlen + 9; - -- r = strlen (reverse_label) + 4; -- i = strlen (case_label) + 4; -+ r = mbstrlen (reverse_label) + 4; -+ i = mbstrlen (case_label) + 4; - if (i > r) - r = i; - -- l = strlen (ok_button) + 6; -- i = strlen (cancel_button) + 4; -+ l = mbstrlen (ok_button) + 6; -+ i = mbstrlen (cancel_button) + 4; - if (i > l) - l = i; - -@@ -312,7 +313,7 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive, int *exec_first) - if (i > SORT_X) - SORT_X = i; - -- i = strlen (sort_title) + 6; -+ i = mbstrlen (sort_title) + 6; - if (i > SORT_X) - SORT_X = i; - -@@ -413,7 +414,7 @@ confirm_box (void) - while (i--) - { - conf_widgets [i].text = _(conf_widgets [i].text); -- l1 = strlen (conf_widgets [i].text) + 3; -+ l1 = mbstrlen (conf_widgets [i].text) + 3; - if (l1 > maxlen) - maxlen = l1; - } -@@ -428,8 +429,8 @@ confirm_box (void) - * And this for the case when buttons with some space to the right - * do not fit within 2/6 - */ -- l1 = strlen (conf_widgets [0].text) + 3; -- i = strlen (conf_widgets [1].text) + 5; -+ l1 = mbstrlen (conf_widgets [0].text) + 3; -+ i = mbstrlen (conf_widgets [1].text) + 5; - if (i > l1) - l1 = i; - -@@ -459,8 +460,8 @@ confirm_box (void) - } - } - --#define DISPY 11 --#define DISPX 46 -+#define DISPY 13 -+#define DISPX 35 - - - #ifndef HAVE_CHARSET -@@ -502,11 +503,11 @@ display_bits_box (void) - { - display_widgets [i].text = _(display_widgets[i].text); - display_bits_str [i] = _(display_bits_str [i]); -- l1 = strlen (display_bits_str [i]); -+ l1 = mbstrlen (display_bits_str [i]); - if (l1 > maxlen) - maxlen = l1; - } -- l1 = strlen (display_widgets [2].text); -+ l1 = mbstrlen (display_widgets [2].text); - if (l1 > maxlen) - maxlen = l1; - -@@ -514,8 +515,8 @@ display_bits_box (void) - display_bits.xlen = (maxlen + 5) * 6 / 4; - - /* See above confirm_box */ -- l1 = strlen (display_widgets [0].text) + 3; -- i = strlen (display_widgets [1].text) + 5; -+ l1 = mbstrlen (display_widgets [0].text) + 3; -+ i = mbstrlen (display_widgets [1].text) + 5; - if (i > l1) - l1 = i; - -@@ -556,23 +557,58 @@ display_bits_box (void) - - - static int new_display_codepage; -+static int new_ftp_codepage; - --static WLabel *cplabel; - static WCheck *inpcheck; - -+static WButton *cpbutton; -+static WButton *cpbutton_ftp; -+ - static int - sel_charset_button (int action) - { - const char *cpname; - char buf[64]; -- new_display_codepage = select_charset (new_display_codepage, 1); -+ new_display_codepage = select_charset (new_display_codepage, 1, _(" Choose input codepage ")); - cpname = (new_display_codepage < 0) - ? _("Other 8 bit") - : codepages[new_display_codepage].name; - - /* avoid strange bug with label repainting */ -- g_snprintf (buf, sizeof (buf), "%-27s", cpname); -- label_set_text (cplabel, buf); -+ sprintf( buf, "%s", cpname ); -+ button_set_text (cpbutton, buf); -+ -+ if(new_display_codepage<0) new_ftp_codepage=-1; -+ cpname = (new_ftp_codepage < 0) -+ ? _("Other 8 bit") -+ : codepages[ new_ftp_codepage ].name; -+ sprintf( buf, "%s", cpname ); -+ button_set_text (cpbutton_ftp, buf); -+ -+ return 0; -+} -+ -+static int sel_charset_button_ftp(int action) { -+ char *cpname, buf[64]; -+ if(new_display_codepage>0) { -+ new_ftp_codepage = select_charset(new_ftp_codepage, 0, _(" Choose default FTP codepage ")); -+ cpname = (new_display_codepage < 0) -+ ? _("Other 8 bit") -+ : codepages[ new_display_codepage ].name; -+ sprintf( buf, "%s", cpname ); -+ button_set_text( cpbutton, buf ); -+ cpname = (new_ftp_codepage < 0) -+ ? _("Other 8 bit") -+ : codepages[ new_ftp_codepage ].name; -+ sprintf( buf, "%s", cpname ); -+ button_set_text( cpbutton_ftp, buf ); -+ } -+ else { -+ message( 1, _(" Warning "), -+ _("To use this feature select your codepage in\n" -+ "Setup / Display Bits dialog!\n" -+ "Do not forget to save options." )); -+ } - return 0; - } - -@@ -594,9 +630,6 @@ init_disp_bits_box (void) - cpname = (new_display_codepage < 0) - ? _("Other 8 bit") - : codepages[new_display_codepage].name; -- cplabel = label_new (4, 4, cpname); -- add_widget (dbits_dlg, cplabel); -- - add_widget (dbits_dlg, - button_new (DISPY - 3, DISPX / 2 + 3, B_CANCEL, - NORMAL_BUTTON, _("&Cancel"), 0)); -@@ -605,13 +638,30 @@ init_disp_bits_box (void) - 0)); - - inpcheck = -- check_new (6, 4, !use_8th_bit_as_meta, _("F&ull 8 bits input")); -+ check_new (8, 4, !use_8th_bit_as_meta, _("F&ull 8 bits input")); - add_widget (dbits_dlg, inpcheck); - -- cpname = _("&Select"); -- add_widget (dbits_dlg, -- button_new (4, DISPX - 8 - strlen (cpname), B_USER, -- NORMAL_BUTTON, cpname, sel_charset_button)); -+ -+ add_widget( dbits_dlg, label_new( 5, 4, _("FTP default codepage:"))); -+ if(n_codepages>0) { -+ cpname = (new_display_codepage < 0) -+ ? _("Other 8 bit") -+ : codepages[ new_display_codepage ].name; -+ } -+ else cpname= _("Other 8 bit"); -+ cpbutton=button_new(4, 5, B_USER, -+ NORMAL_BUTTON, cpname, sel_charset_button); -+ -+ if(n_codepages>0) { -+ cpname = (new_ftp_codepage < 0) -+ ? _("Other 8 bit") -+ : codepages[ new_ftp_codepage ].name; -+ } -+ else cpname= _("Other 8 bit"); -+ cpbutton_ftp=button_new(6, 5, B_USER, -+ NORMAL_BUTTON, cpname, sel_charset_button_ftp); -+ add_widget( dbits_dlg, cpbutton_ftp); -+ add_widget (dbits_dlg, cpbutton); - - return dbits_dlg; - } -@@ -621,6 +671,7 @@ display_bits_box (void) - { - Dlg_head *dbits_dlg; - new_display_codepage = display_codepage; -+ new_ftp_codepage = ftp_codepage; - - application_keypad_mode (); - dbits_dlg = init_disp_bits_box (); -@@ -641,6 +692,17 @@ display_bits_box (void) - && display_codepage != 1) ? 128 : 160; - #endif - use_8th_bit_as_meta = !(inpcheck->state & C_BOOL); -+ -+ ftp_codepage=new_ftp_codepage; -+ if(display_codepage<=0) { -+ panel_reset_codepage(left_panel); -+ paint_dir(left_panel); -+ display_mini_info(left_panel); -+ panel_reset_codepage(right_panel); -+ paint_dir(right_panel); -+ display_mini_info(right_panel); -+ } -+ - } - destroy_dlg (dbits_dlg); - repaint_screen (); -@@ -821,7 +883,7 @@ cd_dialog (void) - quick_widgets [1].y_divisions = - quick_widgets [0].y_divisions = Quick_input.ylen = 5; - -- len = strlen (quick_widgets [1].text); -+ len = mbstrlen (quick_widgets [1].text); - - quick_widgets [0].relative_x = - quick_widgets [1].relative_x + len + 1; -@@ -980,7 +1042,7 @@ jobs_cmd (void) - { - job_buttons [i].name = _(job_buttons [i].name); - -- len = strlen (job_buttons [i].name) + 4; -+ len = mbstrlen (job_buttons [i].name) + 4; - JOBS_X = max (JOBS_X, startx + len + 3); - - job_buttons [i].xpos = startx; -@@ -989,7 +1051,7 @@ jobs_cmd (void) - - /* Last button - Ok a.k.a. Cancel :) */ - job_buttons [n_buttons - 1].xpos = -- JOBS_X - strlen (job_buttons [n_buttons - 1].name) - 7; -+ JOBS_X - mbstrlen (job_buttons [n_buttons - 1].name) - 7; - - i18n_flag = 1; - } -@@ -1047,7 +1109,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, - - while (i--) - { -- l1 = strlen (labs [i] = _(labs [i])); -+ l1 = mbstrlen (labs [i] = _(labs [i])); - if (l1 > maxlen) - maxlen = l1; - } -@@ -1057,7 +1119,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, - - for (i = sizeof(buts)/sizeof(buts[0]), l1 = 0; i--; ) - { -- l1 += strlen (buts [i] = _(buts [i])); -+ l1 += mbstrlen (buts [i] = _(buts [i])); - } - l1 += 15; - if (l1 > dialog_x) -@@ -1066,7 +1128,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, - ilen = dialog_x - 7 - maxlen; /* for the case of very long buttons :) */ - istart = dialog_x - 3 - ilen; - -- b2 = dialog_x - (strlen(buts[1]) + 6); -+ b2 = dialog_x - (mbstrlen(buts[1]) + 6); - - i18n_flag = 1; - } -diff --git a/src/charsets.c b/src/charsets.c -index f2e69e0..bac7b3b 100644 ---- a/src/charsets.c -+++ b/src/charsets.c -@@ -123,8 +123,6 @@ free_codepages_list (void) - } - } - --#define OTHER_8BIT "Other_8_bit" -- - const char * - get_codepage_id (int n) - { -@@ -143,7 +141,7 @@ get_codepage_index (const char *id) - return -1; - } - --static char -+char - translate_character (iconv_t cd, char c) - { - char outbuf[4], *obuf; -diff --git a/src/charsets.h b/src/charsets.h -index b701d5a..0698dc2 100644 ---- a/src/charsets.h -+++ b/src/charsets.h -@@ -6,6 +6,7 @@ - #define UNKNCHAR '\001' - - #define CHARSETS_INDEX "mc.charsets" -+#define OTHER_8BIT "Other_8_bit" - - extern int n_codepages; - -@@ -19,6 +20,10 @@ struct codepage_desc { - - extern struct codepage_desc *codepages; - -+#include -+extern char translate_character(iconv_t cd, char c); -+extern char errbuf[255]; -+ - const char *get_codepage_id (int n); - int get_codepage_index (const char *id); - int load_codepages_list (void); -diff --git a/src/cmd.c b/src/cmd.c -index f82165c..e24d563 100644 ---- a/src/cmd.c -+++ b/src/cmd.c -@@ -73,6 +73,10 @@ - # include "../edit/edit.h" - #endif - -+#ifdef HAVE_CHARSET -+#include "recode.h" -+#endif -+ - /* If set and you don't have subshell support,then C-o will give you a shell */ - int output_starts_shell = 0; - -@@ -353,6 +357,9 @@ void - mkdir_cmd (void) - { - char *dir, *absdir; -+#ifdef HAVE_CHARSET -+ char *recoded_dir; -+#endif - - dir = - input_expand_dialog (_("Create a new Directory"), -@@ -363,8 +370,16 @@ mkdir_cmd (void) - - if (dir[0] == '/' || dir[0] == '~') - absdir = g_strdup (dir); -- else -+ else { -+#ifdef HAVE_CHARSET -+ recoded_dir=g_strdup(dir); -+ my_translate_string(dir,strlen(dir), recoded_dir,current_panel->tr_table_input); -+ absdir = mhl_str_dir_plus_file (current_panel->cwd, recoded_dir); -+ g_free(recoded_dir); -+#else - absdir = mhl_str_dir_plus_file (current_panel->cwd, dir); -+#endif -+ } - - save_cwds_stat (); - if (my_mkdir (absdir, 0777) == 0) { -diff --git a/src/dialog.c b/src/dialog.c -index f8467b9..43d117f 100644 ---- a/src/dialog.c -+++ b/src/dialog.c -@@ -167,7 +167,7 @@ common_dialog_repaint (struct Dlg_head *h) - - if (h->title) { - attrset (DLG_HOT_NORMALC (h)); -- dlg_move (h, space, (h->cols - strlen (h->title)) / 2); -+ dlg_move (h, space, (h->cols - mbstrlen (h->title)) / 2); - addstr (h->title); - } - } -diff --git a/src/file.c b/src/file.c -index 6400e3e..056aa11 100644 ---- a/src/file.c -+++ b/src/file.c -@@ -79,6 +79,9 @@ - #include "../vfs/vfs-impl.h" - - /* }}} */ -+#ifdef HAVE_CHARSET -+#include "recode.h" -+#endif - - /* Hack: the vfs code should not rely on this */ - #define WITH_FULL_PATHS 1 -@@ -167,15 +170,20 @@ static const char * - do_transform_source (FileOpContext *ctx, const char *source) - { - size_t j, k, l, len; -- const char *fnsource = x_basename (source); -+ char *fnsource = g_strdup (x_basename (source)); - int next_reg; - enum CaseConvs case_conv = NO_CONV; - static char fntarget[MC_MAXPATHLEN]; - -+#ifdef UTF8 -+ fix_utf8(fnsource); -+#endif -+ - len = strlen (fnsource); - j = re_match (&ctx->rx, fnsource, len, 0, &ctx->regs); - if (j != len) { - transform_error = FILE_SKIP; -+ g_free (fnsource); - return NULL; - } - for (next_reg = 1, j = 0, k = 0; j < strlen (ctx->dest_mask); j++) { -@@ -225,6 +233,7 @@ do_transform_source (FileOpContext *ctx, const char *source) - || ctx->regs.start[next_reg] < 0) { - message (1, MSG_ERROR, _(" Invalid target mask ")); - transform_error = FILE_ABORT; -+ g_free(fnsource); - return NULL; - } - for (l = (size_t) ctx->regs.start[next_reg]; -@@ -239,6 +248,7 @@ do_transform_source (FileOpContext *ctx, const char *source) - } - } - fntarget[k] = 0; -+ g_free(fnsource); - return fntarget; - } - -@@ -922,7 +932,12 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, - } - /* Dive into subdir if exists */ - if (toplevel && ctx->dive_into_subdirs) { -+#ifdef HAVE_CHARSET -+ /*FIXME: Use here somehow mhl_str_dir_plus_file */ -+ dest_dir = concat_dir_and_recoded_fname(d, x_basename (s), ctx); -+#else - dest_dir = mhl_str_dir_plus_file (d, x_basename (s)); -+#endif - } else { - dest_dir = g_strdup (d); - goto dont_mkdir; -@@ -972,7 +987,11 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, - - (*ctx->stat_func) (path, &buf); - if (S_ISDIR (buf.st_mode)) { -+#ifdef HAVE_CHARSET -+ mdpath = concat_dir_and_recoded_fname(dest_dir, next->d_name, ctx); -+#else - mdpath = mhl_str_dir_plus_file (dest_dir, next->d_name); -+#endif - /* - * From here, we just intend to recursively copy subdirs, not - * the double functionality of copying different when the target -@@ -983,7 +1002,11 @@ copy_dir_dir (FileOpContext *ctx, const char *s, const char *d, int toplevel, - parent_dirs, progress_count, progress_bytes); - g_free (mdpath); - } else { -+#ifdef HAVE_CHARSET -+ dest_file=concat_dir_and_recoded_fname(dest_dir, x_basename(path),ctx); -+#else - dest_file = mhl_str_dir_plus_file (dest_dir, x_basename (path)); -+#endif - return_status = copy_file_file (ctx, path, dest_file, 1, - progress_count, progress_bytes, 0); - g_free (dest_file); -@@ -1173,7 +1196,12 @@ move_dir_dir (FileOpContext *ctx, const char *s, const char *d, - destdir = g_strdup (d); - move_over = 1; - } else -+#ifdef HAVE_CHARSET -+ destdir = concat_dir_and_recoded_fname(d, x_basename (s), ctx); -+#else - destdir = mhl_str_dir_plus_file (d, x_basename (s)); -+#endif -+ - - if (sbuf.st_dev == dbuf.st_dev && sbuf.st_ino == dbuf.st_ino) { - int msize = COLS - 36; -@@ -1700,13 +1728,13 @@ panel_operate_generate_prompt (const WPanel *panel, const int operation, - *dp = '\0'; - - if (single_source) { -- i = fmd_xlen - strlen (format_string) - 4; -+ i = fmd_xlen - mbstrlen (format_string) - 4; - g_snprintf (cmd_buf, sizeof (cmd_buf), format_string, - name_trunc (single_source, i)); - } else { - g_snprintf (cmd_buf, sizeof (cmd_buf), format_string, - panel->marked); -- i = strlen (cmd_buf) + 6 - fmd_xlen; -+ i = mbstrlen (cmd_buf) + 6 - fmd_xlen; - if (i > 0) { - fmd_xlen += i; - fmd_init_i18n (TRUE); /* to recalculate positions of child widgets */ -@@ -1901,7 +1929,12 @@ panel_operate (void *source_panel, FileOperation operation, - if (temp == NULL) { - value = transform_error; - } else { -+#ifdef HAVE_CHARSET -+ char *temp2 = concat_dir_and_recoded_fname (dest, temp, ctx); -+#else - char *temp2 = mhl_str_dir_plus_file (dest, temp); -+#endif -+ - g_free (dest); - dest = temp2; - temp = NULL; -@@ -1995,7 +2028,12 @@ panel_operate (void *source_panel, FileOperation operation, - if (temp == NULL) - value = transform_error; - else { -+#ifdef HAVE_CHARSET -+ char *temp2 = concat_dir_and_recoded_fname(dest, temp, ctx); -+#else - char *temp2 = mhl_str_dir_plus_file (dest, temp); -+#endif -+ - - source_with_path = mhl_shell_unescape_buf(source_with_path); - temp2 = mhl_shell_unescape_buf(temp2); -diff --git a/src/filegui.c b/src/filegui.c -index 441adb7..e9920d0 100644 ---- a/src/filegui.c -+++ b/src/filegui.c -@@ -66,6 +66,11 @@ - #include "filegui.h" - #include "key.h" /* get_event */ - #include "util.h" /* strip_password() */ -+#include "tty.h" -+ -+#ifdef HAVE_CHARSET -+#include "recode.h" -+#endif - - /* }}} */ - -@@ -564,8 +569,8 @@ init_replace (FileOpContext *ctx, enum OperationMode mode) - * longest of "Overwrite..." labels - * (assume "Target date..." are short enough) - */ -- l1 = max (strlen (rd_widgets[6].text), -- strlen (rd_widgets[11].text)); -+ l1 = max (mbstrlen (rd_widgets[6].text), -+ mbstrlen (rd_widgets[11].text)); - - /* longest of button rows */ - i = sizeof (rd_widgets) / sizeof (rd_widgets[0]); -@@ -576,7 +581,7 @@ init_replace (FileOpContext *ctx, enum OperationMode mode) - l2 = max (l2, l); - l = 0; - } -- l += strlen (rd_widgets[i].text) + 4; -+ l += mbstrlen (rd_widgets[i].text) + 4; - } - } - l2 = max (l2, l); /* last row */ -@@ -594,12 +599,12 @@ init_replace (FileOpContext *ctx, enum OperationMode mode) - l = l1; - } - rd_widgets[i].xpos = l; -- l += strlen (rd_widgets[i].text) + 4; -+ l += mbstrlen (rd_widgets[i].text) + 4; - } - } - /* Abort button is centered */ - rd_widgets[1].xpos = -- (rd_xlen - strlen (rd_widgets[1].text) - 3) / 2; -+ (rd_xlen - mbstrlen (rd_widgets[1].text) - 3) / 2; - } - #endif /* ENABLE_NLS */ - -@@ -618,7 +623,7 @@ init_replace (FileOpContext *ctx, enum OperationMode mode) - - ADD_RD_LABEL (ui, 0, - name_trunc (ui->replace_filename, -- rd_trunc - strlen (rd_widgets[0].text)), 0); -+ rd_trunc - mbstrlen (rd_widgets[0].text)), 0); - ADD_RD_BUTTON (1); - - ADD_RD_BUTTON (2); -@@ -721,57 +726,79 @@ file_progress_real_query_replace (FileOpContext *ctx, - } - } - -+#ifdef HAVE_CHARSET -+#define FMDY 15 -+#else - #define FMDY 13 -+#endif -+ - #define FMD_XLEN 64 - extern int fmd_xlen; - static QuickWidget fmd_widgets[] = { - --#define FMCB0 FMDC --#define FMCB12 0 --#define FMCB11 1 -- /* follow symlinks and preserve Attributes must be the first */ -- {quick_checkbox, 3, 64, 8, FMDY, N_("preserve &Attributes"), 9, 0, -- 0 /* &op_preserve */ , 0, NULL}, -- {quick_checkbox, 3, 64, 7, FMDY, N_("follow &Links"), 7, 0, -- 0 /* &file_mask_op_follow_links */ , 0, NULL}, -- {quick_label, 3, 64, 5, FMDY, N_("to:"), 0, 0, 0, 0, NULL}, -- {quick_checkbox, 37, 64, 4, FMDY, N_("&Using shell patterns"), 0, 0, -- 0 /* &source_easy_patterns */ , 0, NULL}, -- {quick_input, 3, 64, 3, FMDY, "", 58, -- 0, 0, 0, "input-def"}, --#define FMDI1 4 --#define FMDI2 5 --#define FMDC 3 -- {quick_input, 3, 64, 6, FMDY, "", 58, 0, -- 0, 0, "input2"}, --#define FMDI0 6 -- {quick_label, 3, 64, 2, FMDY, "", 0, 0, 0, 0, NULL}, --#define FMBRGT 7 -- {quick_button, 42, 64, 9, FMDY, N_("&Cancel"), 0, B_CANCEL, 0, 0, -- NULL}, --#undef SKIP -+#ifdef HAVE_CHARSET -+ #define Y_OK 12 -+#else -+ #define Y_OK 9 -+#endif -+ - #ifdef WITH_BACKGROUND --# define SKIP 5 --# define FMCB21 11 --# define FMCB22 10 --# define FMBLFT 9 --# define FMBMID 8 -- {quick_button, 25, 64, 9, FMDY, N_("&Background"), 0, B_USER, 0, 0, -- NULL}, --#else /* WITH_BACKGROUND */ --# define SKIP 4 --# define FMCB21 10 --# define FMCB22 9 --# define FMBLFT 8 --# undef FMBMID -+ #define ADD 0 -+#else -+ #define ADD -1 - #endif -- {quick_button, 14, 64, 9, FMDY, N_("&OK"), 0, B_ENTER, 0, 0, NULL}, -- {quick_checkbox, 42, 64, 8, FMDY, N_("&Stable Symlinks"), 0, 0, -- 0 /* &file_mask_stable_symlinks */ , 0, NULL}, -- {quick_checkbox, 31, 64, 7, FMDY, N_("&Dive into subdir if exists"), 0, -- 0, -- 0 /* &dive_into_subdirs */ , 0, NULL}, -- NULL_QuickWidget -+ -+ #define FM_STAB_SYM 0 -+ #define FM_DIVE_INTO_SUBDIR 1 -+ #define FM_PRES_ATTR 2 -+ #define FM_FOLLOW_LINKS 3 -+ #define FM_DST_INPUT 4 -+ #define FM_DST_TITLE 5 -+ #define FM_USING_SHELL_PATT 6 -+ #define FM_SRC_INPUT 7 -+ #define FM_SRC_TITLE 8 -+ #define FM_CANCEL 9 -+#ifdef WITH_BACKGROUND -+ #define FM_BKGND 10 -+#endif -+ #define FM_OK 11+ADD -+#ifdef HAVE_CHARSET -+ #define FM_TO_CODEPAGE 12+ADD -+ #define FM_FROM_CODEPAGE 13+ADD -+ #define FM_RECODE_TITLE 14+ADD -+ #define FM_RECODE_ARROW 15+ADD -+#endif // HAVE_CHARSET -+ -+ -+#ifdef HAVE_CHARSET -+ #define SKIP 10 -+ #define B_FROM B_USER+1 -+ #define B_TO B_USER+2 -+#else -+ #define SKIP 10 -+#endif -+ -+ {quick_checkbox, 42,64, 8, FMDY, N_("&Stable Symlinks"),0,0,0,0,"stab-sym"}, -+ {quick_checkbox, 31,64, 7, FMDY, N_("&Dive into subdir if exists"),0,0,0,0,"dive"}, -+ {quick_checkbox, 3, 64, 8, FMDY, N_("preserve &Attributes"),9,0,0,0,"preserve"}, -+ {quick_checkbox, 3, 64, 7, FMDY, N_("follow &Links"),7,0,0,0,"follow"}, -+ {quick_input, 3, 64, 6, FMDY, "", 58, 0, 0, 0, "input2"}, -+ {quick_label, 3, 64, 5, FMDY, N_("to:"), 0, 0, 0, 0, "to"}, -+ {quick_checkbox, 37,64, 4, FMDY, N_("&Using shell patterns"),0,0, 0,0,"us-sh"}, -+ {quick_input, 3, 64, 3, FMDY, "", 58, 0, 0, 0, "input-def"}, -+ {quick_label, 3, 64, 2, FMDY, "", 0, 0, 0, 0, "ql"}, -+ {quick_button, 42,64, Y_OK, FMDY, N_("&Cancel"), 0, B_CANCEL, 0,0, "cancel"}, -+#ifdef WITH_BACKGROUND -+ {quick_button, 25,64, Y_OK, FMDY, N_("&Background"), 0, B_USER, 0,0, "back"}, -+#endif -+ {quick_button, 14,64, Y_OK, FMDY, N_("&OK"), 0, B_ENTER, 0, 0, "ok"}, -+#ifdef HAVE_CHARSET -+ {quick_button, 46,64, 10, FMDY,"to codepage", 0, B_TO, 0, 0, "ql"}, -+ {quick_button, 25,64, 10, FMDY, "from codepage", 0, B_FROM, 0, 0, "ql"}, -+ {quick_label, 3, 64, 10, FMDY, N_("Recode file names:"), 0, 0, 0, 0, "ql"}, -+ {quick_label, 42,64, 10, FMDY, "->", 0, 0, 0, 0, "ql"}, -+#endif -+ {0} - }; - - static int -@@ -805,48 +832,48 @@ fmd_init_i18n (int force) - if (fmd_widgets[i].text[0] != '\0') - fmd_widgets[i].text = _(fmd_widgets[i].text); - -- len = strlen (fmd_widgets[FMCB11].text) -- + strlen (fmd_widgets[FMCB21].text) + 15; -+ len = mbstrlen (fmd_widgets[FM_FOLLOW_LINKS].text) -+ + mbstrlen (fmd_widgets[FM_DIVE_INTO_SUBDIR].text) + 15; - fmd_xlen = max (fmd_xlen, len); - -- len = strlen (fmd_widgets[FMCB12].text) -- + strlen (fmd_widgets[FMCB22].text) + 15; -+ len = mbstrlen (fmd_widgets[FM_PRES_ATTR].text) -+ + mbstrlen (fmd_widgets[FM_STAB_SYM].text) + 15; - fmd_xlen = max (fmd_xlen, len); - -- len = strlen (fmd_widgets[FMBRGT].text) -- + strlen (fmd_widgets[FMBLFT].text) + 11; -+ len = mbstrlen (fmd_widgets[FM_CANCEL].text) -+ + mbstrlen (fmd_widgets[FM_OK].text) + 11; - --#ifdef FMBMID -- len += strlen (fmd_widgets[FMBMID].text) + 6; -+#ifdef FM_BKGND -+ len += mbstrlen (fmd_widgets[FM_BKGND].text) + 6; - #endif - - fmd_xlen = max (fmd_xlen, len + 4); - - len = (fmd_xlen - (len + 6)) / 2; -- i = fmd_widgets[FMBLFT].relative_x = len + 3; -- i += strlen (fmd_widgets[FMBLFT].text) + 8; -+ i = fmd_widgets[FM_OK].relative_x = len + 3; -+ i += mbstrlen (fmd_widgets[FM_OK].text) + 8; - --#ifdef FMBMID -- fmd_widgets[FMBMID].relative_x = i; -- i += strlen (fmd_widgets[FMBMID].text) + 6; -+#ifdef FM_BKGND -+ fmd_widgets[FM_BKGND].relative_x = i; -+ i += mbstrlen (fmd_widgets[FM_BKGND].text) + 6; - #endif - -- fmd_widgets[FMBRGT].relative_x = i; -+ fmd_widgets[FM_CANCEL].relative_x = i; - - #define chkbox_xpos(i) \ -- fmd_widgets [i].relative_x = fmd_xlen - strlen (fmd_widgets [i].text) - 6 -+ fmd_widgets [i].relative_x = fmd_xlen - mbstrlen (fmd_widgets [i].text) - 6 - -- chkbox_xpos (FMCB0); -- chkbox_xpos (FMCB21); -- chkbox_xpos (FMCB22); -+ chkbox_xpos (FM_USING_SHELL_PATT); -+ chkbox_xpos (FM_DIVE_INTO_SUBDIR); -+ chkbox_xpos (FM_STAB_SYM); - - if (fmd_xlen != FMD_XLEN) { - i = sizeof (fmd_widgets) / sizeof (fmd_widgets[0]) - 1; - while (i--) - fmd_widgets[i].x_divisions = fmd_xlen; - -- fmd_widgets[FMDI1].hotkey_pos = -- fmd_widgets[FMDI2].hotkey_pos = fmd_xlen - 6; -+ fmd_widgets[FM_SRC_INPUT].hotkey_pos = -+ fmd_widgets[FM_DST_INPUT].hotkey_pos = fmd_xlen - 6; - } - #undef chkbox_xpos - -@@ -856,7 +883,7 @@ fmd_init_i18n (int force) - - char * - file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, -- const char *def_text, int only_one, int *do_background) -+ const char *def_text_orig, int only_one, int *do_background) - { - int source_easy_patterns = easy_patterns; - char *source_mask, *orig_mask, *dest_dir, *tmpdest; -@@ -865,20 +892,32 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, - struct stat buf; - int val; - QuickDialog Quick_input; -- -+ char *def_text; -+#ifdef HAVE_CHARSET -+ char *errmsg; -+#endif - g_return_val_if_fail (ctx != NULL, NULL); -+ -+ def_text = g_strdup(def_text_orig); -+ - #if 0 - message (1, __FUNCTION__, "text = `%s' \n def_text = `%s'", text, - def_text); - #endif -+ -+#ifdef UTF8 -+ fix_utf8(def_text); -+#endif -+ - fmd_init_i18n (FALSE); - - /* Set up the result pointers */ - -- fmd_widgets[FMCB12].result = &ctx->op_preserve; -- fmd_widgets[FMCB11].result = &ctx->follow_links; -- fmd_widgets[FMCB22].result = &ctx->stable_symlinks; -- fmd_widgets[FMCB21].result = &ctx->dive_into_subdirs; -+ fmd_widgets[FM_PRES_ATTR].result = &ctx->op_preserve; -+ fmd_widgets[FM_FOLLOW_LINKS].result = &ctx->follow_links; -+ fmd_widgets[FM_STAB_SYM].result = &ctx->stable_symlinks; -+ fmd_widgets[FM_DIVE_INTO_SUBDIR].result = &ctx->dive_into_subdirs; -+ - - /* filter out a possible password from def_text */ - def_text_secure = strip_password (g_strdup (def_text), 1); -@@ -886,8 +925,9 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, - /* Create the dialog */ - - ctx->stable_symlinks = 0; -- fmd_widgets[FMDC].result = &source_easy_patterns; -- fmd_widgets[FMDI1].text = easy_patterns ? "*" : "^\\(.*\\)$"; -+ fmd_widgets[FM_USING_SHELL_PATT].result = &source_easy_patterns; -+ fmd_widgets[FM_SRC_INPUT].text = easy_patterns ? "*" : "^\\(.*\\)$"; -+ - Quick_input.xlen = fmd_xlen; - Quick_input.xpos = -1; - Quick_input.title = op_names[operation]; -@@ -895,19 +935,37 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, - Quick_input.ylen = FMDY; - Quick_input.i18n = 1; - Quick_input.widgets = fmd_widgets; -- fmd_widgets[FMDI0].text = text; -- fmd_widgets[FMDI2].text = def_text_secure; -- fmd_widgets[FMDI2].str_result = &dest_dir; -- fmd_widgets[FMDI1].str_result = &source_mask; -+ fmd_widgets[FM_SRC_TITLE].text = text; -+ fmd_widgets[FM_DST_INPUT].text = def_text_secure; -+ fmd_widgets[FM_DST_INPUT].str_result = &dest_dir; -+ fmd_widgets[FM_SRC_INPUT].str_result = &source_mask; - - *do_background = 0; -+ -+#ifdef HAVE_CHARSET -+ ctx->from_codepage=current_panel->src_codepage; -+ ctx->to_codepage=left_panel->src_codepage; -+ if (left_panel) { -+ ctx->to_codepage=left_panel->src_codepage; -+ if( (current_panel==left_panel) && right_panel ) ctx->to_codepage=right_panel->src_codepage; -+ } -+#endif -+ - ask_file_mask: - -+#ifdef HAVE_CHARSET -+ if(operation!=OP_COPY && operation!=OP_MOVE) { -+ ctx->from_codepage=-1; -+ ctx->to_codepage=-1; -+ } -+ fmd_widgets[FM_FROM_CODEPAGE].text=get_codepage_id(ctx->from_codepage); -+ fmd_widgets[FM_TO_CODEPAGE].text=get_codepage_id(ctx->to_codepage); -+#endif -+ - if ((val = quick_dialog_skip (&Quick_input, SKIP)) == B_CANCEL) { - g_free (def_text_secure); - return 0; - } -- g_free (def_text_secure); - - if (ctx->follow_links) - ctx->stat_func = mc_stat; -@@ -929,6 +987,8 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, - orig_mask = source_mask; - if (!dest_dir || !*dest_dir) { - g_free (source_mask); -+ g_free (def_text_secure); -+ g_free(def_text); - return dest_dir; - } - if (source_easy_patterns) { -@@ -982,5 +1042,48 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text, - } - if (val == B_USER) - *do_background = 1; -+#ifdef HAVE_CHARSET -+ if(val == B_FROM) { -+ if(operation==OP_COPY || operation==OP_MOVE) { -+ if(display_codepage<=0) { -+ message( 1, _(" Warning "), -+ _("To use this feature select your codepage in\n" -+ "Setup / Display Bits dialog!\n" -+ "Do not forget to save options." )); -+ goto ask_file_mask; -+ } -+ ctx->from_codepage=select_charset(ctx->from_codepage,0, -+ _(" Choose \"FROM\" codepage for COPY/MOVE operaion ")); -+ } -+ else -+ message(1,"Warning",_("Recoding works only with COPY or MOVE operation")); -+ goto ask_file_mask; -+ } -+ if(val == B_TO) { -+ if(operation==OP_COPY || operation==OP_MOVE) { -+ if(display_codepage<=0) { -+ message( 1, _(" Warning "), -+ _("To use this feature select your codepage in\n" -+ "Setup / Display Bits dialog!\n" -+ "Do not forget to save options." )); -+ goto ask_file_mask; -+ } -+ ctx->to_codepage=select_charset(ctx->to_codepage,0, -+ _(" Choose \"TO\" codepage for COPY/MOVE operaion ")); -+ } -+ else -+ message(1,"Warning",_("Recoding works only with COPY or MOVE operation")); -+ goto ask_file_mask; -+ } -+ -+ errmsg=my_init_tt(ctx->to_codepage,ctx->from_codepage,ctx->tr_table); -+ if(errmsg) { -+ my_reset_tt(ctx->tr_table,256); -+ message( 1, MSG_ERROR, "%s", errmsg); -+ } -+#endif -+ -+ g_free(def_text_secure); -+ g_free(def_text); - return dest_dir; - } -diff --git a/src/fileopctx.c b/src/fileopctx.c -index ad02cf4..904b7f8 100644 ---- a/src/fileopctx.c -+++ b/src/fileopctx.c -@@ -26,8 +26,12 @@ - #include - - #include "global.h" --#include "fileopctx.h" - -+#ifdef HAVE_CHARSET -+#include "recode.h" -+#endif -+ -+#include "fileopctx.h" - - /** - * file_op_context_new: -@@ -54,6 +58,12 @@ file_op_context_new (FileOperation op) - ctx->umask_kill = 0777777; - ctx->erase_at_end = TRUE; - -+#ifdef HAVE_CHARSET -+ ctx->from_codepage=-1; -+ ctx->to_codepage=-1; -+ my_reset_tt(ctx->tr_table,256); -+#endif -+ - return ctx; - } - -diff --git a/src/fileopctx.h b/src/fileopctx.h -index d2de6a9..339ab42 100644 ---- a/src/fileopctx.h -+++ b/src/fileopctx.h -@@ -108,6 +108,14 @@ typedef struct FileOpContext { - /* User interface data goes here */ - - void *ui; -+ -+#ifdef HAVE_CHARSET -+ /* Recode data */ -+ int from_codepage, to_codepage; -+ unsigned char tr_table[256]; -+ unsigned char recode_buf[MC_MAXPATHLEN]; -+#endif -+ - } FileOpContext; - - -diff --git a/src/find.c b/src/find.c -index 9ff1ef7..daa1d5b 100644 ---- a/src/find.c -+++ b/src/find.c -@@ -219,7 +219,7 @@ find_parameters (char **start_dir, char **pattern, char **content) - int l1, maxlen = 0; - - while (i--) { -- l1 = strlen (labs[i] = _(labs[i])); -+ l1 = mbstrlen (labs[i] = _(labs[i])); - if (l1 > maxlen) - maxlen = l1; - } -@@ -228,7 +228,7 @@ find_parameters (char **start_dir, char **pattern, char **content) - FIND_X = i; - - for (i = sizeof (buts) / sizeof (buts[0]), l1 = 0; i--;) { -- l1 += strlen (buts[i] = _(buts[i])); -+ l1 += mbstrlen (buts[i] = _(buts[i])); - } - l1 += 21; - if (l1 > FIND_X) -@@ -237,8 +237,8 @@ find_parameters (char **start_dir, char **pattern, char **content) - ilen = FIND_X - 7 - maxlen; /* for the case of very long buttons :) */ - istart = FIND_X - 3 - ilen; - -- b1 = b0 + strlen (buts[0]) + 7; -- b2 = FIND_X - (strlen (buts[2]) + 6); -+ b1 = b0 + mbstrlen (buts[0]) + 7; -+ b2 = FIND_X - (mbstrlen (buts[2]) + 6); - - i18n_flag = 1; - case_label = _(case_label); -@@ -865,7 +865,7 @@ setup_gui (void) - if (!i18n_flag) { - register int i = sizeof (fbuts) / sizeof (fbuts[0]); - while (i--) -- fbuts[i].len = strlen (fbuts[i].text = _(fbuts[i].text)) + 3; -+ fbuts[i].len = mbstrlen (fbuts[i].text = _(fbuts[i].text)) + 3; - fbuts[2].len += 2; /* DEFPUSH_BUTTON */ - i18n_flag = 1; - } -@@ -1030,7 +1030,7 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname, - - if (!next_free) /* first turn i.e clean old list */ - panel_clean_dir (current_panel); -- list->list[next_free].fnamelen = strlen (name); -+ list->list[next_free].fnamelen = mbstrlen (name); - list->list[next_free].fname = name; - list->list[next_free].f.marked = 0; - list->list[next_free].f.link_to_dir = link_to_dir; -diff --git a/src/help.c b/src/help.c -index 3261cbb..2f5bdac 100644 ---- a/src/help.c -+++ b/src/help.c -@@ -416,10 +416,28 @@ static void help_show (Dlg_head *h, const char *paint_start) - #ifndef HAVE_SLANG - addch (acs_map [c]); - #else -+#if defined(UTF8) && SLANG_VERSION < 20000 -+ SLsmg_draw_object (h->y + line + 2, h->x + col + 2, acs_map [c]); -+#else - SLsmg_draw_object (h->y + line + 2, h->x + col + 2, c); -+#endif /* UTF8 */ - #endif -+ } else { -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) { -+ int len; -+ mbstate_t mbs; -+ wchar_t wc; -+ memset (&mbs, 0, sizeof (mbs)); -+ len = mbrtowc(&wc, p, MB_CUR_MAX, &mbs); -+ if (len <= 0) len = 1; /* skip broken multibyte chars */ -+ -+ SLsmg_write_nwchars(&wc, 1); -+ p += len - 1; - } else -+#endif - addch (c); -+ } - col++; - break; - } -@@ -772,6 +790,12 @@ interactive_display (const char *filename, const char *node) - message (1, MSG_ERROR, _(" Cannot open file %s \n %s "), filename ? filename : hlpfile, - unix_error_string (errno)); - } -+ else -+ { -+ char *conv = utf8_to_local(data); -+ g_free(data); -+ data = conv; -+ } - - if (!filename) - g_free (hlpfile); -diff --git a/src/hotlist.c b/src/hotlist.c -index 737c9c1..74f9568 100644 ---- a/src/hotlist.c -+++ b/src/hotlist.c -@@ -566,7 +566,7 @@ init_i18n_stuff(int list_type, int cols) - - row = hotlist_but [i].y; - ++count [row]; -- len [row] += strlen (hotlist_but [i].text) + 5; -+ len [row] += mbstrlen (hotlist_but [i].text) + 5; - if (hotlist_but [i].flags == DEFPUSH_BUTTON) - len [row] += 2; - } -@@ -591,12 +591,12 @@ init_i18n_stuff(int list_type, int cols) - /* not first int the row */ - if (!strcmp (hotlist_but [i].text, cancel_but)) - hotlist_but [i].x = -- cols - strlen (hotlist_but [i].text) - 13; -+ cols - mbstrlen (hotlist_but [i].text) - 13; - else - hotlist_but [i].x = cur_x [row]; - } - -- cur_x [row] += strlen (hotlist_but [i].text) + 2 -+ cur_x [row] += mbstrlen (hotlist_but [i].text) + 2 - + (hotlist_but [i].flags == DEFPUSH_BUTTON ? 5 : 3); - } - } -@@ -837,7 +837,7 @@ static void add_widgets_i18n(QuickWidget* qw, int len) - for (i = 0; i < 3; i++) - { - qw [i].text = _(qw [i].text); -- l[i] = strlen (qw [i].text) + 3; -+ l[i] = mbstrlen (qw [i].text) + 3; - } - space = (len - 4 - l[0] - l[1] - l[2]) / 4; - -@@ -886,7 +886,7 @@ add_new_entry_input (const char *header, const char *text1, const char *text2, - - msglen(text1, &lines1, &cols1); - msglen(text2, &lines2, &cols2); -- len = max ((int) strlen (header), cols1); -+ len = max ((int) mbstrlen (header), cols1); - len = max (len, cols2) + 4; - len = max (len, 64); - -@@ -982,7 +982,7 @@ add_new_group_input (const char *header, const char *label, char **result) - #endif /* ENABLE_NLS */ - - msglen (label, &lines, &cols); -- len = max ((int) strlen (header), cols) + 4; -+ len = max ((int) mbstrlen (header), cols) + 4; - len = max (len, 64); - - #ifdef ENABLE_NLS -@@ -1038,7 +1038,7 @@ void add2hotlist_cmd (void) - { - char *prompt, *label; - const char *cp = _("Label for \"%s\":"); -- int l = strlen (cp); -+ int l = mbstrlen (cp); - char *label_string = g_strdup (current_panel->cwd); - - strip_password (label_string, 1); -diff --git a/src/layout.c b/src/layout.c -index 9f3616f..c759348 100644 ---- a/src/layout.c -+++ b/src/layout.c -@@ -367,36 +367,36 @@ init_layout (void) - - while (i--) { - s_split_direction[i] = _(s_split_direction[i]); -- l1 = strlen (s_split_direction[i]) + 7; -+ l1 = mbstrlen (s_split_direction[i]) + 7; - if (l1 > first_width) - first_width = l1; - } - - for (i = 0; i <= 8; i++) { - check_options[i].text = _(check_options[i].text); -- l1 = strlen (check_options[i].text) + 7; -+ l1 = mbstrlen (check_options[i].text) + 7; - if (l1 > first_width) - first_width = l1; - } - -- l1 = strlen (title1) + 1; -+ l1 = mbstrlen (title1) + 1; - if (l1 > first_width) - first_width = l1; - -- l1 = strlen (title2) + 1; -+ l1 = mbstrlen (title2) + 1; - if (l1 > first_width) - first_width = l1; - - -- second_width = strlen (title3) + 1; -+ second_width = mbstrlen (title3) + 1; - for (i = 0; i < 6; i++) { - check_options[i].text = _(check_options[i].text); -- l1 = strlen (check_options[i].text) + 7; -+ l1 = mbstrlen (check_options[i].text) + 7; - if (l1 > second_width) - second_width = l1; - } - if (console_flag) { -- l1 = strlen (output_lines_label) + 13; -+ l1 = mbstrlen (output_lines_label) + 13; - if (l1 > second_width) - second_width = l1; - } -@@ -410,14 +410,14 @@ init_layout (void) - * - * Now the last thing to do - properly space buttons... - */ -- l1 = 11 + strlen (ok_button) /* 14 - all brackets and inner space */ -- +strlen (save_button) /* notice: it is 3 char less because */ -- +strlen (cancel_button); /* of '&' char in button text */ -+ l1 = 11 + mbstrlen (ok_button) /* 14 - all brackets and inner space */ -+ +mbstrlen (save_button) /* notice: it is 3 char less because */ -+ +mbstrlen (cancel_button); /* of '&' char in button text */ - - i = (first_width + second_width - l1) / 4; - b1 = 5 + i; -- b2 = b1 + strlen (ok_button) + i + 6; -- b3 = b2 + strlen (save_button) + i + 4; -+ b2 = b1 + mbstrlen (ok_button) + i + 6; -+ b3 = b2 + mbstrlen (save_button) + i + 4; - - i18n_layt_flag = 1; - } -@@ -681,7 +681,7 @@ setup_panels (void) - panel_do_cols (0); - panel_do_cols (1); - -- promptl = strlen (prompt); -+ promptl = mbstrlen (prompt); - - widget_set_size (&the_menubar->widget, 0, 0, 1, COLS); - -diff --git a/src/learn.c b/src/learn.c -index dff560c..cc6ec93 100644 ---- a/src/learn.c -+++ b/src/learn.c -@@ -238,7 +238,7 @@ init_learn (void) - learn_but[0].x = 78 / 2 + 4; - - learn_but[1].text = _(learn_but[1].text); -- learn_but[1].x = 78 / 2 - (strlen (learn_but[1].text) + 9); -+ learn_but[1].x = 78 / 2 - (mbstrlen (learn_but[1].text) + 9); - - learn_title = _(learn_title); - i18n_flag = 1; -diff --git a/src/main.c b/src/main.c -index db26945..edf6a03 100644 ---- a/src/main.c -+++ b/src/main.c -@@ -82,6 +82,7 @@ - - #ifdef HAVE_CHARSET - #include "charsets.h" -+#include "recode.h" - #endif /* HAVE_CHARSET */ - - #ifdef USE_VFS -@@ -98,6 +99,7 @@ - /* The structures for the panels */ - WPanel *left_panel = NULL; - WPanel *right_panel = NULL; -+WPanel* ret_panel=NULL; - - /* The pointer to the tree */ - WTree *the_tree = NULL; -@@ -276,6 +278,9 @@ int midnight_shutdown = 0; - /* The user's shell */ - const char *shell = NULL; - -+/* Is the LANG UTF-8 ? */ -+gboolean is_utf8 = FALSE; -+ - /* mc_home: The home of MC */ - char *mc_home = NULL; - -@@ -587,6 +592,7 @@ _do_panel_cd (WPanel *panel, const char *new_dir, enum cd_enum cd_type) - } - directory = *new_dir ? new_dir : home_dir; - -+ ret_panel=panel; - if (mc_chdir (directory) == -1) { - strcpy (panel->cwd, olddir); - g_free (olddir); -@@ -706,7 +712,7 @@ load_prompt (int fd, void *unused) - int prompt_len; - - tmp_prompt = strip_ctrl_codes (subshell_prompt); -- prompt_len = strlen (tmp_prompt); -+ prompt_len = mbstrlen (tmp_prompt); - - /* Check for prompts too big */ - if (COLS > 8 && prompt_len > COLS - 8) { -@@ -808,6 +814,10 @@ static menu_entry LeftMenu[] = { - {' ', N_("&Quick view C-x q"), 'Q', quick_view_cmd}, - {' ', N_("&Info C-x i"), 'I', info_cmd}, - {' ', N_("&Tree"), 'T', tree_cmd}, -+#ifdef HAVE_CHARSET -+ {' ', "", ' ', 0}, -+ {' ', N_("Panel &codepage"), 'C', fnc_l_cmd}, -+#endif - {' ', "", ' ', 0}, - {' ', N_("&Sort order..."), 'S', sort_cmd}, - {' ', "", ' ', 0}, -@@ -832,6 +842,10 @@ static menu_entry RightMenu[] = { - {' ', N_("&Quick view C-x q"), 'Q', quick_view_cmd}, - {' ', N_("&Info C-x i"), 'I', info_cmd}, - {' ', N_("&Tree"), 'T', tree_cmd}, -+#ifdef HAVE_CHARSET -+ {' ', "", ' ', 0}, -+ {' ', N_("Panel &codepage"), 'C', fnc_r_cmd}, -+#endif - {' ', "", ' ', 0}, - {' ', N_("&Sort order..."), 'S', sort_cmd}, - {' ', "", ' ', 0}, -@@ -1614,7 +1628,11 @@ update_xterm_title_path (void) - if (xterm_flag && xterm_title) { - p = s = g_strdup (strip_home_and_password (current_panel->cwd)); - do { -+#ifndef UTF8 - if (!is_printable ((unsigned char) *s)) -+#else /* UTF8 */ -+ if (*(unsigned char *)s < ' ') -+#endif /* UTF8 */ - *s = '?'; - } while (*++s); - if (!alternate_plus_minus) -@@ -2122,6 +2140,16 @@ handle_args (int argc, char *argv[]) - int - main (int argc, char *argv[]) - { -+ /* Check whether we have UTF-8 locale */ -+ char *lang = getenv("LANG"); -+ size_t len = 0; -+ -+ if ( lang ) -+ len = strlen(lang); -+ -+ if ( len >= 5 && !strcasecmp(&lang[len-5],"UTF-8") ) -+ is_utf8 = TRUE; -+ - /* We had LC_CTYPE before, LC_ALL includs LC_TYPE as well */ - setlocale (LC_ALL, ""); - bindtextdomain ("mc", LOCALEDIR); -diff --git a/src/main.h b/src/main.h -index 3f3c695..fca81e7 100644 ---- a/src/main.h -+++ b/src/main.h -@@ -69,6 +69,7 @@ extern int alternate_plus_minus; - extern int only_leading_plus_minus; - extern int output_starts_shell; - extern int midnight_shutdown; -+extern gboolean is_utf8; - extern char cmd_buf [512]; - extern const char *shell; - -diff --git a/src/menu.c b/src/menu.c -index f291071..862eea8 100644 ---- a/src/menu.c -+++ b/src/menu.c -@@ -23,6 +23,7 @@ - #include - - #include -+#include - - #include "global.h" - #include "tty.h" -@@ -54,35 +55,95 @@ create_menu (const char *name, menu_entry *entries, int count, const char *help_ - { - Menu *menu; - const char *cp; -+ int wlen = 0; -+ mbstate_t s; - - menu = (Menu *) g_malloc (sizeof (*menu)); - menu->count = count; - menu->max_entry_len = 20; - menu->entries = entries; -+ menu->name = g_strdup (name); -+ menu_scan_hotkey (menu); -+#ifdef UTF8 -+ menu->wentries = NULL; -+ menu->wname = NULL; -+ if (SLsmg_Is_Unicode) { -+ const char *str = menu->name; -+ memset (&s, 0, sizeof (s)); -+ wlen = mbsrtowcs (NULL, &str, -1, &s); -+ if (wlen > 0) -+ ++wlen; -+ else { -+ wlen = 0; -+ memset (&s, 0, sizeof (s)); -+ } -+ } -+#endif - - if (entries != (menu_entry*) NULL) { - register menu_entry* mp; - for (mp = entries; count--; mp++) { - if (mp->text[0] != '\0') { -+ int len; - #ifdef ENABLE_NLS - mp->text = _(mp->text); - #endif /* ENABLE_NLS */ - cp = strchr (mp->text,'&'); -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) { -+ len = mbstrlen(mp->text) + 1; -+ wlen += len; -+ menu->max_entry_len = max (len - 1, menu->max_entry_len); -+ } else -+#endif -+ len = strlen (mp->text); - - if (cp != NULL && *(cp+1) != '\0') { - mp->hot_key = tolower ((unsigned char) *(cp+1)); -- menu->max_entry_len = max ((int) (strlen (mp->text) - 1), -- menu->max_entry_len); -+ menu->max_entry_len = max (len - 1, menu->max_entry_len); - } else { -- menu->max_entry_len = max ((int) strlen (mp->text), -- menu->max_entry_len); -+ menu->max_entry_len = max (len, menu->max_entry_len); - } - } - } - } - -- menu->name = g_strdup (name); -- menu_scan_hotkey(menu); -+#ifdef UTF8 -+ if (wlen) { -+ wchar_t *wp; -+ const char *str; -+ int len; -+ -+ menu->wentries = (wchar_t **) -+ g_malloc (sizeof (wchar_t *) * menu->count -+ + wlen * sizeof (wchar_t)); -+ wp = (wchar_t *) (menu->wentries + menu->count); -+ str = menu->name; -+ len = mbsrtowcs (wp, &str, wlen, &s); -+ if (len > 0) { -+ menu->wname = wp; -+ wlen -= len + 1; -+ wp += len + 1; -+ } else -+ memset (&s, 0, sizeof (s)); -+ if (menu->entries != NULL) -+ for (count = 0; count < menu->count; ++count) -+ if (menu->entries[count].text[0] != '\0') { -+ str = menu->entries[count].text; -+ menu->wentries[count] = wp; -+ len = mbsrtowcs (wp, &str, wlen, &s); -+ if (len > 0) { -+ wlen -= len + 1; -+ wp += len + 1; -+ } else { -+ memset (&s, 0, sizeof (s)); -+ *wp++ = L'\0'; -+ --wlen; -+ } -+ } -+ } -+#endif -+ - menu->start_x = 0; - menu->help_node = g_strdup (help_node); - return menu; -@@ -113,8 +174,26 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color) - const char *text; - - addch((unsigned char)menu->entries [idx].first_letter); -- for (text = menu->entries [idx].text; *text; text++) -- { -+#ifdef UTF8 -+ if (menu->wentries) { -+ wchar_t *wtext, *wp; -+ -+ for (wtext = wp = menu->wentries [idx]; *wtext; wtext++) { -+ if (*wtext == L'&') { -+ if (wtext > wp) -+ SLsmg_write_nwchars (wp, wtext - wp); -+ attrset (color == MENU_SELECTED_COLOR ? -+ MENU_HOTSEL_COLOR : MENU_HOT_COLOR); -+ SLsmg_write_nwchars (++wtext, 1); -+ attrset (color); -+ wp = wtext + 1; -+ } -+ } -+ if (wtext > wp) -+ SLsmg_write_nwchars (wp, wtext - wp); -+ } else -+#endif -+ for (text = menu->entries [idx].text; *text; text++) { - if (*text != '&') - addch(*text); - else { -@@ -123,7 +202,7 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color) - addch(*(++text)); - attrset(color); - } -- } -+ } - } - widget_move (&menubar->widget, y, x + 1); - } -@@ -169,6 +248,12 @@ static void menubar_draw (WMenu *menubar) - if (menubar->active) - attrset(i == menubar->selected?MENU_SELECTED_COLOR:SELECTED_COLOR); - widget_move (&menubar->widget, 0, menubar->menu [i]->start_x); -+#ifdef UTF8 -+ if (menubar->menu [i]->wname) -+ SLsmg_write_nwchars (menubar->menu [i]->wname, -+ wcslen (menubar->menu [i]->wname)); -+ else -+#endif - tty_printf ("%s", menubar->menu [i]->name); - } - -@@ -494,7 +579,13 @@ menubar_arrange(WMenu* menubar) - - for (i = 0; i < items; i++) - { -- int len = strlen(menubar->menu[i]->name); -+ int len; -+#ifdef UTF8 -+ if (menubar->menu[i]->wname) -+ len = wcslen (menubar->menu[i]->wname); -+ else -+#endif -+ len = strlen(menubar->menu[i]->name); - menubar->menu[i]->start_x = start_x; - start_x += len + gap; - } -@@ -507,7 +598,13 @@ menubar_arrange(WMenu* menubar) - for (i = 0; i < items; i++) - { - /* preserve length here, to be used below */ -- gap -= (menubar->menu[i]->start_x = strlen(menubar->menu[i]->name)); -+#ifdef UTF8 -+ if (menubar->menu[i]->wname) -+ menubar->menu[i]->start_x = wcslen (menubar->menu[i]->wname); -+ else -+#endif -+ menubar->menu[i]->start_x = strlen (menubar->menu[i]->name); -+ gap -= menubar->menu[i]->start_x; - } - - gap /= (items - 1); -@@ -531,6 +628,9 @@ menubar_arrange(WMenu* menubar) - void - destroy_menu (Menu *menu) - { -+#ifdef UTF8 -+ g_free (menu->wentries); -+#endif - g_free (menu->name); - g_free (menu->help_node); - g_free (menu); -diff --git a/src/menu.h b/src/menu.h -index e3e043e..8f52351 100644 ---- a/src/menu.h -+++ b/src/menu.h -@@ -21,6 +21,8 @@ typedef struct Menu { - menu_entry *entries; - int start_x; /* position relative to menubar start */ - char *help_node; -+ wchar_t **wentries; -+ wchar_t *wname; - } Menu; - - extern int menubar_visible; -diff --git a/src/myslang.h b/src/myslang.h -index 17057e7..774b310 100644 ---- a/src/myslang.h -+++ b/src/myslang.h -@@ -11,6 +11,16 @@ - #endif /* HAVE_SLANG_SLANG_H */ - #endif - -+#if SLANG_VERSION >= 20000 -+#define UTF8 1 -+#define SLsmg_Is_Unicode SLsmg_is_utf8_mode() -+void SLsmg_write_nwchars(wchar_t *s, size_t n); -+#endif -+ -+#ifdef UTF8 -+# include -+#endif -+ - enum { - KEY_BACKSPACE = 400, - KEY_END, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, -diff --git a/src/option.c b/src/option.c -index 2898266..b22c5f2 100644 ---- a/src/option.c -+++ b/src/option.c -@@ -124,12 +124,12 @@ init_configure (void) - title2 = _(" Pause after run... "); - title3 = _(" Other options "); - -- first_width = strlen (title1) + 1; -- second_width = strlen (title3) + 1; -+ first_width = mbstrlen (title1) + 1; -+ second_width = mbstrlen (title3) + 1; - - for (i = 0; check_options[i].text; i++) { - check_options[i].text = _(check_options[i].text); -- l1 = strlen (check_options[i].text) + 7; -+ l1 = mbstrlen (check_options[i].text) + 7; - if (i >= OTHER_OPTIONS) { - if (l1 > first_width) - first_width = l1; -@@ -142,23 +142,23 @@ init_configure (void) - i = PAUSE_OPTIONS; - while (i--) { - pause_options[i] = _(pause_options[i]); -- l1 = strlen (pause_options[i]) + 7; -+ l1 = mbstrlen (pause_options[i]) + 7; - if (l1 > first_width) - first_width = l1; - } - -- l1 = strlen (title2) + 1; -+ l1 = mbstrlen (title2) + 1; - if (l1 > first_width) - first_width = l1; - -- l1 = 11 + strlen (ok_button) -- + strlen (save_button) -- + strlen (cancel_button); -+ l1 = 11 + mbstrlen (ok_button) -+ + mbstrlen (save_button) -+ + mbstrlen (cancel_button); - - i = (first_width + second_width - l1) / 4; - b1 = 5 + i; -- b2 = b1 + strlen (ok_button) + i + 6; -- b3 = b2 + strlen (save_button) + i + 4; -+ b2 = b1 + mbstrlen (ok_button) + i + 6; -+ b3 = b2 + mbstrlen (save_button) + i + 4; - - i18n_config_flag = 1; - } -diff --git a/src/panel.h b/src/panel.h -index 844f359..05ec163 100644 ---- a/src/panel.h -+++ b/src/panel.h -@@ -72,6 +72,19 @@ typedef struct WPanel { - - int searching; - char search_buffer [256]; -+ -+#ifdef HAVE_CHARSET -+ int src_codepage; -+ unsigned char tr_table[256], tr_table_input[256]; -+#endif -+ -+#ifdef USE_VFS -+ #ifdef HAVE_CHARSET -+ int ret_codepage; -+ #endif -+ int is_return; -+ char retdir[MC_MAXPATHLEN]; -+#endif - } WPanel; - - WPanel *panel_new (const char *panel_name); -@@ -97,6 +110,7 @@ int set_panel_formats (WPanel *p); - extern WPanel *left_panel; - extern WPanel *right_panel; - extern WPanel *current_panel; -+extern WPanel* ret_panel; - - void try_to_select (WPanel *panel, const char *name); - -diff --git a/src/panelize.c b/src/panelize.c -index ef80619..d932241 100644 ---- a/src/panelize.c -+++ b/src/panelize.c -@@ -129,7 +129,7 @@ init_panelize (void) - i = sizeof (panelize_but) / sizeof (panelize_but[0]); - while (i--) { - panelize_but[i].text = _(panelize_but[i].text); -- maxlen += strlen (panelize_but[i].text) + 5; -+ maxlen += mbstrlen (panelize_but[i].text) + 5; - } - maxlen += 10; - -@@ -138,11 +138,11 @@ init_panelize (void) - panelize_cols = max (panelize_cols, maxlen); - - panelize_but[2].x = -- panelize_but[3].x + strlen (panelize_but[3].text) + 7; -+ panelize_but[3].x + mbstrlen (panelize_but[3].text) + 7; - panelize_but[1].x = -- panelize_but[2].x + strlen (panelize_but[2].text) + 5; -+ panelize_but[2].x + mbstrlen (panelize_but[2].text) + 5; - panelize_but[0].x = -- panelize_cols - strlen (panelize_but[0].text) - 8 - BX; -+ panelize_cols - mbstrlen (panelize_but[0].text) - 8 - BX; - - #endif /* ENABLE_NLS */ - -diff --git a/src/recode.c b/src/recode.c -new file mode 100644 -index 0000000..b485dfc ---- /dev/null -+++ b/src/recode.c -@@ -0,0 +1,153 @@ -+#include "recode.h" -+#ifdef HAVE_CHARSET -+ -+char *lang; -+char lang_codepage_name[256]; -+int lang_codepage; -+ -+int ftp_codepage=-1; -+ -+// recode buffer for displaying file names -+unsigned char recode_buf[MC_MAXPATHLEN]; -+ -+WPanel* recode_panel; -+ -+//--- get codepage from $LANG -+void get_locale_codepage() { -+ char* a; -+ char* b; -+ int len; -+ -+ lang=getenv("LANG"); -+ if(!lang) { -+ strncpy(lang_codepage_name,OTHER_8BIT, sizeof(OTHER_8BIT)); -+ lang_codepage=-1; -+ return; -+ } -+ -+ a=strchr(lang,'.'); -+ if(!a) { -+ strncpy(lang_codepage_name,OTHER_8BIT, sizeof(OTHER_8BIT)); -+ lang_codepage=-1; -+ return; -+ } -+ ++a; -+ -+ b=strchr(lang,'@'); -+ if(!b) b=lang+strlen(lang); -+ -+ len=b-a; -+ if(len>=sizeof(lang_codepage_name)) len=sizeof(lang_codepage_name)-1; -+ -+ memcpy(lang_codepage_name,a, len); -+ lang_codepage_name[len]='\0'; -+ lang_codepage=get_codepage_index(lang_codepage_name); -+ if(lang_codepage<0) strncpy(lang_codepage_name,OTHER_8BIT, sizeof(OTHER_8BIT)); -+} -+ -+//--- reset translation table -+void my_reset_tt(unsigned char *table,int n) { -+ int i; -+ for(i=0;isrc_codepage=-1; -+ my_reset_tt(p->tr_table,256); -+ my_reset_tt(p->tr_table_input,256); -+} -+ -+//--- Initialize translation table -+// i need this function because init_translation_table from -+// charsets.c fills only fixed translation tables conv_displ and conv_input -+//--- -+char* my_init_tt( int from, int to, unsigned char *table) { -+ int i; -+ iconv_t cd; -+ char *cpfrom, *cpto; -+ -+ if(from < 0 || to < 0 || from == to) { -+ my_reset_tt(table,256); -+ return NULL; -+ } -+ my_reset_tt(table,128); -+ cpfrom=codepages[from ].id; -+ cpto=codepages[to].id; -+ cd=iconv_open(cpfrom, cpto); -+ if(cd==(iconv_t)-1) { -+ snprintf(errbuf, 255, _("Cannot translate from %s to %s"), cpfrom, cpto); -+ return errbuf; -+ } -+ for(i=128; i<=255; ++i) table[i] = translate_character(cd, i); -+ iconv_close(cd); -+ return NULL; -+} -+ -+//--- Translate string from one codepage to another -+void my_translate_string(unsigned char *s1,int l1, unsigned char *s2, unsigned char *table) { -+ int i=0; -+ if(!s1) return; -+ while(irecode_buf,ctx->tr_table); -+ if (dir [i-1] == PATH_SEP) -+ return g_strconcat (dir, ctx->recode_buf, NULL); -+ else -+ return g_strconcat (dir, PATH_SEP_STR, ctx->recode_buf, NULL); -+ return 0; -+} -+ -+ -+//--- Internal handler for "Panel codepage" -+static void fnc_cmd(WPanel *p) { -+ char *errmsg; -+ if(display_codepage > 0) { -+ p->src_codepage=select_charset(p->src_codepage, 0, _(" Choose panel codepage ")); -+ errmsg=my_init_tt(display_codepage,p->src_codepage,p->tr_table); -+ if(errmsg) { -+ panel_reset_codepage(p); -+ message( 1, MSG_ERROR, "%s", errmsg); -+ } -+ errmsg=my_init_tt(p->src_codepage,display_codepage,p->tr_table_input); -+ if (errmsg) { -+ panel_reset_codepage(p); -+ message( 1, MSG_ERROR, "%s", errmsg ); -+ } -+ paint_dir(p); -+ show_dir(p); -+ display_mini_info(p); -+ } -+ else { -+ message( 1, _(" Warning "), -+ _("To use this feature select your codepage in\n" -+ "Setup / Display Bits dialog!\n" -+ "Do not forget to save options." )); -+ } -+} -+ -+//--- Menu handlers for "Panel codepage" for left and right panel menu -+ -+void fnc_l_cmd() { -+ fnc_cmd(left_panel); -+} -+ -+void fnc_r_cmd() { -+ fnc_cmd(right_panel); -+} -+ -+//--- screen handler for "Panel codepage" -+void fnc_c_cmd(WPanel *panel) { -+ fnc_cmd(current_panel); -+} -+ -+#endif //HAVE_CHARSET -diff --git a/src/recode.h b/src/recode.h -new file mode 100644 -index 0000000..8e817ea ---- /dev/null -+++ b/src/recode.h -@@ -0,0 +1,48 @@ -+#ifndef __RECODE_H__ -+#define __RECODE_H__ -+#include -+#ifdef HAVE_CHARSET -+ -+#include -+#include -+#include -+ -+#include "global.h" -+#include "wtools.h" -+#include "panel.h" -+#include "charsets.h" -+#include "selcodepage.h" -+#include "screen.h" -+#include "main.h" -+#include "fileopctx.h" -+ -+extern char *lang; -+extern char lang_codepage_name[256]; -+extern int lang_codepage; -+ -+extern int ftp_codepage; -+ -+// recode buffer for displaying file names -+extern unsigned char recode_buf[MC_MAXPATHLEN]; -+extern WPanel* recode_panel; -+ -+//--- get codepage from $LANG -+extern void get_locale_codepage(); -+ -+//--- reset translation table -+extern void my_reset_tt(unsigned char *table,int n); -+//--- reset panel codepage -+extern void panel_reset_codepage(WPanel *p); -+//--- Initialize translation table -+extern char* my_init_tt( int from, int to, unsigned char *table); -+//--- Translate string from one codepage to another -+extern void my_translate_string(unsigned char *s1,int l1, unsigned char *s2, unsigned char *table); -+//--- Recode filename and concat in to dir -+extern char* concat_dir_and_recoded_fname(const char *dir, const char *fname, FileOpContext *ctx); -+//--- handlers for "Panel codepage" -+extern void fnc_l_cmd(); -+extern void fnc_r_cmd(); -+extern void fnc_c_cmd(WPanel *panel); -+ -+#endif // HAVE_CHARSET -+#endif //__RECODE_H__ -diff --git a/src/screen.c b/src/screen.c -index 6c3821b..1f938bc 100644 ---- a/src/screen.c -+++ b/src/screen.c -@@ -52,6 +52,10 @@ - #include "main.h" /* the_menubar */ - #include "unixcompat.h" - -+#ifdef HAVE_CHARSET -+#include "recode.h" -+#endif -+ - #define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) ) - - #define J_LEFT 1 -@@ -173,21 +177,64 @@ add_permission_string (char *dest, int width, file_entry *fe, int attr, int colo - static const char * - string_file_name (file_entry *fe, int len) - { -- static char buffer [MC_MAXPATHLEN + 1]; - size_t i; -+ char* filename; - -- for (i = 0; i < sizeof(buffer) - 1; i++) { -- char c; -+#ifdef UTF8 -+ static char buffer [BUF_SMALL * 4]; -+ mbstate_t s; -+ int mbmax = MB_CUR_MAX; -+ const char *str = fe->fname; - -- c = fe->fname[i]; -+ memset (&s, 0, sizeof (s)); -+#else -+ static char buffer [BUF_SMALL]; -+#endif - -- if (!c) -- break; -+#ifdef HAVE_CHARSET -+ my_translate_string(fe->fname,fe->fnamelen, recode_buf, recode_panel->tr_table); -+ filename= recode_buf; -+#else -+ filename=fe->fname; -+#endif - -- if (!is_printable(c)) -- c = '?'; -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) -+ for (i = 0; i < sizeof (buffer) - 1; i++) { -+ wchar_t wc; -+ int len; - -- buffer[i] = c; -+ len = mbrtowc (&wc, str, mbmax, &s); -+ if (!len) -+ break; -+ if (len < 0) { -+ memset (&s, 0, sizeof (s)); -+ buffer[i] = '?'; -+ str++; -+ continue; -+ } -+ if (!is_printable (wc)) { -+ buffer[i] = '?'; -+ str++; -+ continue; -+ } -+ if (i >= sizeof (buffer) - len) -+ break; -+ memcpy (buffer + i, str, len); -+ i += len - 1; -+ str += len; -+ } else -+#endif -+ for (i = 0; i < sizeof(buffer) - 1; i++) { -+ char c; -+ -+ c = filename[i]; -+ -+ if (!c) break; -+ -+ if (!is_printable(c)) c = '?'; -+ -+ buffer[i] = c; - } - - buffer[i] = 0; -@@ -452,42 +499,6 @@ static struct { - { "dot", 1, 0, J_RIGHT, " ", 0, string_dot, NULL }, - }; - --static char * --to_buffer (char *dest, int just_mode, int len, const char *txt) --{ -- int txtlen = strlen (txt); -- int still, over; -- -- /* Fill buffer with spaces */ -- memset (dest, ' ', len); -- -- still = (over=(txtlen > len)) ? (txtlen - len) : (len - txtlen); -- -- switch (HIDE_FIT(just_mode)){ -- case J_LEFT: -- still = 0; -- break; -- case J_CENTER: -- still /= 2; -- break; -- case J_RIGHT: -- default: -- break; -- } -- -- if (over){ -- if (IS_FIT(just_mode)) -- strcpy (dest, name_trunc(txt, len)); -- else -- strncpy (dest, txt+still, len); -- } else -- strncpy (dest+still, txt, txtlen); -- -- dest[len] = '\0'; -- -- return (dest + len); --} -- - static int - file_compute_color (int attr, file_entry *fe) - { -@@ -541,14 +552,18 @@ file_compute_color (int attr, file_entry *fe) - - /* Formats the file number file_index of panel in the buffer dest */ - static void --format_file (char *dest, int limit, WPanel *panel, int file_index, int width, int attr, int isstatus) -+format_file (WPanel *panel, int file_index, int width, int attr, int isstatus) - { - int color, length, empty_line; - const char *txt; -- char *old_pos; -- char *cdest = dest; - format_e *format, *home; - file_entry *fe; -+#ifdef UTF8 -+ char buffer[BUF_MEDIUM * sizeof (wchar_t)]; -+#else -+ char buffer[BUF_MEDIUM]; -+#endif -+ int txtwidth = 0; - - length = 0; - empty_line = (file_index >= panel->count); -@@ -566,34 +581,137 @@ format_file (char *dest, int limit, WPanel *panel, int file_index, int width, in - break; - - if (format->string_fn){ -- int len; -+ int len, still, over, perm, txtlen, wide; - - if (empty_line) - txt = " "; - else - txt = (*format->string_fn)(fe, format->field_len); - -- old_pos = cdest; -- - len = format->field_len; - if (len + length > width) - len = width - length; -- if (len + (cdest - dest) > limit) -- len = limit - (cdest - dest); -+ if (len >= BUF_MEDIUM) -+ len = BUF_MEDIUM - 1; - if (len <= 0) - break; -- cdest = to_buffer (cdest, format->just_mode, len, txt); -- length += len; - -- attrset (color); -+ perm = 0; -+ if (permission_mode) { -+ if (!strcmp(format->id, "perm")) -+ perm = 1; -+ else if (!strcmp(format->id, "mode")) -+ perm = 2; -+ } - -- if (permission_mode && !strcmp(format->id, "perm")) -- add_permission_string (old_pos, format->field_len, fe, attr, color, 0); -- else if (permission_mode && !strcmp(format->id, "mode")) -- add_permission_string (old_pos, format->field_len, fe, attr, color, 1); -- else -- addstr (old_pos); -+ wide = 0; -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode && !empty_line && !perm) { -+ mbstate_t s; -+ const char *str = txt; -+ -+ memset (&s, 0, sizeof (s)); -+ txtlen = mbsrtowcs ((wchar_t *) buffer, &str, -+ sizeof (buffer) / sizeof (wchar_t), &s); -+ if (txtlen < 0) { -+ txt = " "; -+ txtlen = 1; -+ } else { -+ wide = 1; -+ txtwidth = wcswidth((wchar_t*)buffer, txtlen); -+ } -+ } else -+#endif -+ { -+ txtlen = mbstrlen (txt); -+ txtwidth = txtlen; -+ } -+ -+ over = txtwidth > len; -+ still = over ? txtlen - len : len - txtlen; -+ -+ switch (HIDE_FIT(format->just_mode)) { -+ case J_LEFT: -+ still = 0; -+ break; -+ case J_CENTER: -+ still /= 2; -+ break; -+ case J_RIGHT: -+ default: -+ break; -+ } -+ -+ attrset (color); -+ -+ if (wide) { -+#ifdef UTF8 -+ if (over) { -+ if (IS_FIT (format->just_mode)) { -+ int n1 = 0; -+ int width1 = 0; -+ int n2 = 0; -+ int width2 = 0; -+ int len1 = len / 2; -+ int len2; -+ -+ while (1) { -+ int w = wcwidth(((wchar_t *) buffer)[n1]); -+ if (width1 + w <= len1) { -+ width1 += w; -+ n1++; -+ } -+ else -+ break; -+ } -+ len2 = len - width1 - 1; -+ -+ while (1) { -+ int w = wcwidth(((wchar_t *) buffer)[txtlen - n2 - 1]); -+ if (width2 + w <= len2) { -+ width2 += w; -+ n2++; -+ } -+ else -+ break; -+ } -+ -+ -+ SLsmg_write_nwchars ((wchar_t *) buffer, n1); -+ SLsmg_write_nwchars (L"~", 1); -+ printw ("%*s", len - width1 - width2 - 1, ""); -+ SLsmg_write_nwchars (((wchar_t *) buffer) -+ + txtlen - n2, n2); -+ } else -+ SLsmg_write_nwchars ((wchar_t *) buffer + still, len); -+ } else { -+ printw ("%*s", still, ""); -+ SLsmg_write_nwchars ((wchar_t *) buffer, txtlen); -+ printw ("%*s", len - txtwidth - still, ""); -+ } -+#endif -+ } else { -+ if (over) { -+ if (IS_FIT (format->just_mode)) -+ strcpy (buffer, name_trunc(txt, len)); -+ else -+ memcpy (buffer, txt + still, len); -+ } else { -+ memset (buffer, ' ', still); -+ memcpy (buffer + still, txt, txtlen); -+ memset (buffer + still + txtlen, ' ', -+ len - txtlen - still); -+ } -+ buffer[len] = '\0'; -+ -+ if (perm) -+ add_permission_string (buffer, format->field_len, fe, -+ attr, color, perm - 1); -+ else -+ addstr (buffer); -+ } - -+ length += len; - } else { - if (attr == SELECTED || attr == MARKED_SELECTED) - attrset (SELECTED_COLOR); -@@ -616,7 +734,10 @@ repaint_file (WPanel *panel, int file_index, int mv, int attr, int isstatus) - { - int second_column = 0; - int width, offset; -- char buffer [BUF_MEDIUM]; -+ -+#ifdef HAVE_CHARSET -+ recode_panel=panel; -+#endif - - offset = 0; - if (!isstatus && panel->split){ -@@ -645,7 +766,7 @@ repaint_file (WPanel *panel, int file_index, int mv, int attr, int isstatus) - widget_move (&panel->widget, file_index - panel->top_file + 2, 1); - } - -- format_file (buffer, sizeof(buffer), panel, file_index, width, attr, isstatus); -+ format_file (panel, file_index, width, attr, isstatus); - - if (!isstatus && panel->split){ - if (second_column) -@@ -657,7 +778,7 @@ repaint_file (WPanel *panel, int file_index, int mv, int attr, int isstatus) - } - } - --static void -+void - display_mini_info (WPanel *panel) - { - if (!show_mini_info) -@@ -694,7 +815,7 @@ display_mini_info (WPanel *panel) - ngettext("%s in %d file", "%s in %d files", panel->marked), - b_bytes, panel->marked); - -- if ((int) strlen (buffer) > cols-2){ -+ if ((int) mbstrlen (buffer) > cols-2){ - buffer [cols] = 0; - p += 2; - } else -@@ -727,7 +848,7 @@ display_mini_info (WPanel *panel) - return; - } - --static void -+void - paint_dir (WPanel *panel) - { - int i; -@@ -765,7 +886,7 @@ mini_info_separator (WPanel *panel) - #endif /* !HAVE_SLANG */ - } - --static void -+void - show_dir (WPanel *panel) - { - char *tmp; -@@ -785,6 +906,9 @@ show_dir (WPanel *panel) - } - #endif /* HAVE_SLANG */ - -+ vscrollbar (panel->widget, panel->widget.lines, panel->widget.cols-1, 2, 2, -+ panel->selected, panel->count, TRUE); -+ - if (panel->active) - attrset (REVERSE_COLOR); - -@@ -794,8 +918,15 @@ show_dir (WPanel *panel) - tmp = g_malloc (panel->widget.cols + 1); - tmp[panel->widget.cols] = '\0'; - -+#ifdef HAVE_CHARSET -+ my_translate_string(panel->cwd,strlen(panel->cwd),recode_buf, panel->tr_table); -+ trim (strip_home_and_password (recode_buf), tmp, -+ min (max (panel->widget.cols - 7, 0), panel->widget.cols) ); -+ #else - trim (strip_home_and_password (panel->cwd), tmp, - max (panel->widget.cols - 9, 0)); -+#endif -+ - addstr (tmp); - g_free (tmp); - -@@ -1008,6 +1139,17 @@ panel_new (const char *panel_name) - mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2); - strcpy (panel->lwd, "."); - -+#ifdef HAVE_CHARSET -+ panel_reset_codepage(panel); -+#endif -+ -+#ifdef USE_VFS -+ panel->is_return=0; -+ #ifdef HAVE_CHARSET -+ panel->ret_codepage=-1; -+ #endif -+#endif -+ - panel->hist_name = g_strconcat ("Dir Hist ", panel_name, (char *) NULL); - panel->dir_history = history_get (panel->hist_name); - directory_history_add (panel, panel->cwd); -@@ -1107,6 +1249,12 @@ paint_frame (WPanel *panel) - int side, width; - - const char *txt; -+#ifdef UTF8 -+ char buffer[30 * sizeof (wchar_t)]; -+ mbstate_t s; -+ -+ memset (&s, 0, sizeof (s)); -+#endif - if (!panel->split) - adjust_top_file (panel); - -@@ -1131,16 +1279,38 @@ paint_frame (WPanel *panel) - if (format->string_fn){ - txt = format->title; - -- header_len = strlen (txt); -+ attrset (MARKED_COLOR); -+ width -= format->field_len; -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) { -+ const char *str = txt; -+ header_len = mbsrtowcs ((wchar_t *) buffer, &str, -+ sizeof (buffer) / sizeof (wchar_t), -+ &s); -+ if (header_len < 0) { -+ memset (&s, 0, sizeof (s)); -+ printw ("%*s", format->field_len, ""); -+ continue; -+ } -+ if (header_len > format->field_len) -+ header_len = format->field_len; -+ spaces = (format->field_len - header_len) / 2; -+ extra = (format->field_len - header_len) % 2; -+ printw ("%*s", spaces, ""); -+ SLsmg_write_nwchars ((wchar_t *) buffer, header_len); -+ printw ("%*s", spaces + extra, ""); -+ continue; -+ } -+#endif -+ -+ header_len = mbstrlen (txt); - if (header_len > format->field_len) - header_len = format->field_len; - -- attrset (MARKED_COLOR); - spaces = (format->field_len - header_len) / 2; - extra = (format->field_len - header_len) % 2; - tty_printf ("%*s%.*s%*s", spaces, "", - header_len, txt, spaces+extra, ""); -- width -= 2 * spaces + extra + header_len; - } else { - attrset (NORMAL_COLOR); - one_vline (); -@@ -1358,7 +1528,7 @@ use_display_format (WPanel *panel, const char *format, char **error, int isstatu - panel->dirty = 1; - - /* Status needn't to be split */ -- usable_columns = ((panel->widget.cols-2)/((isstatus) -+ usable_columns = ((panel->widget.cols-3)/((isstatus) - ? 1 - : (panel->split+1))) - (!isstatus && panel->split); - -@@ -1897,11 +2067,24 @@ do_search (WPanel *panel, int c_code) - int i; - int wrapped = 0; - int found; -+ int prevpos, pos; -+ int j; -+ mbstate_t mbs; - - l = strlen (panel->search_buffer); - if (c_code == KEY_BACKSPACE) { -- if (l) -- panel->search_buffer[--l] = '\0'; -+ if (l) { -+ prevpos = pos = 0; -+ memset (&mbs, 0, sizeof (mbs)); -+ while (pos < l) { -+ prevpos = pos; -+ j = mbrlen (panel->search_buffer + pos, l - pos, &mbs); -+ if (j <= 0) break; -+ pos += j; -+ } -+ --l; -+ panel->search_buffer[prevpos] = 0; -+ } - } else { - if (c_code && l < sizeof (panel->search_buffer)) { - panel->search_buffer[l] = c_code; -@@ -1910,6 +2093,14 @@ do_search (WPanel *panel, int c_code) - } - } - -+ prevpos = pos = 0; -+ memset (&mbs, 0, sizeof (mbs)); -+ while (pos < l) { -+ prevpos = pos; -+ j = mbrlen (panel->search_buffer + pos, l - pos, &mbs); -+ if (j <= 0) break; -+ pos += j; -+ } - found = 0; - for (i = panel->selected; !wrapped || i != panel->selected; i++) { - if (i >= panel->count) { -@@ -1920,9 +2111,9 @@ do_search (WPanel *panel, int c_code) - } - if (panel-> - case_sensitive -- ? (strncmp (panel->dir.list[i].fname, panel->search_buffer, l) -+ ? (strncmp (panel->dir.list[i].fname, panel->search_buffer, pos) - == 0) : (g_strncasecmp (panel->dir.list[i].fname, -- panel->search_buffer, l) == 0)) { -+ panel->search_buffer, pos) == 0)) { - unselect_item (panel); - panel->selected = i; - select_item (panel); -@@ -1931,7 +2122,7 @@ do_search (WPanel *panel, int c_code) - } - } - if (!found) -- panel->search_buffer[--l] = 0; -+ panel->search_buffer[prevpos] = 0; - - paint_panel (panel); - } -@@ -2160,7 +2351,12 @@ static const panel_key_map panel_keymap [] = { - { XCTRL('n'), move_down }, /* C-n like emacs */ - { XCTRL('s'), start_search }, /* C-s like emacs */ - { ALT('s'), start_search }, /* M-s not like emacs */ -+#ifndef HAVE_CHARSET - { XCTRL('t'), mark_file }, -+#endif -+#ifdef HAVE_CHARSET -+ { XCTRL('t'), mark_file }, /* was 'fnc_c_cmd' */ -+#endif - { ALT('o'), chdir_other_panel }, - { ALT('i'), sync_other_panel }, - { ALT('l'), chdir_to_readlink }, -diff --git a/src/screen.h b/src/screen.h -new file mode 100644 -index 0000000..4efb525 ---- /dev/null -+++ b/src/screen.h -@@ -0,0 +1,11 @@ -+#ifndef __SCREEN_H__ -+#define __SCREEN_H__ -+#include -+ -+#include "global.h" -+ -+extern void paint_dir (WPanel *panel); -+extern void display_mini_info (WPanel *panel); -+extern void show_dir(WPanel *panel); -+#endif //__SCREEN_H__ -+ -diff --git a/src/selcodepage.c b/src/selcodepage.c -index 3e9ec63..dabed0e 100644 ---- a/src/selcodepage.c -+++ b/src/selcodepage.c -@@ -45,14 +45,16 @@ get_hotkey (int n) - } - - int --select_charset (int current_charset, int seldisplay) -+select_charset (int current_charset, int seldisplay, const char *title) - { -+ int new_charset; -+ - int i, menu_lines = n_codepages + 1; - char buffer[255]; - - /* Create listbox */ - Listbox *listbox = create_listbox_window (ENTRY_LEN + 2, menu_lines, -- _(" Choose input codepage "), -+ title, - "[Codepages Translation]"); - - if (!seldisplay) -@@ -82,20 +84,26 @@ select_charset (int current_charset, int seldisplay) - - i = run_listbox (listbox); - -- return (seldisplay) ? ((i >= n_codepages) ? -1 : i) -- : (i - 1); -+ if(i==-1) -+ i = (seldisplay) -+ ? ((current_charset < 0) ? n_codepages : current_charset) -+ : (current_charset + 1); -+ -+ new_charset =(seldisplay) ? ( (i >= n_codepages) ? -1 : i ) : ( i-1 ); -+ new_charset = (new_charset==-2) ? current_charset:new_charset; -+ return new_charset; - } - - /* Helper functions for codepages support */ - - - int --do_select_codepage (void) -+do_select_codepage (const char *title) - { - const char *errmsg; - - if (display_codepage > 0) { -- source_codepage = select_charset (source_codepage, 0); -+ source_codepage = select_charset (source_codepage, 0, title); - errmsg = - init_translation_table (source_codepage, display_codepage); - if (errmsg) { -diff --git a/src/selcodepage.h b/src/selcodepage.h -index 06fbd77..f7f16de 100644 ---- a/src/selcodepage.h -+++ b/src/selcodepage.h -@@ -2,8 +2,8 @@ - #define MC_SELCODEPAGE_H - - #ifdef HAVE_CHARSET --int select_charset (int current_charset, int seldisplay); --int do_select_codepage (void); -+int select_charset (int current_charset, int seldisplay, const char *title); -+int do_select_codepage (const char *title); - #endif /* HAVE_CHARSET */ - - #endif -diff --git a/src/setup.c b/src/setup.c -index 67dec4a..4c78e5b 100644 ---- a/src/setup.c -+++ b/src/setup.c -@@ -50,6 +50,8 @@ - - #ifdef HAVE_CHARSET - #include "charsets.h" -+#include"recode.h" -+#include "wtools.h" - #endif - - #ifdef USE_NETCODE -@@ -273,6 +275,11 @@ panel_save_setup (struct WPanel *panel, const char *section) - g_snprintf (buffer, sizeof (buffer), "%d", panel->user_mini_status); - save_string (section, "user_mini_status", buffer, - profile_name); -+ -+#ifdef HAVE_CHARSET -+ // save panel codepage -+ save_string(section, "panel_display_codepage", get_codepage_id(panel->src_codepage), profile_name); -+#endif - } - - void -@@ -375,6 +382,7 @@ save_setup (void) - #ifdef HAVE_CHARSET - save_string( "Misc", "display_codepage", - get_codepage_id( display_codepage ), profile_name ); -+ save_string( "Misc", "ftp_codepage", get_codepage_id(ftp_codepage), profile_name); - #endif /* HAVE_CHARSET */ - - g_free (profile); -@@ -425,6 +433,31 @@ panel_load_setup (WPanel *panel, const char *section) - panel->user_mini_status = - load_int (section, "user_mini_status", 0); - -+#ifdef HAVE_CHARSET -+//--- Loading panel codepage -+ panel_reset_codepage(panel); -+ if(load_codepages_list()>0) { -+ char cpname[128]; -+ char *errmsg; -+ -+ -+ if(display_codepage>=0) { -+ load_string(section, "panel_display_codepage", "", cpname, sizeof(cpname)); -+ if(cpname[0]!='\0') panel->src_codepage = get_codepage_index(cpname); -+ } -+ -+ errmsg=my_init_tt(display_codepage,panel->src_codepage,panel->tr_table); -+ if(errmsg) { -+ panel_reset_codepage(panel); -+ message( 1, MSG_ERROR, "%s", errmsg ); -+ } -+ errmsg=my_init_tt(panel->src_codepage,display_codepage,panel->tr_table_input); -+ if(errmsg) { -+ panel_reset_codepage(panel); -+ message( 1, MSG_ERROR, "%s", errmsg ); -+ } -+ } -+#endif - } - - static void -@@ -574,10 +607,16 @@ load_setup (void) - #ifdef HAVE_CHARSET - if ( load_codepages_list() > 0 ) { - char cpname[128]; -- load_string( "Misc", "display_codepage", "", -- cpname, sizeof(cpname) ); -- if ( cpname[0] != '\0' ) -- display_codepage = get_codepage_index( cpname ); -+ get_locale_codepage(); -+ load_string("Misc", "display_codepage", "", cpname, sizeof(cpname)); -+ if(cpname[0] != '\0') display_codepage=get_codepage_index(cpname); -+ else display_codepage=lang_codepage; -+ -+ ftp_codepage=-1; -+ if(display_codepage >= 0) { -+ load_string( "Misc", "ftp_codepage", "", cpname, sizeof(cpname)); -+ if(cpname[0] != '\0') ftp_codepage=get_codepage_index(cpname); -+ } - } - - init_translation_table( source_codepage, display_codepage ); -diff --git a/src/slint.c b/src/slint.c -index c30fac1..88557ac 100644 ---- a/src/slint.c -+++ b/src/slint.c -@@ -142,7 +142,9 @@ void - slang_init (void) - { - SLtt_get_terminfo (); -- -+#if SLANG_VERSION >= 20000 -+ SLutf8_enable (-1); -+#endif - /* - * If the terminal in not in terminfo but begins with a well-known - * string such as "linux" or "xterm" S-Lang will go on, but the -diff --git a/src/timefmt.h b/src/timefmt.h -index 2b8d52f..2cf4a38 100644 ---- a/src/timefmt.h -+++ b/src/timefmt.h -@@ -19,7 +19,7 @@ - } \ - else \ - { \ -- strftime(buffer, bufsize, fmt, whentm); \ -+ strftime(buffer, bufsize -1, fmt, whentm); \ - } \ - } \ - -diff --git a/src/tty.c b/src/tty.c -index a71c6cc..961132b 100644 ---- a/src/tty.c -+++ b/src/tty.c -@@ -134,10 +134,12 @@ tty_print_char(int c) - * defined or not. Congratulations! At least, they left the API call - * for SLsmg_write_nchars as it has always been. - */ -- char ch; - -- ch = c; -- SLsmg_write_nchars(&ch, 1); -+ /* The above comment is a nonsense, SLsmg_write_char(c) works pretty -+ * good for me. So please don't mess with Red Hat people. -+ * Jindrich Novy (jnovy@redhat.com) -+ */ -+ SLsmg_write_nwchars(&c, 1); - #else - addch(c); - #endif -diff --git a/src/tty.h b/src/tty.h -index 85d286b..d27e639 100644 ---- a/src/tty.h -+++ b/src/tty.h -@@ -8,6 +8,8 @@ - of ifdefs in the other files small. - */ - -+#include /* gboolean is used here */ -+ - #ifdef HAVE_SLANG - # include "myslang.h" - #endif -diff --git a/src/util.c b/src/util.c -index 35658b0..5f87b57 100644 ---- a/src/util.c -+++ b/src/util.c -@@ -34,10 +34,14 @@ - #include - #include - #include -+#include -+#include -+#include - - #include - #include - -+#include "tty.h" - #include "global.h" - #include "profile.h" - #include "main.h" /* mc_home */ -@@ -50,9 +54,39 @@ - #include "charsets.h" - #endif - -+#ifdef UTF8 -+#include -+#endif -+ - static const char app_text [] = "Midnight-Commander"; - int easy_patterns = 1; - -+#if SLANG_VERSION >= 20000 -+void SLsmg_write_nwchars(wchar_t *s, size_t n) -+{ -+ if (SLsmg_is_utf8_mode()) { /* slang can handle it directly */ -+ while(n-- && *s) -+ SLsmg_write_char(*s++); -+ } -+ else { /* convert wchars back to 8bit encoding */ -+ mbstate_t mbs; -+ memset (&mbs, 0, sizeof (mbs)); -+ while (n-- && *s) { -+ char buf[MB_LEN_MAX + 1]; /* should use 1 char, but to be sure */ -+ if (*s < 0x80) { -+ SLsmg_write_char(*s++); /* ASCII */ -+ } -+ else { -+ if (wcrtomb(buf, *s++, &mbs) == 1) -+ SLsmg_write_char((wchar_t)(buf[0])); -+ else -+ SLsmg_write_char('?'); /* should not happen */ -+ } -+ } -+ } -+} -+#endif -+ - extern void str_replace(char *s, char from, char to) - { - for (; *s != '\0'; s++) { -@@ -83,9 +117,106 @@ is_8bit_printable (unsigned char c) - return (c > 31 && c != 127 && c != 155); - } - -+size_t -+mbstrlen (const char *str) -+{ -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) { -+ size_t width = 0; -+ -+ for (; *str; str++) { -+ wchar_t c; -+ size_t len; -+ -+ len = mbrtowc (&c, str, MB_CUR_MAX, NULL); -+ -+ if (len == (size_t)(-1) || len == (size_t)(-2)) break; -+ -+ if (len > 0) { -+ int wcsize = wcwidth(c); -+ width += wcsize > 0 ? wcsize : 0; -+ str += len-1; -+ } -+ } -+ -+ return width; -+ } else -+#endif -+ return strlen (str); -+} -+ -+#ifdef UTF8 -+ -+void -+fix_utf8(char *str) -+{ -+ mbstate_t mbs; -+ -+ char *p = str; -+ -+ while (*p) { -+ int len; -+ memset (&mbs, 0, sizeof (mbs)); -+ len = mbrlen(p, MB_CUR_MAX, &mbs); -+ if (len == -1) { -+ *p = '?'; -+ p++; -+ } else if (len > 0) { -+ p += len; -+ } else { -+ p++; -+ } -+ } -+} -+#endif -+ -+ -+ -+#ifdef UTF8 -+wchar_t * -+mbstr_to_wchar (const char *str) -+{ -+ int len = mbstrlen(str); -+ wchar_t *buf = g_malloc((len+1) * sizeof(wchar_t)); -+ mbstate_t mbs; -+ memset (&mbs, 0, sizeof (mbs)); -+ mbsrtowcs (buf, &str, len, &mbs); -+ buf[len] = 0; -+ return buf; -+} -+ -+char * -+wchar_to_mbstr (const wchar_t *wstr) -+{ -+ mbstate_t mbs; -+ const wchar_t *wstr2; -+ char * string; -+ int len; -+ -+ memset (&mbs, 0, sizeof (mbs)); -+ wstr2 = wstr; -+ len = wcsrtombs(NULL, &wstr2, 0, &mbs); -+ if (len <= 0) -+ return NULL; -+ -+ string = g_malloc(len + 1); -+ -+ wstr2 = wstr; -+ wcsrtombs(string, &wstr2, len, &mbs); -+ string[len] = 0; -+ return string; -+} -+#endif -+ -+ -+ - int - is_printable (int c) - { -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) -+ return iswprint (c); -+#endif - c &= 0xff; - - #ifdef HAVE_CHARSET -@@ -103,7 +234,7 @@ is_printable (int c) - #endif /* !HAVE_CHARSET */ - } - --/* Calculates the message dimensions (lines and columns) */ -+/* Calculates the message dimension in columns and lines. */ - void - msglen (const char *text, int *lines, int *columns) - { -@@ -116,8 +247,21 @@ msglen (const char *text, int *lines, int *columns) - nlines++; - colindex = 0; - } else { -+#ifndef UTF8 - colindex++; - if (colindex > ncolumns) -+#else /* UTF8 */ -+ size_t len; -+ wchar_t c; -+ -+ len = mbrtowc (&c, text, MB_CUR_MAX, NULL); -+ if (len > 0 && len != (size_t)(-1) && len != (size_t)(-2)) { -+ int wcsize = wcwidth(c); -+ colindex += wcsize > 0 ? wcsize-1 : -1; -+ text += len-1; -+ } -+ if (++colindex > ncolumns) -+#endif /* UTF8 */ - ncolumns = colindex; - } - } -@@ -211,7 +355,24 @@ name_quote (const char *s, int quote_percent) - *d++ = '\\'; - break; - } -+#ifndef UTF8 - *d = *s; -+#else /* UTF8 */ -+ { -+ mbstate_t mbs; -+ int len; -+ memset (&mbs, 0, sizeof (mbs)); -+ len = mbrlen(s, MB_CUR_MAX, &mbs); -+ if (len > 0) { -+ while (len-- > 1) -+ *d++ = *s++; -+ *d = *s; -+ } else { -+ *d = '?'; -+ } -+ -+ } -+#endif /* UTF8 */ - } - *d = '\0'; - return ret; -@@ -233,25 +394,90 @@ const char * - name_trunc (const char *txt, int trunc_len) - { - static char x[MC_MAXPATHLEN + MC_MAXPATHLEN]; -- int txt_len; -+ int txt_len, first, skip; - char *p; -+ const char *str; - - if ((size_t) trunc_len > sizeof (x) - 1) { - trunc_len = sizeof (x) - 1; - } -- txt_len = strlen (txt); -- if (txt_len <= trunc_len) { -- strcpy (x, txt); -- } else { -- int y = (trunc_len / 2) + (trunc_len % 2); -- strncpy (x, txt, y); -- strncpy (x + y, txt + txt_len - (trunc_len / 2), trunc_len / 2); -- x[y] = '~'; -+ txt_len = mbstrlen (txt); -+ first = 0; -+ skip = 0; -+ if (txt_len > trunc_len) { -+ first = trunc_len / 2; -+ skip = txt_len - trunc_len + 1; - } -- x[trunc_len] = 0; -- for (p = x; *p; p++) -- if (!is_printable (*p)) -- *p = '?'; -+ -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) { -+ mbstate_t s; -+ int mbmax; -+ -+ str = txt; -+ memset (&s, 0, sizeof (s)); -+ mbmax = MB_CUR_MAX; -+ p = x; -+ while (p < x + sizeof (x) - 1 && trunc_len) { -+ wchar_t wc; -+ int len; -+ -+ len = mbrtowc (&wc, str, mbmax, &s); -+ if (!len) -+ break; -+ if (len < 0) { -+ memset (&s, 0, sizeof (s)); -+ *p = '?'; -+ len = 1; -+ str++; -+ } else if (!is_printable (wc)) { -+ *p = '?'; -+ str += len; -+ len = 1; -+ } else if (p >= x + sizeof (x) - len) -+ break; -+ else { -+ memcpy (p, str, len); -+ str += len; -+ } -+ if (first) { -+ --trunc_len; -+ --first; -+ p += len; -+ if (!first && p < x + sizeof (x) - 1 && trunc_len) { -+ *p++ = '~'; -+ --trunc_len; -+ } -+ } else if (skip) -+ --skip; -+ else { -+ --trunc_len; -+ p += len; -+ } -+ } -+ } else -+#endif -+ { -+ str = txt; -+ p = x; -+ while (p < x + sizeof (x) - 1) { -+ if (*str == '\0') -+ break; -+ else if (!is_printable (*str)) -+ *p++ = '?'; -+ else -+ *p++ = *str; -+ ++str; -+ if (first) { -+ --first; -+ if (!first) { -+ *p++ = '~'; -+ str += skip; -+ } -+ } -+ } -+ } -+ *p = '\0'; - return x; - } - -@@ -683,11 +909,66 @@ load_file (const char *filename) - } - - char * -+utf8_to_local(char *str) -+{ -+ iconv_t cd; -+ size_t buflen; -+ char *output; -+ int retry = 1; -+ -+ if (!str) -+ return 0; -+ -+ buflen = strlen(str); -+ -+ cd = iconv_open (nl_langinfo(CODESET), "UTF-8"); -+ if (cd == (iconv_t) -1) { -+ return g_strdup(str); -+ } -+ -+ output = g_malloc(buflen + 1); -+ -+ while (retry) -+ { -+ char *wrptr = output; -+ char *inptr = str; -+ size_t insize = buflen; -+ size_t avail = buflen; -+ size_t nconv; -+ -+ nconv = iconv (cd, &inptr, &insize, &wrptr, &avail); -+ if (nconv == (size_t) -1) -+ { -+ if (errno == E2BIG) -+ { -+ buflen *= 2; -+ g_free(output); -+ output = g_malloc(buflen + 1); -+ } -+ else -+ { -+ g_free(output); -+ return g_strdup(str); -+ } -+ } -+ else { -+ retry = 0; -+ *wrptr = 0; -+ } -+ } -+ -+ iconv_close (cd); -+ -+ return output; -+} -+ -+char * - load_mc_home_file (const char *filename, char **allocated_filename) - { - char *hintfile_base, *hintfile; - char *lang; - char *data; -+ char *conv_data; - - hintfile_base = mhl_str_dir_plus_file (mc_home, filename); - lang = guess_message_value (); -@@ -720,7 +1001,10 @@ load_mc_home_file (const char *filename, char **allocated_filename) - else - g_free (hintfile); - -- return data; -+ conv_data = utf8_to_local(data); -+ g_free(data); -+ -+ return conv_data; - } - - /* Check strftime() results. Some systems (i.e. Solaris) have different -@@ -736,10 +1020,12 @@ i18n_checktimelength (void) - // huh, localtime() doesnt seem to work ... falling back to "(invalid)" - length = strlen(INVALID_TIME_TEXT); - } else { -- char buf [MAX_I18NTIMELENGTH + 1]; -+ char buf [4* MAX_I18NTIMELENGTH + 1]; - size_t a, b; -- a = strftime (buf, sizeof(buf)-1, _("%b %e %H:%M"), lt); -- b = strftime (buf, sizeof(buf)-1, _("%b %e %Y"), lt); -+ strftime (buf, sizeof(buf)-1, _("%b %e %H:%M"), lt); -+ a = mbstrlen(buf); -+ strftime (buf, sizeof(buf)-1, _("%b %e %Y"), lt); -+ b = mbstrlen(buf); - length = max (a, b); - } - -@@ -753,15 +1039,12 @@ i18n_checktimelength (void) - const char * - file_date (time_t when) - { -- static char timebuf [MAX_I18NTIMELENGTH + 1]; -+ static char timebuf [4 * MAX_I18NTIMELENGTH + 1]; - time_t current_time = time ((time_t) 0); -- static size_t i18n_timelength = 0; - static const char *fmtyear, *fmttime; - const char *fmt; - -- if (i18n_timelength == 0){ -- i18n_timelength = i18n_checktimelength() + 1; -- -+ if ( fmtyear == NULL ) { - /* strftime() format string for old dates */ - fmtyear = _("%b %e %Y"); - /* strftime() format string for recent dates */ -@@ -781,7 +1064,7 @@ file_date (time_t when) - else - fmt = fmttime; - -- FMT_LOCALTIME(timebuf, i18n_timelength, fmt, when); -+ FMT_LOCALTIME(timebuf, sizeof(timebuf), fmt, when); - - return timebuf; - } -@@ -912,10 +1195,27 @@ strip_ctrl_codes (char *s) - r++; - continue; - } -- -+#ifndef UTF8 - if (is_printable(*r)) - *w++ = *r; - ++r; -+#else /* UTF8 */ -+ { -+ mbstate_t mbs; -+ int len; -+ memset (&mbs, 0, sizeof (mbs)); -+ len = mbrlen(r, MB_CUR_MAX, &mbs); -+ -+ if (len > 0 && (unsigned char)*r >= ' ') -+ while (len--) -+ *w++ = *r++; -+ else { -+ if (len == -1) -+ *w++ = '?'; -+ r++; -+ } -+ } -+#endif /* UTF8 */ - } - *w = 0; - return s; -diff --git a/src/util.h b/src/util.h -index 0cf2099..82edcde 100644 ---- a/src/util.h -+++ b/src/util.h -@@ -102,6 +102,13 @@ void init_uid_gid_cache (void); - char *get_group (int); - char *get_owner (int); - -+void fix_utf8(char *str); -+size_t mbstrlen (const char *); -+wchar_t *mbstr_to_wchar (const char *); -+char *wchar_to_mbstr (const wchar_t *); -+char *utf8_to_local(char *str); -+ -+ - #define MAX_I18NTIMELENGTH 14 - #define MIN_I18NTIMELENGTH 10 - #define STD_I18NTIMELENGTH 12 -diff --git a/src/view.c b/src/view.c -index 8465301..8bc1792 100644 ---- a/src/view.c -+++ b/src/view.c -@@ -44,6 +44,10 @@ - #include - #include - -+#ifdef UTF8 -+#include -+#endif /* UTF8 */ -+ - #include "global.h" - #include "tty.h" - #include "cmd.h" /* For view_other_cmd */ -@@ -1643,7 +1647,7 @@ view_display_status (WView *view) - hline (' ', width); - - file_label = _("File: %s"); -- file_label_width = strlen (file_label) - 2; -+ file_label_width = mbstrlen (file_label) - 2; - file_name = view->filename ? view->filename - : view->command ? view->command - : ""; -@@ -1911,6 +1915,12 @@ view_display_text (WView * view) - offset_type from; - int c; - struct hexedit_change_node *curr = view->change_list; -+#ifdef UTF8 -+ mbstate_t mbs; -+ char mbbuf[MB_LEN_MAX]; -+ int mblen; -+ wchar_t wc; -+#endif /* UTF8 */ - - view_display_clean (view); - view_display_ruler (view); -@@ -1923,8 +1933,37 @@ view_display_text (WView * view) - - tty_setcolor (NORMAL_COLOR); - for (row = 0, col = 0; row < height && (c = get_byte (view, from)) != -1; from++) { -- -+#ifndef UTF8 - if (view->text_nroff_mode && c == '\b') { -+#else /* UTF8 */ -+ mblen = 1; -+ mbbuf[0] = convert_to_display_c (c); -+ -+ while (mblen < MB_LEN_MAX) { -+ int res; -+ memset (&mbs, 0, sizeof (mbs)); -+ res = mbrtowc (&wc, mbbuf, mblen, &mbs); -+ if (res <= 0 && res != -2) { -+ wc = '.'; -+ mblen = 1; -+ break; -+ } -+ if (res == mblen) -+ break; -+ -+ mbbuf[mblen] = convert_to_display_c (get_byte (view, from + mblen)); -+ mblen++; -+ } -+ -+ if (mblen == MB_LEN_MAX) { -+ wc = '.'; -+ mblen = 1; -+ } -+ -+ from += mblen - 1; -+ -+ if (view->text_nroff_mode && wc == '\b') { -+#endif /* UTF8 */ - int c_prev; - int c_next; - -@@ -1989,10 +2028,17 @@ view_display_text (WView * view) - if (col >= view->dpy_text_column - && col - view->dpy_text_column < width) { - widget_move (view, top + row, left + (col - view->dpy_text_column)); -+#ifndef UTF8 - c = convert_to_display_c (c); - if (!is_printable (c)) - c = '.'; - tty_print_char (c); -+#else -+ wc = convert_to_display_c (wc); -+ if (!iswprint (wc)) -+ wc = '.'; -+ tty_print_char (wc); -+#endif - } - col++; - tty_setcolor (NORMAL_COLOR); -@@ -3187,7 +3233,7 @@ view_handle_key (WView *view, int c) - - #ifdef HAVE_CHARSET - case XCTRL ('t'): -- do_select_codepage (); -+ do_select_codepage (_(" Choose codepage ")); - view->dirty++; - view_update (view); - return MSG_HANDLED; -diff --git a/src/widget.c b/src/widget.c -index f85cc2a..635441d 100644 ---- a/src/widget.c -+++ b/src/widget.c -@@ -38,6 +38,9 @@ - - #include "global.h" - #include "tty.h" -+#ifdef UTF8 -+#include -+#endif /* UTF8 */ - #include "color.h" - #include "mouse.h" - #include "dialog.h" -@@ -183,6 +186,11 @@ button_callback (Widget *w, widget_msg_t msg, int parm) - if (b->hotpos >= 0) { - widget_selectcolor (w, b->selected, TRUE); - widget_move (w, 0, b->hotpos + off); -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) -+ SLsmg_write_nwchars (&b->hotwc, 1); -+ else -+#endif - addch ((unsigned char) b->text[b->hotpos]); - } - return MSG_HANDLED; -@@ -216,7 +224,7 @@ button_event (Gpm_Event *event, void *data) - static int - button_len (const char *text, unsigned int flags) - { -- int ret = strlen (text); -+ int ret = mbstrlen (text); - switch (flags){ - case DEFPUSH_BUTTON: - ret += 6; -@@ -239,14 +247,36 @@ button_len (const char *text, unsigned int flags) - * the button text is g_malloc()ed, we can safely change and shorten it. - */ - static void --button_scan_hotkey (WButton *b) -+scan_hotkey (char *text, int *hotposp, int *hotkeyp, wchar_t *hotwcp) - { -- char *cp = strchr (b->text, '&'); -+ char *cp = strchr (text, '&'); - - if (cp != NULL && cp[1] != '\0') { -- g_strlcpy (cp, cp + 1, strlen (cp)); -- b->hotkey = tolower ((unsigned char) *cp); -- b->hotpos = cp - b->text; -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) { -+ mbstate_t s; -+ int len; -+ -+ *cp = '\0'; -+ memset (&s, 0, sizeof (s)); -+ len = mbrtowc (hotwcp, cp + 1, MB_CUR_MAX, &s); -+ if (len > 0) { -+ *hotposp = mbstrlen (text); -+ if (*hotposp < 0) { -+ *hotposp = -1; -+ } else { -+ /* FIXME */ -+ *hotkeyp = tolower (*hotwcp); -+ } -+ } -+ } else -+#endif -+ { -+ *hotkeyp = tolower (cp[1]); -+ *hotposp = cp - text; -+ } -+ -+ memmove (cp, cp + 1, strlen (cp + 1) + 1); - } - } - -@@ -267,8 +297,9 @@ button_new (int y, int x, int action, int flags, const char *text, - widget_want_hotkey (b->widget, 1); - b->hotkey = 0; - b->hotpos = -1; -+ b->hotwc = L'\0'; - -- button_scan_hotkey(b); -+ scan_hotkey(b->text, &b->hotpos, &b->hotkey, &b->hotwc); - return b; - } - -@@ -281,14 +312,13 @@ button_get_text (WButton *b) - void - button_set_text (WButton *b, const char *text) - { -- g_free (b->text); -+ g_free (b->text); - b->text = g_strdup (text); - b->widget.cols = button_len (text, b->flags); -- button_scan_hotkey(b); -+ scan_hotkey(b->text, &b->hotpos, &b->hotkey, &b->hotwc); - dlg_redraw (b->widget.parent); - } - -- - /* Radio button widget */ - static int radio_event (Gpm_Event *event, void *); - -@@ -363,14 +393,35 @@ radio_callback (Widget *w, widget_msg_t msg, int parm) - widget_move (&r->widget, i, 0); - - tty_printf ("(%c) ", (r->sel == i) ? '*' : ' '); -- for (cp = r->texts[i]; *cp; cp++) { -- if (*cp == '&') { -- widget_selectcolor (w, focused, TRUE); -+ cp = strchr (r->texts[i], '&'); -+ if (cp != NULL) { -+#ifdef UTF8 -+ mbstate_t s; -+ wchar_t wc; -+ int len; -+#endif -+ tty_printf ("%.*s", (int) ((char *) cp - r->texts[i]), -+ r->texts[i]); -+ widget_selectcolor (w, focused, TRUE); -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) { -+ memset (&s, 0, sizeof (s)); -+ len = mbrtowc (&wc, cp + 1, MB_CUR_MAX, &s); -+ ++cp; -+ if (len > 0) { -+ tty_printf ("%.*s", len, cp); -+ cp += len; -+ } -+ } else -+#endif -+ { - addch (*++cp); -- widget_selectcolor (w, focused, FALSE); -- } else -- addch (*cp); -- } -+ ++cp; -+ } -+ widget_selectcolor (w, focused, FALSE); -+ } else -+ cp = r->texts[i]; -+ addstr ((char *) cp); - } - return MSG_HANDLED; - -@@ -409,7 +460,7 @@ radio_new (int y, int x, int count, const char **texts) - /* Compute the longest string */ - max = 0; - for (i = 0; i < count; i++){ -- m = strlen (texts [i]); -+ m = mbstrlen (texts [i]); - if (m > max) - max = m; - } -@@ -469,6 +520,11 @@ check_callback (Widget *w, widget_msg_t msg, int parm) - if (c->hotpos >= 0) { - widget_selectcolor (w, msg == WIDGET_FOCUS, TRUE); - widget_move (&c->widget, 0, +c->hotpos + 4); -+#ifdef UTF8 -+ if (SLsmg_Is_Unicode) -+ SLsmg_write_nwchars (&c->hotwc, 1); -+ else -+#endif - addch ((unsigned char) c->text[c->hotpos]); - } - return MSG_HANDLED; -@@ -506,35 +562,20 @@ WCheck * - check_new (int y, int x, int state, const char *text) - { - WCheck *c = g_new (WCheck, 1); -- const char *s; -- char *t; -- -- init_widget (&c->widget, y, x, 1, strlen (text), -+ -+ init_widget (&c->widget, y, x, 1, mbstrlen (text), - check_callback, check_event); - c->state = state ? C_BOOL : 0; - c->text = g_strdup (text); - c->hotkey = 0; - c->hotpos = -1; -+ c->hotwc = L'\0'; - widget_want_hotkey (c->widget, 1); - -- /* Scan for the hotkey */ -- for (s = text, t = c->text; *s; s++, t++){ -- if (*s != '&'){ -- *t = *s; -- continue; -- } -- s++; -- if (*s){ -- c->hotkey = tolower ((unsigned char) *s); -- c->hotpos = t - c->text; -- } -- *t = *s; -- } -- *t = 0; -+ scan_hotkey (c->text, &c->hotpos, &c->hotkey, &c->hotwc); - return c; - } - -- - /* Label widget */ - - static cb_ret_t -@@ -573,7 +614,7 @@ label_callback (Widget *w, widget_msg_t msg, int parm) - } - widget_move (&l->widget, y, 0); - tty_printf ("%s", p); -- xlen = l->widget.cols - strlen (p); -+ xlen = l->widget.cols - mbstrlen (p); - if (xlen > 0) - tty_printf ("%*s", xlen, " "); - if (!q) -@@ -607,7 +648,7 @@ label_set_text (WLabel *label, const char *text) - if (text){ - label->text = g_strdup (text); - if (label->auto_adjust_cols) { -- newcols = strlen (text); -+ newcols = mbstrlen (text); - if (newcols > label->widget.cols) - label->widget.cols = newcols; - } -@@ -631,7 +672,7 @@ label_new (int y, int x, const char *text) - if (!text || strchr(text, '\n')) - width = 1; - else -- width = strlen (text); -+ width = mbstrlen (text); - - l = g_new (WLabel, 1); - init_widget (&l->widget, y, x, 1, width, label_callback, NULL); -@@ -779,13 +820,69 @@ static void draw_history_button (WInput * in) - /* Pointer to killed data */ - static char *kill_buffer = 0; - -+#ifdef UTF8 -+static int -+charpos(WInput *in, int idx) -+{ -+ int i, pos, l, len; -+ mbstate_t mbs; -+ memset (&mbs, 0, sizeof (mbs)); -+ i = 0; -+ pos = 0; -+ len = strlen(in->buffer); -+ -+ while (in->buffer[pos]) { -+ if (i == idx) -+ return pos; -+ l = mbrlen(in->buffer + pos, len - pos, &mbs); -+ if (l <= 0) -+ return pos; -+ pos+=l; -+ i++; -+ }; -+ return pos; -+} -+ -+static int -+charcolumn(WInput *in, int idx) -+{ -+ int i, pos, l, width, len; -+ mbstate_t mbs; -+ memset (&mbs, 0, sizeof (mbs)); -+ i = 0; -+ pos = 0; width = 0; -+ len = strlen(in->buffer); -+ -+ while (in->buffer[pos]) { -+ wchar_t wc; -+ if (i == idx) -+ return width; -+ l = mbrtowc(&wc, in->buffer + pos, len - pos, &mbs); -+ if (l <= 0) -+ return width; -+ pos += l; width += wcwidth(wc); -+ i++; -+ }; -+ return width; -+} -+#else -+#define charpos(in, idx) (idx) -+#define charcolumn(in, idx) (idx) -+#endif /* UTF8 */ -+ - void - update_input (WInput *in, int clear_first) - { - int has_history = 0; - int i, j; -- unsigned char c; -- int buf_len = strlen (in->buffer); -+ int buf_len = mbstrlen (in->buffer); -+#ifndef UTF8 -+ unsigned char c; -+#else /* UTF8 */ -+ wchar_t c; -+ mbstate_t mbs; -+ memset (&mbs, 0, sizeof (mbs)); -+#endif /* UTF8 */ - - if (should_show_history_button (in)) - has_history = HISTORY_BUTTON_WIDTH; -@@ -795,7 +892,7 @@ update_input (WInput *in, int clear_first) - - /* Make the point visible */ - if ((in->point < in->first_shown) || -- (in->point >= in->first_shown+in->field_len - has_history)){ -+ (charcolumn(in, in->point) >= charcolumn(in, in->first_shown) + in->field_len - has_history)){ - in->first_shown = in->point - (in->field_len / 3); - if (in->first_shown < 0) - in->first_shown = 0; -@@ -815,14 +912,29 @@ update_input (WInput *in, int clear_first) - addch (' '); - widget_move (&in->widget, 0, 0); - -+#ifndef UTF8 - for (i = 0, j = in->first_shown; i < in->field_len - has_history && in->buffer [j]; i++){ - c = in->buffer [j++]; - c = is_printable (c) ? c : '.'; -+#else /* UTF8 */ -+ for (i = 0, j = in->first_shown; (i < in->field_len - has_history) && (j < buf_len); i++,j++){ -+ char * chp = in->buffer + charpos(in,j); -+ size_t res = mbrtowc(&c, chp, strlen(chp), &mbs); -+ c = (res && iswprint (c)) ? 0 : '.'; -+#endif /* UTF8 */ - if (in->is_password) - c = '*'; -+#ifndef UTF8 - addch (c); -+#else /* UTF8 */ -+ if (c) { -+ addch (c); -+ } -+ else -+ SLsmg_write_nchars (chp, res); -+#endif /* UTF8 */ - } -- widget_move (&in->widget, 0, in->point - in->first_shown); -+ widget_move (&in->widget, 0, charcolumn(in, in->point) - charcolumn(in, in->first_shown)); - - if (clear_first) - in->first = 0; -@@ -975,7 +1087,7 @@ char * - show_hist (GList *history, int widget_x, int widget_y) - { - GList *hi, *z; -- size_t maxlen = strlen (i18n_htitle ()), i, count = 0; -+ size_t maxlen = mbstrlen (i18n_htitle ()), i, count = 0; - int x, y, w, h; - char *q, *r = 0; - Dlg_head *query_dlg; -@@ -988,7 +1100,7 @@ show_hist (GList *history, int widget_x, int widget_y) - z = g_list_first (history); - hi = z; - while (hi) { -- if ((i = strlen ((char *) hi->data)) > maxlen) -+ if ((i = mbstrlen ((char *) hi->data)) > maxlen) - maxlen = i; - count++; - hi = g_list_next (hi); -@@ -1158,35 +1270,83 @@ new_input (WInput *in) - in->need_push = 1; - in->buffer [0] = 0; - in->point = 0; -+ in->charpoint = 0; - in->mark = 0; - free_completions (in); - update_input (in, 0); - } - -+static void -+move_buffer_backward (WInput *in, int point) -+{ -+ int i, pos, len; -+ int str_len = mbstrlen (in->buffer); -+ if (point >= str_len) return; -+ -+ pos = charpos(in,point); -+ len = charpos(in,point + 1) - pos; -+ -+ for (i = pos; in->buffer [i + len - 1]; i++) -+ in->buffer [i] = in->buffer [i + len]; -+} -+ - static cb_ret_t - insert_char (WInput *in, int c_code) - { - size_t i; -+#ifdef UTF8 -+ mbstate_t mbs; -+ int res; -+ -+ memset (&mbs, 0, sizeof (mbs)); -+#else -+ in->charpoint = 0; -+#endif /* UTF8 */ - - if (c_code == -1) - return MSG_NOT_HANDLED; - -+#ifdef UTF8 -+ if (in->charpoint >= MB_CUR_MAX) return 1; -+ -+ in->charbuf[in->charpoint++] = c_code; -+ -+ res = mbrlen((char *)in->charbuf, in->charpoint, &mbs); -+ if (res < 0) { -+ if (res != -2) in->charpoint = 0; /* broken multibyte char, skip */ -+ return 1; -+ } -+ -+#endif /* UTF8 */ - in->need_push = 1; -- if (strlen (in->buffer)+1 == (size_t) in->current_max_len){ -+ if (strlen (in->buffer) + 1 + in->charpoint >= (size_t) in->current_max_len){ - /* Expand the buffer */ -- char *narea = g_realloc (in->buffer, in->current_max_len + in->field_len); -+ char *narea = g_realloc (in->buffer, in->current_max_len + in->field_len + in->charpoint); - if (narea){ - in->buffer = narea; -- in->current_max_len += in->field_len; -+ in->current_max_len += in->field_len + in->charpoint; - } - } -+#ifndef UTF8 - if (strlen (in->buffer)+1 < (size_t) in->current_max_len){ - size_t l = strlen (&in->buffer [in->point]); - for (i = l+1; i > 0; i--) - in->buffer [in->point+i] = in->buffer [in->point+i-1]; - in->buffer [in->point] = c_code; -+#else /* UTF8 */ -+ if (strlen (in->buffer) + in->charpoint < in->current_max_len){ -+ size_t ins_point = charpos(in,in->point); /* bytes from begin */ -+ /* move chars */ -+ size_t rest_bytes = strlen (in->buffer + ins_point); -+ -+ for (i = rest_bytes + 1; i > 0; i--) -+ in->buffer [ins_point + i + in->charpoint - 1] = in->buffer [ins_point + i - 1]; -+ -+ memcpy(in->buffer + ins_point, in->charbuf, in->charpoint); -+#endif /* UTF8 */ - in->point++; - } -+ in->charpoint = 0; - return MSG_HANDLED; - } - -@@ -1194,12 +1354,14 @@ static void - beginning_of_line (WInput *in) - { - in->point = 0; -+ in->charpoint = 0; - } - - static void - end_of_line (WInput *in) - { -- in->point = strlen (in->buffer); -+ in->point = mbstrlen (in->buffer); -+ in->charpoint = 0; - } - - static void -@@ -1207,18 +1369,21 @@ backward_char (WInput *in) - { - if (in->point) - in->point--; -+ in->charpoint = 0; - } - - static void - forward_char (WInput *in) - { -- if (in->buffer [in->point]) -+ if (in->buffer [charpos(in,in->point)]) - in->point++; -+ in->charpoint = 0; - } - - static void - forward_word (WInput * in) - { -+#ifndef UTF8 - char *p = in->buffer + in->point; - - while (*p -@@ -1228,11 +1393,39 @@ forward_word (WInput * in) - while (*p && isalnum ((unsigned char) *p)) - p++; - in->point = p - in->buffer; -+#else /* UTF8 */ -+ mbstate_t mbs; -+ int len = mbstrlen (in->buffer); -+ memset (&mbs, 0, sizeof (mbs)); -+ -+ while (in->point < len) { -+ wchar_t c; -+ char *p = in->buffer + charpos(in,in->point); -+ size_t res = mbrtowc(&c, p, strlen(p), &mbs); -+ if (res <= 0 || !(iswspace (c) || iswpunct (c))) -+ break; -+ in->point++; -+ } -+ -+ memset (&mbs, 0, sizeof (mbs)); -+ -+ while (in->point < len) { -+ wchar_t c; -+ char *p = in->buffer + charpos(in,in->point); -+ size_t res = mbrtowc(&c, p, strlen(p), &mbs); -+ if (res <= 0 || !iswalnum (c)) -+ break; -+ in->point++; -+ } -+ -+ in->charpoint = 0; -+#endif /* UTF8 */ - } - - static void - backward_word (WInput *in) - { -+#ifndef UTF8 - char *p = in->buffer + in->point; - - while (p - 1 > in->buffer - 1 && (isspace ((unsigned char) *(p - 1)) -@@ -1242,6 +1435,32 @@ backward_word (WInput *in) - while (p - 1 > in->buffer - 1 && isalnum ((unsigned char) *(p - 1))) - p--; - in->point = p - in->buffer; -+#else /* UTF8 */ -+ mbstate_t mbs; -+ -+ memset (&mbs, 0, sizeof (mbs)); -+ while (in->point > 0) { -+ wchar_t c; -+ char *p = in->buffer + charpos(in,in->point); -+ size_t res = mbrtowc(&c, p, strlen(p), &mbs); -+ if (*p && (res <= 0 || !(iswspace (c) || iswpunct (c)))) -+ break; -+ in->point--; -+ } -+ -+ memset (&mbs, 0, sizeof (mbs)); -+ -+ while (in->point > 0) { -+ wchar_t c; -+ char *p = in->buffer + charpos(in,in->point); -+ size_t res = mbrtowc(&c, p, strlen(p), &mbs); -+ if (*p && (res <= 0 || !iswalnum (c))) -+ break; -+ in->point--; -+ } -+ -+ in->charpoint = 0; -+#endif /* UTF8 */ - } - - static void -@@ -1270,12 +1489,12 @@ key_ctrl_right (WInput *in) - static void - backward_delete (WInput *in) - { -- int i; - - if (!in->point) - return; -- for (i = in->point; in->buffer [i-1]; i++) -- in->buffer [i-1] = in->buffer [i]; -+ -+ move_buffer_backward(in, in->point - 1); -+ in->charpoint = 0; - in->need_push = 1; - in->point--; - } -@@ -1283,10 +1502,8 @@ backward_delete (WInput *in) - static void - delete_char (WInput *in) - { -- int i; -- -- for (i = in->point; in->buffer [i]; i++) -- in->buffer [i] = in->buffer [i+1]; -+ move_buffer_backward(in, in->point); -+ in->charpoint = 0; - in->need_push = 1; - } - -@@ -1301,6 +1518,9 @@ copy_region (WInput *in, int x_first, int x_last) - - g_free (kill_buffer); - -+ first=charpos(in,first); -+ last=charpos(in,last); -+ - kill_buffer = g_strndup(in->buffer+first,last-first); - } - -@@ -1309,11 +1529,13 @@ delete_region (WInput *in, int x_first, int x_last) - { - int first = min (x_first, x_last); - int last = max (x_first, x_last); -- size_t len = strlen (&in->buffer [last]) + 1; -+ size_t len; - - in->point = first; - in->mark = first; -- memmove (&in->buffer [first], &in->buffer [last], len); -+ len = strlen (&in->buffer [charpos(in,last)]) + 1; -+ memmove (&in->buffer [charpos(in,first)], &in->buffer [charpos(in,last)], len); -+ in->charpoint = 0; - in->need_push = 1; - } - -@@ -1330,6 +1552,8 @@ kill_word (WInput *in) - copy_region (in, old_point, new_point); - delete_region (in, old_point, new_point); - in->need_push = 1; -+ in->charpoint = 0; -+ in->charpoint = 0; - } - - static void -@@ -1373,16 +1597,20 @@ yank (WInput *in) - - if (!kill_buffer) - return; -+ in->charpoint = 0; - for (p = kill_buffer; *p; p++) - insert_char (in, *p); -+ in->charpoint = 0; - } - - static void - kill_line (WInput *in) - { -+ int chp = charpos(in,in->point); - g_free (kill_buffer); -- kill_buffer = g_strdup (&in->buffer [in->point]); -- in->buffer [in->point] = 0; -+ kill_buffer = g_strdup (&in->buffer [chp]); -+ in->buffer [chp] = 0; -+ in->charpoint = 0; - } - - void -@@ -1392,9 +1620,10 @@ assign_text (WInput *in, const char *text) - g_free (in->buffer); - in->buffer = g_strdup (text); /* was in->buffer->text */ - in->current_max_len = strlen (in->buffer) + 1; -- in->point = strlen (in->buffer); -+ in->point = mbstrlen (in->buffer); - in->mark = 0; - in->need_push = 1; -+ in->charpoint = 0; - } - - static void -@@ -1521,6 +1750,7 @@ port_region_marked_for_delete (WInput *in) - *in->buffer = 0; - in->point = 0; - in->first = 0; -+ in->charpoint = 0; - } - - cb_ret_t -@@ -1549,7 +1779,11 @@ handle_char (WInput *in, int c_code) - } - } - if (!input_map [i].fn){ -+#ifndef UTF8 - if (c_code > 255 || !is_printable (c_code)) -+#else /* UTF8 */ -+ if (c_code > 255) -+#endif /* UTF8 */ - return MSG_NOT_HANDLED; - if (in->first){ - port_region_marked_for_delete (in); -@@ -1582,6 +1816,9 @@ input_set_point (WInput *in, int pos) - if (pos != in->point) - free_completions (in); - in->point = pos; -+#ifdef UTF8 -+ in->charpoint = 0; -+#endif /* UTF8 */ - update_input (in, 1); - } - -@@ -1622,7 +1859,7 @@ input_callback (Widget *w, widget_msg_t msg, int parm) - return MSG_HANDLED; - - case WIDGET_CURSOR: -- widget_move (&in->widget, 0, in->point - in->first_shown); -+ widget_move (&in->widget, 0, charcolumn(in, in->point) - charcolumn(in, in->first_shown)); - return MSG_HANDLED; - - case WIDGET_DESTROY: -@@ -1646,7 +1883,7 @@ input_event (Gpm_Event * event, void *data) - && should_show_history_button (in)) { - do_show_hist (in); - } else { -- in->point = strlen (in->buffer); -+ in->point = mbstrlen (in->buffer); - if (event->x - in->first_shown - 1 < in->point) - in->point = event->x - in->first_shown - 1; - if (in->point < 0) -@@ -1701,56 +1938,91 @@ input_new (int y, int x, int color, int len, const char *def_text, - in->is_password = 0; - - strcpy (in->buffer, def_text); -- in->point = strlen (in->buffer); -+ in->point = mbstrlen (in->buffer); -+ in->charpoint = 0; - return in; - } - -- --/* Listbox widget */ -+/* Vertical scrollbar widget */ - --/* Should draw the scrollbar, but currently draws only -- * indications that there is more information -- */ --static int listbox_cdiff (WLEntry *s, WLEntry *e); -- --static void --listbox_drawscroll (WListbox *l) -+void -+vscrollbar (Widget widget, int height, int width, int tpad, int bpad, -+ int selected, int count, gboolean color) - { - int line; -- int i, top; -- int max_line = l->height-1; -- -+ int i; -+ - /* Are we at the top? */ -- widget_move (&l->widget, 0, l->width); -- if (l->list == l->top) -- one_vline (); -+ widget_move (&widget, tpad, width); -+#ifndef UTF8 -+ if (!selected) -+ one_vline (); -+ else -+ addch ('^'); -+#else -+ if (color) attrset (MARKED_COLOR); -+ if (is_utf8) -+ SLsmg_write_string("â–´"); - else -- addch ('^'); -+ addch ('^'); -+ if (color) attrset (NORMAL_COLOR); -+#endif - - /* Are we at the bottom? */ -- widget_move (&l->widget, max_line, l->width); -- top = listbox_cdiff (l->list, l->top); -- if ((top + l->height == l->count) || l->height >= l->count) -- one_vline (); -+ widget_move (&widget, height-1-bpad, width); -+#ifndef UTF8 -+ if (selected == count-1) -+ one_vline (); -+ else -+ addch ('v'); -+#else -+ if (color) attrset (MARKED_COLOR); -+ if (is_utf8) -+ SLsmg_write_string("â–¾"); - else -- addch ('v'); -+ addch('v'); -+ if (color) attrset (NORMAL_COLOR); -+#endif - - /* Now draw the nice relative pointer */ -- if (l->count) -- line = 1+ ((l->pos * (l->height-2)) / l->count); -+ if (count > 1) -+ line = tpad + 1 + ((selected * (height-3-tpad-bpad)) / (count-1)); - else -- line = 0; -- -- for (i = 1; i < max_line; i++){ -- widget_move (&l->widget, i, l->width); -- if (i != line) -- one_vline (); -- else -- addch ('*'); -+ line = 0; -+ -+ for (i = tpad + 1; i < height-1-bpad; i++){ -+ widget_move (&widget, i, width); -+ if (i != line) -+#ifndef UTF8 -+ one_vline (); -+ else -+ addch ('*'); -+#else -+ if (is_utf8) -+ SLsmg_write_string("â–’"); -+ else -+ one_vline(); -+ else { -+ if (color) attrset (MARKED_COLOR); -+ if (is_utf8) -+ SLsmg_write_string("â—ˆ"); -+ else -+ addch('*'); -+ if (color) attrset (NORMAL_COLOR); -+ } -+#endif - } - } -- --static void -+ -+ -+/* Listbox widget */ -+ -+/* Should draw the scrollbar, but currently draws only -+ * indications that there is more information -+ */ -+static int listbox_cdiff (WLEntry *s, WLEntry *e); -+ -+void - listbox_draw (WListbox *l, int focused) - { - WLEntry *e; -@@ -1791,7 +2063,7 @@ listbox_draw (WListbox *l, int focused) - if (!l->scrollbar) - return; - attrset (normalc); -- listbox_drawscroll (l); -+ vscrollbar (l->widget, l->height, l->width, 0, 0, l->pos, l->count, FALSE); - } - - /* Returns the number of items between s and e, -diff --git a/src/widget.h b/src/widget.h -index 8c6f781..d1d91f2 100644 ---- a/src/widget.h -+++ b/src/widget.h -@@ -39,6 +39,7 @@ typedef struct WButton { - char *text; /* text of button */ - int hotkey; /* hot KEY */ - int hotpos; /* offset hot KEY char in text */ -+ wchar_t hotwc; - bcback callback; /* Callback function */ - } WButton; - -@@ -59,6 +60,7 @@ typedef struct WCheck { - char *text; /* text of check button */ - int hotkey; /* hot KEY */ - int hotpos; /* offset hot KEY char in text */ -+ wchar_t hotwc; - } WCheck; - - typedef struct WGauge { -@@ -74,16 +76,20 @@ char *show_hist (GList *history, int widget_y, int widget_x); - - typedef struct { - Widget widget; -- int point; /* cursor position in the input line */ -- int mark; /* The mark position */ -- int first_shown; /* Index of the first shown character */ -- int current_max_len; /* Maximum length of input line */ -- int field_len; /* Length of the editing field */ -+ int point; /* cursor position in the input line (mb chars) */ -+ int mark; /* The mark position (mb chars) */ -+ int first_shown; /* Index of the first shown character (mb chars) */ -+ int current_max_len; /* Maximum length of input line (bytes) */ -+ int field_len; /* Length of the editing field (mb chars) */ - int color; /* color used */ - int first; /* Is first keystroke? */ - int disable_update; /* Do we want to skip updates? */ - int is_password; /* Is this a password input line? */ - char *buffer; /* pointer to editing buffer */ -+#ifdef UTF8 -+ char charbuf[MB_LEN_MAX]; -+#endif /* UTF8 */ -+ int charpoint; - GList *history; /* The history */ - int need_push; /* need to push the current Input on hist? */ - char **completions; /* Possible completions array */ -@@ -181,6 +187,10 @@ void button_set_text (WButton *b, const char *text); - /* Listbox manager */ - WLEntry *listbox_get_data (WListbox *l, int pos); - -+/* Vertical scrollbar */ -+void vscrollbar (Widget widget, int height, int width, int tpad, int bpad, -+ int selected, int count, gboolean color); -+ - /* search text int listbox entries */ - WLEntry *listbox_search_text (WListbox *l, const char *text); - void listbox_select_entry (WListbox *l, WLEntry *dest); -diff --git a/src/wtools.c b/src/wtools.c -index ba317e9..a6eaffa 100644 ---- a/src/wtools.c -+++ b/src/wtools.c -@@ -49,11 +49,11 @@ create_listbox_window (int cols, int lines, const char *title, const char *help) - /* Adjust sizes */ - lines = (lines > LINES - 6) ? LINES - 6 : lines; - -- if (title && (cols < (len = strlen (title) + 2))) -+ if (title && (cols < (len = mbstrlen (title) + 2))) - cols = len; - - /* no &, but 4 spaces around button for brackets and such */ -- if (cols < (len = strlen (cancel_string) + 3)) -+ if (cols < (len = mbstrlen (cancel_string) + 3)) - cols = len; - - cols = cols > COLS - 6 ? COLS - 6 : cols; -@@ -124,7 +124,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...) - va_start (ap, count); - for (i = 0; i < count; i++) { - char *cp = va_arg (ap, char *); -- win_len += strlen (cp) + 6; -+ win_len += mbstrlen (cp) + 6; - if (strchr (cp, '&') != NULL) - win_len--; - } -@@ -133,7 +133,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...) - - /* count coordinates */ - msglen (text, &lines, &cols); -- cols = 6 + max (win_len, max ((int) strlen (header), cols)); -+ cols = 6 + max (win_len, max ((int) mbstrlen (header), cols)); - lines += 4 + (count > 0 ? 2 : 0); - xpos = COLS / 2 - cols / 2; - ypos = LINES / 3 - (lines - 3) / 2; -@@ -148,7 +148,7 @@ query_dialog (const char *header, const char *text, int flags, int count, ...) - va_start (ap, count); - for (i = 0; i < count; i++) { - cur_name = va_arg (ap, char *); -- xpos = strlen (cur_name) + 6; -+ xpos = mbstrlen (cur_name) + 6; - if (strchr (cur_name, '&') != NULL) - xpos--; - -@@ -467,7 +467,7 @@ fg_input_dialog_help (const char *header, const char *text, const char *help, - } - - msglen (text, &lines, &cols); -- len = max ((int) strlen (header), cols) + 4; -+ len = max ((int) mbstrlen (header), cols) + 4; - len = max (len, 64); - - /* The special value of def_text is used to identify password boxes -@@ -489,7 +489,7 @@ fg_input_dialog_help (const char *header, const char *text, const char *help, - quick_widgets[1].text = _(quick_widgets[1].text); - quick_widgets[0].relative_x = len / 2 + 4; - quick_widgets[1].relative_x = -- len / 2 - (strlen (quick_widgets[1].text) + 9); -+ len / 2 - (mbstrlen (quick_widgets[1].text) + 9); - quick_widgets[0].x_divisions = quick_widgets[1].x_divisions = len; - #endif /* ENABLE_NLS */ - -diff --git a/vfs/vfs.c b/vfs/vfs.c -index 39fdc73..1658eaa 100644 ---- a/vfs/vfs.c -+++ b/vfs/vfs.c -@@ -56,6 +56,11 @@ - #include "smbfs.h" - #include "local.h" - -+#include "../src/panel.h" -+#ifdef HAVE_CHARSET -+#include "../src/recode.h" -+#endif -+ - /* They keep track of the current directory */ - static struct vfs_class *current_vfs; - static char *current_dir; -@@ -688,8 +693,66 @@ mc_chdir (const char *path) - vfsid old_vfsid; - int result; - -+#ifdef HAVE_CHARSET -+ char* errmsg; -+#endif -+ WPanel* p=ret_panel; -+ - new_dir = vfs_canon (path); - new_vfs = vfs_get_class (new_dir); -+ old_vfsid = vfs_getid (current_vfs, current_dir); -+ old_vfs = current_vfs; -+ -+ if(p) { -+ -+ // Change from localfs to ftpfs -+ ret_panel=NULL; -+ if( (strcmp(old_vfs->name,"localfs")==0) && -+ (strcmp(new_vfs->name,"ftpfs")==0)){ -+ p->is_return=1; -+ strncpy(p->retdir,current_dir, MC_MAXPATHLEN); -+#ifdef HAVE_CHARSET -+ p->ret_codepage=p->src_codepage; -+ p->src_codepage=ftp_codepage; -+ errmsg=my_init_tt(display_codepage,p->src_codepage,p->tr_table); -+ if(errmsg) { -+ panel_reset_codepage(p); -+ message( 1, MSG_ERROR, "%s", errmsg ); -+ } -+ errmsg=my_init_tt(p->src_codepage,display_codepage,p->tr_table_input); -+ if(errmsg) { -+ panel_reset_codepage(p); -+ message( 1, MSG_ERROR, "%s", errmsg ); -+ } -+#endif -+ } -+ -+ // Change from ftpfs to localfs -+ if( (strcmp(old_vfs->name,"ftpfs")==0) && -+ (strcmp(new_vfs->name,"localfs")==0) && -+ p->is_return){ -+ p->is_return=0; -+ g_free(new_dir); -+ new_dir = vfs_canon (p->retdir); -+ new_vfs = vfs_get_class (new_dir); -+#ifdef HAVE_CHARSET -+ p->src_codepage=p->ret_codepage; -+ errmsg=my_init_tt(display_codepage,p->src_codepage,p->tr_table); -+ if(errmsg) { -+ panel_reset_codepage(p); -+ message( 1, MSG_ERROR, "%s", errmsg ); -+ } -+ errmsg=my_init_tt(p->src_codepage,display_codepage,p->tr_table_input); -+ if(errmsg) { -+ panel_reset_codepage(p); -+ message( 1, MSG_ERROR, "%s", errmsg ); -+ } -+#endif -+ } -+ } -+ -+ -+ - if (!new_vfs->chdir) { - g_free (new_dir); - return -1; -@@ -703,9 +766,6 @@ mc_chdir (const char *path) - return -1; - } - -- old_vfsid = vfs_getid (current_vfs, current_dir); -- old_vfs = current_vfs; -- - /* Actually change directory */ - g_free (current_dir); - current_dir = new_dir; diff --git a/mc-64bit.patch b/mc-64bit.patch deleted file mode 100644 index 12356e9..0000000 --- a/mc-64bit.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- mc-4.6.1a/src/mountlist.c.64bit 2005-02-08 23:33:52.000000000 +0100 -+++ mc-4.6.1a/src/mountlist.c 2005-05-10 17:09:24.122853504 +0200 -@@ -131,11 +131,19 @@ struct mount_entry - - struct fs_usage - { -+#ifndef HAVE_SYS_STATVFS_H - long fsu_blocks; /* Total blocks. */ - long fsu_bfree; /* Free blocks available to superuser. */ - long fsu_bavail; /* Free blocks available to non-superuser. */ - long fsu_files; /* Total file nodes. */ - long fsu_ffree; /* Free file nodes. */ -+#else /* We have sys/statvfs.h, use proper data types when _FILE_OFFSET_BITS=64 */ -+ fsblkcnt_t fsu_blocks; -+ fsblkcnt_t fsu_bfree; -+ fsblkcnt_t fsu_bavail; -+ fsblkcnt_t fsu_files; -+ fsblkcnt_t fsu_ffree; -+#endif /* HAVE_SYS_STATVFS_H */ - }; - - static int get_fs_usage (char *path, struct fs_usage *fsp); -@@ -665,6 +673,7 @@ my_statfs (struct my_statfs *myfs_stats, - BLOCKS FROMSIZE-byte blocks, rounding away from zero. - TOSIZE must be positive. Return -1 if FROMSIZE is not positive. */ - -+#if !defined(HAVE_SYS_STATFS_H) || !defined(STAT_STATVFS) - static long - fs_adjust_blocks (long blocks, int fromsize, int tosize) - { -@@ -672,13 +681,21 @@ fs_adjust_blocks (long blocks, int froms - abort (); - if (fromsize <= 0) - return -1; -- -+#else -+static fsblkcnt_t -+fs_adjust_blocks (fsblkcnt_t blocks, unsigned long fromsize, unsigned long tosize) -+{ -+ if (!tosize) -+ abort (); -+ if (!fromsize) -+ return -1; -+#endif - if (fromsize == tosize) /* E.g., from 512 to 512. */ - return blocks; - else if (fromsize > tosize) /* E.g., from 2048 to 512. */ - return blocks * (fromsize / tosize); - else /* E.g., from 256 to 512. */ -- return (blocks + (blocks < 0 ? -1 : 1)) / (tosize / fromsize); -+ return (blocks + 1) / (tosize / fromsize); - } - - #if defined(_AIX) && defined(_I386) diff --git a/mc-cedit-configurable-highlight.patch b/mc-cedit-configurable-highlight.patch deleted file mode 100644 index 99c8160..0000000 --- a/mc-cedit-configurable-highlight.patch +++ /dev/null @@ -1,363 +0,0 @@ - -Move syntax highlighting options into their own menu, and make TAB and -Whitespace highlighting selectable. - -Signed-off-by: Jan Engelhardt - ---- - edit/edit.c | 6 ++ - edit/edit.h | 7 ++ - edit/editcmddef.h | 1 - edit/editdraw.c | 4 + - edit/editkeys.c | 1 - edit/editmenu.c | 6 ++ - edit/editoptions.c | 141 ++++++++++++++++++++++++++++++++++++++++------------- - src/setup.c | 1 - 8 files changed, 133 insertions(+), 34 deletions(-) - -Index: mc/edit/edit.c -=================================================================== ---- mc.orig/edit/edit.c -+++ mc/edit/edit.c -@@ -2487,6 +2487,12 @@ edit_execute_cmd (WEdit *edit, int comma - edit->force |= REDRAW_PAGE; - break; - -+ case CK_Toggle_Syntax2: -+ ++option_highlighting; -+ option_highlighting %= 4; -+ edit->force |= REDRAW_PAGE; -+ break; -+ - case CK_Find: - edit_search_cmd (edit, 0); - break; -Index: mc/edit/edit.h -=================================================================== ---- mc.orig/edit/edit.h -+++ mc/edit/edit.h -@@ -228,6 +228,7 @@ int line_is_blank (WEdit *edit, long lin - int edit_indent_width (WEdit *edit, long p); - void edit_insert_indent (WEdit *edit, int indent); - void edit_options_dialog (void); -+void edit_syntax_opt_dialog(void); - void edit_syntax_dialog (void); - void edit_mail_dialog (WEdit *edit); - void format_paragraph (WEdit *edit, int force); -@@ -279,10 +280,16 @@ typedef enum { - EDIT_DO_BACKUP - } edit_save_mode_t; - -+enum { -+ HL_WHITESPACE = 1 << 0, -+ HL_TABS = 1 << 1, -+}; -+ - extern int option_save_mode; - extern int option_save_position; - extern int option_max_undo; - extern int option_syntax_highlighting; -+extern unsigned int option_highlighting; - extern int option_auto_syntax; - extern char *option_syntax_type; - extern int editor_option_check_nl_at_eof; -Index: mc/edit/editcmddef.h -=================================================================== ---- mc.orig/edit/editcmddef.h -+++ mc/edit/editcmddef.h -@@ -109,6 +109,7 @@ - #define CK_Maximize 458 - - #define CK_Toggle_Syntax 480 -+#define CK_Toggle_Syntax2 481 - - /* macro */ - #define CK_Begin_Record_Macro 501 -Index: mc/edit/editdraw.c -=================================================================== ---- mc.orig/edit/editdraw.c -+++ mc/edit/editdraw.c -@@ -273,7 +273,9 @@ print_to_widget (WEdit *edit, long row, - } - } - --int visible_tabs = 1, visible_tws = 1; -+unsigned int option_highlighting = HL_TABS | HL_WHITESPACE; -+#define visible_tabs (option_highlighting & HL_TABS) -+#define visible_tws (option_highlighting & HL_WHITESPACE) - - /* b is a pointer to the beginning of the line */ - static void -Index: mc/edit/editkeys.c -=================================================================== ---- mc.orig/edit/editkeys.c -+++ mc/edit/editkeys.c -@@ -114,6 +114,7 @@ static const edit_key_map_type common_ke - { XCTRL ('l'), CK_Refresh }, - { XCTRL ('o'), CK_Shell }, - { XCTRL ('s'), CK_Toggle_Syntax }, -+ { XCTRL ('v'), CK_Toggle_Syntax2 }, - { XCTRL ('u'), CK_Undo }, - { XCTRL ('t'), CK_Select_Codepage }, - { XCTRL ('q'), CK_Insert_Literal }, -Index: mc/edit/editmenu.c -=================================================================== ---- mc.orig/edit/editmenu.c -+++ mc/edit/editmenu.c -@@ -283,6 +283,11 @@ menu_options (void) - edit_options_dialog (); - } - -+static void menu_syntax_options(void) -+{ -+ edit_syntax_opt_dialog(); -+} -+ - static void - menu_syntax (void) - { -@@ -410,6 +415,7 @@ static menu_entry CmdMenuEmacs[] = - static menu_entry OptMenu[] = - { - {' ', N_("&General... "), 'G', menu_options}, -+ {' ', N_("Highlight options... "), ' ', menu_syntax_options}, - {' ', N_("&Save mode..."), 'S', menu_save_mode_cmd}, - {' ', N_("Learn &Keys..."), 'K', learn_keys}, - {' ', N_("Syntax &Highlighting..."), 'H', menu_syntax}, -Index: mc/edit/editoptions.c -=================================================================== ---- mc.orig/edit/editoptions.c -+++ mc/edit/editoptions.c -@@ -43,9 +43,6 @@ - #include "../src/dialog.h" /* B_CANCEL */ - #include "../src/wtools.h" /* QuickDialog */ - --#define OPT_DLG_H 17 --#define OPT_DLG_W 72 -- - #ifndef USE_INTERNAL_EDIT - #define USE_INTERNAL_EDIT 1 - #endif -@@ -65,12 +62,98 @@ i18n_translate_array (const char *array[ - } - } - -+#define OPT_DLG_H 12 -+#define OPT_DLG_W 40 -+void edit_syntax_opt_dialog(void) -+{ -+ int f_syntax_hl = option_syntax_highlighting; -+ int f_tab_hl = option_highlighting & HL_TABS; -+ int f_ws_hl = option_highlighting & HL_WHITESPACE; -+ -+ int old_syntax_hl = f_syntax_hl; -+ -+ QuickWidget quick_widgets[] = { -+ { -+ .widget_type = quick_button, -+ .relative_x = 6, -+ .x_divisions = 10, -+ .relative_y = OPT_DLG_H - 3, -+ .y_divisions = OPT_DLG_H, -+ .text = N_("&Cancel"), -+ .value = B_CANCEL, -+ }, -+ { -+ .widget_type = quick_button, -+ .relative_x = 2, -+ .x_divisions = 10, -+ .relative_y = OPT_DLG_H - 3, -+ .y_divisions = OPT_DLG_H, -+ .text = N_("&OK"), -+ .value = B_ENTER, -+ }, -+ { -+ .widget_type = quick_checkbox, -+ .relative_x = 6, -+ .x_divisions = OPT_DLG_W, -+ .relative_y = 6, -+ .y_divisions = OPT_DLG_H, -+ .text = N_("Whitespace highlighting"), -+ .result = &f_ws_hl, -+ }, -+ { -+ .widget_type = quick_checkbox, -+ .relative_x = 6, -+ .x_divisions = OPT_DLG_W, -+ .relative_y = 5, -+ .y_divisions = OPT_DLG_H, -+ .text = N_("Tab highlighting"), -+ .result = &f_tab_hl, -+ }, -+ { -+ .widget_type = quick_checkbox, -+ .relative_x = 6, -+ .x_divisions = OPT_DLG_W, -+ .relative_y = 4, -+ .y_divisions = OPT_DLG_H, -+ .text = N_("Syntax highlighting"), -+ .result = &f_syntax_hl, -+ }, -+ NULL_QuickWidget, -+ }; -+ QuickDialog quick_options = { -+ .xlen = OPT_DLG_W, -+ .ylen = OPT_DLG_H, -+ .xpos = -1, -+ .ypos = 0, -+ .title = N_(" Syntax options "), -+ .help = "", -+ .widgets = quick_widgets, -+ }; -+ -+ if (quick_dialog(&quick_options) == B_CANCEL) -+ return; -+ -+ if (old_syntax_hl != f_syntax_hl) -+ /* Load or unload syntax rules if the option has changed */ -+ edit_load_syntax(wedit, NULL, option_syntax_type); -+ -+ option_syntax_highlighting = f_syntax_hl; -+ option_highlighting = 0; -+ if (f_tab_hl) -+ option_highlighting |= HL_TABS; -+ if (f_ws_hl) -+ option_highlighting |= HL_WHITESPACE; -+} -+#undef OPT_DLG_H -+#undef OPT_DLG_W -+ -+#define OPT_DLG_H 17 -+#define OPT_DLG_W 72 - void - edit_options_dialog (void) - { - char wrap_length[32], tab_spacing[32], *p, *q; - int wrap_mode = 0; -- int old_syntax_hl; - int tedit_key_emulation = edit_key_emulation; - int toption_fill_tabs_with_spaces = option_fill_tabs_with_spaces; - int toption_save_position = option_save_position; -@@ -102,37 +185,34 @@ edit_options_dialog (void) - OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0, - "edit-tab-spacing"}, - /* 6 */ -- {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 8, -- OPT_DLG_H, N_("Synta&x highlighting"), 8, 0, 0, 0, NULL}, -- /* 7 */ - {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 9, - OPT_DLG_H, N_("Save file &position"), 0, 0, 0, 0, NULL}, -- /* 8 */ -+ /* 7 */ - {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 10, - OPT_DLG_H, N_("Confir&m before saving"), 6, 0, 0, 0, NULL}, -- /* 9 */ -+ /* 8 */ - {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11, - OPT_DLG_H, N_("Fill tabs with &spaces"), 0, 0, 0, 0, NULL}, -- /* 10 */ -+ /* 9 */ - {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12, - OPT_DLG_H, N_("&Return does autoindent"), 0, 0, 0, 0, NULL}, -- /* 11 */ -+ /* 10 */ - {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 13, - OPT_DLG_H, N_("&Backspace through tabs"), 0, 0, 0, 0, NULL}, -- /* 12 */ -+ /* 11 */ - {quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 14, - OPT_DLG_H, N_("&Fake half tabs"), 0, 0, 0, 0, NULL}, -- /* 13 */ -+ /* 12 */ - {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, "", 3, 0, 0, - const_cast(char **, wrap_str), "wrapm"}, -- /* 14 */ -+ /* 13 */ - {quick_label, 4, OPT_DLG_W, OPT_DLG_H - 8, OPT_DLG_H, - N_("Wrap mode"), 0, 0, - 0, 0, NULL}, -- /* 15 */ -+ /* 14 */ - {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 13, OPT_DLG_H, "", 3, 0, 0, - const_cast(char **, key_emu_str), "keyemu"}, -- /* 16 */ -+ /* 15 */ - {quick_label, 4, OPT_DLG_W, OPT_DLG_H - 14, OPT_DLG_H, - N_("Key emulation"), 0, 0, 0, 0, NULL}, - NULL_QuickWidget -@@ -156,13 +236,12 @@ edit_options_dialog (void) - quick_widgets[3].str_result = &p; - quick_widgets[5].text = tab_spacing; - quick_widgets[5].str_result = &q; -- quick_widgets[6].result = &tedit_syntax_highlighting; -- quick_widgets[7].result = &toption_save_position; -- quick_widgets[8].result = &tedit_confirm_save; -- quick_widgets[9].result = &toption_fill_tabs_with_spaces; -- quick_widgets[10].result = &toption_return_does_auto_indent; -- quick_widgets[11].result = &toption_backspace_through_tabs; -- quick_widgets[12].result = &toption_fake_half_tabs; -+ quick_widgets[6].result = &toption_save_position; -+ quick_widgets[7].result = &tedit_confirm_save; -+ quick_widgets[8].result = &toption_fill_tabs_with_spaces; -+ quick_widgets[9].result = &toption_return_does_auto_indent; -+ quick_widgets[10].result = &toption_backspace_through_tabs; -+ quick_widgets[11].result = &toption_fake_half_tabs; - - if (option_auto_para_formatting) - wrap_mode = 1; -@@ -171,19 +250,17 @@ edit_options_dialog (void) - else - wrap_mode = 0; - -- quick_widgets[13].result = &wrap_mode; -- quick_widgets[13].value = wrap_mode; -+ quick_widgets[12].result = &wrap_mode; -+ quick_widgets[12].value = wrap_mode; - -- quick_widgets[15].result = &tedit_key_emulation; -- quick_widgets[15].value = tedit_key_emulation; -+ quick_widgets[14].result = &tedit_key_emulation; -+ quick_widgets[14].value = tedit_key_emulation; - - Quick_options.widgets = quick_widgets; - - if (quick_dialog (&Quick_options) == B_CANCEL) - return; - -- old_syntax_hl = option_syntax_highlighting; -- - if (p) { - option_word_wrap_line_length = atoi (p); - g_free (p); -@@ -195,7 +272,6 @@ edit_options_dialog (void) - g_free (q); - } - -- option_syntax_highlighting = tedit_syntax_highlighting; - edit_confirm_save = tedit_confirm_save; - option_save_position = toption_save_position; - option_fill_tabs_with_spaces = toption_fill_tabs_with_spaces; -@@ -220,9 +296,8 @@ edit_options_dialog (void) - edit_reload_menu (); - } - -- /* Load or unload syntax rules if the option has changed */ -- if (option_syntax_highlighting != old_syntax_hl) -- edit_load_syntax (wedit, NULL, option_syntax_type); - /* Load usermap if it's needed */ - edit_load_user_map (wedit); - } -+#undef DLG_OPT_W -+#undef DLG_OPT_H -Index: mc/src/setup.c -=================================================================== ---- mc.orig/src/setup.c -+++ mc/src/setup.c -@@ -216,6 +216,7 @@ static const struct { - { "editor_option_typewriter_wrap", &option_typewriter_wrap }, - { "editor_edit_confirm_save", &edit_confirm_save }, - { "editor_syntax_highlighting", &option_syntax_highlighting }, -+ { "editor_highlight", &option_highlighting }, - #endif /* USE_INTERNAL_EDIT */ - - { "nice_rotating_dash", &nice_rotating_dash }, diff --git a/mc-cedit.patch b/mc-cedit.patch deleted file mode 100644 index 0c788de..0000000 --- a/mc-cedit.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- mc-4.6.1a/lib/cedit.menu.changelog 2005-05-27 05:35:12.000000000 +0200 -+++ mc-4.6.1a/lib/cedit.menu 2006-01-30 10:46:11.000000000 +0100 -@@ -449,6 +449,13 @@ - EMAIL="<$REPLYTO>" - echo "$DATE $AUTHOR $EMAIL" >%b - -+S Insert `Spec-file Changelog' string -+ DATE="`date +\"%%a %%b %%e %%Y\"`" -+ MY_UID="`id | sed 's/^.*uid=\([^(]*\).*$/\1/'`" -+ AUTHOR="`awk -F: '$3 == '$MY_UID' {print $5}' /etc/passwd`" -+ EMAIL="<$REPLYTO>" -+ echo "* $DATE $AUTHOR $EMAIL" >%b -+ - s Invoke `shell' - sh - diff --git a/mc-delcheck.patch b/mc-delcheck.patch deleted file mode 100644 index 09214e3..0000000 --- a/mc-delcheck.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- mc-4.6.1a/src/file.c.delcheck 2006-04-28 13:46:33.000000000 +0200 -+++ mc-4.6.1a/src/file.c 2006-04-28 13:52:48.000000000 +0200 -@@ -1755,6 +1755,12 @@ - free_linklist (&linklist); - free_linklist (&dest_dirs); - -+ /* Update panel contents to avoid actions on deleted files */ -+ if (!panel->is_panelized) { -+ update_panels (UP_RELOAD, UP_KEEPSEL); -+ repaint_screen (); -+ } -+ - if (single_entry) { - if (force_single) { - source = selection (panel)->fname; diff --git a/mc-edit-segv.patch b/mc-edit-segv.patch deleted file mode 100644 index 45767e0..0000000 --- a/mc-edit-segv.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -up mc-4.6.2-pre1/edit/edit.c.segv mc-4.6.2-pre1/edit/edit.c ---- mc-4.6.2-pre1/edit/edit.c.segv 2009-05-15 11:42:08.000000000 +0200 -+++ mc-4.6.2-pre1/edit/edit.c 2009-05-15 11:54:29.000000000 +0200 -@@ -1808,6 +1808,7 @@ my_type_of (int c) - c = '0'; - else if (iswspace (c)) - c = ' '; -+ if ( c > 0xff ) c = ' '; - #endif /* UTF8 */ - q = strchr (option_chars_move_whole_word, c); - if (!q) diff --git a/mc-etcmc.patch b/mc-etcmc.patch deleted file mode 100644 index bd26f4b..0000000 --- a/mc-etcmc.patch +++ /dev/null @@ -1,356 +0,0 @@ -diff -up mc-4.6.2/edit/editcmd.c.etcmc mc-4.6.2/edit/editcmd.c ---- mc-4.6.2/edit/editcmd.c.etcmc 2009-05-26 18:05:21.000000000 +0200 -+++ mc-4.6.2/edit/editcmd.c 2009-05-26 18:05:21.000000000 +0200 -@@ -51,7 +51,7 @@ - #include "../src/tty.h" /* LINES */ - #include "../src/widget.h" /* listbox_new() */ - #include "../src/layout.h" /* clr_scr() */ --#include "../src/main.h" /* mc_home */ -+#include "../src/main.h" /* mc_home, mc_home_alt */ - #include "../src/help.h" /* interactive_display() */ - #include "../src/key.h" /* XCTRL */ - #include "../src/dialog.h" /* do_refresh() */ -@@ -2833,12 +2833,15 @@ edit_block_process_cmd (WEdit *edit, con - return; - } - if (!(script_src = fopen (o, "r"))) { -- fclose (script_home); -- unlink (h); -- edit_error_dialog ("", get_sys_error (catstrs -- (_("Error reading script:"), -- o, (char *) NULL))); -- return; -+ o = catstrs (mc_home_alt, shell_cmd, (char *) NULL); -+ if (!(script_src = fopen (o, "r"))) { -+ fclose (script_home); -+ unlink (h); -+ edit_error_dialog ("", get_sys_error (catstrs -+ (_("Error reading script:"), -+ o, (char *) NULL))); -+ return; -+ } - } - while (fgets (buf, sizeof (buf), script_src)) - fputs (buf, script_home); -diff -up mc-4.6.2/edit/syntax.c.etcmc mc-4.6.2/edit/syntax.c ---- mc-4.6.2/edit/syntax.c.etcmc 2009-02-01 20:30:21.000000000 +0100 -+++ mc-4.6.2/edit/syntax.c 2009-05-26 18:05:21.000000000 +0200 -@@ -39,7 +39,7 @@ - #include "edit.h" - #include "edit-widget.h" - #include "../src/color.h" /* use_colors */ --#include "../src/main.h" /* mc_home */ -+#include "../src/main.h" /* mc_home, mc_home_alt */ - #include "../src/wtools.h" /* message() */ - - /* bytes */ -@@ -682,6 +682,12 @@ static FILE *open_include_file (const ch - g_free (error_file_name); - error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR, - filename, (char *) NULL); -+ if (!(f = fopen (error_file_name, "r"))) { -+ g_free (error_file_name); -+ error_file_name = g_strconcat (mc_home_alt, PATH_SEP_STR "syntax" PATH_SEP_STR, -+ filename, (char *) NULL); -+ } else return f; -+ - return fopen (error_file_name, "r"); - } - -diff -up mc-4.6.2/src/charsets.c.etcmc mc-4.6.2/src/charsets.c ---- mc-4.6.2/src/charsets.c.etcmc 2009-05-26 18:05:21.000000000 +0200 -+++ mc-4.6.2/src/charsets.c 2009-05-26 18:05:21.000000000 +0200 -@@ -47,12 +47,17 @@ load_codepages_list (void) - char *fname; - char buf[256]; - extern char *mc_home; -+ extern char *mc_home_alt; - extern int display_codepage; - char *default_codepage = NULL; - - fname = mhl_str_dir_plus_file (mc_home, CHARSETS_INDEX); - if (!(f = fopen (fname, "r"))) { -- fprintf (stderr, _("Warning: file %s not found\n"), fname); -+ g_free (fname); -+ fname = mhl_str_dir_plus_file (mc_home_alt, CHARSETS_INDEX); -+ if (!(f = fopen (fname, "r"))) { -+ fprintf (stderr, _("Warning: file %s not found\n"), fname); -+ } - g_free (fname); - return -1; - } -diff -up mc-4.6.2/src/cmd.c.etcmc mc-4.6.2/src/cmd.c ---- mc-4.6.2/src/cmd.c.etcmc 2009-05-26 18:05:21.000000000 +0200 -+++ mc-4.6.2/src/cmd.c 2009-05-26 18:05:21.000000000 +0200 -@@ -592,8 +592,13 @@ void ext_cmd (void) - check_for_default (extdir, buffer); - do_edit (buffer); - g_free (buffer); -- } else if (dir == 1) -+ } else if (dir == 1) { -+ if (!exist_file(extdir)) { -+ g_free (extdir); -+ extdir = mhl_str_dir_plus_file (mc_home_alt, MC_LIB_EXT); -+ } - do_edit (extdir); -+ } - - g_free (extdir); - flush_extension_file (); -@@ -616,6 +621,11 @@ menu_edit_cmd (int where) - ); - - menufile = mhl_str_dir_plus_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); -+ -+ if (!exist_file(menufile)) { -+ g_free (menufile); -+ menufile = mhl_str_dir_plus_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); -+ } - - switch (dir) { - case 0: -@@ -630,6 +640,10 @@ menu_edit_cmd (int where) - - case 2: - buffer = mhl_str_dir_plus_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); -+ if (!exist_file(buffer)) { -+ g_free (buffer); -+ buffer = mhl_str_dir_plus_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); -+ } - break; - - default: -@@ -688,7 +702,7 @@ edit_syntax_cmd (void) - _(" Which syntax file you want to edit? "), 0, 2, - _("&User"), _("&System Wide")); - } -- extdir = mhl_str_dir_plus_file (mc_home, "syntax" PATH_SEP_STR "Syntax"); -+ extdir = mhl_str_dir_plus_file (mc_home_alt, "syntax" PATH_SEP_STR "Syntax"); - - if (dir == 0) { - buffer = mhl_str_dir_plus_file (home_dir, SYNTAX_FILE); -diff -up mc-4.6.2/src/ext.c.etcmc mc-4.6.2/src/ext.c ---- mc-4.6.2/src/ext.c.etcmc 2009-02-01 20:30:21.000000000 +0100 -+++ mc-4.6.2/src/ext.c 2009-05-26 18:05:21.000000000 +0200 -@@ -446,6 +446,10 @@ regex_command (const char *filename, con - g_free (extension_file); - check_stock_mc_ext: - extension_file = mhl_str_dir_plus_file (mc_home, MC_LIB_EXT); -+ if (!exist_file (extension_file)) { -+ g_free (extension_file); -+ extension_file = mhl_str_dir_plus_file (mc_home_alt, MC_LIB_EXT); -+ } - mc_user_ext = 0; - } - data = load_file (extension_file); -diff -up mc-4.6.2/src/main.c.etcmc mc-4.6.2/src/main.c ---- mc-4.6.2/src/main.c.etcmc 2009-05-26 18:05:21.000000000 +0200 -+++ mc-4.6.2/src/main.c 2009-05-26 18:07:07.000000000 +0200 -@@ -291,9 +291,12 @@ char *xterm_title_str = NULL; - /* Is the LANG UTF-8 ? */ - gboolean is_utf8 = FALSE; - --/* mc_home: The home of MC */ -+/* mc_home: The home of MC - /etc/mc or defined by MC_DATADIR */ - char *mc_home = NULL; - -+/* mc_home_alt: Alternative home of MC - deprecated /usr/share/mc */ -+char *mc_home_alt = NULL; -+ - char cmd_buf[512]; - - static void -@@ -1858,8 +1861,9 @@ OS_Setup (void) - if ((mc_libdir = getenv ("MC_DATADIR")) != NULL) { - mc_home = g_strdup (mc_libdir); - } else { -- mc_home = g_strdup (DATADIR); -+ mc_home = g_strdup (SYSCONFDIR); - } -+ mc_home_alt = mc_libdir != NULL ? g_strdup (SYSCONFDIR) : g_strdup (DATADIR); - } - - static void -@@ -1989,7 +1993,7 @@ process_args (poptContext ctx, int c, co - break; - - case 'f': -- printf ("%s\n", mc_home); -+ printf ("%s (%s)\n", mc_home, mc_home_alt); - exit (0); - break; - -@@ -2339,6 +2343,7 @@ main (int argc, char *argv[]) - } - g_free (last_wd_string); - -+ g_free (mc_home_alt); - g_free (mc_home); - done_key (); - #ifdef HAVE_CHARSET -diff -up mc-4.6.2/src/main.h.etcmc mc-4.6.2/src/main.h ---- mc-4.6.2/src/main.h.etcmc 2009-05-26 18:05:21.000000000 +0200 -+++ mc-4.6.2/src/main.h 2009-05-26 18:05:21.000000000 +0200 -@@ -114,7 +114,7 @@ void print_vfs_message(const char *msg, - - extern const char *prompt; - extern const char *edit_one_file; --extern char *mc_home; -+extern char *mc_home, *mc_home_alt; - char *get_mc_lib_dir (void); - - int maybe_cd (int move_up_dir); -diff -up mc-4.6.2/src/Makefile.am.etcmc mc-4.6.2/src/Makefile.am ---- mc-4.6.2/src/Makefile.am.etcmc 2009-05-26 18:05:21.000000000 +0200 -+++ mc-4.6.2/src/Makefile.am 2009-05-26 18:05:21.000000000 +0200 -@@ -8,9 +8,11 @@ bin_PROGRAMS = mc mcmfmt - if CONS_SAVER - pkglibexec_PROGRAMS = cons.saver - AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ -- -DSAVERDIR=\""$(pkglibexecdir)"\" -+ -DSAVERDIR=\""$(pkglibexecdir)"\" \ -+ -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" - else --AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" -+AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ -+ -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" - endif - - noinst_PROGRAMS = man2hlp -diff -up mc-4.6.2/src/Makefile.in.etcmc mc-4.6.2/src/Makefile.in ---- mc-4.6.2/src/Makefile.in.etcmc 2009-02-01 20:46:26.000000000 +0100 -+++ mc-4.6.2/src/Makefile.in 2009-05-26 18:09:15.000000000 +0200 -@@ -294,9 +294,8 @@ top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ - AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) - pkglibexecdir = $(libexecdir)/@PACKAGE@ --@CONS_SAVER_FALSE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" --@CONS_SAVER_TRUE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ --@CONS_SAVER_TRUE@ -DSAVERDIR=\""$(pkglibexecdir)"\" -+@CONS_SAVER_FALSE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" -+@CONS_SAVER_TRUE@AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" -DSAVERDIR=\""$(pkglibexecdir)"\" -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" - - man2hlp_LDADD = $(GLIB_LIBS) - mcmfmt_SOURCES = mfmt.c -diff -up mc-4.6.2/src/setup.c.etcmc mc-4.6.2/src/setup.c ---- mc-4.6.2/src/setup.c.etcmc 2009-05-26 18:05:21.000000000 +0200 -+++ mc-4.6.2/src/setup.c 2009-05-26 18:05:21.000000000 +0200 -@@ -522,8 +522,15 @@ setup_init (void) - if (exist_file (inifile)){ - g_free (profile); - profile = inifile; -- } else -+ } else { - g_free (inifile); -+ inifile = mhl_str_dir_plus_file (mc_home_alt, "mc.ini"); -+ if (exist_file (inifile)) { -+ g_free (profile); -+ profile = inifile; -+ } else -+ g_free (inifile); -+ } - } - - profile_name = profile; -@@ -542,6 +549,11 @@ load_setup (void) - /* mc.lib is common for all users, but has priority lower than - ~/.mc/ini. FIXME: it's only used for keys and treestore now */ - global_profile_name = mhl_str_dir_plus_file (mc_home, "mc.lib"); -+ -+ if (!exist_file(global_profile_name)) { -+ g_free (global_profile_name); -+ global_profile_name = mhl_str_dir_plus_file (mc_home_alt, "mc.lib"); -+ } - - /* Load integer boolean options */ - for (i = 0; int_options[i].opt_name; i++) -diff -up mc-4.6.2/src/user.c.etcmc mc-4.6.2/src/user.c ---- mc-4.6.2/src/user.c.etcmc 2009-02-01 20:30:21.000000000 +0100 -+++ mc-4.6.2/src/user.c 2009-05-26 18:05:21.000000000 +0200 -@@ -729,6 +729,11 @@ user_menu_cmd (struct WEdit *edit_widget - g_free (menu); - menu = mhl_str_dir_plus_file \ - (mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); -+ if (!exist_file (menu)) { -+ g_free (menu); -+ menu = mhl_str_dir_plus_file \ -+ (mc_home_alt, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); -+ } - } - } - -diff -up mc-4.6.2/src/util.c.etcmc mc-4.6.2/src/util.c ---- mc-4.6.2/src/util.c.etcmc 2009-05-26 18:05:21.000000000 +0200 -+++ mc-4.6.2/src/util.c 2009-05-26 18:05:21.000000000 +0200 -@@ -44,7 +44,7 @@ - #include "tty.h" - #include "global.h" - #include "profile.h" --#include "main.h" /* mc_home */ -+#include "main.h" /* mc_home, mc_home_alt */ - #include "cmd.h" /* guess_message_value */ - #include "mountlist.h" - #include "win.h" /* xterm_flag */ -@@ -978,16 +978,25 @@ load_mc_home_file (const char *filename, - - if (!data) { - g_free (hintfile); -- /* Fall back to the two-letter language code */ -- if (lang[0] && lang[1]) -- lang[2] = 0; -+ g_free (hintfile_base); -+ -+ hintfile_base = mhl_str_dir_plus_file (mc_home_alt, filename); -+ - hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); - data = load_file (hintfile); -- -+ - if (!data) { -- g_free (hintfile); -- hintfile = hintfile_base; -- data = load_file (hintfile_base); -+ /* Fall back to the two-letter language code */ -+ if (lang[0] && lang[1]) -+ lang[2] = 0; -+ hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); -+ data = load_file (hintfile); -+ -+ if (!data) { -+ g_free (hintfile); -+ hintfile = hintfile_base; -+ data = load_file (hintfile_base); -+ } - } - } - -diff -up mc-4.6.2/vfs/extfs.c.etcmc mc-4.6.2/vfs/extfs.c ---- mc-4.6.2/vfs/extfs.c.etcmc 2009-02-01 20:30:21.000000000 +0100 -+++ mc-4.6.2/vfs/extfs.c 2009-05-26 18:05:21.000000000 +0200 -@@ -249,7 +249,7 @@ extfs_open_archive (int fstype, const ch - tmp = name_quote (name, 0); - } - -- mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR); -+ mc_extfsdir = mhl_str_dir_plus_file (mc_home_alt, "extfs" PATH_SEP_STR); - cmd = - g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ", - local_name ? local_name : tmp, (char *) NULL); -@@ -624,7 +624,7 @@ extfs_cmd (const char *extfs_cmd, struct - archive_name = name_quote (extfs_get_archive_name (archive), 0); - quoted_localname = name_quote (localname, 0); - -- mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR); -+ mc_extfsdir = mhl_str_dir_plus_file (mc_home_alt, "extfs" PATH_SEP_STR); - cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], - extfs_cmd, archive_name, " ", quoted_file, " ", - quoted_localname, (char *) NULL); -@@ -653,7 +653,7 @@ extfs_run (struct vfs_class *me, const c - g_free (p); - - archive_name = name_quote (extfs_get_archive_name (archive), 0); -- mc_extfsdir = mhl_str_dir_plus_file (mc_home, "extfs" PATH_SEP_STR); -+ mc_extfsdir = mhl_str_dir_plus_file (mc_home_alt, "extfs" PATH_SEP_STR); - cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], - " run ", archive_name, " ", q, (char *) NULL); - g_free (mc_extfsdir); diff --git a/mc-exit.patch b/mc-exit.patch index f6f48c4..8d66dad 100644 --- a/mc-exit.patch +++ b/mc-exit.patch @@ -1,14 +1,15 @@ ---- mc-2006-08-12-18/src/command.c.exit 2005-06-07 16:16:19.000000000 +0200 -+++ mc-2006-08-12-18/src/command.c 2006-08-15 12:48:12.000000000 +0200 -@@ -214,6 +214,11 @@ +diff -up mc-4.6.99/src/command.c.exit mc-4.6.99/src/command.c +--- mc-4.6.99/src/command.c.exit 2009-07-31 19:27:10.000000000 +0200 ++++ mc-4.6.99/src/command.c 2009-07-31 20:08:01.000000000 +0200 +@@ -224,6 +224,11 @@ enter (WInput *cmdline) size_t i, j, cmd_len; if (!vfs_current_is_local ()) { -+ if (strcmp (cmd, "exit") == 0) { -+ quiet_quit_cmd (); -+ return MSG_HANDLED; -+ } ++ if (strcmp (cmd, "exit") == 0) { ++ quiet_quit_cmd (); ++ return MSG_HANDLED; ++ } + - message (1, MSG_ERROR, + message (D_ERROR, MSG_ERROR, _ (" Cannot execute commands on non-local filesystems")); diff --git a/mc-extensions.patch b/mc-extensions.patch deleted file mode 100644 index 25b7570..0000000 --- a/mc-extensions.patch +++ /dev/null @@ -1,272 +0,0 @@ -diff -up mc-4.6.2/configure.ac.extensions mc-4.6.2/configure.ac ---- mc-4.6.2/configure.ac.extensions 2009-02-01 20:30:21.000000000 +0100 -+++ mc-4.6.2/configure.ac 2009-05-26 14:42:48.000000000 +0200 -@@ -81,7 +81,7 @@ AC_PROG_LN_S - AC_CHECK_TOOL(AR, ar, ar) - - dnl Only list browsers here that can be run in background (i.e. with `&') --AC_CHECK_PROGS(X11_WWW, [gnome-moz-remote mozilla konqueror opera netscape]) -+AC_CHECK_PROGS(X11_WWW, [firefox gnome-moz-remote mozilla konqueror opera netscape]) - - dnl - dnl Ovverriding mmap support. This has to be before AC_FUNC_MMAP is used. -diff -up mc-4.6.2/configure.extensions mc-4.6.2/configure ---- mc-4.6.2/configure.extensions 2009-02-01 20:46:23.000000000 +0100 -+++ mc-4.6.2/configure 2009-05-26 14:42:48.000000000 +0200 -@@ -6843,7 +6843,7 @@ else - fi - - --for ac_prog in gnome-moz-remote mozilla konqueror opera netscape -+for ac_prog in firefox gnome-moz-remote mozilla konqueror opera netscape - do - # Extract the first word of "$ac_prog", so it can be a program name with args. - set dummy $ac_prog; ac_word=$2 -diff -up mc-4.6.2/lib/mc.ext.in.extensions mc-4.6.2/lib/mc.ext.in ---- mc-4.6.2/lib/mc.ext.in.extensions 2009-02-01 20:30:21.000000000 +0100 -+++ mc-4.6.2/lib/mc.ext.in 2009-05-26 14:44:46.000000000 +0200 -@@ -119,6 +119,11 @@ regex/\.t(ar\.bz2|bz|b2)$ - Open=%cd %p#utar - View=%view{ascii} bzip2 -dc %f 2>/dev/null | tar tvvf - - -+# .tar.lzma, .tlz -+regex/\.t(ar\.lzma|lz)$ -+ Open=%cd %p#utar -+ View=%view{ascii} lzma -dc %f 2>/dev/null | tar tvvf - -+ - # .tar.F - used in QNX - regex/\.tar\.F$ - # Open=%cd %p#utar -@@ -198,8 +203,8 @@ regex/\.(rpm|spm)$ - - # deb - regex/\.u?deb$ -- Open=%cd %p#deb -- View=%view{ascii} dpkg-deb -I %f && echo && dpkg-deb -c %f -+ Open=%cd %p#uar -+ View=%view{ascii} file %f && nm %f - - # ISO9660 - regex/\.iso$ -@@ -220,14 +225,25 @@ type/^ASCII\ mail\ text - - # C - shell/.c -- Open=%var{EDITOR:vi} %f -+ Include=editor - - # Fortran - shell/.f -- Open=%var{EDITOR:vi} %f -+ Include=editor - - # Header --regex/\.(h|hpp)$ -+regex/\.([Hh]|[Hh]pp|HPP)$ -+ Include=editor -+ -+# Asm -+regex/\.([Ss]|[Aa]sm|ASM)$ -+ Include=editor -+ -+# C++ -+regex/\.(C|cc|[Cc]pp|CPP)$ -+ Include=editor -+ -+include/editor - Open=%var{EDITOR:vi} %f - - # Object -@@ -251,10 +267,12 @@ regex/\.(te?xi|texinfo)$ - - # GNU Info page - type/^Info\ text -- Open=info -f %f -+ #Open=info -f %f -+ Open=pinfo %f - - shell/.info -- Open=info -f %f -+ #Open=info -f %f -+ Open=pinfo %f - - # Manual page - # Exception - .so libraries are not manual pages -@@ -298,6 +316,10 @@ regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*| - Open=case %d/%f in */log/*|*/logs/*) bzip2 -dc %f ;; *) bzip2 -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more} - View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) bzip2 -dc %f ;; *) bzip2 -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac - -+regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lzma$ -+ Open=case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more} -+ View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac -+ - - ### Images ### - -@@ -328,18 +350,24 @@ type/^PPM - type/^Netpbm - Include=image - -+type/^JNG -+ Include=image -+ -+type/^MNG -+ Include=image -+ - shell/.xcf - Open=(gimp %f &) - - shell/.xbm -- Open=bitmap %f -+ Include=image - - shell/.xpm - Include=image - View=sxpm %f - - include/image -- Open=if [ "$DISPLAY" = "" ]; then zgv %f; else (gqview %f &); fi -+ Open=if [ "$DISPLAY" = "" ]; then zgv %f; else (xdg-open %f &); fi - View=%view{ascii} identify %f - #View=%view{ascii} asciiview %f - -@@ -347,7 +375,8 @@ include/image - ### Sound files ### - - regex/\.([wW][aA][vV]|[sS][nN][dD]|[vV][oO][cC]|[aA][uU]|[sS][mM][pP]|[aA][iI][fF][fF]|[sS][nN][dD])$ -- Open=if [ "$DISPLAY" = "" ]; then play %f; else (xmms %f >/dev/null 2>&1 &); fi -+ Open=play %f -+# Open=if [ "$DISPLAY" = "" ]; then play %f; else (xmms %f >/dev/null 2>&1 &); fi - - regex/\.([mM][oO][dD]|[sS]3[mM]|[xX][mM]|[iI][tT]|[mM][tT][mM]|669|[sS][tT][mM]|[uU][lL][tT]|[fF][aA][rR])$ - Open=mikmod %f -@@ -357,11 +386,16 @@ regex/\.([wW][aA][wW]22)$ - Open=vplay -s 22 %f - - regex/\.([mM][pP]3)$ -- Open=if [ "$DISPLAY" = "" ]; then mpg123 %f; else (xmms %f >/dev/null 2>&1 &); fi -- View=%view{ascii} mpg123 -vtn1 %f 2>&1 | sed -n '/^Title/,/^Comment/p;/^MPEG/,/^Audio/p' -+ Include=audio -+# Open=if [ "$DISPLAY" = "" ]; then mpg123 %f; else (xmms %f >/dev/null 2>&1 &); fi -+# View=%view{ascii} mpg123 -vtn1 %f 2>&1 | sed -n '/^Title/,/^Comment/p;/^MPEG/,/^Audio/p' -+ -+regex/\.([mM][kK][aA])$ -+ Include=audio - - regex/\.([oO][gG][gG])$ -- Open=if [ "$DISPLAY" = "" ]; then ogg123 %f; else (xmms %f >/dev/null 2>&1 &); fi -+ Open=ogg123 %f -+# Open=if [ "$DISPLAY" = "" ]; then ogg123 %f; else (xmms %f >/dev/null 2>&1 &); fi - View=%view{ascii} ogginfo %s - - regex/\.([mM][iI][dD][iI]?|[rR][mM][iI][dD]?)$ -@@ -371,11 +405,15 @@ regex/\.([wW][mM][aA])$ - Open=mplayer -vo null %f - View=%view{ascii} mplayer -quiet -slave -frames 0 -vo null -ao null -identify %f 2>/dev/null | tail +13 || file %f - -+include/audio -+ Open=mplayer %f -+ View=%view{ascii} mplayer -identify -vo null -ao null -frames 0 %f 2>&1 | sed -n '/^ID_/p' - - ### Play lists ### - - regex/\.([mM]3[uU]|[pP][lL][sS])$ -- Open=if [ -z "$DISPLAY" ]; then mplayer -vo null -playlist %f; else (xmms -p %f >/dev/null 2>&1 &); fi -+ Open=mplayer -vo null -playlist %f -+# Open=if [ -z "$DISPLAY" ]; then mplayer -vo null -playlist %f; else (xmms -p %f >/dev/null 2>&1 &); fi - - - ### Video ### -@@ -389,6 +427,9 @@ regex/\.([aA][sS][fFxX])$ - regex/\.([dD][iI][vV][xX])$ - Include=video - -+regex/\.([mM][kK][vV])$ -+ Include=video -+ - regex/\.([mM][oO][vV]|[qQ][tT])$ - Include=video - -@@ -408,10 +449,11 @@ regex/\.([oO][gG][mM])$ - Include=video - - regex/\.([rR][aA]?[mM])$ -- Open=(realplay %f >/dev/null 2>&1 &) -+ Include=video - - include/video - Open=(mplayer %f >/dev/null 2>&1 &) -+ View=%view{ascii} mplayer -identify -vo null -ao null -frames 0 %f 2>&1 | sed -n '/^ID_/p' - #Open=(gtv %f >/dev/null 2>&1 &) - #Open=(xanim %f >/dev/null 2>&1 &) - -@@ -420,12 +462,13 @@ include/video - - # Postscript - type/^PostScript -- Open=(gv %f &) -+ Open=(evince %f >/dev/null 2>&1 &) - View=%view{ascii} ps2ascii %f - - # PDF - type/^PDF -- Open=(xpdf %f &) -+ Open=(xdg-open %f >/dev/null 2>&1 &) -+ #Open=(xpdf %f >/dev/null 2>&1 &) - #Open=(acroread %f &) - #Open=(ghostview %f &) - View=%view{ascii} pdftotext %f - -@@ -436,7 +479,7 @@ type/^PDF - # html - regex/\.([hH][tT][mM][lL]?)$ - Open=(if test -n "@X11_WWW@" && test -n "$DISPLAY"; then (@X11_WWW@ file://%d/%p &) 1>&2; else links %f || lynx -force_html %f || ${PAGER:-more} %f; fi) 2>/dev/null -- View=%view{ascii} lynx -dump -force_html %f -+ View=%view{ascii} links -dump %f - - # StarOffice 5.2 - shell/.sdw -@@ -453,22 +496,27 @@ shell/.abw - - # Microsoft Word Document - regex/\.([Dd][oO][cCtT]|[Ww][rR][iI])$ -- Open=(abiword %f >/dev/null 2>&1 &) -+ Open=(ooffice %f &) -+# Open=(abiword %f >/dev/null 2>&1 &) - View=%view{ascii} catdoc -w %f || word2x -f text %f - || strings %f - type/^Microsoft\ Word -- Open=(abiword %f >/dev/null 2>&1 &) -+ Open=(ooffice %f &) -+# Open=(abiword %f >/dev/null 2>&1 &) - View=%view{ascii} catdoc -w %f || word2x -f text %f - || strings %f - - # RTF document - regex/\.([rR][tT][fF])$ -- Open=(abiword %f >/dev/null 2>&1 &) -+ Open=(ooffice %f &) -+# Open=(abiword %f >/dev/null 2>&1 &) - - # Microsoft Excel Worksheet - regex/\.([xX][lL][sSwW])$ -- Open=(gnumeric %f >/dev/null 2>&1 &) -+ Open=(ooffice %f &) -+# Open=(gnumeric %f >/dev/null 2>&1 &) - View=%view{ascii} xls2csv %f || strings %f - type/^Microsoft\ Excel -- Open=(gnumeric %f >/dev/null 2>&1 &) -+ Open=(ooffice %f &) -+# Open=(gnumeric %f >/dev/null 2>&1 &) - View=%view{ascii} xls2csv %f || strings %f - - # Use OpenOffice.org to open any MS Office documents -@@ -545,6 +593,11 @@ type/^compress - Open=gzip -dc %f | %var{PAGER:more} - View=%view{ascii} gzip -dc %f 2>/dev/null - -+# lzma -+regex/\.lzma$ -+ Open=lzma -dc %f | %var{PAGER:more} -+ View=%view{ascii} lzma -dc %f 2>/dev/null -+ - - ### Default ### - diff --git a/mc-hintchk.patch b/mc-hintchk.patch deleted file mode 100644 index d4efe75..0000000 --- a/mc-hintchk.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff -up mc-4.6.2-pre1/src/util.c.hintchk mc-4.6.2-pre1/src/util.c ---- mc-4.6.2-pre1/src/util.c.hintchk 2008-03-27 12:39:54.000000000 +0100 -+++ mc-4.6.2-pre1/src/util.c 2008-03-27 12:46:39.000000000 +0100 -@@ -995,6 +995,11 @@ load_mc_home_file (const char *filename, - if (hintfile != hintfile_base) - g_free (hintfile_base); - -+ if (!data) { -+ g_free(hintfile); -+ return NULL; -+ } -+ - if (allocated_filename) - *allocated_filename = hintfile; - else diff --git a/mc-lzma.patch b/mc-lzma.patch deleted file mode 100644 index 0b41f20..0000000 --- a/mc-lzma.patch +++ /dev/null @@ -1,182 +0,0 @@ -# LZMA support for Midnight Commander -# 2006-03-17 -# -# This patch adds basic support for LZMA compressed files to -# Midnight Commander 4.6.1. You should have LZMA utils 4.32.x -# or later. Older versions of LZMA utils will *not* work. -# -# Copyright (C) 2006 Lasse Collin -# -# This patch is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -diff -up mc-4.6.2-pre1/edit/edit.c.lzmavfs mc-4.6.2-pre1/edit/edit.c ---- mc-4.6.2-pre1/edit/edit.c.lzmavfs 2008-08-05 15:31:29.000000000 +0200 -+++ mc-4.6.2-pre1/edit/edit.c 2008-08-05 15:31:29.000000000 +0200 -@@ -185,6 +185,7 @@ edit_load_file_fast (WEdit *edit, const - static const struct edit_filters { - const char *read, *write, *extension; - } all_filters[] = { -+ { "lzma -cd %s 2>&1", "lzma > %s", ".lzma" }, - { "bzip2 -cd %s 2>&1", "bzip2 > %s", ".bz2" }, - { "gzip -cd %s 2>&1", "gzip > %s", ".gz" }, - { "gzip -cd %s 2>&1", "gzip > %s", ".Z" } -diff -up mc-4.6.2-pre1/src/util.c.lzmavfs mc-4.6.2-pre1/src/util.c ---- mc-4.6.2-pre1/src/util.c.lzmavfs 2008-08-05 15:31:29.000000000 +0200 -+++ mc-4.6.2-pre1/src/util.c 2008-08-05 15:31:29.000000000 +0200 -@@ -1239,7 +1239,7 @@ get_current_wd (char *buffer, int size) - enum compression_type - get_compression_type (int fd) - { -- unsigned char magic[4]; -+ unsigned char magic[16]; - - /* Read the magic signature */ - if (mc_read (fd, (char *) magic, 4) != 4) -@@ -1283,6 +1283,31 @@ get_compression_type (int fd) - return COMPRESSION_BZIP2; - } - } -+ -+ /* LZMA files; both LZMA_Alone and LZMA utils formats. The LZMA_Alone -+ * format is used by the LZMA_Alone tool from LZMA SDK. The LZMA utils -+ * format is the default format of LZMA utils 4.32.1 and later. */ -+ if (magic[0] < 0xE1 || (magic[0] == 0xFF && magic[1] == 'L' && -+ magic[2] == 'Z' && magic[3] == 'M')) { -+ if (mc_read (fd, (char *) magic + 4, 9) == 9) { -+ /* LZMA utils format */ -+ if (magic[0] == 0xFF && magic[4] == 'A' && magic[5] == 0x00) -+ return COMPRESSION_LZMA; -+ /* The LZMA_Alone format has no magic bytes, thus we -+ * need to play a wizard. This can give false positives, -+ * thus the detection below should be removed when -+ * the newer LZMA utils format has got popular. */ -+ if (magic[0] < 0xE1 && magic[4] < 0x20 && -+ ((magic[10] == 0x00 && magic[11] == 0x00 && -+ magic[12] == 0x00) || -+ (magic[5] == 0xFF && magic[6] == 0xFF && -+ magic[7] == 0xFF && magic[8] == 0xFF && -+ magic[9] == 0xFF && magic[10] == 0xFF && -+ magic[11] == 0xFF && magic[12] == 0xFF))) -+ return COMPRESSION_LZMA; -+ } -+ } -+ - return 0; - } - -@@ -1293,6 +1318,7 @@ decompress_extension (int type) - case COMPRESSION_GZIP: return "#ugz"; - case COMPRESSION_BZIP: return "#ubz"; - case COMPRESSION_BZIP2: return "#ubz2"; -+ case COMPRESSION_LZMA: return "#ulzma"; - } - /* Should never reach this place */ - fprintf (stderr, "Fatal: decompress_extension called with an unknown argument\n"); -diff -up mc-4.6.2-pre1/src/util.h.lzmavfs mc-4.6.2-pre1/src/util.h ---- mc-4.6.2-pre1/src/util.h.lzmavfs 2008-08-05 15:31:29.000000000 +0200 -+++ mc-4.6.2-pre1/src/util.h 2008-08-05 15:31:29.000000000 +0200 -@@ -186,7 +186,8 @@ enum compression_type { - COMPRESSION_NONE, - COMPRESSION_GZIP, - COMPRESSION_BZIP, -- COMPRESSION_BZIP2 -+ COMPRESSION_BZIP2, -+ COMPRESSION_LZMA - }; - - /* Looks for ``magic'' bytes at the start of the VFS file to guess the -diff -up mc-4.6.2-pre1/vfs/extfs/iso9660.in.lzmavfs mc-4.6.2-pre1/vfs/extfs/iso9660.in ---- mc-4.6.2-pre1/vfs/extfs/iso9660.in.lzmavfs 2006-07-19 13:19:52.000000000 +0200 -+++ mc-4.6.2-pre1/vfs/extfs/iso9660.in 2008-08-05 15:31:29.000000000 +0200 -@@ -29,6 +29,7 @@ test_iso () { - mcisofs_list () { - # left as a reminder to implement compressed image support =) - case "$1" in -+ *.lzma) MYCAT="lzma -dc";; - *.bz2) MYCAT="bzip2 -dc";; - *.gz) MYCAT="gzip -dc";; - *.z) MYCAT="gzip -dc";; -diff -up mc-4.6.2-pre1/vfs/extfs/lslR.in.lzmavfs mc-4.6.2-pre1/vfs/extfs/lslR.in ---- mc-4.6.2-pre1/vfs/extfs/lslR.in.lzmavfs 2003-06-22 11:54:21.000000000 +0200 -+++ mc-4.6.2-pre1/vfs/extfs/lslR.in 2008-08-05 15:31:29.000000000 +0200 -@@ -12,6 +12,7 @@ AWK=@AWK@ - - mclslRfs_list () { - case "$1" in -+ *.lzma) MYCAT="lzma -dc";; - *.bz2) MYCAT="bzip2 -dc";; - *.gz) MYCAT="gzip -dc";; - *.z) MYCAT="gzip -dc";; -diff -up mc-4.6.2-pre1/vfs/extfs/mailfs.in.lzmavfs mc-4.6.2-pre1/vfs/extfs/mailfs.in ---- mc-4.6.2-pre1/vfs/extfs/mailfs.in.lzmavfs 2006-05-28 14:35:57.000000000 +0200 -+++ mc-4.6.2-pre1/vfs/extfs/mailfs.in 2008-08-05 15:31:29.000000000 +0200 -@@ -7,6 +7,7 @@ use bytes; - - $zcat="zcat"; # gunzip to stdout - $bzcat="bzip2 -dc"; # bunzip2 to stdout -+$lzcat="lzma -dc"; # unlzma to stdout - $file="file"; # "file" command - $TZ='GMT'; # default timezone (for Date module) - -@@ -182,6 +183,8 @@ if (/gzip/) { - exit 1 unless (open IN, "$zcat $mbox_qname|"); - } elsif (/bzip/) { - exit 1 unless (open IN, "$bzcat $mbox_qname|"); -+} elsif (/lzma/) { -+ exit 1 unless (open IN, "$lzcat $mbox_qname|"); - } else { - exit 1 unless (open IN, "<$mbox_name"); - } -diff -up mc-4.6.2-pre1/vfs/extfs/patchfs.in.lzmavfs mc-4.6.2-pre1/vfs/extfs/patchfs.in ---- mc-4.6.2-pre1/vfs/extfs/patchfs.in.lzmavfs 2004-11-17 00:00:40.000000000 +0100 -+++ mc-4.6.2-pre1/vfs/extfs/patchfs.in 2008-08-05 15:31:29.000000000 +0200 -@@ -12,6 +12,7 @@ use POSIX; - use File::Temp 'tempfile'; - - # standard binaries -+my $lzma = 'lzma'; - my $bzip = 'bzip2'; - my $gzip = 'gzip'; - my $fileutil = 'file'; -@@ -70,7 +71,9 @@ sub myin - my ($qfname)=(quotemeta $_[0]); - - $_=`$fileutil $qfname`; -- if (/bzip/) { -+ if (/lzma/) { -+ return "$lzma -dc $qfname"; -+ } elsif (/bzip/) { - return "$bzip -dc $qfname"; - } elsif (/gzip/) { - return "$gzip -dc $qfname"; -@@ -86,7 +89,9 @@ sub myout - my ($sep) = $append ? '>>' : '>'; - - $_=`$fileutil $qfname`; -- if (/bzip/) { -+ if (/lzma/) { -+ return "$lzma -c $sep $qfname"; -+ } elsif (/bzip/) { - return "$bzip -c $sep $qfname"; - } elsif (/gzip/) { - return "$gzip -c $sep $qfname"; -diff -up mc-4.6.2-pre1/vfs/extfs/sfs.ini.lzmavfs mc-4.6.2-pre1/vfs/extfs/sfs.ini ---- mc-4.6.2-pre1/vfs/extfs/sfs.ini.lzmavfs 1998-12-15 16:57:43.000000000 +0100 -+++ mc-4.6.2-pre1/vfs/extfs/sfs.ini 2008-08-05 15:31:29.000000000 +0200 -@@ -10,6 +10,8 @@ bz/1 bzip < %1 > %3 - ubz/1 bzip -d < %1 > %3 - bz2/1 bzip2 < %1 > %3 - ubz2/1 bzip2 -d < %1 > %3 -+lzma/1 lzma < %1 > %3 -+ulzma/1 lzma -d < %1 > %3 - tar/1 tar cf %3 %1 - tgz/1 tar czf %3 %1 - uhtml/1 lynx -force_html -dump %1 > %3 diff --git a/mc-ministatus.patch b/mc-ministatus.patch deleted file mode 100644 index c087e11..0000000 --- a/mc-ministatus.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- mc-4.6.1a/src/screen.c.ministatus 2005-11-17 22:01:32.000000000 +0100 -+++ mc-4.6.1a/src/screen.c 2005-11-17 22:02:31.000000000 +0100 -@@ -471,7 +471,7 @@ static struct { - { "mtime", 12, 0, J_RIGHT, N_("MTime"), 1, string_file_mtime, (sortfn *) sort_time }, - { "atime", 12, 0, J_RIGHT, N_("ATime"), 1, string_file_atime, (sortfn *) sort_atime }, - { "ctime", 12, 0, J_RIGHT, N_("CTime"), 1, string_file_ctime, (sortfn *) sort_ctime }, --{ "perm", 10, 0, J_LEFT, N_("Permission"),1,string_file_permission, NULL }, -+{ "perm", 12, 0, J_CENTER, N_("Permission"),1,string_file_permission, NULL }, - { "mode", 6, 0, J_RIGHT, N_("Perm"), 1, string_file_perm_octal, NULL }, - { "nlink", 2, 0, J_RIGHT, N_("Nl"), 1, string_file_nlinks, (sortfn *) sort_links }, - { "inode", 5, 0, J_RIGHT, N_("Inode"), 1, string_inode, (sortfn *) sort_inode }, diff --git a/mc-newlinedir.patch b/mc-newlinedir.patch deleted file mode 100644 index c74d9e3..0000000 --- a/mc-newlinedir.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -up mc-4.6.2/src/main.c.newlinedir mc-4.6.2/src/main.c ---- mc-4.6.2/src/main.c.newlinedir 2009-05-26 15:55:43.000000000 +0200 -+++ mc-4.6.2/src/main.c 2009-05-26 15:56:47.000000000 +0200 -@@ -640,7 +640,7 @@ _do_panel_cd (WPanel *panel, const char - directory = *new_dir ? new_dir : home_dir; - - ret_panel=panel; -- if (mc_chdir (directory) == -1) { -+ if (strchr(directory,'\n') || mc_chdir (directory) == -1) { - strcpy (panel->cwd, olddir); - g_free (olddir); - g_free (translated_url); diff --git a/mc-oldrpmtags.patch b/mc-oldrpmtags.patch deleted file mode 100644 index 6c8c686..0000000 --- a/mc-oldrpmtags.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff -up mc-4.6.2-pre1/vfs/extfs/rpm.oldrpmtags mc-4.6.2-pre1/vfs/extfs/rpm ---- mc-4.6.2-pre1/vfs/extfs/rpm.oldrpmtags 2006-11-01 11:30:26.000000000 +0100 -+++ mc-4.6.2-pre1/vfs/extfs/rpm 2008-08-05 15:26:47.000000000 +0200 -@@ -95,10 +95,6 @@ mcrpmfs_list () - echo "$FILEPREF 0 $DATE INFO/PACKAGER" - test "`$RPM -qp --qf \"%{URL}\" \"$f\"`" = "(none)" || - echo "$FILEPREF 0 $DATE INFO/URL" -- test "`$RPM -qp --qf \"%{SERIAL}\" \"$f\"`" = "(none)" || -- echo "$FILEPREF 0 $DATE INFO/SERIAL" -- test "`$RPM -qp --qf \"%{COPYRIGHT}\" \"$f\"`" = "(none)" || -- echo "$FILEPREF 0 $DATE INFO/COPYRIGHT" - test "`$RPM -qp --qf \"%{EPOCH}\" \"$f\"`" = "(none)" || - echo "$FILEPREF 0 $DATE INFO/EPOCH" - test "`$RPM -qp --qf \"%{LICENSE}\" \"$f\"`" = "(none)" || diff --git a/mc-prompt.patch b/mc-prompt.patch index f4813ac..2e7dea9 100644 --- a/mc-prompt.patch +++ b/mc-prompt.patch @@ -1,6 +1,7 @@ ---- mc-2007-06-04-22/src/execute.c.prompt 2005-09-28 23:28:06.000000000 +0200 -+++ mc-2007-06-04-22/src/execute.c 2007-06-20 14:07:17.000000000 +0200 -@@ -140,6 +140,8 @@ do_execute (const char *shell, const cha +diff -up mc-4.6.99/src/execute.c.prompt mc-4.6.99/src/execute.c +--- mc-4.6.99/src/execute.c.prompt 2009-07-31 14:57:10.000000000 +0200 ++++ mc-4.6.99/src/execute.c 2009-07-31 14:58:21.000000000 +0200 +@@ -146,6 +146,8 @@ do_execute (const char *shell, const cha printf ("\r\n"); fflush (stdout); } @@ -9,9 +10,10 @@ if (console_flag) { if (output_lines && keybar_visible) { putchar ('\n'); ---- mc-2007-06-04-22/src/main.c.prompt 2007-06-20 14:07:17.000000000 +0200 -+++ mc-2007-06-04-22/src/main.c 2007-06-20 14:07:17.000000000 +0200 -@@ -454,7 +454,7 @@ void +diff -up mc-4.6.99/src/main.c.prompt mc-4.6.99/src/main.c +--- mc-4.6.99/src/main.c.prompt 2009-07-31 14:57:10.000000000 +0200 ++++ mc-4.6.99/src/main.c 2009-07-31 14:58:21.000000000 +0200 +@@ -459,7 +459,7 @@ void do_update_prompt (void) { if (update_prompt) { @@ -20,21 +22,10 @@ fflush (stdout); update_prompt = 0; } ---- mc-2007-06-04-22/src/subshell.h.prompt 2004-12-03 20:17:47.000000000 +0100 -+++ mc-2007-06-04-22/src/subshell.h 2007-06-20 14:07:17.000000000 +0200 -@@ -20,6 +20,9 @@ extern enum subshell_state_enum subshell - /* Holds the latest prompt captured from the subshell */ - extern char *subshell_prompt; - -+/* Holds the latest prompt captured from the subshell with terminal codes */ -+extern char *original_subshell_prompt; -+ - /* For the `how' argument to various functions */ - enum {QUIETLY, VISIBLY}; - ---- mc-2007-06-04-22/src/subshell.c.prompt 2007-06-20 14:07:17.000000000 +0200 -+++ mc-2007-06-04-22/src/subshell.c 2007-06-20 14:24:14.000000000 +0200 -@@ -107,6 +107,9 @@ enum subshell_state_enum subshell_state; +diff -up mc-4.6.99/src/subshell.c.prompt mc-4.6.99/src/subshell.c +--- mc-4.6.99/src/subshell.c.prompt 2009-07-31 14:57:11.000000000 +0200 ++++ mc-4.6.99/src/subshell.c 2009-07-31 15:02:35.000000000 +0200 +@@ -114,6 +114,9 @@ enum subshell_state_enum subshell_state; /* Holds the latest prompt captured from the subshell */ char *subshell_prompt = NULL; @@ -44,7 +35,7 @@ /* Initial length of the buffer for the subshell's prompt */ #define INITIAL_PROMPT_SIZE 10 -@@ -148,6 +151,7 @@ static struct termios raw_mode; +@@ -160,6 +163,7 @@ static struct termios raw_mode; /* This counter indicates how many characters of prompt we have read */ /* FIXME: try to figure out why this had to become global */ static int prompt_pos; @@ -52,7 +43,7 @@ /* -@@ -567,6 +571,7 @@ int invoke_subshell (const char *command +@@ -598,6 +602,7 @@ int invoke_subshell (const char *command init_subshell (); prompt_pos = 0; @@ -60,7 +51,7 @@ return quit; } -@@ -576,6 +581,7 @@ int +@@ -607,6 +612,7 @@ int read_subshell_prompt (void) { static int prompt_size = INITIAL_PROMPT_SIZE; @@ -68,7 +59,7 @@ int bytes = 0, i, rc = 0; struct timeval timeleft = { 0, 0 }; -@@ -586,7 +592,10 @@ read_subshell_prompt (void) +@@ -617,7 +623,10 @@ read_subshell_prompt (void) if (subshell_prompt == NULL) { /* First time through */ subshell_prompt = g_malloc (prompt_size); *subshell_prompt = '\0'; @@ -79,7 +70,7 @@ } while (subshell_alive -@@ -607,20 +616,27 @@ read_subshell_prompt (void) +@@ -638,20 +647,27 @@ read_subshell_prompt (void) /* Extract the prompt from the shell output */ @@ -111,16 +102,15 @@ } if (rc == 0 && bytes == 0) return FALSE; -@@ -743,6 +759,8 @@ subshell_name_quote (const char *s) - void - do_subshell_chdir (const char *directory, int do_update, int reset_prompt) - { +@@ -792,6 +808,7 @@ do_subshell_chdir (const char *directory + char *pcwd; + char *temp; + char *translate; + static char *old_subshell_prompt = NULL; -+ - if (! - (subshell_state == INACTIVE - && strcmp (subshell_cwd, current_panel->cwd))) { -@@ -750,8 +768,14 @@ do_subshell_chdir (const char *directory + + pcwd = vfs_translate_path_n (current_panel->cwd); + +@@ -802,8 +819,14 @@ do_subshell_chdir (const char *directory * the main program. Please note that in the code after this * if, the cd command that is sent will make the subshell * repaint the prompt, so we don't have to paint it. */ @@ -129,15 +119,15 @@ + if (do_update) { + if (old_subshell_prompt == NULL + || strcmp (old_subshell_prompt, original_subshell_prompt)) { -+ g_free (old_subshell_prompt); -+ old_subshell_prompt = g_strdup (original_subshell_prompt); -+ do_update_prompt (); ++ g_free (old_subshell_prompt); ++ old_subshell_prompt = g_strdup (original_subshell_prompt); ++ do_update_prompt (); + } + } + g_free (pcwd); return; } - -@@ -802,8 +826,10 @@ do_subshell_chdir (const char *directory +@@ -861,8 +884,10 @@ do_subshell_chdir (const char *directory } } @@ -147,5 +137,18 @@ + original_prompt_pos = 0; + } update_prompt = FALSE; - /* Make sure that MC never stores the CWD in a silly format */ - /* like /usr////lib/../bin, or the strcmp() above will fail */ + + g_free (pcwd); +diff -up mc-4.6.99/src/subshell.h.prompt mc-4.6.99/src/subshell.h +--- mc-4.6.99/src/subshell.h.prompt 2009-07-31 14:57:10.000000000 +0200 ++++ mc-4.6.99/src/subshell.h 2009-07-31 14:58:21.000000000 +0200 +@@ -25,6 +25,9 @@ extern enum subshell_state_enum subshell + /* Holds the latest prompt captured from the subshell */ + extern char *subshell_prompt; + ++/* Holds the latest prompt captured from the subshell with terminal codes */ ++extern char *original_subshell_prompt; ++ + /* For the `how' argument to various functions */ + enum {QUIETLY, VISIBLY}; + diff --git a/mc-refresh.patch b/mc-refresh.patch deleted file mode 100644 index 2c71750..0000000 --- a/mc-refresh.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- mc-2007-06-04-22/src/file.c.refresh 2007-06-19 10:23:47.000000000 +0200 -+++ mc-2007-06-04-22/src/file.c 2007-06-19 10:33:02.000000000 +0200 -@@ -746,7 +746,10 @@ copy_file_file (FileOpContext *ctx, cons - return_status = - file_progress_show (ctx, n_read_total + ctx->do_reget, file_size); - } -- mc_refresh (); -+ if (winch_flag) -+ change_screen_size (); -+ else -+ mc_refresh(); - if (return_status != FILE_CONT) - goto ret; - } diff --git a/mc-shellcwd.patch b/mc-shellcwd.patch deleted file mode 100644 index 7843314..0000000 --- a/mc-shellcwd.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff -up mc-4.6.2-pre1/src/subshell.c.shellcwd mc-4.6.2-pre1/src/subshell.c ---- mc-4.6.2-pre1/src/subshell.c.shellcwd 2008-09-02 11:28:31.000000000 +0200 -+++ mc-4.6.2-pre1/src/subshell.c 2008-09-02 11:41:39.000000000 +0200 -@@ -562,9 +562,6 @@ int invoke_subshell (const char *command - - feed_subshell (how, FALSE); - -- if (new_dir && subshell_alive && strcmp (subshell_cwd, current_panel->cwd)) -- *new_dir = subshell_cwd; /* Make MC change to the subshell's CWD */ -- - /* Restart the subshell if it has died by SIGHUP, SIGQUIT, etc. */ - while (!subshell_alive && !quit && use_subshell) - init_subshell (); diff --git a/mc-showfree.patch b/mc-showfree.patch deleted file mode 100644 index 52b6e2f..0000000 --- a/mc-showfree.patch +++ /dev/null @@ -1,310 +0,0 @@ -diff -up mc-4.6.2/src/layout.c.showfree mc-4.6.2/src/layout.c ---- mc-4.6.2/src/layout.c.showfree 2009-05-26 14:57:36.000000000 +0200 -+++ mc-4.6.2/src/layout.c 2009-05-26 14:57:36.000000000 +0200 -@@ -97,6 +97,9 @@ int message_visible = 1; - /* Set to show current working dir in xterm window title */ - int xterm_title = 1; - -+/* Set to show free space on device assigned to current directory */ -+int free_space = 1; -+ - /* The starting line for the output of the subprogram */ - int output_start_y = 0; - -@@ -126,6 +129,7 @@ static int _command_prompt; - static int _keybar_visible; - static int _message_visible; - static int _xterm_title; -+static int _free_space; - static int _permission_mode; - static int _filetype_mode; - -@@ -156,6 +160,7 @@ static struct { - int *variable; - WCheck *widget; - } check_options [] = { -+ { N_("show free sp&Ace"), &free_space, 0 }, - { N_("&Xterm window title"), &xterm_title, 0 }, - { N_("h&Intbar visible"), &message_visible, 0 }, - { N_("&Keybar visible"), &keybar_visible, 0 }, -@@ -227,8 +232,8 @@ static int b2left_cback (int action) - if (_equal_split){ - /* Turn equal split off */ - _equal_split = 0; -- check_options [6].widget->state = check_options [6].widget->state & ~C_BOOL; -- dlg_select_widget (check_options [6].widget); -+ check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL; -+ dlg_select_widget (check_options [7].widget); - dlg_select_widget (bleft_widget); - } - _first_panel_size++; -@@ -242,8 +247,8 @@ static int b2right_cback (int action) - if (_equal_split){ - /* Turn equal split off */ - _equal_split = 0; -- check_options [6].widget->state = check_options [6].widget->state & ~C_BOOL; -- dlg_select_widget (check_options [6].widget); -+ check_options [7].widget->state = check_options [7].widget->state & ~C_BOOL; -+ dlg_select_widget (check_options [7].widget); - dlg_select_widget (bright_widget); - } - _first_panel_size--; -@@ -289,23 +294,24 @@ layout_callback (struct Dlg_head *h, dlg - if (old_output_lines != _output_lines){ - old_output_lines = _output_lines; - attrset (COLOR_NORMAL); -- dlg_move (h, 9, 16 + first_width); -+ dlg_move (h, 10, 16 + first_width); - addstr (output_lines_label); -- dlg_move (h, 9, 10 + first_width); -+ dlg_move (h, 10, 10 + first_width); - tty_printf ("%02d", _output_lines); - } - } - return MSG_HANDLED; - - case DLG_POST_KEY: -- _filetype_mode = check_options [8].widget->state & C_BOOL; -- _permission_mode = check_options [7].widget->state & C_BOOL; -- _equal_split = check_options [6].widget->state & C_BOOL; -- _menubar_visible = check_options [5].widget->state & C_BOOL; -- _command_prompt = check_options [4].widget->state & C_BOOL; -- _keybar_visible = check_options [2].widget->state & C_BOOL; -- _message_visible = check_options [1].widget->state & C_BOOL; -- _xterm_title = check_options [0].widget->state & C_BOOL; -+ _filetype_mode = check_options [9].widget->state & C_BOOL; -+ _permission_mode = check_options [8].widget->state & C_BOOL; -+ _equal_split = check_options [7].widget->state & C_BOOL; -+ _menubar_visible = check_options [6].widget->state & C_BOOL; -+ _command_prompt = check_options [5].widget->state & C_BOOL; -+ _keybar_visible = check_options [3].widget->state & C_BOOL; -+ _message_visible = check_options [2].widget->state & C_BOOL; -+ _xterm_title = check_options [1].widget->state & C_BOOL; -+ _free_space = check_options [0].widget->state & C_BOOL; - if (console_flag){ - int minimum; - if (_output_lines < 0) -@@ -333,7 +339,7 @@ layout_callback (struct Dlg_head *h, dlg - if (old_output_lines != _output_lines){ - old_output_lines = _output_lines; - attrset (COLOR_NORMAL); -- dlg_move (h, 9, 10 + first_width); -+ dlg_move (h, 10, 10 + first_width); - tty_printf ("%02d", _output_lines); - } - } -@@ -372,7 +378,7 @@ init_layout (void) - first_width = l1; - } - -- for (i = 0; i <= 8; i++) { -+ for (i = 0; i <= 9; i++) { - check_options[i].text = _(check_options[i].text); - l1 = mbstrlen (check_options[i].text) + 7; - if (l1 > first_width) -@@ -389,7 +395,7 @@ init_layout (void) - - - second_width = mbstrlen (title3) + 1; -- for (i = 0; i < 6; i++) { -+ for (i = 0; i < 7; i++) { - check_options[i].text = _(check_options[i].text); - l1 = mbstrlen (check_options[i].text) + 7; - if (l1 > second_width) -@@ -444,23 +450,23 @@ init_layout (void) - 0)); - if (console_flag) { - add_widget (layout_dlg, -- button_new (9, 12 + first_width, B_MINUS, -+ button_new (10, 12 + first_width, B_MINUS, - NARROW_BUTTON, "&-", bminus_cback)); - add_widget (layout_dlg, -- button_new (9, 7 + first_width, B_PLUS, NARROW_BUTTON, -+ button_new (10, 7 + first_width, B_PLUS, NARROW_BUTTON, - "&+", bplus_cback)); - } - #define XTRACT(i) *check_options[i].variable, check_options[i].text - -- for (i = 0; i < 6; i++) { -+ for (i = 0; i < 7; i++) { - check_options[i].widget = -- check_new (8 - i, 7 + first_width, XTRACT (i)); -+ check_new (9 - i, 7 + first_width, XTRACT (i)); - add_widget (layout_dlg, check_options[i].widget); - } -- check_options[8].widget = check_new (10, 6, XTRACT (8)); -+ check_options[9].widget = check_new (10, 6, XTRACT (9)); -+ add_widget (layout_dlg, check_options[9].widget); -+ check_options[8].widget = check_new (9, 6, XTRACT (8)); - add_widget (layout_dlg, check_options[8].widget); -- check_options[7].widget = check_new (9, 6, XTRACT (7)); -- add_widget (layout_dlg, check_options[7].widget); - - _filetype_mode = filetype_mode; - _permission_mode = permission_mode; -@@ -470,20 +476,21 @@ init_layout (void) - _keybar_visible = keybar_visible; - _message_visible = message_visible; - _xterm_title = xterm_title; -+ _free_space = free_space; - bright_widget = - button_new (6, 15, B_2RIGHT, NARROW_BUTTON, "&>", b2right_cback); - add_widget (layout_dlg, bright_widget); - bleft_widget = - button_new (6, 9, B_2LEFT, NARROW_BUTTON, "&<", b2left_cback); - add_widget (layout_dlg, bleft_widget); -- check_options[6].widget = check_new (5, 6, XTRACT (6)); -+ check_options[7].widget = check_new (5, 6, XTRACT (7)); - old_first_panel_size = -1; - old_horizontal_split = -1; - old_output_lines = -1; - - _first_panel_size = first_panel_size; - _output_lines = output_lines; -- add_widget (layout_dlg, check_options[6].widget); -+ add_widget (layout_dlg, check_options[7].widget); - radio_widget = radio_new (3, 6, 2, s_split_direction); - add_widget (layout_dlg, radio_widget); - radio_widget->sel = horizontal_split; -diff -up mc-4.6.2/src/layout.h.showfree mc-4.6.2/src/layout.h ---- mc-4.6.2/src/layout.h.showfree 2009-02-01 20:30:21.000000000 +0100 -+++ mc-4.6.2/src/layout.h 2009-05-26 14:57:36.000000000 +0200 -@@ -39,6 +39,7 @@ extern int keybar_visible; - extern int output_start_y; - extern int message_visible; - extern int xterm_title; -+extern int free_space; - - extern int horizontal_split; - extern int nice_rotating_dash; -diff -up mc-4.6.2/src/main.c.showfree mc-4.6.2/src/main.c ---- mc-4.6.2/src/main.c.showfree 2009-05-26 14:57:36.000000000 +0200 -+++ mc-4.6.2/src/main.c 2009-05-26 14:57:36.000000000 +0200 -@@ -62,6 +62,7 @@ - #include "listmode.h" - #include "execute.h" - #include "ext.h" /* For flush_extension_file() */ -+#include "mountlist.h" /* my_statfs */ - - /* Listbox for the command history feature */ - #include "widget.h" -@@ -233,6 +234,12 @@ Dlg_head *midnight_dlg; - /* We need to paint it after CONSOLE_RESTORE, see: load_prompt */ - int update_prompt = 0; - -+/* Old current working directory for displaying free space */ -+char *old_cwd = NULL; -+ -+/* Used to figure out how many free space we have */ -+struct my_statfs myfs_stats; -+ - /* The home directory */ - const char *home_dir = NULL; - -@@ -404,6 +411,8 @@ update_panels (int force_update, const c - int reload_other = !(force_update & UP_ONLY_CURRENT); - WPanel *panel; - -+ show_free_space(current_panel); -+ - update_one_panel (get_current_index (), force_update, current_file); - if (reload_other) - update_one_panel (get_other_index (), force_update, UP_KEEPSEL); -@@ -469,6 +478,38 @@ stop_dialogs (void) - } - } - -+void -+show_free_space(WPanel *panel) -+{ -+ /* Don't try to stat non-local fs */ -+ if (!vfs_file_is_local(panel->cwd) || !free_space) -+ return; -+ -+ if (old_cwd == NULL || strcmp(old_cwd, panel->cwd) != 0) { -+ char rpath[PATH_MAX]; -+ -+ init_my_statfs(); -+ g_free(old_cwd); -+ old_cwd = g_strdup(panel->cwd); -+ -+ if (mc_realpath (panel->cwd, rpath) == NULL) -+ return; -+ my_statfs (&myfs_stats, rpath); -+ } -+ -+ if (myfs_stats.avail > 0 || myfs_stats.total > 0) { -+ char buffer1 [6], buffer2[6], *tmp; -+ size_trunc_len (buffer1, 5, myfs_stats.avail, 1); -+ size_trunc_len (buffer2, 5, myfs_stats.total, 1); -+ tmp = g_strdup_printf (_("%s (%d%%) of %s"), buffer1, myfs_stats.total > 0 ? -+ (int)(100 * (double)myfs_stats.avail / myfs_stats.total) : 0, -+ buffer2); -+ widget_move (&panel->widget, panel->widget.lines-1, panel->widget.cols-2-strlen(tmp)); -+ addstr (tmp); -+ g_free (tmp); -+ } -+} -+ - static int - quit_cmd_internal (int quiet) - { -diff -up mc-4.6.2/src/main.h.showfree mc-4.6.2/src/main.h ---- mc-4.6.2/src/main.h.showfree 2009-05-26 14:57:36.000000000 +0200 -+++ mc-4.6.2/src/main.h 2009-05-26 14:57:36.000000000 +0200 -@@ -55,6 +55,7 @@ extern int cd_symlinks; - extern int show_all_if_ambiguous; - extern int slow_terminal; - extern int update_prompt; /* To comunicate with subshell */ -+extern char *old_cwd; - extern int safe_delete; - extern int confirm_delete; - extern int confirm_directory_hotlist_delete; -@@ -102,6 +103,7 @@ void change_panel (void); - int load_prompt (int, void *); - void save_cwds_stat (void); - void quiet_quit_cmd (void); /* For cmd.c and command.c */ -+void show_free_space(WPanel *panel); - - void touch_bar (void); - void update_xterm_title_path (void); -diff -up mc-4.6.2/src/screen.c.showfree mc-4.6.2/src/screen.c ---- mc-4.6.2/src/screen.c.showfree 2009-05-26 14:57:36.000000000 +0200 -+++ mc-4.6.2/src/screen.c 2009-05-26 14:59:37.000000000 +0200 -@@ -49,7 +49,7 @@ - #include "widget.h" - #include "menu.h" /* menubar_visible */ - #define WANT_WIDGETS --#include "main.h" /* the_menubar */ -+#include "main.h" /* the_menubar, show_free_space() */ - #include "unixcompat.h" - - #ifdef HAVE_CHARSET -@@ -884,6 +884,7 @@ mini_info_separator (WPanel *panel) - hline ((slow_terminal ? '-' : ACS_HLINE) | NORMAL_COLOR, - panel->widget.cols - 2); - #endif /* !HAVE_SLANG */ -+ show_free_space (panel); - } - - void -@@ -938,6 +939,8 @@ show_dir (WPanel *panel) - widget_move (&panel->widget, 0, panel->widget.cols - 3); - addstr ("v"); - -+ mini_info_separator (panel); -+ - if (panel->active) - standend (); - } -diff -up mc-4.6.2/src/setup.c.showfree mc-4.6.2/src/setup.c ---- mc-4.6.2/src/setup.c.showfree 2009-05-26 14:57:36.000000000 +0200 -+++ mc-4.6.2/src/setup.c 2009-05-26 14:57:36.000000000 +0200 -@@ -138,6 +138,7 @@ static const struct { - { "show_mini_info", &show_mini_info }, - { "permission_mode", &permission_mode }, - { "filetype_mode", &filetype_mode }, -+ { "free_space", &free_space }, - { 0, 0 } - }; - diff --git a/mc-spaceprompt.patch b/mc-spaceprompt.patch deleted file mode 100644 index 9a24953..0000000 --- a/mc-spaceprompt.patch +++ /dev/null @@ -1,30 +0,0 @@ ---- mc-4.6.1a/src/main.c.spaceprompt 2005-05-26 15:06:42.285109424 +0200 -+++ mc-4.6.1a/src/main.c 2005-05-26 15:15:15.964018360 +0200 -@@ -1490,9 +1491,15 @@ midnight_callback (struct Dlg_head *h, d - if (parm == '\t') - free_completions (cmdline); - -- if (parm == '\n' && cmdline->buffer[0]) { -- send_message ((Widget *) cmdline, WIDGET_KEY, parm); -- return MSG_HANDLED; -+ if (parm == '\n') { -+ for (i = 0; cmdline->buffer[i] && -+ (cmdline->buffer[i] == ' ' || cmdline->buffer[i] == '\t'); i++); -+ if (cmdline->buffer[i]) { -+ send_message ((Widget *) cmdline, WIDGET_KEY, parm); -+ return MSG_HANDLED; -+ } -+ stuff (cmdline, "", 0); -+ cmdline->point = 0; - } - - /* Ctrl-Enter and Alt-Enter */ -@@ -1527,7 +1534,7 @@ midnight_callback (struct Dlg_head *h, d - reverse_selection_cmd (); - return MSG_HANDLED; - } -- } else if (!command_prompt || !strlen (cmdline->buffer)) { -+ } else if (!command_prompt || !cmdline->buffer[0]) { - /* Special treatement '+', '-', '\', '*' only when this is - * first char on input line - */ diff --git a/mc-userhost.patch b/mc-userhost.patch deleted file mode 100644 index 59a6a04..0000000 --- a/mc-userhost.patch +++ /dev/null @@ -1,115 +0,0 @@ -diff -up mc-4.6.2/edit/editwidget.c.userhost mc-4.6.2/edit/editwidget.c ---- mc-4.6.2/edit/editwidget.c.userhost 2009-05-26 14:45:19.000000000 +0200 -+++ mc-4.6.2/edit/editwidget.c 2009-05-26 14:49:35.000000000 +0200 -@@ -46,6 +46,9 @@ - #include "../src/widget.h" /* buttonbar_redraw() */ - #include "../src/menu.h" /* menubar_new() */ - #include "../src/key.h" /* is_idle() */ -+#include "../src/main.h" /* xterm_title_str */ -+#include "../src/win.h" /* xterm_flag */ -+#include "../src/layout.h" /* xterm_title */ - - WEdit *wedit; - struct WMenu *edit_menubar; -@@ -174,6 +177,11 @@ edit_file (const char *_file, int line) - Dlg_head *edit_dlg; - WButtonBar *edit_bar; - -+ if (xterm_flag && xterm_title && xterm_title_str) { -+ fprintf (stdout, "\33]0;mc - %s/%s\7", xterm_title_str, _file); -+ fflush(stdout); -+ } -+ - if (!made_directory) { - char *dir = mhl_str_dir_plus_file (home_dir, EDIT_DIR); - made_directory = (mkdir (dir, 0700) != -1 || errno == EEXIST); -@@ -208,6 +216,8 @@ edit_file (const char *_file, int line) - edit_done_menu (edit_menubar); /* editmenu.c */ - - destroy_dlg (edit_dlg); -+ -+ update_xterm_title_path(); - - return 1; - } -diff -up mc-4.6.2/src/main.c.userhost mc-4.6.2/src/main.c ---- mc-4.6.2/src/main.c.userhost 2009-05-26 14:45:19.000000000 +0200 -+++ mc-4.6.2/src/main.c 2009-05-26 14:48:06.000000000 +0200 -@@ -278,6 +278,9 @@ int midnight_shutdown = 0; - /* The user's shell */ - const char *shell = NULL; - -+/* The xterm title */ -+char *xterm_title_str = NULL; -+ - /* Is the LANG UTF-8 ? */ - gboolean is_utf8 = FALSE; - -@@ -1624,9 +1627,23 @@ void - update_xterm_title_path (void) - { - char *p, *s; -+ char h[64]; -+ struct passwd *pw; - - if (xterm_flag && xterm_title) { -+ if ( xterm_title_str ) g_free (xterm_title_str); - p = s = g_strdup (strip_home_and_password (current_panel->cwd)); -+ if ( !gethostname (h, 64) ) { -+ h[63] = '\0'; /* Be sure the hostname is NUL terminated */ -+ s = g_strdup_printf ("%s:%s", h, s); -+ g_free (p); -+ p = s; -+ } -+ if ( (pw = getpwuid(getuid())) ) { -+ s = g_strdup_printf ("%s@%s", pw->pw_name, s); -+ g_free (p); -+ p = s; -+ } - do { - #ifndef UTF8 - if (!is_printable ((unsigned char) *s)) -@@ -1639,7 +1656,7 @@ update_xterm_title_path (void) - numeric_keypad_mode (); - fprintf (stdout, "\33]0;mc - %s\7", p); - fflush (stdout); -- g_free (p); -+ xterm_title_str = p; - } - } - -diff -up mc-4.6.2/src/main.h.userhost mc-4.6.2/src/main.h ---- mc-4.6.2/src/main.h.userhost 2009-05-26 14:45:19.000000000 +0200 -+++ mc-4.6.2/src/main.h 2009-05-26 14:46:33.000000000 +0200 -@@ -69,6 +69,7 @@ extern int alternate_plus_minus; - extern int only_leading_plus_minus; - extern int output_starts_shell; - extern int midnight_shutdown; -+extern char *xterm_title_str; - extern gboolean is_utf8; - extern char cmd_buf [512]; - extern const char *shell; -diff -up mc-4.6.2/src/view.c.userhost mc-4.6.2/src/view.c ---- mc-4.6.2/src/view.c.userhost 2009-05-26 14:45:19.000000000 +0200 -+++ mc-4.6.2/src/view.c 2009-05-26 14:45:19.000000000 +0200 -@@ -3368,6 +3368,11 @@ mc_internal_viewer (const char *command, - WButtonBar *bar; - Dlg_head *view_dlg; - -+ if (xterm_flag && xterm_title && xterm_title_str) { -+ fprintf (stdout, "\33]0;mc - %s/%s\7", xterm_title_str, file); -+ fflush(stdout); -+ } -+ - /* Create dialog and widgets, put them on the dialog */ - view_dlg = - create_dlg (0, 0, LINES, COLS, NULL, view_dialog_callback, -@@ -3391,6 +3396,8 @@ mc_internal_viewer (const char *command, - } - destroy_dlg (view_dlg); - -+ update_xterm_title_path(); -+ - return succeeded; - } - diff --git a/mc.spec b/mc.spec index b4f911e..d72f564 100644 --- a/mc.spec +++ b/mc.spec @@ -1,38 +1,23 @@ +%define alphatag 20090731git + Summary: User-friendly text console file manager and visual shell Name: mc -Version: 4.6.2 -Release: 12%{?dist} +Version: 4.6.99 +Release: 0.%{alphatag}%{?dist} Epoch: 1 License: GPLv2 Group: System Environment/Shells -# tarball from http://www.midnight-commander.org/downloads/3 -Source0: mc-%{version}.tar.gz +# tarball created from git clone git://midnight-commander.org/git/mc.git +Source0: mc-%{version}-%{alphatag}.tar.bz2 URL: http://www.midnight-commander.org/ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: glib2-devel e2fsprogs-devel slang-devel -BuildRequires: gettext cvs automake autoconf -Requires: dev >= 0:3.3-3 +BuildRequires: gettext cvs automake autoconf libtool +Requires: dev >= 3.3-3 -# UTF-8 patch from http://www.midnight-commander.org/downloads/4 -Patch0: mc-4.6.2-utf8.patch -Patch1: mc-extensions.patch -Patch2: mc-userhost.patch -Patch3: mc-64bit.patch -Patch6: mc-showfree.patch -Patch7: mc-cedit.patch -Patch8: mc-delcheck.patch -Patch9: mc-etcmc.patch -Patch10: mc-exit.patch -Patch12: mc-ipv6.patch -Patch13: mc-newlinedir.patch -Patch15: mc-prompt.patch -Patch16: mc-refresh.patch -Patch18: mc-lzma.patch -Patch19: mc-hintchk.patch -Patch21: mc-oldrpmtags.patch -Patch22: mc-shellcwd.patch -Patch23: mc-cedit-configurable-highlight.patch -Patch24: mc-edit-segv.patch +Patch1: mc-ipv6.patch +Patch2: mc-prompt.patch +Patch3: mc-exit.patch %description Midnight Commander is a visual shell much like a file manager, only @@ -43,88 +28,13 @@ specific files. %prep %setup -q -%patch0 -p1 -b .utf8 -%patch1 -p1 -b .extensions -%patch2 -p1 -b .userhost -%patch3 -p1 -b .64bit -%patch6 -p1 -b .showfree -%patch7 -p1 -b .cedit -%patch8 -p1 -b .delcheck -%patch9 -p1 -b .etcmc -%patch10 -p1 -b .exit -%patch12 -p1 -b .ipv6 -%patch13 -p1 -b .newlinedir -%patch15 -p1 -b .prompt -%patch16 -p1 -b .refresh -%patch18 -p1 -b .lzmavfs -%patch19 -p1 -b .hintchk -%patch21 -p1 -b .oldrpmtags -%patch22 -p1 -b .shellcwd -%patch23 -p1 -b .cedit-configurable-highlight -%patch24 -p1 -b .edit-segv - -# convert files in /lib to UTF-8 -pushd lib -for i in mc.hint mc.hint.es mc.hint.it mc.hint.nl; do - iconv -f iso-8859-1 -t utf-8 < ${i} > ${i}.tmp - mv -f ${i}.tmp ${i} -done - -for i in mc.hint.cs mc.hint.hu mc.hint.pl; do - iconv -f iso-8859-2 -t utf-8 < ${i} > ${i}.tmp - mv -f ${i}.tmp ${i} -done - -for i in mc.hint.sr mc.menu.sr; do - iconv -f iso-8859-5 -t utf-8 < ${i} > ${i}.tmp - mv -f ${i}.tmp ${i} -done - -iconv -f koi8-r -t utf8 < mc.hint.ru > mc.hint.ru.tmp -mv -f mc.hint.ru.tmp mc.hint.ru -iconv -f koi8-u -t utf8 < mc.hint.uk > mc.hint.uk.tmp -mv -f mc.hint.uk.tmp mc.hint.uk -iconv -f big5 -t utf8 < mc.hint.zh > mc.hint.zh.tmp -mv -f mc.hint.zh.tmp mc.hint.zh -popd - - -# convert man pages in /doc to UTF-8 -pushd doc - -pushd ru -for i in mc.1.in xnc.hlp; do - iconv -f koi8-r -t utf-8 < ${i} > ${i}.tmp - mv -f ${i}.tmp ${i} -done -popd - -pushd sr -for i in mc.1.in mcserv.8.in xnc.hlp; do - iconv -f iso-8859-5 -t utf-8 < ${i} > ${i}.tmp - mv -f ${i}.tmp ${i} -done -popd - -for d in es it; do - for i in mc.1.in xnc.hlp; do - iconv -f iso-8859-3 -t utf-8 < ${d}/${i} > ${d}/${i}.tmp - mv -f ${d}/${i}.tmp ${d}/${i} - done -done - -for d in hu pl; do - for i in mc.1.in xnc.hlp; do - iconv -f iso-8859-2 -t utf-8 < ${d}/${i} > ${d}/${i}.tmp - mv -f ${d}/${i}.tmp ${d}/${i} - done -done - -popd +%patch1 -p1 -b .ipv6 +%patch2 -p1 -b .prompt +%patch3 -p1 -b .exit %build ./autogen.sh -export CFLAGS="-DUTF8=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $RPM_OPT_FLAGS -fgnu89-inline" +export CFLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $RPM_OPT_FLAGS" %configure --with-screen=slang \ --enable-charset \ --with-samba \ @@ -134,33 +44,13 @@ make %{?_smp_mflags} %install rm -rf $RPM_BUILD_ROOT -install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/profile.d -install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/mc -install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/mc/extfs -install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/mc/syntax make install DESTDIR="$RPM_BUILD_ROOT" -install lib/{mc.sh,mc.csh} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d - -# move configuration files to /etc/mc to make it FHS compliant (#2188) -mv -f $RPM_BUILD_ROOT%{_datadir}/mc/{cedit.menu,edit.indent.rc,edit.spell.rc,\ -mc.ext,mc.lib,mc.menu,mc.charsets} $RPM_BUILD_ROOT%{_sysconfdir}/mc -mv -f $RPM_BUILD_ROOT%{_datadir}/mc/extfs/*.ini $RPM_BUILD_ROOT%{_sysconfdir}/mc/extfs -mv -f $RPM_BUILD_ROOT%{_datadir}/mc/syntax/Syntax $RPM_BUILD_ROOT%{_sysconfdir}/mc/syntax - -# install man pages in various languages -for l in es hu it pl ru sr; do -mkdir -p $RPM_BUILD_ROOT%{_mandir}/${l} -mkdir -p $RPM_BUILD_ROOT%{_mandir}/${l}/man1 -install -m 644 doc/${l}/mc.1 $RPM_BUILD_ROOT%{_mandir}/${l}/man1 -done - -for I in /etc/pam.d/mcserv \ - /etc/rc.d/init.d/mcserv \ - /etc/mc.global; do - rm -rf ${RPM_BUILD_ROOT}${I} -done +install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/profile.d +install contrib/{mc.sh,mc.csh} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d +#mkdir -p $RPM_BUILD_ROOT%{_datadir}/mc/bin +#mv $RPM_BUILD_ROOT%{_libexecdir}/mc/{mc.sh,mc.csh,mc-wrapper.sh,mc-wrapper.csh} $RPM_BUILD_ROOT%{_datadir}/mc/bin %find_lang %{name} @@ -169,14 +59,14 @@ rm -rf $RPM_BUILD_ROOT %files -f %{name}.lang %defattr(-, root, root) - -%doc FAQ COPYING NEWS README +%doc doc/FAQ doc/COPYING doc/NEWS doc/README %{_bindir}/mc %{_bindir}/mcedit %{_bindir}/mcmfmt %{_bindir}/mcview %{_datadir}/mc/* %attr(4711, vcsa, root) %{_libexecdir}/mc/cons.saver +%{_libexecdir}/mc/mc* %{_mandir}/man1/* %lang(es) %{_mandir}/es/man1/mc.1* %lang(hu) %{_mandir}/hu/man1/mc.1* @@ -185,7 +75,7 @@ rm -rf $RPM_BUILD_ROOT %lang(ru) %{_mandir}/ru/man1/mc.1* %lang(sr) %{_mandir}/sr/man1/mc.1* %{_sysconfdir}/profile.d/* -%config %{_sysconfdir}/mc/syntax/Syntax +%config %{_sysconfdir}/mc/Syntax %config %{_sysconfdir}/mc/mc.charsets %config %{_sysconfdir}/mc/mc.lib %config(noreplace) %{_sysconfdir}/mc/*edit* @@ -195,11 +85,14 @@ rm -rf $RPM_BUILD_ROOT %config(noreplace) %{_sysconfdir}/mc/extfs/sfs.ini %dir %{_datadir}/mc %dir %{_sysconfdir}/mc -%dir %{_sysconfdir}/mc/syntax %dir %{_sysconfdir}/mc/extfs %dir %{_libexecdir}/mc %changelog +* Fri Jul 31 2009 Jindrich Novy 4.6.99-0.20090731git +- update to latest GIT mc +- forwardport prompt fix and exit patch, keep IPv6 patch and drop the others + * Sat Jul 25 2009 Fedora Release Engineering - 1:4.6.2-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild diff --git a/sources b/sources index 70216ee..4f23568 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -ec92966f4d0c8b50c344fe901859ae2a mc-4.6.2.tar.gz +9f705ec40a2551121ddf0f517c13d96b mc-4.6.99-20090731git.tar.bz2