mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 07:50:16 +01:00
ifcfg-rh: add svSetValueFull() to support writing empty values
svSetValue() treated the empty word like %NULL. Handle empty differently from unset.
This commit is contained in:
parent
51255d8b64
commit
0348bc9195
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