diff options
author | Jordan Justen <jordan.l.justen@intel.com> | 2017-04-06 11:07:13 -0700 |
---|---|---|
committer | Jordan Justen <jordan.l.justen@intel.com> | 2017-04-06 13:36:10 -0700 |
commit | c1ddf71fa26d6067a3f289a755185866e9249331 (patch) | |
tree | b645d0a8819931274f9fd9ff0f00747d6b8b1a08 | |
parent | 5bcc001c639eab5d39d7a791e60d02e793532c41 (diff) |
intel/aubinator_error_decode: Avoid exit when using a pageraubinator
I have an error state which includes an ascii85 section that fails to
decode. If we exit early when using a pager, it confuses the terminal.
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
-rw-r--r-- | src/intel/tools/aubinator_error_decode.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c index 21386fef8a..5ce6932f2b 100644 --- a/src/intel/tools/aubinator_error_decode.c +++ b/src/intel/tools/aubinator_error_decode.c @@ -52,6 +52,7 @@ static bool option_full_decode = true; static bool option_print_offsets = true; static enum { COLOR_AUTO, COLOR_ALWAYS, COLOR_NEVER } option_color; static char *xml_path = NULL; +static bool pager = false; static uint32_t print_head(unsigned int reg) @@ -427,8 +428,12 @@ read_data_file(FILE *file) if (ascii85_start) { count = ascii85_decode(line+1, &data, line[0] == ':'); if (count == 0) { - fprintf(stderr, "ASCII85 decode failed.\n"); - exit(1); + fprintf(pager ? stdout : stderr, + "ascii85 decode failed on line %d\n", line_number); + if (pager) + continue; + else + exit(1); } decode(spec, buffer_name, ring_name, @@ -608,7 +613,7 @@ main(int argc, char *argv[]) const char *path; struct stat st; int c, i, error; - bool help = false, pager = true; + bool help = false; const struct option aubinator_opts[] = { { "help", no_argument, (int *) &help, true }, { "no-pager", no_argument, (int *) &pager, false }, @@ -619,6 +624,7 @@ main(int argc, char *argv[]) { NULL, 0, NULL, 0 } }; + pager = true; i = 0; while ((c = getopt_long(argc, argv, "", aubinator_opts, &i)) != -1) { switch (c) { @@ -682,7 +688,9 @@ main(int argc, char *argv[]) if (option_color == COLOR_AUTO) option_color = isatty(1) ? COLOR_ALWAYS : COLOR_NEVER; - if (isatty(1) && pager) + if (!isatty(1)) + pager = false; + if (pager) setup_pager(); if (S_ISDIR(st.st_mode)) { |