MSVC warnings fix (#72)

This commit is contained in:
Vladislav Laetansky 2022-04-04 21:24:53 +03:00 committed by GitHub
parent 99c1e33222
commit 8a863d1ec8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

41
toml.c
View file

@ -220,8 +220,8 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
110xxxxx 10xxxxxx 110xxxxx 10xxxxxx
*/ */
if (code <= 0x000007FF) { if (code <= 0x000007FF) {
buf[0] = 0xc0 | (code >> 6); buf[0] = (unsigned char) (0xc0 | (code >> 6));
buf[1] = 0x80 | (code & 0x3f); buf[1] = (unsigned char) (0x80 | (code & 0x3f));
return 2; return 2;
} }
@ -229,9 +229,9 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
1110xxxx 10xxxxxx 10xxxxxx 1110xxxx 10xxxxxx 10xxxxxx
*/ */
if (code <= 0x0000FFFF) { if (code <= 0x0000FFFF) {
buf[0] = 0xe0 | (code >> 12); buf[0] = (unsigned char) (0xe0 | (code >> 12));
buf[1] = 0x80 | ((code >> 6) & 0x3f); buf[1] = (unsigned char) (0x80 | ((code >> 6) & 0x3f));
buf[2] = 0x80 | (code & 0x3f); buf[2] = (unsigned char) (0x80 | (code & 0x3f));
return 3; return 3;
} }
@ -239,10 +239,10 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
*/ */
if (code <= 0x001FFFFF) { if (code <= 0x001FFFFF) {
buf[0] = 0xf0 | (code >> 18); buf[0] = (unsigned char) (0xf0 | (code >> 18));
buf[1] = 0x80 | ((code >> 12) & 0x3f); buf[1] = (unsigned char) (0x80 | ((code >> 12) & 0x3f));
buf[2] = 0x80 | ((code >> 6) & 0x3f); buf[2] = (unsigned char) (0x80 | ((code >> 6) & 0x3f));
buf[3] = 0x80 | (code & 0x3f); buf[3] = (unsigned char) (0x80 | (code & 0x3f));
return 4; return 4;
} }
@ -250,11 +250,11 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
*/ */
if (code <= 0x03FFFFFF) { if (code <= 0x03FFFFFF) {
buf[0] = 0xf8 | (code >> 24); buf[0] = (unsigned char) (0xf8 | (code >> 24));
buf[1] = 0x80 | ((code >> 18) & 0x3f); buf[1] = (unsigned char) (0x80 | ((code >> 18) & 0x3f));
buf[2] = 0x80 | ((code >> 12) & 0x3f); buf[2] = (unsigned char) (0x80 | ((code >> 12) & 0x3f));
buf[3] = 0x80 | ((code >> 6) & 0x3f); buf[3] = (unsigned char) (0x80 | ((code >> 6) & 0x3f));
buf[4] = 0x80 | (code & 0x3f); buf[4] = (unsigned char) (0x80 | (code & 0x3f));
return 5; return 5;
} }
@ -262,12 +262,12 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
*/ */
if (code <= 0x7FFFFFFF) { if (code <= 0x7FFFFFFF) {
buf[0] = 0xfc | (code >> 30); buf[0] = (unsigned char) (0xfc | (code >> 30));
buf[1] = 0x80 | ((code >> 24) & 0x3f); buf[1] = (unsigned char) (0x80 | ((code >> 24) & 0x3f));
buf[2] = 0x80 | ((code >> 18) & 0x3f); buf[2] = (unsigned char) (0x80 | ((code >> 18) & 0x3f));
buf[3] = 0x80 | ((code >> 12) & 0x3f); buf[3] = (unsigned char) (0x80 | ((code >> 12) & 0x3f));
buf[4] = 0x80 | ((code >> 6) & 0x3f); buf[4] = (unsigned char) (0x80 | ((code >> 6) & 0x3f));
buf[5] = 0x80 | (code & 0x3f); buf[5] = (unsigned char) (0x80 | (code & 0x3f));
return 6; return 6;
} }
@ -1496,6 +1496,7 @@ toml_table_t *toml_parse_file(FILE *fp, char *errbuf, int errbufsz) {
int n = fread(buf + off, 1, bufsz - off, fp); int n = fread(buf + off, 1, bufsz - off, fp);
if (ferror(fp)) { if (ferror(fp)) {
snprintf(errbuf, errbufsz, "%s", snprintf(errbuf, errbufsz, "%s",
#pragma warning(suppress : 4996)
errno ? strerror(errno) : "Error reading file"); errno ? strerror(errno) : "Error reading file");
xfree(buf); xfree(buf);
return 0; return 0;