summaryrefslogtreecommitdiff
path: root/src/include/packing.i
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/packing.i')
-rw-r--r--src/include/packing.i36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/include/packing.i b/src/include/packing.i
index 7178052ed91..6e0e7be13eb 100644
--- a/src/include/packing.i
+++ b/src/include/packing.i
@@ -248,6 +248,20 @@ __pack_size(WT_SESSION_IMPL *session, WT_PACK_VALUE *pv)
switch (pv->type) {
case 'x':
return (pv->size);
+ case 'j':
+ case 'J':
+ if (pv->type == 'j' || pv->havesize)
+ s = pv->size;
+ else {
+ ssize_t len;
+
+ /* The string was previously validated. */
+ len = __wt_json_strlen(pv->u.item.data,
+ pv->u.item.size);
+ WT_ASSERT(session, len >= 0);
+ s = (size_t)len + 1;
+ }
+ return (s);
case 's':
case 'S':
if (pv->type == 's' || pv->havesize)
@@ -329,6 +343,28 @@ __pack_write(
*pp += pad;
}
break;
+ case 'j':
+ case 'J':
+ s = pv->u.item.size;
+ if ((pv->type == 'j' || pv->havesize) && pv->size < s) {
+ s = pv->size;
+ pad = 0;
+ } else if (pv->havesize)
+ pad = pv->size - s;
+ else
+ pad = 1;
+ if (s > 0) {
+ oldp = *pp;
+ WT_RET(__wt_json_strncpy((char **)pp, maxlen,
+ pv->u.item.data, s));
+ maxlen -= (size_t)(*pp - oldp);
+ }
+ if (pad > 0) {
+ WT_SIZE_CHECK(pad, maxlen);
+ memset(*pp, 0, pad);
+ *pp += pad;
+ }
+ break;
case 'U':
case 'u':
s = pv->u.item.size;