modified bts2str to also escape double quotes
This commit is contained in:
parent
8e7e1320ac
commit
b909bb629b
2 changed files with 2 additions and 1 deletions
|
@ -19,7 +19,7 @@ bts2str(b, n, s)
|
||||||
|
|
||||||
while (n-- > 0) {
|
while (n-- > 0) {
|
||||||
if (is_print(*f)) {
|
if (is_print(*f)) {
|
||||||
if (*f == '\\') *t++ = *f;
|
if (*f == '\\' || *f == '"') *t++ = '\\';
|
||||||
*t++ = *f++;
|
*t++ = *f++;
|
||||||
} else {
|
} else {
|
||||||
*t++ = '\\';
|
*t++ = '\\';
|
||||||
|
|
|
@ -156,6 +156,7 @@ into a null-terminated string, starting at
|
||||||
.IR s .
|
.IR s .
|
||||||
Printable characters are copied and non-printable characters are transformed
|
Printable characters are copied and non-printable characters are transformed
|
||||||
into sequences of printable characters, representing those characters.
|
into sequences of printable characters, representing those characters.
|
||||||
|
Also, back-slashes and double quotes are escaped with a back-slash.
|
||||||
The transformation agrees with the representation of non-printable
|
The transformation agrees with the representation of non-printable
|
||||||
characters in C strings.
|
characters in C strings.
|
||||||
.br
|
.br
|
||||||
|
|
Loading…
Reference in a new issue