]> granicus.if.org Git - strace/commitdiff
Add printstr_ex which allows for providing user quotation style
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 3 Oct 2016 18:35:45 +0000 (21:35 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 3 Oct 2016 21:50:33 +0000 (21:50 +0000)
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.

defs.h
util.c

diff --git a/defs.h b/defs.h
index d35d7cf8bd113cb3ea63ee9545c20e2d7a60b462..62f38b23980475f87d9803efc088d9e52703f559 100644 (file)
--- 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 39abcc6127cf973bb07002113662769ad7fe8f6c..23a5fdbfd04907112dfe1421e4608dd3db7e73ca 100644 (file)
--- 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)...
         */