summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 97cbe3c)
raw | patch | inline | side by side (parent: 97cbe3c)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 18:23:26 +0000 (20:23 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 18:23:26 +0000 (20:23 +0200) |
src/core/data.c | patch | blob | history | |
t/unit/core/data_test.c | patch | blob | history |
diff --git a/src/core/data.c b/src/core/data.c
index 1188b4030ba4215304c4f7a47ae25e68a5feb49f..a57c8c6affc739a2e95bad3c0bd9dc08442c5088 100644 (file)
--- a/src/core/data.c
+++ b/src/core/data.c
return 42;
case SDB_TYPE_STRING:
if (! datum->data.string)
- return 6; /* "NULL" */
+ return 8; /* "<NULL>" */
/* in the worst case, each character needs to be escaped */
return 2 * strlen(datum->data.string) + 2;
case SDB_TYPE_DATETIME:
/* "YYYY-MM-DD HH:MM:SS +zzzz" */
return 27;
case SDB_TYPE_BINARY:
+ if (! datum->data.binary.datum)
+ return 8; /* "<NULL>" */
/* "\xNN" */
return 4 * datum->data.binary.length + 2;
}
break;
case SDB_TYPE_STRING:
if (! datum->data.string)
- data = "NULL";
+ data = "<NULL>";
else {
pos = 0;
for (i = 0; i < strlen(datum->data.string); ++i) {
tmp[pos] = hex[byte & 0xf];
++pos;
}
- tmp[pos] = '\0';
- data = tmp;
+ if (datum->data.binary.datum) {
+ tmp[pos] = '\0';
+ data = tmp;
+ }
+ else
+ data = "<NULL>";
break;
}
index 606eae53b1cf69415eb2076a8c868be0ae890f40..6f9376ff48fdd5ad4a22b247bca20c6b5683dc41 100644 (file)
--- a/t/unit/core/data_test.c
+++ b/t/unit/core/data_test.c
},
{
{ SDB_TYPE_STRING, { .string = NULL } },
- "\"NULL\"",
+ "\"<NULL>\"",
},
{
{ SDB_TYPE_STRING, { .string = "this is a test" } },
},
{
{ SDB_TYPE_BINARY, { .binary = { 0, NULL } } },
- "\"\"",
+ "\"<NULL>\"",
},
{
{