ifcfg: use nm_ascii_is_ctrl() helper in shvar.c

No change in behavior.
This commit is contained in:
Thomas Haller 2021-07-16 08:29:06 +02:00
parent 4b21056fde
commit 6841bb1b26
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -172,7 +172,7 @@ _escape_ansic(const char *source)
n_alloc += 2;
break;
default:
if ((*p < ' ') || (*p >= 0177))
if (!nm_ascii_is_regular(*p))
n_alloc += 4;
else
n_alloc += 1;
@ -221,7 +221,7 @@ _escape_ansic(const char *source)
*q++ = *p;
break;
default:
if ((*p < ' ') || (*p >= 0177)) {
if (!nm_ascii_is_regular(*p)) {
*q++ = '\\';
*q++ = '0' + (((*p) >> 6) & 07);
*q++ = '0' + (((*p) >> 3) & 07);
@ -262,13 +262,13 @@ svEscape(const char *s, char **to_free)
mangle++;
else if (_char_req_quotes(s[slen]))
requires_quotes = TRUE;
else if (((guchar) s[slen]) < ' ') {
else if (nm_ascii_is_ctrl(s[slen])) {
/* 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
* them too. */
return (*to_free = _escape_ansic(s));
} else if (((guchar) s[slen]) >= 0177) {
} else if (nm_ascii_is_non_ascii(s[slen])) {
all_ascii = FALSE;
requires_quotes = TRUE;
}