Skip to content

Commit

Permalink
Eliminate warnings when base char type is unsigned (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan4thewin authored Apr 22, 2021
1 parent 04edabb commit f81dec2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions docs/doxygen/include/size_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
</tr>
<tr>
<td>core_json.c</td>
<td><center>2.7K</center></td>
<td><center>2.2K</center></td>
<td><center>2.9K</center></td>
<td><center>2.3K</center></td>
</tr>
<tr>
<td><b>Total estimates</b></td>
<td><b><center>2.7K</center></b></td>
<td><b><center>2.2K</center></b></td>
<td><b><center>2.9K</center></b></td>
<td><b><center>2.3K</center></b></td>
</tr>
</table>
15 changes: 10 additions & 5 deletions source/core_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include <assert.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include "core_json.h"
Expand All @@ -39,8 +40,13 @@ typedef union
uint8_t u;
} char_;

#define isdigit_( x ) ( ( ( x ) >= '0' ) && ( ( x ) <= '9' ) )
#define iscntrl_( x ) ( ( ( x ) >= '\0' ) && ( ( x ) < ' ' ) )
#if ( CHAR_MIN == 0 )
#define isascii_( x ) ( ( x ) <= '\x7F' )
#else
#define isascii_( x ) ( ( x ) >= '\0' )
#endif
#define iscntrl_( x ) ( isascii_( x ) && ( ( x ) < ' ' ) )
#define isdigit_( x ) ( ( ( x ) >= '0' ) && ( ( x ) <= '9' ) )
/* NB. This is whitespace as defined by the JSON standard (ECMA-404). */
#define isspace_( x ) \
( ( ( x ) == ' ' ) || ( ( x ) == '\t' ) || \
Expand Down Expand Up @@ -190,7 +196,7 @@ static bool skipUTF8MultiByte( const char * buf,

i = *start;
assert( i < max );
assert( buf[ i ] < '\0' );
assert( !isascii_( buf[ i ] ) );

c.c = buf[ i ];

Expand Down Expand Up @@ -251,8 +257,7 @@ static bool skipUTF8( const char * buf,

if( *start < max )
{
/* an ASCII byte */
if( buf[ *start ] >= '\0' )
if( isascii_( buf[ *start ] ) )
{
*start += 1U;
ret = true;
Expand Down

0 comments on commit f81dec2

Please sign in to comment.