mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
(edit_read_syntax_rules): minor refactoring of keyword first chars collect.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
172196d16a
commit
32cfbfaef1
@ -1199,28 +1199,28 @@ edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size)
|
|||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *first_chars;
|
GString *first_chars;
|
||||||
|
|
||||||
if (num_contexts == -1)
|
if (num_contexts == -1)
|
||||||
return line;
|
return line;
|
||||||
|
|
||||||
first_chars = g_malloc0 (max_alloc_words_per_context + 2);
|
first_chars = g_string_sized_new (max_alloc_words_per_context + 2);
|
||||||
|
|
||||||
for (i = 0; edit->rules[i] != NULL; i++)
|
for (i = 0; edit->rules[i] != NULL; i++)
|
||||||
{
|
{
|
||||||
char *p;
|
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
g_string_set_size (first_chars, 0);
|
||||||
c = edit->rules[i];
|
c = edit->rules[i];
|
||||||
p = first_chars;
|
|
||||||
*p++ = (char) 1;
|
g_string_append_c (first_chars, (char) 1);
|
||||||
for (j = 1; c->keyword[j] != NULL; j++)
|
for (j = 1; c->keyword[j] != NULL; j++)
|
||||||
*p++ = c->keyword[j]->first;
|
g_string_append_c (first_chars, c->keyword[j]->first);
|
||||||
*p = '\0';
|
|
||||||
c->keyword_first_chars = g_strdup (first_chars);
|
c->keyword_first_chars = g_strndup (first_chars->str, first_chars->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (first_chars);
|
g_string_free (first_chars, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user