Skip to content

Commit df06917

Browse files
committed
Use stdbool rather than custom booleans
Fixes: #817
1 parent 8bcc070 commit df06917

22 files changed

+1477
-1489
lines changed

cutils.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int dbuf_realloc(DynBuf *s, size_t new_size)
125125
new_size = size;
126126
new_buf = s->realloc_func(s->opaque, s->buf, new_size);
127127
if (!new_buf) {
128-
s->error = TRUE;
128+
s->error = true;
129129
return -1;
130130
}
131131
s->buf = new_buf;
@@ -1209,12 +1209,12 @@ typedef struct {
12091209
js__once_cb callback;
12101210
} js__once_data_t;
12111211

1212-
static BOOL WINAPI js__once_inner(INIT_ONCE *once, void *param, void **context) {
1212+
static int WINAPI js__once_inner(INIT_ONCE *once, void *param, void **context) {
12131213
js__once_data_t *data = param;
12141214

12151215
data->callback();
12161216

1217-
return TRUE;
1217+
return 1;
12181218
}
12191219

12201220
void js_once(js_once_t *guard, js__once_cb callback) {

cutils.h

+7-15
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#ifndef CUTILS_H
2626
#define CUTILS_H
2727

28+
#include <stdbool.h>
2829
#include <stdlib.h>
2930
#include <string.h>
3031
#include <inttypes.h>
@@ -112,15 +113,6 @@ extern "C" {
112113
#define minimum_length(n) static n
113114
#endif
114115

115-
typedef int BOOL;
116-
117-
#ifndef FALSE
118-
enum {
119-
FALSE = 0,
120-
TRUE = 1,
121-
};
122-
#endif
123-
124116
void js__pstrcpy(char *buf, int buf_size, const char *str);
125117
char *js__pstrcat(char *buf, int buf_size, const char *s);
126118
int js__strstart(const char *str, const char *val, const char **ptr);
@@ -428,7 +420,7 @@ typedef struct DynBuf {
428420
uint8_t *buf;
429421
size_t size;
430422
size_t allocated_size;
431-
BOOL error; /* true if a memory allocation error occurred */
423+
bool error; /* true if a memory allocation error occurred */
432424
DynBufReallocFunc *realloc_func;
433425
void *opaque; /* for realloc_func */
434426
} DynBuf;
@@ -456,12 +448,12 @@ static inline int dbuf_put_u64(DynBuf *s, uint64_t val)
456448
int __attribute__((format(printf, 2, 3))) dbuf_printf(DynBuf *s,
457449
FORMAT_STRING(const char *fmt), ...);
458450
void dbuf_free(DynBuf *s);
459-
static inline BOOL dbuf_error(DynBuf *s) {
451+
static inline bool dbuf_error(DynBuf *s) {
460452
return s->error;
461453
}
462454
static inline void dbuf_set_error(DynBuf *s)
463455
{
464-
s->error = TRUE;
456+
s->error = true;
465457
}
466458

467459
/*---- UTF-8 and UTF-16 handling ----*/
@@ -485,17 +477,17 @@ size_t utf8_decode_buf16(uint16_t *dest, size_t dest_len, const char *src, size_
485477
size_t utf8_encode_buf8(char *dest, size_t dest_len, const uint8_t *src, size_t src_len);
486478
size_t utf8_encode_buf16(char *dest, size_t dest_len, const uint16_t *src, size_t src_len);
487479

488-
static inline BOOL is_surrogate(uint32_t c)
480+
static inline bool is_surrogate(uint32_t c)
489481
{
490482
return (c >> 11) == (0xD800 >> 11); // 0xD800-0xDFFF
491483
}
492484

493-
static inline BOOL is_hi_surrogate(uint32_t c)
485+
static inline bool is_hi_surrogate(uint32_t c)
494486
{
495487
return (c >> 10) == (0xD800 >> 10); // 0xD800-0xDBFF
496488
}
497489

498-
static inline BOOL is_lo_surrogate(uint32_t c)
490+
static inline bool is_lo_surrogate(uint32_t c)
499491
{
500492
return (c >> 10) == (0xDC00 >> 10); // 0xDC00-0xDFFF
501493
}

dirent_compat.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ dirent_next(
656656
} else if (dirp->handle != INVALID_HANDLE_VALUE) {
657657

658658
/* Get the next directory entry from stream */
659-
if (FindNextFileW (dirp->handle, &dirp->data) != FALSE) {
659+
if (FindNextFileW (dirp->handle, &dirp->data) != 0) {
660660
/* Got a file */
661661
p = &dirp->data;
662662
} else {
@@ -1163,4 +1163,4 @@ dirent_set_errno(
11631163
#ifdef __cplusplus
11641164
}
11651165
#endif
1166-
#endif /*DIRENT_H*/
1166+
#endif /*DIRENT_H*/

gen/function_source.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const uint32_t qjsc_function_source_size = 320;
66

77
const uint8_t qjsc_function_source[320] = {
8-
0x13, 0x05, 0x01, 0x30, 0x74, 0x65, 0x73, 0x74,
8+
0x14, 0x05, 0x01, 0x30, 0x74, 0x65, 0x73, 0x74,
99
0x73, 0x2f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
1010
0x6f, 0x6e, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63,
1111
0x65, 0x2e, 0x6a, 0x73, 0x01, 0x0c, 0x61, 0x63,
@@ -15,13 +15,13 @@ const uint8_t qjsc_function_source[320] = {
1515
0x6e, 0x20, 0x66, 0x28, 0x29, 0x20, 0x7b, 0x20,
1616
0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x34,
1717
0x32, 0x20, 0x7d, 0x0d, 0xc0, 0x03, 0x00, 0x00,
18-
0x00, 0x00, 0x00, 0x0c, 0x20, 0xfa, 0x01, 0xa2,
18+
0x00, 0x00, 0x00, 0x0c, 0x20, 0x0a, 0x01, 0xa2,
1919
0x01, 0x00, 0x05, 0x00, 0x03, 0x02, 0x01, 0x74,
2020
0x05, 0xc2, 0x03, 0x02, 0x00, 0x30, 0xc4, 0x03,
2121
0x04, 0x00, 0x70, 0xc2, 0x03, 0x04, 0x02, 0x70,
2222
0x10, 0x00, 0x01, 0x00, 0xe4, 0x01, 0x00, 0x01,
2323
0x00, 0xc6, 0x03, 0x00, 0x0d, 0xc4, 0x03, 0x01,
24-
0x01, 0x0c, 0x43, 0xfa, 0x01, 0xc4, 0x03, 0x00,
24+
0x01, 0x0c, 0x43, 0x0a, 0x01, 0xc4, 0x03, 0x00,
2525
0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0xbd,
2626
0x2a, 0x28, 0xc0, 0x03, 0x03, 0x01, 0x00, 0x1a,
2727
0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,

gen/hello.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
const uint32_t qjsc_hello_size = 103;
66

77
const uint8_t qjsc_hello[103] = {
8-
0x13, 0x04, 0x01, 0x22, 0x65, 0x78, 0x61, 0x6d,
8+
0x14, 0x04, 0x01, 0x22, 0x65, 0x78, 0x61, 0x6d,
99
0x70, 0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c,
1010
0x6c, 0x6f, 0x2e, 0x6a, 0x73, 0x01, 0x0e, 0x63,
1111
0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x01, 0x06,
1212
0x6c, 0x6f, 0x67, 0x01, 0x16, 0x48, 0x65, 0x6c,
1313
0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64,
1414
0x0d, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
15-
0x0c, 0x20, 0xfa, 0x01, 0xa2, 0x01, 0x00, 0x00,
15+
0x0c, 0x20, 0x0a, 0x01, 0xa2, 0x01, 0x00, 0x00,
1616
0x00, 0x03, 0x00, 0x00, 0x19, 0x00, 0x08, 0xeb,
1717
0x02, 0x29, 0x39, 0xe1, 0x00, 0x00, 0x00, 0x43,
1818
0xe2, 0x00, 0x00, 0x00, 0x04, 0xe3, 0x00, 0x00,

gen/hello_module.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
const uint32_t qjsc_fib_module_size = 290;
66

77
const uint8_t qjsc_fib_module[290] = {
8-
0x13, 0x03, 0x01, 0x2c, 0x65, 0x78, 0x61, 0x6d,
8+
0x14, 0x03, 0x01, 0x2c, 0x65, 0x78, 0x61, 0x6d,
99
0x70, 0x6c, 0x65, 0x73, 0x2f, 0x66, 0x69, 0x62,
1010
0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e,
1111
0x6a, 0x73, 0x01, 0x06, 0x66, 0x69, 0x62, 0x01,
1212
0x02, 0x6e, 0x0d, 0xc0, 0x03, 0x00, 0x01, 0x00,
1313
0x00, 0xc2, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x20,
14-
0xfa, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x01,
14+
0x0a, 0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x01,
1515
0x01, 0x01, 0x09, 0x00, 0xc2, 0x03, 0x00, 0x01,
16-
0x0c, 0x43, 0xfa, 0x01, 0xc2, 0x03, 0x01, 0x00,
16+
0x0c, 0x43, 0x0a, 0x01, 0xc2, 0x03, 0x01, 0x00,
1717
0x01, 0x04, 0x01, 0x00, 0x1a, 0x01, 0xc4, 0x03,
1818
0x00, 0x01, 0x00, 0xc2, 0x03, 0x00, 0x00, 0xd2,
1919
0xb5, 0xa8, 0xeb, 0x03, 0xb5, 0x28, 0xd2, 0xb6,
@@ -47,7 +47,7 @@ const uint8_t qjsc_fib_module[290] = {
4747
const uint32_t qjsc_hello_module_size = 187;
4848

4949
const uint8_t qjsc_hello_module[187] = {
50-
0x13, 0x07, 0x01, 0x30, 0x65, 0x78, 0x61, 0x6d,
50+
0x14, 0x07, 0x01, 0x30, 0x65, 0x78, 0x61, 0x6d,
5151
0x70, 0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c,
5252
0x6c, 0x6f, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c,
5353
0x65, 0x2e, 0x6a, 0x73, 0x01, 0x1e, 0x2e, 0x2f,
@@ -59,7 +59,7 @@ const uint8_t qjsc_hello_module[187] = {
5959
0x57, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x10, 0x66,
6060
0x69, 0x62, 0x28, 0x31, 0x30, 0x29, 0x3d, 0x0d,
6161
0xc0, 0x03, 0x01, 0xc2, 0x03, 0x00, 0x00, 0x01,
62-
0x00, 0xc4, 0x03, 0x00, 0x00, 0x0c, 0x20, 0xfa,
62+
0x00, 0xc4, 0x03, 0x00, 0x00, 0x0c, 0x20, 0x0a,
6363
0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x05, 0x01,
6464
0x00, 0x32, 0x00, 0xc4, 0x03, 0x00, 0x0c, 0x08,
6565
0xeb, 0x02, 0x29, 0x39, 0xe3, 0x00, 0x00, 0x00,

gen/repl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const uint32_t qjsc_repl_size = 23360;
66

77
const uint8_t qjsc_repl[23360] = {
8-
0x13, 0x96, 0x04, 0x01, 0x0e, 0x72, 0x65, 0x70,
8+
0x14, 0x96, 0x04, 0x01, 0x0e, 0x72, 0x65, 0x70,
99
0x6c, 0x2e, 0x6a, 0x73, 0x01, 0x0e, 0x71, 0x6a,
1010
0x73, 0x3a, 0x73, 0x74, 0x64, 0x01, 0x0c, 0x71,
1111
0x6a, 0x73, 0x3a, 0x6f, 0x73, 0x01, 0x12, 0x71,

gen/standalone.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const uint32_t qjsc_standalone_size = 2466;
66

77
const uint8_t qjsc_standalone[2466] = {
8-
0x13, 0x4d, 0x01, 0x1a, 0x73, 0x74, 0x61, 0x6e,
8+
0x14, 0x4d, 0x01, 0x1a, 0x73, 0x74, 0x61, 0x6e,
99
0x64, 0x61, 0x6c, 0x6f, 0x6e, 0x65, 0x2e, 0x6a,
1010
0x73, 0x01, 0x0e, 0x71, 0x6a, 0x73, 0x3a, 0x73,
1111
0x74, 0x64, 0x01, 0x0c, 0x71, 0x6a, 0x73, 0x3a,

gen/test_fib.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const uint32_t qjsc_test_fib_size = 294;
66

77
const uint8_t qjsc_test_fib[294] = {
8-
0x13, 0x0e, 0x01, 0x28, 0x65, 0x78, 0x61, 0x6d,
8+
0x14, 0x0e, 0x01, 0x28, 0x65, 0x78, 0x61, 0x6d,
99
0x70, 0x6c, 0x65, 0x73, 0x2f, 0x74, 0x65, 0x73,
1010
0x74, 0x5f, 0x66, 0x69, 0x62, 0x2e, 0x6a, 0x73,
1111
0x01, 0x0c, 0x71, 0x6a, 0x73, 0x3a, 0x6f, 0x73,
@@ -21,7 +21,7 @@ const uint8_t qjsc_test_fib[294] = {
2121
0x57, 0x6f, 0x72, 0x6c, 0x64, 0x01, 0x10, 0x66,
2222
0x69, 0x62, 0x28, 0x31, 0x30, 0x29, 0x3d, 0x0d,
2323
0xc0, 0x03, 0x01, 0xc2, 0x03, 0x00, 0x00, 0x01,
24-
0x00, 0xfc, 0x01, 0x00, 0x01, 0x0c, 0x20, 0xfa,
24+
0x00, 0xfc, 0x01, 0x00, 0x01, 0x0c, 0x20, 0x0a,
2525
0x01, 0xa2, 0x01, 0x00, 0x00, 0x00, 0x05, 0x03,
2626
0x00, 0x73, 0x00, 0xc4, 0x03, 0x00, 0x0d, 0xc6,
2727
0x03, 0x00, 0x0d, 0xc8, 0x03, 0x01, 0x0d, 0x08,

0 commit comments

Comments
 (0)