Stop parsing when an escape is missing or consumes no input, and count only successfully decoded bytes. This avoids the extra strtol call beyond the command terminator while preserving valid raw commands.
Reject stream read errors instead of synthesizing empty commands, validate raw hexadecimal command syntax without reading past its terminator, and keep fixed-size command and description inputs within their actual capacities.
glibc implements some new parts of the C23 standard:
(Taken from https://download.opensuse.org/tumbleweed/iso/Changes.20260430.txt)
* For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr,
strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return
pointers into their input arrays now have definitions as macros that
return a pointer to a const-qualified type when the input argument is
a pointer to a const-qualified type
and
* The aforementioned change in ISO C23 of the declaration of bsearch,
memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr,
wcsstr, and wmemchr as const-preserving macros can lead to compilation
issues in code not set up for it
This lead to some warnings about assigning returns from strchr(const, target)
to non-const pointers, and then discovering that Hamlib was modifying
those const parameters.
This commit aligns the const-ness of the offending parameters. Only affects
internal functions in ampctl_parse.c, rigctl_parse.c and rotctl_parse.c,
so API/ABI should not change.
Allocate and free it.
For access apps must
1) #include <hamlib/rig_state.h> and
2) Use HAMLIB_STATE(rig) to get the address
Also fix a couple of misuses of STATE() macro.
The needed value is already in the variable.
Test case /to check that the changes don't break the code):
tests/rigctl --set-conf=rig_pathname=test,write_delay=1,timeout=2 --show-conf Q | grep --no-group-separator -A1 -E "(rig_pathname|^write_delay|^timeout):"
tests/rotctl --set-conf=rot_pathname=test,write_delay=1,timeout=2 --show-conf Q | grep --no-group-separator -A1 -E "(rot_pathname|^write_delay|^timeout):"
The output before and after this patch is:
rig_pathname: "Path name to the device file of the rig"
Default: /dev/rig, Value: test
write_delay: "Delay in ms between each byte sent out"
Default: 0, Value: 1
timeout: "Timeout in ms"
Default: 0, Value: 2
Command 'Q' not found!
rot_pathname: "Path name to the device file of the rotator"
Default: /dev/rotator, Value: test
write_delay: "Delay in ms between each byte sent out"
Default: 0, Value: 1
timeout: "Timeout in ms"
Default: 0, Value: 2