Minor clean up.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-04-15 22:04:21 +04:00 committed by Ilia Maslakov
parent 14fa0ea1e2
commit 29cab775c7
5 changed files with 20 additions and 33 deletions

View File

@ -959,7 +959,7 @@ compare_dirs_cmd (void)
void
diff_view_cmd (void)
{
dview_diff_cmd (NULL);
dview_diff_cmd ();
}
#endif

View File

@ -76,7 +76,7 @@ typedef struct
DSRC dsrc;
} PRINTER_CTX;
typedef struct WDiff_struct
typedef struct WDiff
{
Widget widget;

View File

@ -152,7 +152,6 @@ mcdiffview_dialog_search (WDiff * dview)
return FALSE;
}
#ifdef HAVE_CHARSET
{
GString *tmp = str_convert_to_input (exp);
@ -237,7 +236,6 @@ mcdiffview_do_search (WDiff * dview)
{
gboolean present_result = FALSE;
tty_enable_interrupt_key ();
if (mcdiffview_search_options.backwards)
@ -256,7 +254,6 @@ mcdiffview_do_search (WDiff * dview)
dview->search.last_found_line = -1;
error_dialog (_("Search"), _(" Search string not found "));
}
}
/* --------------------------------------------------------------------------------------------- */
@ -295,16 +292,11 @@ void
dview_continue_search_cmd (WDiff * dview)
{
if (dview->dsrc != DATA_SRC_MEM)
{
error_dialog (_("Search"), _(" Search is disabled "));
return;
}
if (dview->search.handle == NULL)
{
else if (dview->search.handle == NULL)
dview_search_cmd (dview);
return;
}
mcdiffview_do_search (dview);
else
mcdiffview_do_search (dview);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -30,6 +30,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "lib/global.h"
#include "lib/tty/tty.h"
@ -49,7 +50,6 @@
#include "src/history.h"
#include "src/panel.h" /* Needed for current_panel and other_panel */
#include "src/layout.h" /* Needed for get_current_index and get_other_panel */
/* mc_open, mc_close, mc_read, mc_stat */
#include "src/main.h" /* mc_run_mode */
#include "src/selcodepage.h"
@ -131,14 +131,12 @@ dview_set_codeset (WDiff * dview)
/* --------------------------------------------------------------------------------------------- */
void
static dview_select_encoding (WDiff * dview)
static void
dview_select_encoding (WDiff * dview)
{
#ifdef HAVE_CHARSET
if (do_select_codepage ())
{
dview_set_codeset (dview);
}
#else
(void) dview;
#endif
@ -651,7 +649,7 @@ dview_get_utf (char * str, int * char_width, gboolean * result)
static int
dview_str_utf8_offset_to_pos (const char *text, size_t length)
{
int result;
ptrdiff_t result;
if (text == NULL || text[0] == '\0')
return length;
if (g_utf8_validate (text, -1, NULL))
@ -680,7 +678,7 @@ dview_str_utf8_offset_to_pos (const char *text, size_t length)
result = g_utf8_offset_to_pointer (tmpbuf, length) - tmpbuf;
g_free (buffer);
}
return max (length, result);
return max (length, (size_t) result);
}
@ -1989,7 +1987,7 @@ find_prev_hunk (const GArray * a, int pos)
{
pos--;
}
if (pos > 0 && pos < a->len)
if (pos > 0 && (size_t) pos < a->len)
pos++;
#else
while (pos > 0 && ((DIFFLN *) &g_array_index (a, DIFFLN, pos - 1))->ch == EQU_CH)
@ -2007,10 +2005,9 @@ find_prev_hunk (const GArray * a, int pos)
/* --------------------------------------------------------------------------------------------- */
static int
static size_t
find_next_hunk (const GArray * a, size_t pos)
{
int result = 0;
while (pos < a->len && ((DIFFLN *) &g_array_index (a, DIFFLN, pos))->ch != EQU_CH)
{
pos++;
@ -2037,7 +2034,7 @@ get_current_hunk (WDiff * dview, int *start_line1, int *end_line1, int *start_li
{
const GArray *a0 = dview->a[0];
const GArray *a1 = dview->a[1];
size_t tmp, pos;
size_t pos;
int ch;
int res = 0;
@ -2174,7 +2171,6 @@ dview_replace_hunk (WDiff * dview, FILE * merge_file, int from1, int to1, int fr
static void
do_merge_hunk (WDiff * dview)
{
int i, diff;
int from1, to1, from2, to2;
int res;
int hunk;
@ -3212,7 +3208,7 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
} while (0)
void
dview_diff_cmd (WDiff *dview)
dview_diff_cmd (void)
{
int rv = 0;
char *file0 = NULL;
@ -3220,7 +3216,7 @@ dview_diff_cmd (WDiff *dview)
int is_dir0 = 0;
int is_dir1 = 0;
if ((mc_run_mode == MC_RUN_FULL) && (dview == NULL))
if (mc_run_mode == MC_RUN_FULL)
{
const WPanel *panel0 = current_panel;
const WPanel *panel1 = other_panel;
@ -3235,7 +3231,8 @@ dview_diff_cmd (WDiff *dview)
is_dir1 = S_ISDIR (selection (panel1)->st.st_mode);
}
if (rv == 0) {
if (rv == 0)
{
rv = -1;
if (file0 != NULL && !is_dir0 && file1 != NULL && !is_dir1)
{
@ -3259,9 +3256,8 @@ dview_diff_cmd (WDiff *dview)
g_free (file1);
g_free (file0);
if (rv != 0) {
message (1, MSG_ERROR, _("Need two files to compare"));
}
if (rv != 0)
message (1, MSG_ERROR, _("Two files are needed to compare"));
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -2,7 +2,6 @@
#define MC__DIFFVIEW_YDIFF_H
/*** typedefs(not structures) and defined constants **********************************************/
struct WDiff_struct;
/*** enums ***************************************************************************************/
@ -12,7 +11,7 @@ struct WDiff_struct;
/*** declarations of public functions ************************************************************/
void dview_diff_cmd (struct WDiff_struct * dview);
void dview_diff_cmd (void);
int diff_view (const char *file1, const char *file2, const char *label1, const char *label2);
#endif /* MC__DIFFVIEW_YDIFF_H */