From 7f7a75f988c030e67cbd6909283d98ea8fdabdaf Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 10 Oct 2012 12:52:22 +0400 Subject: [PATCH] (get_first_editor_line): minor refactoring. Signed-off-by: Andrew Borodin --- src/editor/syntax.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/editor/syntax.c b/src/editor/syntax.c index 949130ed2..50cf3dcdb 100644 --- a/src/editor/syntax.c +++ b/src/editor/syntax.c @@ -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) { - size_t i; static char s[256]; 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); - if (s[i] == '\n') + size_t i; + + for (i = 0; i < sizeof (s) - 1; i++) { - s[i] = '\0'; - break; + s[i] = edit_get_byte (edit, i); + if (s[i] == '\n') + { + s[i] = '\0'; + break; + } } + + s[sizeof (s) - 1] = '\0'; } - s[sizeof (s) - 1] = '\0'; + return s; }