]> granicus.if.org Git - strace/commit
util.c: add support for additional escape characters in string_quote
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 2 Feb 2018 17:46:29 +0000 (18:46 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 1 Mar 2018 01:00:24 +0000 (01:00 +0000)
commit0b732f7e9dd0b3c6b7a5300c71b82ece3b2e3997
tree7c9e2257ea19724135e3cafb701cd9b0e99b7269
parente196eebea44494a79e8ba39c005502f2069185fc
util.c: add support for additional escape characters in string_quote

Quotes are not always used to denote string limits; printfd uses angle
brackets for that, for example.  As result, mechanism for supplying
set of additional characters in order to avoid ambiguities regarding
the end of the quoted string is needed.

* defs.h (string_quote): Add escape_chars parameter.
(print_quoted_string_ex): New function prototype.
* util.c (string_quote): Add escape_chars parameter.
(print_quoted_string_ex): Rename from print_quoted_string, add
escape_chars parameter, pass it to string_quote call.
(print_quoted_string): Turn into a thin wrapper around
print_quoted_string_ex.
(printstr_ex): Pass NULL as escape_chars argument of string_quote call.
* socketutils.c (unix_parse_response): Pass NULL as escape_chars
argument of string_quote call.
* tests/print_quoted_string.c (print_octal): New function.
print_quoted_memory_ex): Use it.  Add escape_chars parameter.
(print_quoted_memory): Pass NULL as escape_chars argument
of print_quoted_memory_ex call.
* tests/tests.h (print_quoted_string_ex, print_quoted_memory_ex): Add
escape_chars parameter.
* tests/fsync-y.c: Pass NULL as escape_chars argument of
print_quoted_string_ex call.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
defs.h
socketutils.c
tests/fsync-y.c
tests/print_quoted_string.c
tests/tests.h
util.c