mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-14 22:40:35 +01:00
ifcfg-rh: avoid creating temporary string prefix for svGetValueFull()
This commit is contained in:
parent
487dcf7e55
commit
d7b4733d3e
1 changed files with 4 additions and 7 deletions
|
|
@ -271,26 +271,23 @@ svGetValueFull (shvarFile *s, const char *key, gboolean verbatim)
|
|||
{
|
||||
char *value = NULL;
|
||||
char *line;
|
||||
char *keyString;
|
||||
int len;
|
||||
guint len;
|
||||
|
||||
g_return_val_if_fail (s != NULL, NULL);
|
||||
g_return_val_if_fail (key != NULL, NULL);
|
||||
|
||||
keyString = g_strdup_printf ("%s=", key);
|
||||
len = strlen (keyString);
|
||||
len = strlen (key);
|
||||
|
||||
for (s->current = s->lineList; s->current; s->current = s->current->next) {
|
||||
line = s->current->data;
|
||||
if (!strncmp (keyString, line, len)) {
|
||||
if (!strncmp (key, line, len) && line[len] == '=') {
|
||||
/* Strip trailing spaces before unescaping to preserve spaces quoted whitespace */
|
||||
value = g_strchomp (g_strdup (line + len));
|
||||
value = g_strchomp (g_strdup (line + len + 1));
|
||||
if (!verbatim)
|
||||
svUnescape (value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_free (keyString);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue