From: Eugene Syromyatnikov Date: Mon, 3 Oct 2016 18:35:45 +0000 (+0300) Subject: Add printstr_ex which allows for providing user quotation style X-Git-Tag: v4.14~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee70a1baac4a53e5b4f962d482a5db76d711c922;p=strace Add printstr_ex which allows for providing user quotation style This is useful for providing QUOTE_OMIT_TRAILING_0 and maybe other flags. * defs.h (printstr_ex): New prototype. (printstr): Change to a wrapper around printstr_ex with zero user style. * util.c (printstr): Rename to ... (printstr_ex) ... new function, add user_style argument which is or'ed with computed style. --- diff --git a/defs.h b/defs.h index d35d7cf8..62f38b23 100644 --- a/defs.h +++ b/defs.h @@ -563,7 +563,8 @@ extern void dumpiov_upto(struct tcb *, int, long, unsigned long); #define dumpiov(tcp, len, addr) \ dumpiov_upto((tcp), (len), (addr), (unsigned long) -1L) extern void dumpstr(struct tcb *, long, int); -extern void printstr(struct tcb *, long, long); +extern void printstr_ex(struct tcb *, long addr, long len, + unsigned int user_style); extern bool printnum_short(struct tcb *, long, const char *) ATTRIBUTE_FORMAT((printf, 3, 0)); extern bool printnum_int(struct tcb *, long, const char *) @@ -669,6 +670,12 @@ extern void unwind_print_stacktrace(struct tcb* tcp); extern void unwind_capture_stacktrace(struct tcb* tcp); #endif +static inline void +printstr(struct tcb *tcp, long addr, long len) +{ + printstr_ex(tcp, addr, len, 0); +} + static inline int printflags(const struct xlat *x, unsigned int flags, const char *dflt) { diff --git a/util.c b/util.c index 39abcc61..23a5fdbf 100644 --- a/util.c +++ b/util.c @@ -798,7 +798,7 @@ printpath(struct tcb *tcp, long addr) * If string length exceeds `max_strlen', append `...' to the output. */ void -printstr(struct tcb *tcp, long addr, long len) +printstr_ex(struct tcb *tcp, long addr, long len, unsigned int user_style) { static char *str = NULL; static char *outstr; @@ -842,6 +842,8 @@ printstr(struct tcb *tcp, long addr, long len) style = 0; } + style |= user_style; + /* If string_quote didn't see NUL and (it was supposed to be ASCIZ str * or we were requested to print more than -s NUM chars)... */