libubox: Drop extraneous space when appending values to variable#16
libubox: Drop extraneous space when appending values to variable#16pprindeville wants to merge 1 commit into
Conversation
|
Can we please get some progress on this? |
|
Robert (@robimarko) do you think thank you could help Philip to look at this? :) |
|
Could you describe a "test case" where this helps. This could be just a few lines of codes where the patch creates a difference. Just by looking at it, I don't understand it. |
If you do: You'll end up with |
|
Functions starting with an underscore are internal functions. Are there paths to trigger the difference without using those that affect the final JSON? |
I don't understand the question. One of the variables modified by |
|
This is trivial to demonstrate. And fix. It's a 3-line test and a 1 line fix. This might be why we're not seeing new contributors sign up.... |
Don't have a leading space when building out a variable via appends. fixes: issue openwrt#15 Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
dace612 to
95481d8
Compare
|
If it's trivial to demonstrate, then please demonstrate it. I am not asking for direct calls to this particular function as this is an internal function that should not be used directly. This "names that start with underscore are internal API only" is a common convention used in languages that have no or a limited concept of encapsulation. So I am asking for a script that constructs a json object, json array or whatever using the public API only (functions not starting with an underscore) where you suggested change causes a difference.
When contributing, I expect some quality assurance. If I can not explain why my change is an improvement, I don't expect anyone to accept it upstream. That's why the explanation of the change sometimes takes much more effort than the actual change. I don't know your expectations. This is also the other way around: If I see some project merging random stuff without reason, I can not trust that project anymore. |
I'm not saying it's publicly callable. But in writing additional functions (which are) that call through it, those functions didn't operate correctly because of the leading space interfering. This fix is a prerequisite to PR #6. To reiterate, this bug was confirmed by @nbd168 and he provided the fix. |
|
So #6 is affected by this changes? Which difference does it create there and where/why? |
I had to copy and paste |
|
But this PR itself is not at all about |
Verifies the fix in commit 2065c3909935 ("libubox: Drop extraneous space
when appending values to variable") that prevents leading spaces when
appending to empty variables.
test_jshn_append_no_leading_space
ASSERT:expected:<foo> but was:< foo>
ASSERT:expected:<first second> but was:< first second>
References: #16
Signed-off-by: Petr Štetiar <ynezz@true.cz>
I added such test 240d2d5, without this commit it results in https://github.com/ynezz/openwrt-libubox/actions/runs/19329020923/job/55287207923#step:9:30 Sorry for pushing it directly, I wanted to update this PR, PEBKAC error :) Thus closed via 240d2d5, thanks! |
Add new test which verifies _jshn_append leading space fix by appending keys to JSON objects, making sure there is no leading space on the first key when adding second key. Tests: openwrt#16 Signed-off-by: Petr Štetiar <ynezz@true.cz>
Add another test which verifies _jshn_append leading space fix in commit 82cb5fd ("libubox: Drop extraneous space when appending values to variable") by appending keys to JSON objects, making sure there is no leading space on the first key when adding second key. test_jshn_append_via_json_script ASSERT:expected:<first> but was:< first> ASSERT:expected:<first second> but was:< first second> Tests: openwrt#16 Signed-off-by: Petr Štetiar <ynezz@true.cz>
Add another test which verifies _jshn_append leading space fix in commit 82cb5fd ("libubox: Drop extraneous space when appending values to variable") by appending keys to JSON objects, making sure there is no leading space on the first key when adding second key. test_jshn_append_via_json_script ASSERT:expected:<first> but was:< first> ASSERT:expected:<first second> but was:< first second> Tests: openwrt#16 Signed-off-by: Petr Štetiar <ynezz@true.cz> Link: openwrt#30 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
If you (as someone extending this library) use
__jshn_append()it will create a string with an undesired leading space.fixes: issue #15