mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
MFC jls: fix the -q option to put quotes around all whitespace
PR: 283414 (cherry picked from commit 3d11af1e595b5a3646be370e33c4aa850dc62bb0)
This commit is contained in:
parent
486af41443
commit
dc384b9622
1 changed files with 15 additions and 6 deletions
|
|
@ -38,6 +38,7 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <jail.h>
|
||||
|
|
@ -516,13 +517,21 @@ quoted_print(int pflags, char *name, char *value)
|
|||
}
|
||||
|
||||
/*
|
||||
* The value will be surrounded by quotes if it contains spaces
|
||||
* or quotes.
|
||||
* The value will be surrounded by quotes if it contains
|
||||
* whitespace or quotes.
|
||||
*/
|
||||
qc = strchr(p, '\'') ? '"'
|
||||
: strchr(p, '"') ? '\''
|
||||
: strchr(p, ' ') || strchr(p, '\t') ? '"'
|
||||
: 0;
|
||||
if (strchr(p, '\''))
|
||||
qc = '"';
|
||||
else if (strchr(p, '"'))
|
||||
qc = '\'';
|
||||
else {
|
||||
qc = 0;
|
||||
for (; *p; ++p)
|
||||
if (isspace(*p)) {
|
||||
qc = '"';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (qc && pflags & PRINT_QUOTED)
|
||||
xo_emit("{P:/%c}", qc);
|
||||
|
|
|
|||
Loading…
Reference in a new issue