mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-15 02:10:32 +01:00
ifcfg-rh: add svSetValueFull() to support writing empty values
svSetValue() treated the empty word like %NULL.
Handle empty differently from unset.
(cherry picked from commit 0348bc9195)
This commit is contained in:
parent
7a98e481d9
commit
c933bacd4a
2 changed files with 10 additions and 1 deletions
|
|
@ -368,6 +368,14 @@ svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 m
|
|||
*/
|
||||
void
|
||||
svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim)
|
||||
{
|
||||
svSetValueFull (s, key, value && value[0] ? value : NULL, verbatim);
|
||||
}
|
||||
|
||||
/* Same as svSetValue() but it preserves empty @value -- contrary to
|
||||
* svSetValue() for which "" effectively means to remove the value. */
|
||||
void
|
||||
svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verbatim)
|
||||
{
|
||||
gs_free char *newval_free = NULL;
|
||||
gs_free char *oldval = NULL;
|
||||
|
|
@ -384,7 +392,7 @@ svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim)
|
|||
newval = svEscape (value, &newval_free);
|
||||
oldval = svGetValueFull (s, key, FALSE);
|
||||
|
||||
if (!newval || !newval[0]) {
|
||||
if (!newval) {
|
||||
/* delete value */
|
||||
if (oldval) {
|
||||
/* delete line */
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ gint64 svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, g
|
|||
* to the top of the file.
|
||||
*/
|
||||
void svSetValue (shvarFile *s, const char *key, const char *value, gboolean verbatim);
|
||||
void svSetValueFull (shvarFile *s, const char *key, const char *value, gboolean verbatim);
|
||||
|
||||
|
||||
/* Write the current contents iff modified. Returns FALSE on error
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue