summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-11-07 18:42:29 +0100
committerThomas Haller <thaller@redhat.com>2016-11-09 12:07:34 +0100
commit337fc582b2d119200d71a7bfcc110e60a3ee2d77 (patch)
treebdf41dc8ad9fbaea20199c93ab01599933c99417
parentc55b7e866efe069e01a4af6953a2fd783caf1c71 (diff)
downloadNetworkManager-337fc582b2d119200d71a7bfcc110e60a3ee2d77.tar.gz
ifcfg-rh: use macro _char_in_strset() for svEscape()
-rw-r--r--src/settings/plugins/ifcfg-rh/shvar.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c
index 886e301659..c49cda6a54 100644
--- a/src/settings/plugins/ifcfg-rh/shvar.c
+++ b/src/settings/plugins/ifcfg-rh/shvar.c
@@ -172,6 +172,8 @@ _escape_ansic (const char *source)
/*****************************************************************************/
+#define _char_in_strset(ch, str) (!!strchr (""str"", (ch)))
+
#define ESC_ESCAPEES "\"'\\$~`" /* must be escaped */
#define ESC_SPACES " \t|&;()<>" /* only require "" */
@@ -187,11 +189,11 @@ svEscape (const char *s, char **to_free)
slen = strlen (s);
for (i = 0; i < slen; i++) {
- if (strchr (ESC_ESCAPEES, s[i]))
+ if (_char_in_strset (s[i], ESC_ESCAPEES))
mangle++;
- if (strchr (ESC_SPACES, s[i]))
+ else if (_char_in_strset (s[i], ESC_SPACES))
has_space = TRUE;
- if (s[i] < ' ') {
+ else if (s[i] < ' ') {
/* if the string contains newline we can only express it using ANSI C quotation
* (as we don't support line continuation).
* Additionally, ANSI control characters look odd with regular quotation, so handle
@@ -210,7 +212,7 @@ svEscape (const char *s, char **to_free)
j = 0;
new[j++] = '"';
for (i = 0; i < slen; i++) {
- if (strchr (ESC_ESCAPEES, s[i])) {
+ if (_char_in_strset (s[i], ESC_ESCAPEES)) {
new[j++] = '\\';
}
new[j++] = s[i];