-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow null character in keys #715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
`struct lh_string` really needs to be renamed and moved to json_object.h
|
Hmm, well, good to know it doesn't compile on Windows (I should've tested that) |
|
@hawicz This now compiles properly and is ready for review |
|
First of all, thank you for working on this. I don't have a whole lot of time right now, but the things that I noticed so far from glancing at the diffs are:
I'm planning on taking a more in-depth look at this soon, so I'll probably have a few more things to comment on. |
I moved this before when I was using ssize_t in linkhash.c, but I moved `struct lh_string` to `struct json_key` in a different file, so this isn't needed anymore
| * | ||
| * Note: caller is responsible for freeing *dst if this fails and returns -1. | ||
| */ | ||
| static int json_object_deep_copy_recursive_len(struct json_object *src, struct json_object *parent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json_object_deep_copy_recursive_len() looks like a lot of code duplication just to pass a different shallow_copy function pointer. Instead, add another argument to the existing json_object_deep_copy_recursive() and have it use whichever one is non-NULL.
| #if defined(__GNUC__) && !defined(__STRICT_ANSI__) && \ | ||
| (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) | ||
|
|
||
| #define json_object_object_foreach(obj, key, val) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The json_object_object_foreach_len() macro duplicates most of the code for json_object_object_foreach(). How about instead of doing that we have json_object_object_foreach() define a variable in addition to "key", perhaps "key_with_len" (though I'm not too excited about that var name)?
|
I started gathering some notes about possible buffer implementations to use over at https://github.com/json-c/json-c/wiki/Proposal:-Use-sized-buffers-instead-of-asciiz-strings Also, the naming of the new functions, _key isn't so great either, because "key" doesn't seem to describe very well what makes those different. |
|
I'm not a huge fan of _key either, but I didn't really know what to name them with. Also, for the |
|
Apologies for the delay, I just had a concern, am I free to modify I think it would be possible to get away without modifying either that or Though, I'd already be modifying |
This allows keys to contain null characters (
\u0000). While there were no changes made to thejson_object_object_*functions, there were some changes needed for some of the others.This tries to fix issue #108 (merge request #528 will no longer be needed)