mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-27 13:39:30 +03:00
Merge branch '2277_mcdiff_warnings_fix'
* 2277_mcdiff_warnings_fix: Ticket #2277 (mcdiff cleanup)
This commit is contained in:
commit
dc9795108b
@ -128,7 +128,7 @@ typedef struct WDiff
|
||||
gchar *last_string;
|
||||
|
||||
ssize_t last_found_line;
|
||||
size_t last_accessed_num_line;
|
||||
ssize_t last_accessed_num_line;
|
||||
} search;
|
||||
|
||||
} WDiff;
|
||||
|
@ -175,17 +175,21 @@ mcdiffview_dialog_search (WDiff * dview)
|
||||
static gboolean
|
||||
mcdiffview_do_search_backward (WDiff * dview)
|
||||
{
|
||||
size_t ind;
|
||||
ssize_t ind;
|
||||
DIFFLN *p;
|
||||
|
||||
dview->search.last_accessed_num_line--;
|
||||
|
||||
if (dview->search.last_accessed_num_line < 0)
|
||||
return FALSE;
|
||||
|
||||
for (ind = dview->search.last_accessed_num_line; ind > 0; ind--)
|
||||
{
|
||||
p = (DIFFLN *) & g_array_index (dview->a[dview->ord], DIFFLN, ind);
|
||||
dview->search.last_accessed_num_line = -1;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((size_t) dview->search.last_accessed_num_line >= dview->a[dview->ord]->len)
|
||||
dview->search.last_accessed_num_line = (ssize_t) dview->a[dview->ord]->len;
|
||||
|
||||
for (ind = --dview->search.last_accessed_num_line; ind >= 0; ind--)
|
||||
{
|
||||
p = (DIFFLN *) & g_array_index (dview->a[dview->ord], DIFFLN, (size_t) ind);
|
||||
if (p->u.len == 0)
|
||||
continue;
|
||||
|
||||
@ -208,12 +212,15 @@ mcdiffview_do_search_forward (WDiff * dview)
|
||||
size_t ind;
|
||||
DIFFLN *p;
|
||||
|
||||
dview->search.last_accessed_num_line++;
|
||||
if (dview->search.last_accessed_num_line < 0)
|
||||
dview->search.last_accessed_num_line = -1;
|
||||
else if ((size_t) dview->search.last_accessed_num_line >= dview->a[dview->ord]->len)
|
||||
{
|
||||
dview->search.last_accessed_num_line = (ssize_t) dview->a[dview->ord]->len;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (dview->search.last_accessed_num_line > dview->a[dview->ord]->len)
|
||||
return FALSE;
|
||||
|
||||
for (ind = dview->search.last_accessed_num_line; ind < dview->a[dview->ord]->len; ind++)
|
||||
for (ind = (size_t) ++dview->search.last_accessed_num_line; ind < dview->a[dview->ord]->len; ind++)
|
||||
{
|
||||
p = (DIFFLN *) & g_array_index (dview->a[dview->ord], DIFFLN, ind);
|
||||
if (p->u.len == 0)
|
||||
@ -222,7 +229,7 @@ mcdiffview_do_search_forward (WDiff * dview)
|
||||
if (mc_search_run (dview->search.handle, p->p, 0, p->u.len, NULL))
|
||||
{
|
||||
dview->skip_rows = dview->search.last_found_line =
|
||||
dview->search.last_accessed_num_line = ind;
|
||||
dview->search.last_accessed_num_line = (ssize_t) ind;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -1648,16 +1648,16 @@ cvt_fget (FBUF * f, off_t off, char *dst, size_t dstsize, int skip, int ts, int
|
||||
}
|
||||
}
|
||||
|
||||
useful = base - skip;
|
||||
offset = skip - old_base;
|
||||
|
||||
if (useful < 0)
|
||||
if (base < skip)
|
||||
{
|
||||
memset (dst, ' ', dstsize);
|
||||
dst[dstsize] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
useful = base - skip;
|
||||
offset = skip - old_base;
|
||||
|
||||
if (useful <= dstsize)
|
||||
{
|
||||
if (useful != 0)
|
||||
@ -2349,7 +2349,7 @@ dview_init (WDiff * dview, const char *args, const char *file1, const char *file
|
||||
dview->search.handle = NULL;
|
||||
dview->search.last_string = NULL;
|
||||
dview->search.last_found_line = -1;
|
||||
dview->search.last_accessed_num_line = 0;
|
||||
dview->search.last_accessed_num_line = -1;
|
||||
|
||||
dview->opt.quality = 0;
|
||||
dview->opt.strip_trailing_cr = 0;
|
||||
@ -2803,7 +2803,7 @@ dview_goto_cmd (WDiff * dview, int ord)
|
||||
}
|
||||
}
|
||||
}
|
||||
dview->skip_rows = dview->search.last_accessed_num_line = i;
|
||||
dview->skip_rows = dview->search.last_accessed_num_line = (ssize_t) i;
|
||||
g_snprintf (prev, sizeof (prev), "%d", newline);
|
||||
}
|
||||
g_free (input);
|
||||
@ -3071,20 +3071,29 @@ dview_execute_cmd (WDiff * dview, unsigned long command)
|
||||
dview->skip_rows = dview->search.last_accessed_num_line = dview->a[0]->len - 1;
|
||||
break;
|
||||
case CK_DiffUp:
|
||||
dview->skip_rows--;
|
||||
dview->search.last_accessed_num_line = dview->skip_rows;
|
||||
if (dview->skip_rows > 0)
|
||||
{
|
||||
dview->skip_rows--;
|
||||
dview->search.last_accessed_num_line = dview->skip_rows;
|
||||
}
|
||||
break;
|
||||
case CK_DiffDown:
|
||||
dview->skip_rows++;
|
||||
dview->search.last_accessed_num_line = dview->skip_rows;
|
||||
break;
|
||||
case CK_DiffPageDown:
|
||||
dview->skip_rows += dview->height - 2;
|
||||
dview->search.last_accessed_num_line = dview->skip_rows;
|
||||
if (dview->height > 2)
|
||||
{
|
||||
dview->skip_rows += dview->height - 2;
|
||||
dview->search.last_accessed_num_line = dview->skip_rows;
|
||||
}
|
||||
break;
|
||||
case CK_DiffPageUp:
|
||||
dview->skip_rows -= dview->height - 2;
|
||||
dview->search.last_accessed_num_line = dview->skip_rows;
|
||||
if (dview->height > 2)
|
||||
{
|
||||
dview->skip_rows -= dview->height - 2;
|
||||
dview->search.last_accessed_num_line = dview->skip_rows;
|
||||
}
|
||||
break;
|
||||
case CK_DiffLeft:
|
||||
dview->skip_cols--;
|
||||
|
Loading…
x
Reference in New Issue
Block a user