MSVC warnings fix (#72)
This commit is contained in:
parent
99c1e33222
commit
8a863d1ec8
1 changed files with 21 additions and 20 deletions
41
toml.c
41
toml.c
|
@ -220,8 +220,8 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
|
|||
110xxxxx 10xxxxxx
|
||||
*/
|
||||
if (code <= 0x000007FF) {
|
||||
buf[0] = 0xc0 | (code >> 6);
|
||||
buf[1] = 0x80 | (code & 0x3f);
|
||||
buf[0] = (unsigned char) (0xc0 | (code >> 6));
|
||||
buf[1] = (unsigned char) (0x80 | (code & 0x3f));
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@ -229,9 +229,9 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
|
|||
1110xxxx 10xxxxxx 10xxxxxx
|
||||
*/
|
||||
if (code <= 0x0000FFFF) {
|
||||
buf[0] = 0xe0 | (code >> 12);
|
||||
buf[1] = 0x80 | ((code >> 6) & 0x3f);
|
||||
buf[2] = 0x80 | (code & 0x3f);
|
||||
buf[0] = (unsigned char) (0xe0 | (code >> 12));
|
||||
buf[1] = (unsigned char) (0x80 | ((code >> 6) & 0x3f));
|
||||
buf[2] = (unsigned char) (0x80 | (code & 0x3f));
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -239,10 +239,10 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
|
|||
11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
*/
|
||||
if (code <= 0x001FFFFF) {
|
||||
buf[0] = 0xf0 | (code >> 18);
|
||||
buf[1] = 0x80 | ((code >> 12) & 0x3f);
|
||||
buf[2] = 0x80 | ((code >> 6) & 0x3f);
|
||||
buf[3] = 0x80 | (code & 0x3f);
|
||||
buf[0] = (unsigned char) (0xf0 | (code >> 18));
|
||||
buf[1] = (unsigned char) (0x80 | ((code >> 12) & 0x3f));
|
||||
buf[2] = (unsigned char) (0x80 | ((code >> 6) & 0x3f));
|
||||
buf[3] = (unsigned char) (0x80 | (code & 0x3f));
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -250,11 +250,11 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
|
|||
111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
*/
|
||||
if (code <= 0x03FFFFFF) {
|
||||
buf[0] = 0xf8 | (code >> 24);
|
||||
buf[1] = 0x80 | ((code >> 18) & 0x3f);
|
||||
buf[2] = 0x80 | ((code >> 12) & 0x3f);
|
||||
buf[3] = 0x80 | ((code >> 6) & 0x3f);
|
||||
buf[4] = 0x80 | (code & 0x3f);
|
||||
buf[0] = (unsigned char) (0xf8 | (code >> 24));
|
||||
buf[1] = (unsigned char) (0x80 | ((code >> 18) & 0x3f));
|
||||
buf[2] = (unsigned char) (0x80 | ((code >> 12) & 0x3f));
|
||||
buf[3] = (unsigned char) (0x80 | ((code >> 6) & 0x3f));
|
||||
buf[4] = (unsigned char) (0x80 | (code & 0x3f));
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
@ -262,12 +262,12 @@ int toml_ucs_to_utf8(int64_t code, char buf[6]) {
|
|||
1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
*/
|
||||
if (code <= 0x7FFFFFFF) {
|
||||
buf[0] = 0xfc | (code >> 30);
|
||||
buf[1] = 0x80 | ((code >> 24) & 0x3f);
|
||||
buf[2] = 0x80 | ((code >> 18) & 0x3f);
|
||||
buf[3] = 0x80 | ((code >> 12) & 0x3f);
|
||||
buf[4] = 0x80 | ((code >> 6) & 0x3f);
|
||||
buf[5] = 0x80 | (code & 0x3f);
|
||||
buf[0] = (unsigned char) (0xfc | (code >> 30));
|
||||
buf[1] = (unsigned char) (0x80 | ((code >> 24) & 0x3f));
|
||||
buf[2] = (unsigned char) (0x80 | ((code >> 18) & 0x3f));
|
||||
buf[3] = (unsigned char) (0x80 | ((code >> 12) & 0x3f));
|
||||
buf[4] = (unsigned char) (0x80 | ((code >> 6) & 0x3f));
|
||||
buf[5] = (unsigned char) (0x80 | (code & 0x3f));
|
||||
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);
|
||||
if (ferror(fp)) {
|
||||
snprintf(errbuf, errbufsz, "%s",
|
||||
#pragma warning(suppress : 4996)
|
||||
errno ? strerror(errno) : "Error reading file");
|
||||
xfree(buf);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue