Skip to content

Commit f81dec2

Browse files
authored
Eliminate warnings when base char type is unsigned (#95)
1 parent 04edabb commit f81dec2

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

docs/doxygen/include/size_table.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
</tr>
1010
<tr>
1111
<td>core_json.c</td>
12-
<td><center>2.7K</center></td>
13-
<td><center>2.2K</center></td>
12+
<td><center>2.9K</center></td>
13+
<td><center>2.3K</center></td>
1414
</tr>
1515
<tr>
1616
<td><b>Total estimates</b></td>
17-
<td><b><center>2.7K</center></b></td>
18-
<td><b><center>2.2K</center></b></td>
17+
<td><b><center>2.9K</center></b></td>
18+
<td><b><center>2.3K</center></b></td>
1919
</tr>
2020
</table>

source/core_json.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727

2828
#include <assert.h>
29+
#include <limits.h>
2930
#include <stddef.h>
3031
#include <stdint.h>
3132
#include "core_json.h"
@@ -39,8 +40,13 @@ typedef union
3940
uint8_t u;
4041
} char_;
4142

42-
#define isdigit_( x ) ( ( ( x ) >= '0' ) && ( ( x ) <= '9' ) )
43-
#define iscntrl_( x ) ( ( ( x ) >= '\0' ) && ( ( x ) < ' ' ) )
43+
#if ( CHAR_MIN == 0 )
44+
#define isascii_( x ) ( ( x ) <= '\x7F' )
45+
#else
46+
#define isascii_( x ) ( ( x ) >= '\0' )
47+
#endif
48+
#define iscntrl_( x ) ( isascii_( x ) && ( ( x ) < ' ' ) )
49+
#define isdigit_( x ) ( ( ( x ) >= '0' ) && ( ( x ) <= '9' ) )
4450
/* NB. This is whitespace as defined by the JSON standard (ECMA-404). */
4551
#define isspace_( x ) \
4652
( ( ( x ) == ' ' ) || ( ( x ) == '\t' ) || \
@@ -190,7 +196,7 @@ static bool skipUTF8MultiByte( const char * buf,
190196

191197
i = *start;
192198
assert( i < max );
193-
assert( buf[ i ] < '\0' );
199+
assert( !isascii_( buf[ i ] ) );
194200

195201
c.c = buf[ i ];
196202

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

252258
if( *start < max )
253259
{
254-
/* an ASCII byte */
255-
if( buf[ *start ] >= '\0' )
260+
if( isascii_( buf[ *start ] ) )
256261
{
257262
*start += 1U;
258263
ret = true;

0 commit comments

Comments
 (0)