Merge pull request #19 from DavidKinder/master

Fix compiler warnings on Windows for new JSON code
This commit is contained in:
Graham Nelson 2022-06-19 20:09:54 +01:00 committed by GitHub
commit a0d42811ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -26,6 +26,10 @@ int Characters::islower(wchar_t c) {
int Characters::isalnum(wchar_t c) { int Characters::isalnum(wchar_t c) {
return isalnum((int) c); return isalnum((int) c);
} }
int Characters::iscntrl(wchar_t c) {
int i = c;
return ((i >= 0) && (i < 32));
}
int Characters::vowel(wchar_t c) { int Characters::vowel(wchar_t c) {
if ((c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u')) return TRUE; if ((c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u')) return TRUE;
return FALSE; return FALSE;

View file

@ -258,7 +258,8 @@ the JSON standard), and the special cases |true|, |false| and |null|.
= =
JSON_value *JSON::decode_range(text_stream *T, int from, int to, text_file_position *tfp) { JSON_value *JSON::decode_range(text_stream *T, int from, int to, text_file_position *tfp) {
int first_nws = -1, last_nws = -1, first_c = 0, last_c = 0; int first_nws = -1, last_nws = -1;
wchar_t first_c = 0, last_c = 0;
@<Find the first and last non-whitespace character@>; @<Find the first and last non-whitespace character@>;
switch (first_c) { switch (first_c) {
case '[': case '[':
@ -456,7 +457,7 @@ JSON_value *JSON::decode_string(text_stream *T, int from, int to, text_file_posi
if (c == '\\') { if (c == '\\') {
i++; i++;
c = Str::get_at(T, i); c = Str::get_at(T, i);
if ((c >= 0) && (c < 32)) return JSON::decode_error(I"unescaped control character", tfp); if (Characters::iscntrl(c)) return JSON::decode_error(I"unescaped control character", tfp);
switch (c) { switch (c) {
case 'b': c = 8; break; case 'b': c = 8; break;
case 't': c = 9; break; case 't': c = 9; break;
@ -571,7 +572,7 @@ void JSON::encode_string(OUTPUT_STREAM, text_stream *T) {
case 12: WRITE("\\f"); break; case 12: WRITE("\\f"); break;
case 13: WRITE("\\r"); break; case 13: WRITE("\\r"); break;
default: default:
if ((c >= 0) && (c < 32)) WRITE("\\u%04x", c); if (Characters::iscntrl(c)) WRITE("\\u%04x", (int)c);
else PUT(c); else PUT(c);
break; break;
} }
@ -991,7 +992,8 @@ JSON requirement.
= =
JSON_requirement *JSON::decode_req_range(text_stream *T, int from, int to, JSON_requirement *JSON::decode_req_range(text_stream *T, int from, int to,
dictionary *known_names) { dictionary *known_names) {
int first_nws = -1, last_nws = -1, first_c = 0, last_c = 0; int first_nws = -1, last_nws = -1;
wchar_t first_c = 0, last_c = 0;
@<Find the first and last non-whitespace character in requirement@>; @<Find the first and last non-whitespace character in requirement@>;
if (first_c == '(') { if (first_c == '(') {
if (last_c != ')') if (last_c != ')')
@ -1035,7 +1037,8 @@ for what it's worth, we opt for the value.
= =
JSON_single_requirement *JSON::decode_sreq_range(text_stream *T, int from, int to, JSON_single_requirement *JSON::decode_sreq_range(text_stream *T, int from, int to,
dictionary *known_names) { dictionary *known_names) {
int first_nws = -1, last_nws = -1, first_c = 0, last_c = 0; int first_nws = -1, last_nws = -1;
wchar_t first_c = 0, last_c = 0;
@<Find the first and last non-whitespace character in requirement@>; @<Find the first and last non-whitespace character in requirement@>;
if (first_nws < 0) return JSON::error_sr(I"whitespace where requirement expected"); if (first_nws < 0) return JSON::error_sr(I"whitespace where requirement expected");
switch (first_c) { switch (first_c) {