mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Refactoring of endless loops and some type accuracy.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
b2f97443e2
commit
6c94ef16ec
@ -2227,7 +2227,7 @@ learn_key (void)
|
||||
endtime.tv_sec++;
|
||||
}
|
||||
tty_nodelay (TRUE);
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
while ((c = tty_lowlevel_getch ()) == -1)
|
||||
{
|
||||
|
@ -135,9 +135,10 @@ show_rxvt_contents (int starty, unsigned char y1, unsigned char y2)
|
||||
bytes = (y2 - y1) * (COLS + 1) + 1; /* *should* be the number of bytes read */
|
||||
j = 0;
|
||||
k = g_malloc (bytes);
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
int c;
|
||||
|
||||
c = rxvt_getc ();
|
||||
if (c < 0)
|
||||
break;
|
||||
|
24
lib/util.c
24
lib/util.c
@ -991,32 +991,32 @@ diff_two_paths (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
|
||||
{
|
||||
p = my_first;
|
||||
q = my_second;
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
r = strchr (p, PATH_SEP);
|
||||
s = strchr (q, PATH_SEP);
|
||||
if (!r || !s)
|
||||
if (r == NULL || s == NULL)
|
||||
break;
|
||||
*r = 0;
|
||||
*s = 0;
|
||||
if (strcmp (p, q))
|
||||
*r = '\0';
|
||||
*s = '\0';
|
||||
if (strcmp (p, q) != 0)
|
||||
{
|
||||
*r = PATH_SEP;
|
||||
*s = PATH_SEP;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
*r = PATH_SEP;
|
||||
*s = PATH_SEP;
|
||||
}
|
||||
|
||||
*r = PATH_SEP;
|
||||
*s = PATH_SEP;
|
||||
|
||||
p = r + 1;
|
||||
q = s + 1;
|
||||
}
|
||||
p--;
|
||||
for (i = 0; (p = strchr (p + 1, PATH_SEP)) != NULL; i++);
|
||||
for (i = 0; (p = strchr (p + 1, PATH_SEP)) != NULL; i++)
|
||||
;
|
||||
currlen = (i + 1) * 3 + strlen (q) + 1;
|
||||
if (j)
|
||||
if (j != 0)
|
||||
{
|
||||
if (currlen < prevlen)
|
||||
g_free (buf);
|
||||
|
@ -977,7 +977,7 @@ my_type_of (int c)
|
||||
const char option_chars_move_whole_word[] =
|
||||
"!=&|<>^~ !:;, !'!`!.?!\"!( !) !{ !} !Aa0 !+-*/= |<> ![ !] !\\#! ";
|
||||
|
||||
if (!c)
|
||||
if (c == 0)
|
||||
return 0;
|
||||
if (c == '!')
|
||||
{
|
||||
@ -1014,27 +1014,27 @@ my_type_of (int c)
|
||||
static void
|
||||
edit_left_word_move (WEdit * edit, int s)
|
||||
{
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
if (edit->column_highlight
|
||||
&& edit->mark1 != edit->mark2
|
||||
&& edit->over_col == 0 && edit->curs1 == edit_bol (edit, edit->curs1))
|
||||
break;
|
||||
edit_cursor_move (edit, -1);
|
||||
if (!edit->curs1)
|
||||
if (edit->curs1 == 0)
|
||||
break;
|
||||
c1 = edit_get_byte (edit, edit->curs1 - 1);
|
||||
c2 = edit_get_byte (edit, edit->curs1);
|
||||
if (c1 == '\n' || c2 == '\n')
|
||||
break;
|
||||
if (!(my_type_of (c1) & my_type_of (c2)))
|
||||
if ((my_type_of (c1) & my_type_of (c2)) == 0)
|
||||
break;
|
||||
if (isspace (c1) && !isspace (c2))
|
||||
break;
|
||||
if (s)
|
||||
if (!isspace (c1) && isspace (c2))
|
||||
break;
|
||||
if (s != 0 && !isspace (c1) && isspace (c2))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1052,9 +1052,10 @@ edit_left_word_move_cmd (WEdit * edit)
|
||||
static void
|
||||
edit_right_word_move (WEdit * edit, int s)
|
||||
{
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
int c1, c2;
|
||||
|
||||
if (edit->column_highlight
|
||||
&& edit->mark1 != edit->mark2
|
||||
&& edit->over_col == 0 && edit->curs1 == edit_eol (edit, edit->curs1))
|
||||
@ -1066,13 +1067,12 @@ edit_right_word_move (WEdit * edit, int s)
|
||||
c2 = edit_get_byte (edit, edit->curs1);
|
||||
if (c1 == '\n' || c2 == '\n')
|
||||
break;
|
||||
if (!(my_type_of (c1) & my_type_of (c2)))
|
||||
if ((my_type_of (c1) & my_type_of (c2)) == 0)
|
||||
break;
|
||||
if (isspace (c1) && !isspace (c2))
|
||||
break;
|
||||
if (s)
|
||||
if (!isspace (c1) && isspace (c2))
|
||||
break;
|
||||
if (s != 0 && !isspace (c1) && isspace (c2))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1194,18 +1194,17 @@ edit_move_updown (WEdit * edit, long lines, gboolean do_scroll, gboolean directi
|
||||
static void
|
||||
edit_right_delete_word (WEdit * edit)
|
||||
{
|
||||
int c1, c2;
|
||||
for (;;)
|
||||
while (edit->curs1 < edit->last_byte)
|
||||
{
|
||||
if (edit->curs1 >= edit->last_byte)
|
||||
break;
|
||||
int c1, c2;
|
||||
|
||||
c1 = edit_delete (edit, TRUE);
|
||||
c2 = edit_get_byte (edit, edit->curs1);
|
||||
if (c1 == '\n' || c2 == '\n')
|
||||
break;
|
||||
if ((isspace (c1) == 0) != (isspace (c2) == 0))
|
||||
break;
|
||||
if (!(my_type_of (c1) & my_type_of (c2)))
|
||||
if ((my_type_of (c1) & my_type_of (c2)) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1215,18 +1214,17 @@ edit_right_delete_word (WEdit * edit)
|
||||
static void
|
||||
edit_left_delete_word (WEdit * edit)
|
||||
{
|
||||
int c1, c2;
|
||||
for (;;)
|
||||
while (edit->curs1 > 0)
|
||||
{
|
||||
if (edit->curs1 <= 0)
|
||||
break;
|
||||
int c1, c2;
|
||||
|
||||
c1 = edit_backspace (edit, TRUE);
|
||||
c2 = edit_get_byte (edit, edit->curs1 - 1);
|
||||
if (c1 == '\n' || c2 == '\n')
|
||||
break;
|
||||
if ((isspace (c1) == 0) != (isspace (c2) == 0))
|
||||
break;
|
||||
if (!(my_type_of (c1) & my_type_of (c2)))
|
||||
if ((my_type_of (c1) & my_type_of (c2)) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1473,11 +1471,12 @@ edit_auto_indent (WEdit * edit)
|
||||
{
|
||||
off_t p;
|
||||
char c;
|
||||
|
||||
p = edit->curs1;
|
||||
/* use the previous line as a template */
|
||||
p = edit_move_backward (edit, p, 1);
|
||||
/* copy the leading whitespace of the line */
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{ /* no range check - the line _is_ \n-terminated */
|
||||
c = edit_get_byte (edit, p++);
|
||||
if (c != ' ' && c != '\t')
|
||||
@ -1558,7 +1557,7 @@ check_and_wrap_line (WEdit * edit)
|
||||
if (edit->curs_col < option_word_wrap_line_length)
|
||||
return;
|
||||
curs = edit->curs1;
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
curs--;
|
||||
c = edit_get_byte (edit, curs);
|
||||
|
@ -615,7 +615,7 @@ read_one_line (char **line, FILE * f)
|
||||
/* not reallocate string too often */
|
||||
p = g_string_sized_new (64);
|
||||
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -906,7 +906,7 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
if (!edit->defines)
|
||||
edit->defines = g_tree_new ((GCompareFunc) strcmp);
|
||||
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
char **a;
|
||||
size_t len;
|
||||
@ -915,47 +915,41 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
l = 0;
|
||||
|
||||
len = read_one_line (&l, f);
|
||||
if (len == 0)
|
||||
{
|
||||
if (g)
|
||||
{
|
||||
fclose (f);
|
||||
f = g;
|
||||
g = 0;
|
||||
line = save_line + 1;
|
||||
MC_PTR_FREE (error_file_name);
|
||||
MC_PTR_FREE (l);
|
||||
len = read_one_line (&l, f);
|
||||
if (len == 0)
|
||||
break;
|
||||
else
|
||||
xx_lowerize_line (edit, l, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (len != 0)
|
||||
xx_lowerize_line (edit, l, len);
|
||||
else
|
||||
{
|
||||
if (g == NULL)
|
||||
break;
|
||||
|
||||
fclose (f);
|
||||
f = g;
|
||||
g = NULL;
|
||||
line = save_line + 1;
|
||||
MC_PTR_FREE (error_file_name);
|
||||
MC_PTR_FREE (l);
|
||||
len = read_one_line (&l, f);
|
||||
if (len == 0)
|
||||
break;
|
||||
xx_lowerize_line (edit, l, len);
|
||||
}
|
||||
|
||||
argc = get_args (l, args, args_size);
|
||||
a = args + 1;
|
||||
if (!args[0])
|
||||
if (args[0] == NULL)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
else if (!strcmp (args[0], "include"))
|
||||
else if (strcmp (args[0], "include") == 0)
|
||||
{
|
||||
if (g || argc != 2)
|
||||
if (g != NULL || argc != 2)
|
||||
{
|
||||
result = line;
|
||||
break;
|
||||
}
|
||||
g = f;
|
||||
f = open_include_file (args[1]);
|
||||
if (!f)
|
||||
if (f == NULL)
|
||||
{
|
||||
MC_PTR_FREE (error_file_name);
|
||||
result = line;
|
||||
@ -964,19 +958,19 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
save_line = line;
|
||||
line = 0;
|
||||
}
|
||||
else if (!strcmp (args[0], "caseinsensitive"))
|
||||
else if (strcmp (args[0], "caseinsensitive") == 0)
|
||||
{
|
||||
edit->is_case_insensitive = TRUE;
|
||||
}
|
||||
else if (!strcmp (args[0], "wholechars"))
|
||||
else if (strcmp (args[0], "wholechars") == 0)
|
||||
{
|
||||
check_a;
|
||||
if (!strcmp (*a, "left"))
|
||||
if (strcmp (*a, "left") == 0)
|
||||
{
|
||||
a++;
|
||||
g_strlcpy (whole_left, *a, sizeof (whole_left));
|
||||
}
|
||||
else if (!strcmp (*a, "right"))
|
||||
else if (strcmp (*a, "right") == 0)
|
||||
{
|
||||
a++;
|
||||
g_strlcpy (whole_right, *a, sizeof (whole_right));
|
||||
@ -989,12 +983,12 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
a++;
|
||||
check_not_a;
|
||||
}
|
||||
else if (!strcmp (args[0], "context"))
|
||||
else if (strcmp (args[0], "context") == 0)
|
||||
{
|
||||
check_a;
|
||||
if (num_contexts == -1)
|
||||
{
|
||||
if (strcmp (*a, "default"))
|
||||
if (strcmp (*a, "default") != 0)
|
||||
{ /* first context is the default */
|
||||
break_a;
|
||||
}
|
||||
@ -1009,30 +1003,30 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
/* Terminate previous context. */
|
||||
r[num_contexts - 1]->keyword[num_words] = NULL;
|
||||
c = r[num_contexts] = g_malloc0 (sizeof (struct context_rule));
|
||||
if (!strcmp (*a, "exclusive"))
|
||||
if (strcmp (*a, "exclusive") == 0)
|
||||
{
|
||||
a++;
|
||||
c->between_delimiters = 1;
|
||||
}
|
||||
check_a;
|
||||
if (!strcmp (*a, "whole"))
|
||||
if (strcmp (*a, "whole") == 0)
|
||||
{
|
||||
a++;
|
||||
c->whole_word_chars_left = g_strdup (whole_left);
|
||||
c->whole_word_chars_right = g_strdup (whole_right);
|
||||
}
|
||||
else if (!strcmp (*a, "wholeleft"))
|
||||
else if (strcmp (*a, "wholeleft") == 0)
|
||||
{
|
||||
a++;
|
||||
c->whole_word_chars_left = g_strdup (whole_left);
|
||||
}
|
||||
else if (!strcmp (*a, "wholeright"))
|
||||
else if (strcmp (*a, "wholeright") == 0)
|
||||
{
|
||||
a++;
|
||||
c->whole_word_chars_right = g_strdup (whole_right);
|
||||
}
|
||||
check_a;
|
||||
if (!strcmp (*a, "linestart"))
|
||||
if (strcmp (*a, "linestart") == 0)
|
||||
{
|
||||
a++;
|
||||
c->line_start_left = 1;
|
||||
@ -1040,7 +1034,7 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
check_a;
|
||||
c->left = g_strdup (*a++);
|
||||
check_a;
|
||||
if (!strcmp (*a, "linestart"))
|
||||
if (strcmp (*a, "linestart") == 0)
|
||||
{
|
||||
a++;
|
||||
c->line_start_right = 1;
|
||||
@ -1055,17 +1049,17 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
c->keyword[0] = g_malloc0 (sizeof (struct key_word));
|
||||
subst_defines (edit->defines, a, &args[1024]);
|
||||
fg = *a;
|
||||
if (*a)
|
||||
if (*a != '\0')
|
||||
a++;
|
||||
bg = *a;
|
||||
if (*a)
|
||||
if (*a != '\0')
|
||||
a++;
|
||||
attrs = *a;
|
||||
if (*a)
|
||||
if (*a != '\0')
|
||||
a++;
|
||||
g_strlcpy (last_fg, fg ? fg : "", sizeof (last_fg));
|
||||
g_strlcpy (last_bg, bg ? bg : "", sizeof (last_bg));
|
||||
g_strlcpy (last_attrs, attrs ? attrs : "", sizeof (last_attrs));
|
||||
g_strlcpy (last_fg, fg != NULL ? fg : "", sizeof (last_fg));
|
||||
g_strlcpy (last_bg, bg != NULL ? bg : "", sizeof (last_bg));
|
||||
g_strlcpy (last_attrs, attrs != NULL ? attrs : "", sizeof (last_attrs));
|
||||
c->keyword[0]->color = this_try_alloc_color_pair (fg, bg, attrs);
|
||||
c->keyword[0]->keyword = g_strdup (" ");
|
||||
check_not_a;
|
||||
@ -1080,16 +1074,16 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
r = tmp;
|
||||
}
|
||||
}
|
||||
else if (!strcmp (args[0], "spellcheck"))
|
||||
else if (strcmp (args[0], "spellcheck") == 0)
|
||||
{
|
||||
if (!c)
|
||||
if (c == NULL)
|
||||
{
|
||||
result = line;
|
||||
break;
|
||||
}
|
||||
c->spelling = TRUE;
|
||||
}
|
||||
else if (!strcmp (args[0], "keyword"))
|
||||
else if (strcmp (args[0], "keyword") == 0)
|
||||
{
|
||||
struct key_word *k;
|
||||
|
||||
@ -1097,30 +1091,30 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
break_a;
|
||||
check_a;
|
||||
k = r[num_contexts - 1]->keyword[num_words] = g_malloc0 (sizeof (struct key_word));
|
||||
if (!strcmp (*a, "whole"))
|
||||
if (strcmp (*a, "whole") == 0)
|
||||
{
|
||||
a++;
|
||||
k->whole_word_chars_left = g_strdup (whole_left);
|
||||
k->whole_word_chars_right = g_strdup (whole_right);
|
||||
}
|
||||
else if (!strcmp (*a, "wholeleft"))
|
||||
else if (strcmp (*a, "wholeleft") == 0)
|
||||
{
|
||||
a++;
|
||||
k->whole_word_chars_left = g_strdup (whole_left);
|
||||
}
|
||||
else if (!strcmp (*a, "wholeright"))
|
||||
else if (strcmp (*a, "wholeright") == 0)
|
||||
{
|
||||
a++;
|
||||
k->whole_word_chars_right = g_strdup (whole_right);
|
||||
}
|
||||
check_a;
|
||||
if (!strcmp (*a, "linestart"))
|
||||
if (strcmp (*a, "linestart") == 0)
|
||||
{
|
||||
a++;
|
||||
k->line_start = 1;
|
||||
}
|
||||
check_a;
|
||||
if (!strcmp (*a, "whole"))
|
||||
if (strcmp (*a, "whole") == 0)
|
||||
{
|
||||
break_a;
|
||||
}
|
||||
@ -1128,19 +1122,19 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
k->first = *k->keyword;
|
||||
subst_defines (edit->defines, a, &args[1024]);
|
||||
fg = *a;
|
||||
if (*a)
|
||||
if (*a != '\0')
|
||||
a++;
|
||||
bg = *a;
|
||||
if (*a)
|
||||
if (*a != '\0')
|
||||
a++;
|
||||
attrs = *a;
|
||||
if (*a)
|
||||
if (*a != '\0')
|
||||
a++;
|
||||
if (!fg)
|
||||
if (fg == NULL)
|
||||
fg = last_fg;
|
||||
if (!bg)
|
||||
if (bg == NULL)
|
||||
bg = last_bg;
|
||||
if (!attrs)
|
||||
if (attrs == NULL)
|
||||
attrs = last_attrs;
|
||||
k->color = this_try_alloc_color_pair (fg, bg, attrs);
|
||||
check_not_a;
|
||||
@ -1162,11 +1156,11 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
{
|
||||
/* do nothing for comment */
|
||||
}
|
||||
else if (!strcmp (args[0], "file"))
|
||||
else if (strcmp (args[0], "file") == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (!strcmp (args[0], "define"))
|
||||
else if (strcmp (args[0], "define") == 0)
|
||||
{
|
||||
char *key = *a++;
|
||||
char **argv;
|
||||
@ -1182,9 +1176,7 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
argv = g_new (char *, argc - 1);
|
||||
g_tree_insert (edit->defines, key, argv);
|
||||
while (*a != NULL)
|
||||
{
|
||||
*argv++ = g_strdup (*a++);
|
||||
}
|
||||
*argv = NULL;
|
||||
}
|
||||
else
|
||||
@ -1204,28 +1196,24 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
||||
r[num_contexts] = NULL;
|
||||
}
|
||||
|
||||
if (!edit->rules[0])
|
||||
if (edit->rules[0] == NULL)
|
||||
MC_PTR_FREE (edit->rules);
|
||||
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (num_contexts == -1)
|
||||
{
|
||||
return line;
|
||||
}
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
char *first_chars, *p;
|
||||
|
||||
if (num_contexts == -1)
|
||||
return line;
|
||||
|
||||
first_chars = g_malloc0 (max_alloc_words_per_context + 2);
|
||||
|
||||
for (i = 0; edit->rules[i]; i++)
|
||||
for (i = 0; edit->rules[i] != NULL; i++)
|
||||
{
|
||||
c = edit->rules[i];
|
||||
p = first_chars;
|
||||
*p++ = (char) 1;
|
||||
for (j = 1; c->keyword[j]; j++)
|
||||
for (j = 1; c->keyword[j] != NULL; j++)
|
||||
*p++ = c->keyword[j]->first;
|
||||
*p = '\0';
|
||||
c->keyword_first_chars = g_strdup (first_chars);
|
||||
@ -1265,7 +1253,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
|
||||
}
|
||||
|
||||
args[0] = NULL;
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
line++;
|
||||
MC_PTR_FREE (l);
|
||||
|
@ -230,7 +230,8 @@ static inline int
|
||||
line_pixel_length (unsigned char *t, long b, int l)
|
||||
{
|
||||
int x = 0, c, xn = 0;
|
||||
for (;;)
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
c = t[b];
|
||||
switch (c)
|
||||
@ -286,12 +287,15 @@ static inline int
|
||||
word_start (unsigned char *t, int q, int size)
|
||||
{
|
||||
int i = q;
|
||||
|
||||
if (t[q] == ' ' || t[q] == '\t')
|
||||
return next_word_start (t, q, size);
|
||||
for (;;)
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
int c;
|
||||
if (!i)
|
||||
|
||||
if (i == 0)
|
||||
return -1;
|
||||
c = t[i - 1];
|
||||
if (c == '\n')
|
||||
@ -309,13 +313,15 @@ static inline void
|
||||
format_this (unsigned char *t, int size, int indent)
|
||||
{
|
||||
int q = 0, ww;
|
||||
|
||||
strip_newlines (t, size);
|
||||
ww = option_word_wrap_line_length * FONT_MEAN_WIDTH - indent;
|
||||
if (ww < FONT_MEAN_WIDTH * 2)
|
||||
ww = FONT_MEAN_WIDTH * 2;
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
int p;
|
||||
|
||||
q = line_pixel_length (t, q, ww);
|
||||
if (q > size)
|
||||
break;
|
||||
@ -330,7 +336,7 @@ format_this (unsigned char *t, int size, int indent)
|
||||
q = p;
|
||||
if (q == -1) /* end of paragraph */
|
||||
break;
|
||||
if (q)
|
||||
if (q != 0)
|
||||
t[q - 1] = '\n';
|
||||
}
|
||||
}
|
||||
@ -353,6 +359,7 @@ put_paragraph (WEdit * edit, unsigned char *t, off_t p, int indent, int size)
|
||||
{
|
||||
long cursor;
|
||||
int i, c = 0;
|
||||
|
||||
cursor = edit->curs1;
|
||||
if (indent)
|
||||
while (strchr ("\t ", edit_get_byte (edit, p)))
|
||||
|
@ -893,7 +893,7 @@ get_line_at (int file_fd, char *buf, int buf_size, int *pos, int *n_read, gboole
|
||||
char ch = 0;
|
||||
int i = 0;
|
||||
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
if (*pos >= *n_read)
|
||||
{
|
||||
|
@ -1269,9 +1269,11 @@ safe_read (int fd, void *buf, size_t count)
|
||||
enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
|
||||
/* *INDENT-ON* */
|
||||
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
ssize_t result = read (fd, buf, count);
|
||||
ssize_t result;
|
||||
|
||||
result = read (fd, buf, count);
|
||||
|
||||
if (0 <= result)
|
||||
return result;
|
||||
|
@ -192,16 +192,17 @@ fish_load_script_from_file (const char *hostname, const char *script_name, const
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static int
|
||||
fish_decode_reply (char *s, int was_garbage)
|
||||
fish_decode_reply (char *s, gboolean was_garbage)
|
||||
{
|
||||
int code;
|
||||
if (!sscanf (s, "%d", &code))
|
||||
|
||||
if (sscanf (s, "%d", &code) == 0)
|
||||
{
|
||||
code = 500;
|
||||
return 5;
|
||||
}
|
||||
if (code < 100)
|
||||
return was_garbage ? ERROR : (!code ? COMPLETE : PRELIM);
|
||||
return was_garbage ? ERROR : (code == 0 ? COMPLETE : PRELIM);
|
||||
return code / 100;
|
||||
}
|
||||
|
||||
@ -212,25 +213,23 @@ static int
|
||||
fish_get_reply (struct vfs_class *me, int sock, char *string_buf, int string_len)
|
||||
{
|
||||
char answer[BUF_1K];
|
||||
int was_garbage = 0;
|
||||
gboolean was_garbage = FALSE;
|
||||
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
if (!vfs_s_get_line (me, sock, answer, sizeof (answer), '\n'))
|
||||
{
|
||||
if (string_buf)
|
||||
*string_buf = 0;
|
||||
if (string_buf != NULL)
|
||||
*string_buf = '\0';
|
||||
return 4;
|
||||
}
|
||||
|
||||
if (strncmp (answer, "### ", 4))
|
||||
{
|
||||
was_garbage = 1;
|
||||
if (string_buf)
|
||||
g_strlcpy (string_buf, answer, string_len);
|
||||
}
|
||||
else
|
||||
return fish_decode_reply (answer + 4, was_garbage);
|
||||
if (strncmp (answer, "### ", 4) == 0)
|
||||
return fish_decode_reply (answer + 4, was_garbage ? 1 : 0);
|
||||
|
||||
was_garbage = TRUE;
|
||||
if (string_buf != NULL)
|
||||
g_strlcpy (string_buf, answer, string_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,31 +377,31 @@ ftpfs_get_reply (struct vfs_class *me, int sock, char *string_buf, int string_le
|
||||
char answer[BUF_1K];
|
||||
int i;
|
||||
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
if (!vfs_s_get_line (me, sock, answer, sizeof (answer), '\n'))
|
||||
{
|
||||
if (string_buf)
|
||||
*string_buf = 0;
|
||||
if (string_buf != NULL)
|
||||
*string_buf = '\0';
|
||||
code = 421;
|
||||
return 4;
|
||||
}
|
||||
switch (sscanf (answer, "%d", &code))
|
||||
switch (sscanf (answer, "%d", &code) != 0)
|
||||
{
|
||||
case 0:
|
||||
if (string_buf)
|
||||
if (string_buf != NULL)
|
||||
g_strlcpy (string_buf, answer, string_len);
|
||||
code = 500;
|
||||
return 5;
|
||||
case 1:
|
||||
if (answer[3] == '-')
|
||||
{
|
||||
while (1)
|
||||
while (TRUE)
|
||||
{
|
||||
if (!vfs_s_get_line (me, sock, answer, sizeof (answer), '\n'))
|
||||
{
|
||||
if (string_buf)
|
||||
*string_buf = 0;
|
||||
if (string_buf != NULL)
|
||||
*string_buf = '\0';
|
||||
code = 421;
|
||||
return 4;
|
||||
}
|
||||
@ -409,7 +409,7 @@ ftpfs_get_reply (struct vfs_class *me, int sock, char *string_buf, int string_le
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (string_buf)
|
||||
if (string_buf != NULL)
|
||||
g_strlcpy (string_buf, answer, string_len);
|
||||
return code / 100;
|
||||
}
|
||||
@ -432,7 +432,6 @@ ftpfs_reconnect (struct vfs_class *me, struct vfs_s_super *super)
|
||||
SUP->sock = sock;
|
||||
SUP->current_dir = NULL;
|
||||
|
||||
|
||||
if (ftpfs_login_server (me, super, super->path_element->password) != 0)
|
||||
{
|
||||
if (cwdir == NULL)
|
||||
|
@ -765,7 +765,7 @@ tar_open_archive (struct vfs_s_super *archive, const vfs_path_t * vpath,
|
||||
if (tard == -1)
|
||||
return -1;
|
||||
|
||||
for (;;)
|
||||
while (TRUE)
|
||||
{
|
||||
size_t h_size;
|
||||
|
||||
@ -774,7 +774,6 @@ tar_open_archive (struct vfs_s_super *archive, const vfs_path_t * vpath,
|
||||
|
||||
switch (status)
|
||||
{
|
||||
|
||||
case STATUS_SUCCESS:
|
||||
tar_skip_n_records (archive, tard, (h_size + RECORDSIZE - 1) / RECORDSIZE);
|
||||
continue;
|
||||
@ -788,7 +787,6 @@ tar_open_archive (struct vfs_s_super *archive, const vfs_path_t * vpath,
|
||||
case STATUS_BADCHECKSUM:
|
||||
switch (prev_status)
|
||||
{
|
||||
|
||||
/* Error on first record */
|
||||
case STATUS_EOFMARK:
|
||||
{
|
||||
@ -818,7 +816,7 @@ tar_open_archive (struct vfs_s_super *archive, const vfs_path_t * vpath,
|
||||
break;
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user