summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/cursor
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2021-12-15 13:27:17 +1100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-15 03:09:53 +0000
commite63929afac9c27cb42965bd8f68fcbde6f50b84b (patch)
treef7c30c2d72916c2ca2490e7ea7d233acb496b174 /src/third_party/wiredtiger/src/cursor
parentd14302f5993b5dfd3209155d74a387e12bf43690 (diff)
downloadmongo-e63929afac9c27cb42965bd8f68fcbde6f50b84b.tar.gz
Import wiredtiger: eeb51ded34980625c5548f22105e6b9abf026894 from branch mongodb-master
ref: c9a4f73f9b..eeb51ded34 for: 5.3.0 WT-8545 Don't truncate WiredTiger verbose/error messages
Diffstat (limited to 'src/third_party/wiredtiger/src/cursor')
-rw-r--r--src/third_party/wiredtiger/src/cursor/cur_json.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/third_party/wiredtiger/src/cursor/cur_json.c b/src/third_party/wiredtiger/src/cursor/cur_json.c
index cc3e4c61206..be9016a2159 100644
--- a/src/third_party/wiredtiger/src/cursor/cur_json.c
+++ b/src/third_party/wiredtiger/src/cursor/cur_json.c
@@ -306,7 +306,8 @@ __wt_json_close(WT_SESSION_IMPL *session, WT_CURSOR *cursor)
/*
* __wt_json_unpack_char --
- * Unpack a single character into JSON escaped format. Can be called with null buf for sizing.
+ * Unpack a single character into JSON escaped format. Can be called with NULL buf for sizing,
+ * and won't overwrite the buffer end in any case.
*/
size_t
__wt_json_unpack_char(u_char ch, u_char *buf, size_t bufsz, bool force_unicode)
@@ -360,6 +361,28 @@ __wt_json_unpack_char(u_char ch, u_char *buf, size_t bufsz, bool force_unicode)
}
/*
+ * __wt_json_unpack_str --
+ * Unpack a string into JSON escaped format. Can be called with NULL buf for sizing and won't
+ * overwrite the buffer end in any case.
+ */
+size_t
+__wt_json_unpack_str(u_char *dest, size_t dest_len, const u_char *src, size_t src_len)
+{
+ size_t n, total;
+
+ for (total = 0; src_len > 0; ++src, --src_len, total += n) {
+ n = __wt_json_unpack_char(*src, dest, dest_len, false);
+ if (dest_len >= n) {
+ dest_len -= n;
+ dest += n;
+ }
+ }
+ if (dest_len > 0)
+ *dest = '\0';
+ return (total);
+}
+
+/*
* __wt_json_column_init --
* Set json_key_names, json_value_names to comma separated lists of column names.
*/