mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-18 09:19:24 +03:00
Merge branch '2182_tab_size_zero_fix'
* 2182_tab_size_zero_fix: Ticket #2182 (fix incorrect tab size)
This commit is contained in:
commit
5ab3f7cb63
@ -86,19 +86,28 @@ do { \
|
|||||||
#define HDIFF_MINCTX 5
|
#define HDIFF_MINCTX 5
|
||||||
#define HDIFF_DEPTH 10
|
#define HDIFF_DEPTH 10
|
||||||
|
|
||||||
#define TAB_SKIP(ts, pos) ((ts) - (pos) % (ts))
|
|
||||||
|
|
||||||
#define FILE_DIRTY(fs) \
|
#define FILE_DIRTY(fs) \
|
||||||
do { \
|
do { \
|
||||||
(fs)->pos = 0; \
|
(fs)->pos = 0; \
|
||||||
(fs)->len = 0; \
|
(fs)->len = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
/*** file scope type declarations ****************************************************************/
|
/*** file scope type declarations ****************************************************************/
|
||||||
|
|
||||||
/*** file scope variables ************************************************************************/
|
/*** file scope variables ************************************************************************/
|
||||||
|
|
||||||
/*** file scope functions ************************************************************************/
|
/*** file scope functions ************************************************************************/
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
TAB_SKIP (int ts, int pos)
|
||||||
|
{
|
||||||
|
if (ts > 0 && ts < 9)
|
||||||
|
return ts - pos % ts;
|
||||||
|
else
|
||||||
|
return 8 - pos % 8;
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -188,8 +197,7 @@ open_temp (void **name)
|
|||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
message (D_ERROR, MSG_ERROR,
|
message (D_ERROR, MSG_ERROR,
|
||||||
_(" Cannot create temporary diff file \n %s "),
|
_(" Cannot create temporary diff file \n %s "), unix_error_string (errno));
|
||||||
unix_error_string (errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*name = diff_file_name;
|
*name = diff_file_name;
|
||||||
@ -581,7 +589,7 @@ p_close (FBUF * fs)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dview_get_byte (char * str, gboolean * result)
|
dview_get_byte (char *str, gboolean * result)
|
||||||
{
|
{
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
{
|
{
|
||||||
@ -602,7 +610,7 @@ dview_get_byte (char * str, gboolean * result)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dview_get_utf (char * str, int * char_width, gboolean * result)
|
dview_get_utf (char *str, int *char_width, gboolean * result)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
gunichar ch;
|
gunichar ch;
|
||||||
@ -1451,7 +1459,7 @@ cvt_mget (const char *src, size_t srcsize, char *dst, int dstsize, int skip, int
|
|||||||
int w;
|
int w;
|
||||||
|
|
||||||
skip--;
|
skip--;
|
||||||
utf_ch = dview_get_utf ((char *)src, &w, &res);
|
utf_ch = dview_get_utf ((char *) src, &w, &res);
|
||||||
if (w > 1)
|
if (w > 1)
|
||||||
skip += w - 1;
|
skip += w - 1;
|
||||||
if (!g_unichar_isprint (utf_ch))
|
if (!g_unichar_isprint (utf_ch))
|
||||||
@ -1982,26 +1990,26 @@ static int
|
|||||||
find_prev_hunk (const GArray * a, int pos)
|
find_prev_hunk (const GArray * a, int pos)
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
while (pos > 0 && ((DIFFLN *) &g_array_index (a, DIFFLN, pos))->ch != EQU_CH)
|
while (pos > 0 && ((DIFFLN *) & g_array_index (a, DIFFLN, pos))->ch != EQU_CH)
|
||||||
{
|
{
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
while (pos > 0 && ((DIFFLN *) &g_array_index (a, DIFFLN, pos))->ch == EQU_CH)
|
while (pos > 0 && ((DIFFLN *) & g_array_index (a, DIFFLN, pos))->ch == EQU_CH)
|
||||||
{
|
{
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
while (pos > 0 && ((DIFFLN *) &g_array_index (a, DIFFLN, pos))->ch != EQU_CH)
|
while (pos > 0 && ((DIFFLN *) & g_array_index (a, DIFFLN, pos))->ch != EQU_CH)
|
||||||
{
|
{
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
if (pos > 0 && (size_t) pos < a->len)
|
if (pos > 0 && (size_t) pos < a->len)
|
||||||
pos++;
|
pos++;
|
||||||
#else
|
#else
|
||||||
while (pos > 0 && ((DIFFLN *) &g_array_index (a, DIFFLN, pos - 1))->ch == EQU_CH)
|
while (pos > 0 && ((DIFFLN *) & g_array_index (a, DIFFLN, pos - 1))->ch == EQU_CH)
|
||||||
{
|
{
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
while (pos > 0 && ((DIFFLN *) &g_array_index (a, DIFFLN, pos - 1))->ch != EQU_CH)
|
while (pos > 0 && ((DIFFLN *) & g_array_index (a, DIFFLN, pos - 1))->ch != EQU_CH)
|
||||||
{
|
{
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
@ -2015,11 +2023,11 @@ find_prev_hunk (const GArray * a, int pos)
|
|||||||
static size_t
|
static size_t
|
||||||
find_next_hunk (const GArray * a, size_t pos)
|
find_next_hunk (const GArray * a, size_t pos)
|
||||||
{
|
{
|
||||||
while (pos < a->len && ((DIFFLN *) &g_array_index (a, DIFFLN, pos))->ch != EQU_CH)
|
while (pos < a->len && ((DIFFLN *) & g_array_index (a, DIFFLN, pos))->ch != EQU_CH)
|
||||||
{
|
{
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
while (pos < a->len && ((DIFFLN *) &g_array_index (a, DIFFLN, pos))->ch == EQU_CH)
|
while (pos < a->len && ((DIFFLN *) & g_array_index (a, DIFFLN, pos))->ch == EQU_CH)
|
||||||
{
|
{
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
@ -2051,7 +2059,7 @@ get_current_hunk (WDiff * dview, int *start_line1, int *end_line1, int *start_li
|
|||||||
*end_line2 = 1;
|
*end_line2 = 1;
|
||||||
|
|
||||||
pos = dview->skip_rows;
|
pos = dview->skip_rows;
|
||||||
ch = ((DIFFLN *) &g_array_index (a0, DIFFLN, pos))->ch;
|
ch = ((DIFFLN *) & g_array_index (a0, DIFFLN, pos))->ch;
|
||||||
if (ch != EQU_CH)
|
if (ch != EQU_CH)
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
@ -2066,21 +2074,21 @@ get_current_hunk (WDiff * dview, int *start_line1, int *end_line1, int *start_li
|
|||||||
res = DIFF_CHG;
|
res = DIFF_CHG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
while (pos > 0 && ((DIFFLN *) &g_array_index (a0, DIFFLN, pos))->ch != EQU_CH)
|
while (pos > 0 && ((DIFFLN *) & g_array_index (a0, DIFFLN, pos))->ch != EQU_CH)
|
||||||
{
|
{
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
if (pos > 0)
|
if (pos > 0)
|
||||||
{
|
{
|
||||||
*start_line1 = ((DIFFLN *) &g_array_index (a0, DIFFLN, pos))->line + 1;
|
*start_line1 = ((DIFFLN *) & g_array_index (a0, DIFFLN, pos))->line + 1;
|
||||||
*start_line2 = ((DIFFLN *) &g_array_index (a1, DIFFLN, pos))->line + 1;
|
*start_line2 = ((DIFFLN *) & g_array_index (a1, DIFFLN, pos))->line + 1;
|
||||||
}
|
}
|
||||||
pos = dview->skip_rows;
|
pos = dview->skip_rows;
|
||||||
while (pos < a0->len && ((DIFFLN *) &g_array_index (a0, DIFFLN, pos))->ch != EQU_CH)
|
while (pos < a0->len && ((DIFFLN *) & g_array_index (a0, DIFFLN, pos))->ch != EQU_CH)
|
||||||
{
|
{
|
||||||
int l0, l1;
|
int l0, l1;
|
||||||
l0 = ((DIFFLN *) &g_array_index (a0, DIFFLN, pos))->line;
|
l0 = ((DIFFLN *) & g_array_index (a0, DIFFLN, pos))->line;
|
||||||
l1 = ((DIFFLN *) &g_array_index (a1, DIFFLN, pos))->line;
|
l1 = ((DIFFLN *) & g_array_index (a1, DIFFLN, pos))->line;
|
||||||
if (l0 > 0)
|
if (l0 > 0)
|
||||||
*end_line1 = max (*start_line1, l0);
|
*end_line1 = max (*start_line1, l0);
|
||||||
if (l1 > 0)
|
if (l1 > 0)
|
||||||
@ -2337,8 +2345,8 @@ dview_init (WDiff * dview, const char *args, const char *file1, const char *file
|
|||||||
dview->ord = 0;
|
dview->ord = 0;
|
||||||
dview->full = 0;
|
dview->full = 0;
|
||||||
|
|
||||||
dview->search.handle=NULL;
|
dview->search.handle = NULL;
|
||||||
dview->search.last_string=NULL;
|
dview->search.last_string = NULL;
|
||||||
dview->search.last_found_line = -1;
|
dview->search.last_found_line = -1;
|
||||||
dview->search.last_accessed_num_line = 0;
|
dview->search.last_accessed_num_line = 0;
|
||||||
|
|
||||||
@ -2420,6 +2428,7 @@ dview_diff_options (WDiff * dview)
|
|||||||
dview_reread (dview);
|
dview_reread (dview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2457,10 +2466,13 @@ dview_display_file (const WDiff * dview, int ord, int r, int c, int height, int
|
|||||||
int display_symbols = dview->display_symbols;
|
int display_symbols = dview->display_symbols;
|
||||||
int display_numbers = dview->display_numbers;
|
int display_numbers = dview->display_numbers;
|
||||||
int show_cr = dview->show_cr;
|
int show_cr = dview->show_cr;
|
||||||
int tab_size = dview->tab_size;
|
int tab_size = 8;
|
||||||
const DIFFLN *p;
|
const DIFFLN *p;
|
||||||
int nwidth = display_numbers;
|
int nwidth = display_numbers;
|
||||||
int xwidth = display_symbols + display_numbers;
|
int xwidth = display_symbols + display_numbers;
|
||||||
|
if (dview->tab_size > 0 && dview->tab_size < 9)
|
||||||
|
tab_size = dview->tab_size;
|
||||||
|
|
||||||
if (xwidth)
|
if (xwidth)
|
||||||
{
|
{
|
||||||
if (xwidth > width && display_symbols)
|
if (xwidth > width && display_symbols)
|
||||||
@ -2495,7 +2507,7 @@ dview_display_file (const WDiff * dview, int ord, int r, int c, int height, int
|
|||||||
{
|
{
|
||||||
int ch, next_ch, col;
|
int ch, next_ch, col;
|
||||||
size_t cnt;
|
size_t cnt;
|
||||||
p = (DIFFLN *) &g_array_index (dview->a[ord], DIFFLN, i);
|
p = (DIFFLN *) & g_array_index (dview->a[ord], DIFFLN, i);
|
||||||
ch = p->ch;
|
ch = p->ch;
|
||||||
tty_setcolor (NORMAL_COLOR);
|
tty_setcolor (NORMAL_COLOR);
|
||||||
if (display_symbols)
|
if (display_symbols)
|
||||||
@ -2556,12 +2568,18 @@ dview_display_file (const WDiff * dview, int ord, int r, int c, int height, int
|
|||||||
{
|
{
|
||||||
tty_setcolor (att[cnt] ? DFF_CHH_COLOR : DFF_CHG_COLOR);
|
tty_setcolor (att[cnt] ? DFF_CHH_COLOR : DFF_CHG_COLOR);
|
||||||
#ifdef HAVE_CHARSET
|
#ifdef HAVE_CHARSET
|
||||||
if (utf8_display) {
|
if (utf8_display)
|
||||||
if (!dview->utf8) {
|
{
|
||||||
next_ch = convert_from_8bit_to_utf_c ((unsigned char) next_ch, dview->converter);
|
if (!dview->utf8)
|
||||||
|
{
|
||||||
|
next_ch =
|
||||||
|
convert_from_8bit_to_utf_c ((unsigned char) next_ch,
|
||||||
|
dview->converter);
|
||||||
}
|
}
|
||||||
} else if (dview->utf8)
|
}
|
||||||
next_ch = convert_from_utf_to_current_c (next_ch, dview->converter);
|
else if (dview->utf8)
|
||||||
|
next_ch =
|
||||||
|
convert_from_utf_to_current_c (next_ch, dview->converter);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
next_ch = convert_to_display_c (next_ch);
|
next_ch = convert_to_display_c (next_ch);
|
||||||
@ -2628,11 +2646,15 @@ dview_display_file (const WDiff * dview, int ord, int r, int c, int height, int
|
|||||||
if (ch_res)
|
if (ch_res)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_CHARSET
|
#ifdef HAVE_CHARSET
|
||||||
if (utf8_display) {
|
if (utf8_display)
|
||||||
if (!dview->utf8) {
|
{
|
||||||
next_ch = convert_from_8bit_to_utf_c ((unsigned char) next_ch, dview->converter);
|
if (!dview->utf8)
|
||||||
|
{
|
||||||
|
next_ch =
|
||||||
|
convert_from_8bit_to_utf_c ((unsigned char) next_ch, dview->converter);
|
||||||
}
|
}
|
||||||
} else if (dview->utf8)
|
}
|
||||||
|
else if (dview->utf8)
|
||||||
next_ch = convert_from_utf_to_current_c (next_ch, dview->converter);
|
next_ch = convert_from_utf_to_current_c (next_ch, dview->converter);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@ -2869,6 +2891,7 @@ static void
|
|||||||
dview_load_options (WDiff * dview)
|
dview_load_options (WDiff * dview)
|
||||||
{
|
{
|
||||||
gboolean show_numbers, show_symbols;
|
gboolean show_numbers, show_symbols;
|
||||||
|
int tab_size;
|
||||||
|
|
||||||
show_symbols = mc_config_get_bool (mc_main_config, "DiffView", "show_symbols", FALSE);
|
show_symbols = mc_config_get_bool (mc_main_config, "DiffView", "show_symbols", FALSE);
|
||||||
if (show_symbols)
|
if (show_symbols)
|
||||||
@ -2876,7 +2899,11 @@ dview_load_options (WDiff * dview)
|
|||||||
show_numbers = mc_config_get_bool (mc_main_config, "DiffView", "show_numbers", FALSE);
|
show_numbers = mc_config_get_bool (mc_main_config, "DiffView", "show_numbers", FALSE);
|
||||||
if (show_numbers)
|
if (show_numbers)
|
||||||
dview->display_numbers = calc_nwidth ((const GArray ** const) dview->a);
|
dview->display_numbers = calc_nwidth ((const GArray ** const) dview->a);
|
||||||
dview->tab_size = mc_config_get_int (mc_main_config, "DiffView", "tab_size", 8);
|
tab_size = mc_config_get_int (mc_main_config, "DiffView", "tab_size", 8);
|
||||||
|
if (tab_size > 0 && tab_size < 9)
|
||||||
|
dview->tab_size = tab_size;
|
||||||
|
else
|
||||||
|
dview->tab_size = 8;
|
||||||
|
|
||||||
dview->opt.quality = mc_config_get_int (mc_main_config, "DiffView", "diff_quality", 0);
|
dview->opt.quality = mc_config_get_int (mc_main_config, "DiffView", "diff_quality", 0);
|
||||||
|
|
||||||
@ -2905,7 +2932,8 @@ dview_ok_to_exit (WDiff * dview)
|
|||||||
if (!dview->merged)
|
if (!dview->merged)
|
||||||
return res;
|
return res;
|
||||||
switch (query_dialog
|
switch (query_dialog
|
||||||
(_("Quit"), _(" File was modified, Save with exit? "), D_NORMAL, 2, _("&Yes"), _("&No")))
|
(_("Quit"), _(" File was modified, Save with exit? "), D_NORMAL, 2, _("&Yes"),
|
||||||
|
_("&No")))
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
@ -2987,10 +3015,12 @@ dview_execute_cmd (WDiff * dview, unsigned long command)
|
|||||||
dview_redo (dview);
|
dview_redo (dview);
|
||||||
break;
|
break;
|
||||||
case CK_DiffNextHunk:
|
case CK_DiffNextHunk:
|
||||||
dview->skip_rows = dview->search.last_accessed_num_line = find_next_hunk (dview->a[0], dview->skip_rows);
|
dview->skip_rows = dview->search.last_accessed_num_line =
|
||||||
|
find_next_hunk (dview->a[0], dview->skip_rows);
|
||||||
break;
|
break;
|
||||||
case CK_DiffPrevHunk:
|
case CK_DiffPrevHunk:
|
||||||
dview->skip_rows = dview->search.last_accessed_num_line = find_prev_hunk (dview->a[0], dview->skip_rows);
|
dview->skip_rows = dview->search.last_accessed_num_line =
|
||||||
|
find_prev_hunk (dview->a[0], dview->skip_rows);
|
||||||
break;
|
break;
|
||||||
case CK_DiffGoto:
|
case CK_DiffGoto:
|
||||||
dview_goto_cmd (dview, TRUE);
|
dview_goto_cmd (dview, TRUE);
|
||||||
|
Loading…
Reference in New Issue
Block a user