Merge pull request #7 from AlamyLiu/fix_from_Alamy

Fix from alamy
This commit is contained in:
Rafa García 2020-03-14 00:55:26 +01:00 committed by GitHub
commit 1fe46ee557
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
/* /*
<https://github.com/rafagafe/tiny-json> <https://github.com/rafagafe/tiny-json>
Licensed under the MIT License <http://opensource.org/licenses/MIT>. Licensed under the MIT License <http://opensource.org/licenses/MIT>.
SPDX-License-Identifier: MIT SPDX-License-Identifier: MIT
Copyright (c) 2016-2018 Rafa Garcia <rafagarcia77@gmail.com>. Copyright (c) 2016-2018 Rafa Garcia <rafagarcia77@gmail.com>.
@ -24,7 +24,7 @@
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#include <string.h> #include <string.h>
@ -130,7 +130,7 @@ static unsigned char getCharFromUnicode( unsigned char const* str ) {
static char* parseString( char* str ) { static char* parseString( char* str ) {
unsigned char* head = (unsigned char*)str; unsigned char* head = (unsigned char*)str;
unsigned char* tail = (unsigned char*)str; unsigned char* tail = (unsigned char*)str;
for( ; *head >= ' '; ++head, ++tail ) { for( ; *head; ++head, ++tail ) {
if ( *head == '\"' ) { if ( *head == '\"' ) {
*tail = '\0'; *tail = '\0';
return (char*)++head; return (char*)++head;
@ -245,7 +245,7 @@ static char* nullValue( char* ptr, json_t* property ) {
* @retval Null pointer if any error occur. */ * @retval Null pointer if any error occur. */
static char* expValue( char* ptr ) { static char* expValue( char* ptr ) {
if ( *ptr == '-' || *ptr == '+' ) ++ptr; if ( *ptr == '-' || *ptr == '+' ) ++ptr;
if ( !isdigit( *ptr ) ) return 0; if ( !isdigit( (int)(*ptr) ) ) return 0;
ptr = goNum( ++ptr ); ptr = goNum( ++ptr );
return ptr; return ptr;
} }
@ -255,7 +255,7 @@ static char* expValue( char* ptr ) {
* @retval Pointer to first non numerical after the string. If success. * @retval Pointer to first non numerical after the string. If success.
* @retval Null pointer if any error occur. */ * @retval Null pointer if any error occur. */
static char* fraqValue( char* ptr ) { static char* fraqValue( char* ptr ) {
if ( !isdigit( *ptr ) ) return 0; if ( !isdigit( (int)(*ptr) ) ) return 0;
ptr = goNum( ++ptr ); ptr = goNum( ++ptr );
if ( !ptr ) return 0; if ( !ptr ) return 0;
return ptr; return ptr;
@ -269,12 +269,12 @@ static char* fraqValue( char* ptr ) {
* @retval Null pointer if any error occur. */ * @retval Null pointer if any error occur. */
static char* numValue( char* ptr, json_t* property ) { static char* numValue( char* ptr, json_t* property ) {
if ( *ptr == '-' ) ++ptr; if ( *ptr == '-' ) ++ptr;
if ( !isdigit( *ptr ) ) return 0; if ( !isdigit( (int)(*ptr) ) ) return 0;
if ( *ptr != '0' ) { if ( *ptr != '0' ) {
ptr = goNum( ptr ); ptr = goNum( ptr );
if ( !ptr ) return 0; if ( !ptr ) return 0;
} }
else if ( isdigit( *++ptr ) ) return 0; else if ( isdigit( (int)(*++ptr) ) ) return 0;
property->type = JSON_INTEGER; property->type = JSON_INTEGER;
if ( *ptr == '.' ) { if ( *ptr == '.' ) {
ptr = fraqValue( ++ptr ); ptr = fraqValue( ++ptr );
@ -440,7 +440,7 @@ static char* goBlank( char* str ) {
* @return The final pointer value or null pointer if the null character was found. */ * @return The final pointer value or null pointer if the null character was found. */
static char* goNum( char* str ) { static char* goNum( char* str ) {
for( ; *str != '\0'; ++str ) { for( ; *str != '\0'; ++str ) {
if ( !isdigit( *str ) ) if ( !isdigit( (int)(*str) ) )
return str; return str;
} }
return 0; return 0;