Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Do not include escape sequences in color_vfprintf return

color_vprintf was including the length of the invisible escape sequences
in its return argument. Don't include them to make the return value
usable for indentation calculations.

v2: Add comment, rebase

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1438649408-20807-3-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Andi Kleen and committed by
Arnaldo Carvalho de Melo
b7a001d2 8011de7a

+3 -2
+3 -2
tools/perf/util/color.c
··· 67 67 return r; 68 68 } 69 69 70 + /* Colors are not included in return value */ 70 71 static int __color_vfprintf(FILE *fp, const char *color, const char *fmt, 71 72 va_list args) 72 73 { ··· 84 83 } 85 84 86 85 if (perf_use_color_default && *color) 87 - r += fprintf(fp, "%s", color); 86 + fprintf(fp, "%s", color); 88 87 r += vfprintf(fp, fmt, args); 89 88 if (perf_use_color_default && *color) 90 - r += fprintf(fp, "%s", PERF_COLOR_RESET); 89 + fprintf(fp, "%s", PERF_COLOR_RESET); 91 90 return r; 92 91 } 93 92