Skip to content

Commit f552351

Browse files
committed
Use stdbool
1 parent bfb7797 commit f552351

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

ext/json/ext/parser/parser.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ case 2:
169169
#line 153 "parser.rl"
170170
{
171171
char *np;
172-
json->parsing_name = 1;
172+
json->parsing_name = true;
173173
np = JSON_parse_string(json, p, pe, &last_name);
174-
json->parsing_name = 0;
174+
json->parsing_name = false;
175175
if (np == NULL) { p--; {p++; cs = 3; goto _out;} } else {p = (( np))-1;}
176176
}
177177
goto st3;
@@ -1816,29 +1816,29 @@ static void parser_init(JSON_Parser *json, VALUE source, VALUE opts)
18161816
if (option_given_p(opts, tmp)) {
18171817
json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
18181818
} else {
1819-
json->allow_nan = 0;
1819+
json->allow_nan = false;
18201820
}
18211821
tmp = ID2SYM(i_symbolize_names);
18221822
if (option_given_p(opts, tmp)) {
18231823
json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
18241824
} else {
1825-
json->symbolize_names = 0;
1825+
json->symbolize_names = false;
18261826
}
18271827
tmp = ID2SYM(i_freeze);
18281828
if (option_given_p(opts, tmp)) {
18291829
json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
18301830
} else {
1831-
json->freeze = 0;
1831+
json->freeze = false;
18321832
}
18331833
tmp = ID2SYM(i_create_additions);
18341834
if (option_given_p(opts, tmp)) {
18351835
tmp = rb_hash_aref(opts, tmp);
18361836
if (NIL_P(tmp)) {
1837-
json->create_additions = 1;
1838-
json->deprecated_create_additions = 1;
1837+
json->create_additions = true;
1838+
json->deprecated_create_additions = true;
18391839
} else {
18401840
json->create_additions = RTEST(tmp);
1841-
json->deprecated_create_additions = 0;
1841+
json->deprecated_create_additions = false;
18421842
}
18431843
}
18441844

ext/json/ext/parser/parser.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ typedef struct JSON_ParserStruct {
3838
VALUE match_string;
3939
FBuffer fbuffer;
4040
int max_nesting;
41-
char allow_nan;
42-
char parsing_name;
43-
char symbolize_names;
44-
char freeze;
45-
char create_additions;
46-
char deprecated_create_additions;
41+
bool allow_nan;
42+
bool parsing_name;
43+
bool symbolize_names;
44+
bool freeze;
45+
bool create_additions;
46+
bool deprecated_create_additions;
4747
} JSON_Parser;
4848

4949
#define GET_PARSER \

ext/json/ext/parser/parser.rl

+8-8
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ static int utf8_encindex;
152152

153153
action parse_name {
154154
char *np;
155-
json->parsing_name = 1;
155+
json->parsing_name = true;
156156
np = JSON_parse_string(json, fpc, pe, &last_name);
157-
json->parsing_name = 0;
157+
json->parsing_name = false;
158158
if (np == NULL) { fhold; fbreak; } else fexec np;
159159
}
160160

@@ -711,29 +711,29 @@ static void parser_init(JSON_Parser *json, VALUE source, VALUE opts)
711711
if (option_given_p(opts, tmp)) {
712712
json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
713713
} else {
714-
json->allow_nan = 0;
714+
json->allow_nan = false;
715715
}
716716
tmp = ID2SYM(i_symbolize_names);
717717
if (option_given_p(opts, tmp)) {
718718
json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
719719
} else {
720-
json->symbolize_names = 0;
720+
json->symbolize_names = false;
721721
}
722722
tmp = ID2SYM(i_freeze);
723723
if (option_given_p(opts, tmp)) {
724724
json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
725725
} else {
726-
json->freeze = 0;
726+
json->freeze = false;
727727
}
728728
tmp = ID2SYM(i_create_additions);
729729
if (option_given_p(opts, tmp)) {
730730
tmp = rb_hash_aref(opts, tmp);
731731
if (NIL_P(tmp)) {
732-
json->create_additions = 1;
733-
json->deprecated_create_additions = 1;
732+
json->create_additions = true;
733+
json->deprecated_create_additions = true;
734734
} else {
735735
json->create_additions = RTEST(tmp);
736-
json->deprecated_create_additions = 0;
736+
json->deprecated_create_additions = false;
737737
}
738738
}
739739

0 commit comments

Comments
 (0)