(get_first_editor_line): minor refactoring.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-10-10 12:52:22 +04:00
parent 8883273bdd
commit 7f7a75f988
1 changed files with 14 additions and 10 deletions

View File

@ -1386,26 +1386,30 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static char * static const char *
get_first_editor_line (WEdit * edit) get_first_editor_line (WEdit * edit)
{ {
size_t i;
static char s[256]; static char s[256];
s[0] = '\0'; s[0] = '\0';
if (edit == NULL)
return s;
for (i = 0; i < sizeof (s) - 1; i++) if (edit != NULL)
{ {
s[i] = edit_get_byte (edit, i); size_t i;
if (s[i] == '\n')
for (i = 0; i < sizeof (s) - 1; i++)
{ {
s[i] = '\0'; s[i] = edit_get_byte (edit, i);
break; if (s[i] == '\n')
{
s[i] = '\0';
break;
}
} }
s[sizeof (s) - 1] = '\0';
} }
s[sizeof (s) - 1] = '\0';
return s; return s;
} }