0 Replies Latest reply: Jun 23, 2012 9:15 AM by 853849 RSS

    db_printlog : ambiguous output

    853849
      The db_printlog output for DBT data produces ambiguous output which makes interpretation difficult.

      The auto generated code for DBT data uses the following :

      // from __bam_repl_print (v 4.8.26)

      for (i = 0; i < argp->repl.size; i++) {
                ch = ((u_int8_t *)argp->repl.data);
                printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
           }

      When c == 0, the output is "0 " which is per the C language. From Kernighan and Ritchie, "#, which specifies an alternate output form. For o, the first digit will be zero. For x or X, 0x or 0X will be prefixed to a non-zero result ..."

      The same output is generated if the dbt contains the sequence "0" (not binary 0, but ascii 0) followed by a space - in this case, both are printable and so the output is once again "0 ".

      A fix would be to not rely on the # flag of printf and instead write it as

      for (i = 0; i < argp->repl.size; i++) {
                ch = ((u_int8_t *)argp->repl.data)[i];
                printf(isprint(ch) || ch == 0x0a ? "%c" : "0x%x ", ch);
           }

      This will produce output that can be parsed without ambiguity.


      Kimman