-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100715c
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.
This looks strange to me:
As a C programmer I would expect a \0 at the end of a string not at the beginning.
100715c
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.
@xypron Looks ok to me. Will silently crop all zeros, tabs and spaces off the remaining Data, making sure that if anything 'non-space' is left there it will be returned to the case statement. In our case it should return only <<>>.
100715c
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.
Here is an example of the trim function failing:
It simply does not remove trailing zeros. A C program will not produce a \0 byte at the beginning but at the end of a string. So I do not understand the rationale of Petr's patch.
The Kerlink gateway only produces a single 0x00 in the TX_ACK message, e.g.:
100715c
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 function is meant to remove whitespace from a whitespace-only string. If there is a space, zero, two zeros, whatever, this fun reduces it to <<>>. If there is anything else than whitespace, then the standard JSON parse is invoked (on the non-trimmed string). Therefore, removing trailing zeros is superfluous.