Remove unneeded vars in edit/edit.c to avoid compiler warnings

Signed-off-by: Patrick Winnertz <winnie@debian.org>

edit: cleanup: moved variable declaration to begin of block
edit: have_charset: added explicit variable declarations

Signed-off-by: Sergei Trofimovich <slyfox@inbox.ru>

fix not initialized variable 'cw'
fix variables 'cw', 'utf_ch', make more safety algorithm.
This commit is contained in:
Patrick Winnertz 2009-06-30 13:10:42 +02:00 committed by Slava Zanko
parent 0bffb32dd1
commit bada6849cd
5 changed files with 18 additions and 13 deletions

View File

@ -1470,16 +1470,21 @@ long edit_move_forward3 (WEdit * edit, long current, int cols, long upto)
{
long p, q;
int col = 0;
int cw = 1;
gunichar utf_ch = 0;
#ifdef HAVE_CHARSET
int cw = 1;
int utf_ch = 0;
#endif
if (upto) {
q = upto;
cols = -10;
} else
q = edit->last_byte + 2;
for (col = 0, p = current; p < q; p++) {
int c;
#ifdef HAVE_CHARSET
cw = 1;
utf_ch = 0;
#endif
if (cols != -10) {
if (col == cols)
return p;
@ -2416,8 +2421,6 @@ static const char * const shell_cmd[] = SHELL_COMMANDS_i;
void
edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
{
int i = 0;
edit->force |= REDRAW_LINE;
/* The next key press will unhighlight the found string, so update
@ -2457,6 +2460,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
#ifdef HAVE_CHARSET
if ( char_for_insertion > 255 && utf8_display == 0 ) {
unsigned char str[6 + 1];
size_t i = 0;
int res = g_unichar_to_utf8 (char_for_insertion, (char *)str);
if ( res == 0 ) {
str[0] = '.';

View File

@ -1437,7 +1437,7 @@ edit_replace_cmd (WEdit *edit, int again)
/*returns negative on not found or error in pattern */
if (edit->search_start >= 0) {
int i;
guint i;
edit->found_start = edit->search_start;
i = edit->found_len = len;

View File

@ -283,8 +283,9 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real,
edit_move (x1, y);
hline (' ', end_col + 1 - EDIT_TEXT_HORIZONTAL_OFFSET - x1);
if ( option_line_state ) {
for (int i = 0; i < LINE_STATE_WIDTH; i++) {
if (option_line_state) {
int i;
for (i = 0; i < LINE_STATE_WIDTH; i++) {
if ( status[i] == '\0' ) {
status[i] = ' ';
}

View File

@ -890,7 +890,7 @@ int num_history_items_recorded = 60;
GList *
history_get (const char *input_name)
{
int i;
size_t i;
GList *hist = NULL;
char *profile;
mc_config_t *cfg;
@ -912,7 +912,7 @@ history_get (const char *input_name)
for (i = 0; i < keys_num; i++) {
char key_name[BUF_TINY];
g_snprintf (key_name, sizeof (key_name), "%d", i);
g_snprintf (key_name, sizeof (key_name), "%lu", (unsigned long)i);
this_entry = mc_config_get_string (cfg, input_name, key_name, "");
if (this_entry && *this_entry)

View File

@ -137,7 +137,7 @@ vfs_op (int handle)
struct vfs_openfile *h;
if (handle < VFS_FIRST_HANDLE ||
handle - VFS_FIRST_HANDLE >= vfs_openfiles->len)
(guint)(handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
return NULL;
h = (struct vfs_openfile *) g_ptr_array_index (
@ -157,7 +157,7 @@ vfs_info (int handle)
struct vfs_openfile *h;
if (handle < VFS_FIRST_HANDLE ||
handle - VFS_FIRST_HANDLE >= vfs_openfiles->len)
(guint)(handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
return NULL;
h = (struct vfs_openfile *) g_ptr_array_index (
@ -175,7 +175,7 @@ static inline void
vfs_free_handle (int handle)
{
if (handle < VFS_FIRST_HANDLE ||
handle - VFS_FIRST_HANDLE >= vfs_openfiles->len)
(guint)(handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len)
return;
g_ptr_array_index (vfs_openfiles, handle - VFS_FIRST_HANDLE) =