Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 596026 Details for
Bug 699530
openrc-settingsd generates incorrect 02locale
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch 2
fix-shellparser.patch (text/plain), 5.64 KB, created by
Pierre Labastie
on 2019-11-13 21:22:47 UTC
(
hide
)
Description:
Proposed patch 2
Filename:
MIME Type:
Creator:
Pierre Labastie
Created:
2019-11-13 21:22:47 UTC
Size:
5.64 KB
patch
obsolete
>From b912b457a33a3bd6a82481ddf767e72564d67683 Mon Sep 17 00:00:00 2001 >From: Pierre Labastie <pierre.labastie@neuf.fr> >Date: Thu, 7 Nov 2019 16:50:18 +0100 >Subject: [PATCH] Add a separator before creating a variable > >In shell_parser_set_variable, when the variable name does not exist, >it is added to the parser. This leads to an incorrect syntax if >there is no separator before (the beginning of the file is considered >as a separator). So add one in this case >--- > src/utils.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 79 insertions(+), 2 deletions(-) > >diff --git a/src/utils.c b/src/utils.c >index f76c335..13edc86 100644 >--- a/src/utils.c >+++ b/src/utils.c >@@ -489,14 +489,56 @@ shell_parser_set_variable (ShellParser *parser, > if (found_entry != NULL) { > g_free (found_entry->string); > found_entry->string = g_strdup_printf ("%s=%s", variable, quoted_value); >+ g_free (found_entry->unquoted_value); >+ found_entry->unquoted_value = g_strdup (value); > ret = TRUE; > } else { > if (add_if_unset) { >+ GList *appended; >+ GList *last = g_list_last (parser->entry_list); >+ struct ShellEntry *last_entry = NULL; >+ if (last != NULL) >+ last_entry = (struct ShellEntry *)last->data; >+/* Add a separator before the new variable if there is none */ >+ if (last_entry != NULL && >+ last_entry->type != SHELL_ENTRY_TYPE_SEPARATOR && >+ last_entry->type != SHELL_ENTRY_TYPE_COMMENT) { >+ last_entry = g_new0 (struct ShellEntry, 1); >+ last_entry->type = SHELL_ENTRY_TYPE_SEPARATOR; >+ last_entry->string = g_strdup ("\n"); >+ appended = g_list_alloc(); >+ appended->prev = last; >+ appended->next = NULL; >+ appended->data = (gpointer)last_entry; >+ last->next = appended; >+ last = appended; >+ } >+/* Add a the new variable at the end of the parser */ > found_entry = g_new0 (struct ShellEntry, 1); > found_entry->type = SHELL_ENTRY_TYPE_ASSIGNMENT; > found_entry->variable = g_strdup (variable); >- found_entry->string = g_strdup_printf ("%s=%s", variable, quoted_value); >- parser->entry_list = g_list_append (parser->entry_list, found_entry); >+ found_entry->unquoted_value = g_strdup (value); >+ found_entry->string = g_strdup_printf ("%s=%s", variable, >+ quoted_value); >+ appended = g_list_alloc(); >+ appended->prev = last; >+ appended->next = NULL; >+ appended->data = (gpointer)found_entry; >+ if (last != NULL) >+ last->next = appended; >+ else >+ parser->entry_list = appended; /* parser was empty */ >+/* Add a separator at the end of the parser */ >+ last = appended; >+ last_entry = g_new0 (struct ShellEntry, 1); >+ last_entry->type = SHELL_ENTRY_TYPE_SEPARATOR; >+ last_entry->string = g_strdup ("\n"); >+ appended = g_list_alloc(); >+ appended->prev = last; >+ appended->next = NULL; >+ appended->data = (gpointer)last_entry; >+ last->next = appended; >+ > ret = TRUE; > } > } >@@ -527,8 +569,43 @@ shell_parser_clear_variable (ShellParser *parser, > curr->prev = NULL; > curr->next = NULL; > g_list_free_full (curr, (GDestroyNotify)shell_entry_free); >+ /* for a normal variable assignment, there is a separator >+ * before and a separator after, so that we need to remove >+ * one (otherwise, after a while, the file while have a lot >+ * of blank lines!), but we need to choose which one. Things are >+ * slightly more complicated, because one or both separators >+ * may be comments, which we do not want to remove, and also, >+ * we may be at the end or the beginning of the file: >+ * - if we are at the beginning of the file, remove next, >+ * except if next is a comment >+ * - if we are at the end of file or if next is a comment, >+ * remove prev, except if prev is a comment >+ * - if the preceding is a comment, remove next, >+ * except if it is a comment >+ * - it may happen that both prev and next are NULL, in which >+ * case, we do not remove anything. >+ * Summary: if next is a separator, remove it, else, if prev >+ * is a separator, remove it. >+ */ >+ if (next != NULL && >+ ((struct ShellEntry*)next->data)->type == >+ SHELL_ENTRY_TYPE_SEPARATOR) { >+ GList *next_next = next->next; >+ next->prev = next->next = NULL; >+ g_list_free_full (next, (GDestroyNotify)shell_entry_free); >+ next = next_next; >+ } else if (prev != NULL && >+ ((struct ShellEntry*)next->data)->type == >+ SHELL_ENTRY_TYPE_SEPARATOR) { >+ GList *prev_prev=prev->prev; >+ prev->prev = prev->next = NULL; >+ g_list_free_full (prev, (GDestroyNotify)shell_entry_free); >+ prev = prev_prev; >+ } > if (prev != NULL) > prev->next = next; >+ else >+ parser->entry_list = next; > if (next != NULL) > next->prev = prev; > curr = next; >-- >2.23.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 699530
:
595222
|
595512
| 596026