Commit 72d51976 authored by unknown's avatar unknown

NdbRecAttr.cpp:

  improved printout routine


ndb/src/ndbapi/NdbRecAttr.cpp:
  improved printout routine
parent 22c23f22
...@@ -141,40 +141,29 @@ static void ...@@ -141,40 +141,29 @@ static void
ndbrecattr_print_string(NdbOut& out, const char *type, ndbrecattr_print_string(NdbOut& out, const char *type,
const char *ref, unsigned sz) const char *ref, unsigned sz)
{ {
int i; int i, len, printable= 1;
// trailing zeroes are not printed // trailing zeroes are not printed
for (i=sz-1; i >= 0; i--) for (i=sz-1; i >= 0; i--)
if (ref[i] == 0) sz--; if (ref[i] == 0) sz--;
else break; else break;
if (sz == 0) return; // empty if (sz == 0) return; // empty
char *str= (char*)malloc(sz+1); for (len=0; len < (int)sz && ref[i] != 0; len++)
memcpy(str, ref, sz); if (printable && !isprint((int)ref[i]))
str[sz]= 0; // null terminate
int len= strlen(str);
int printable= 1;
for (i=0; i < len; i++)
{
if (str[i] < 32) {
printable= 0; printable= 0;
break;
}
}
if (printable) if (printable)
out.print("%.*s", len, str); out.print("%.*s", len, ref);
else else
{
for (i=0; i < len; i++) for (i=0; i < len; i++)
out.print("%02X", (int)str[i]); out.print("%02X", (int)ref[i]);
}
free(str);
if (len != (int)sz) if (len != (int)sz)
{ {
out.print("["); out.print("[");
for (i= len+1; ref[i] != 0; i++) for (i= len+1; ref[i] != 0; i++)
out.print("%u]",len-i); out.print("%u]",len-i);
assert(sz > i); assert((int)sz > i);
ndbrecattr_print_string(out,type,ref+i,sz-i); ndbrecattr_print_string(out,type,ref+i,sz-i);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment