From 933a1fdd8d3e96e33ce3565ba6db382b982b24ec Mon Sep 17 00:00:00 2001 From: "T. J. Moran" Date: Thu, 18 Dec 2014 23:17:47 +0000 Subject: [PATCH] Add explicit wchar_t casts in stb.h --- stb.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/stb.h b/stb.h index f903140..ab36a66 100644 --- a/stb.h +++ b/stb.h @@ -851,7 +851,7 @@ void stbprint(const char *fmt, ...) #ifdef _WIN32 - #define stb__fopen(x,y) _wfopen(stb__from_utf8(x), stb__from_utf8_alt(y)) + #define stb__fopen(x,y) _wfopen((const wchar_t *)stb__from_utf8(x), (const wchar_t *)stb__from_utf8_alt(y)) #define stb__windows(x,y) x #else #define stb__fopen(x,y) fopen(x,y) @@ -1244,7 +1244,7 @@ void stb_newell_normal(float *normal, int num_vert, float **vert, int normalize) int stb_box_face_vertex_axis_side(int face_number, int vertex_number, int axis) { - static box_vertices[6][4][3] = + static int box_vertices[6][4][3] = { { { 1,1,1 }, { 1,0,1 }, { 1,0,0 }, { 1,1,0 } }, { { 0,0,0 }, { 0,0,1 }, { 0,1,1 }, { 0,1,0 } }, @@ -4910,7 +4910,7 @@ void stb_nptr_recache(void) #ifdef _MSC_VER - #define stb_rename(x,y) _wrename(stb__from_utf8(x), stb__from_utf8_alt(y)) + #define stb_rename(x,y) _wrename((const wchar_t *)stb__from_utf8(x), (const wchar_t *)stb__from_utf8_alt(y)) #define stb_mktemp _mktemp #else #define stb_mktemp mktemp @@ -5049,7 +5049,7 @@ int stb_fexists(char *filename) { struct stb__stat buf; return stb__windows( - _wstat(stb__from_utf8(filename), &buf), + _wstat((const wchar_t *)stb__from_utf8(filename), &buf), stat(filename,&buf) ) == 0; } @@ -5058,7 +5058,7 @@ time_t stb_ftimestamp(char *filename) { struct stb__stat buf; if (stb__windows( - _wstat(stb__from_utf8(filename), &buf), + _wstat((const wchar_t *)stb__from_utf8(filename), &buf), stat(filename,&buf) ) == 0) { @@ -5837,7 +5837,7 @@ static char **readdir_raw(char *dir, int return_subdirs, char *mask) #ifdef _MSC_VER strcpy(buffer+n, "*.*"); ws = stb__from_utf8(buffer); - z = _wfindfirst(ws, &data); + z = _wfindfirst((const wchar_t *)ws, &data); #else z = opendir(dir); #endif @@ -5855,7 +5855,7 @@ static char **readdir_raw(char *dir, int return_subdirs, char *mask) do { int is_subdir; #ifdef _MSC_VER - char *name = stb__to_utf8(data.name); + char *name = stb__to_utf8((stb__wchar *)data.name); if (name == NULL) { fprintf(stderr, "%s to convert '%S' to %s!\n", "Unable", data.name, "utf8"); continue; @@ -6804,9 +6804,9 @@ static void stb__dirtree_scandir(char *path, time_t last_time, stb_dirtree *acti has_slash = (path[0] && path[strlen(path)-1] == '/'); if (has_slash) - swprintf(full_path, L"%s*", stb__from_utf8(path)); + swprintf((wchar_t *)full_path, L"%s*", stb__from_utf8(path)); else - swprintf(full_path, L"%s/*", stb__from_utf8(path)); + swprintf((wchar_t *)full_path, L"%s/*", stb__from_utf8(path)); // it's possible this directory is already present: that means it was in the // cache, but its parent wasn't... in that case, we're done with it @@ -6818,13 +6818,13 @@ static void stb__dirtree_scandir(char *path, time_t last_time, stb_dirtree *acti stb__dirtree_add_dir(path, last_time, active); n = stb_arr_lastn(active->dirs); - if( (hFile = _wfindfirst( full_path, &c_file )) != -1L ) { + if( (hFile = _wfindfirst((const wchar_t *)full_path, &c_file )) != -1L ) { do { if (c_file.attrib & _A_SUBDIR) { // ignore subdirectories starting with '.', e.g. "." and ".." if (c_file.name[0] != '.') { char *new_path = (char *) full_path; - char *temp = stb__to_utf8(c_file.name); + char *temp = stb__to_utf8((stb__wchar *)c_file.name); if (has_slash) sprintf(new_path, "%s%s", path, temp); else @@ -6832,7 +6832,7 @@ static void stb__dirtree_scandir(char *path, time_t last_time, stb_dirtree *acti stb__dirtree_scandir(new_path, c_file.time_write, active); } } else { - char *temp = stb__to_utf8(c_file.name); + char *temp = stb__to_utf8((stb__wchar *)c_file.name); stb__dirtree_add_file(temp, n, c_file.size, c_file.time_write, active); } } while( _wfindnext( hFile, &c_file ) == 0 ); @@ -11049,7 +11049,7 @@ stb_arith_symstate *stb_arith_state_create(int num_sym) return s; } -static stb_arith_state_rescale(stb_arith_symstate *s) +static void stb_arith_state_rescale(stb_arith_symstate *s) { if (s->pow2 < POW2_LIMIT) { int pcf, cf, cf_next, next, i;