Hi Heinrich, On 22 December 2016 at 10:54, Heinrich Schuchardt <xypron.glpk@xxxxxx> wrote: > A new command line option is added > -c, --color <arg> Colorize, argument can be auto, never or always > which defaults to auto. > > For colored output in pipes use 'always', e.g. > fdtdump -c always file.dtb | less -R > > If you don't like colors use > alias fdtdump="fdtdump -c none" > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@xxxxxx> > --- > Makefile | 2 +- > fdtdump.c | 37 +++++++++++++++++++++++++++++++++---- > util.c | 12 +++++++----- > util.h | 8 ++++++++ > 4 files changed, 49 insertions(+), 10 deletions(-) > Reviewed-by: Simon Glass <sjg@xxxxxxxxxxxx> But please see below. > diff --git a/Makefile b/Makefile > index 32dcfcf..ee543b9 100644 > --- a/Makefile > +++ b/Makefile > @@ -18,7 +18,7 @@ CONFIG_LOCALVERSION = > CPPFLAGS = -I libfdt -I . > WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \ > -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow > -CFLAGS = -g -Os -fPIC -Werror $(WARNINGS) > +CFLAGS = -g -Os -fPIC -Werror $(WARNINGS) -lncurses > > BISON = bison > LEX = flex > diff --git a/fdtdump.c b/fdtdump.c > index 717fef5..59194cd 100644 > --- a/fdtdump.c > +++ b/fdtdump.c > @@ -2,6 +2,9 @@ > * fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com> > */ > > +#include <unistd.h> > +#include <curses.h> > +#include <term.h> > #include <stdbool.h> > #include <stdint.h> > #include <stdio.h> > @@ -63,7 +66,7 @@ static void dump_blob(void *blob, bool debug) > depth = 0; > shift = 4; > > - printf("/dts-v1/;\n"); > + printf("%s/dts-v1/;\n", COLNONE); > printf("// magic:\t\t0x%x\n", fdt32_to_cpu(bph->magic)); > printf("// totalsize:\t\t0x%x (%d)\n", totalsize, totalsize); > printf("// off_dt_struct:\t0x%x\n", off_dt); > @@ -104,10 +107,11 @@ static void dump_blob(void *blob, bool debug) > s = p; > p = PALIGN(p + strlen(s) + 1, 4); > > + printf("%s", COLNODE); Another option would be to make COLNODE a function that returns either "" or an ANSI string, depending on the setting of 'colored'. Then you can avoid the global variable. E.g.: char str[ANSI_LEN]; printf("%s", get_ansi(str, COL_NODE)); > if (*s == '\0') > s = "/"; > Regards, Simon -- To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html