Merge branch 'splitpath_raw_fix' of https://github.com/bcollins526/stb into work2

This commit is contained in:
Sean Barrett 2020-02-02 10:06:31 -08:00
commit d2569111cd

8
stb.h
View File

@ -198,6 +198,7 @@ CREDITS
github:infatum github:infatum
Dave Butler (Croepha) Dave Butler (Croepha)
Ethan Lee (flibitijibibo) Ethan Lee (flibitijibibo)
Brian Collins
*/ */
#include <stdarg.h> #include <stdarg.h>
@ -2006,7 +2007,7 @@ char *stb_trimwhite(char *s)
char *stb_strncpy(char *s, char *t, int n) char *stb_strncpy(char *s, char *t, int n)
{ {
stb_p_strncpy_s(s,n+1,t,n); stb_p_strncpy_s(s,n+1,t,n);
s[n-1] = 0; s[n] = 0;
return s; return s;
} }
@ -2437,7 +2438,7 @@ static char *stb__splitpath_raw(char *buffer, char *path, int flag)
} else { } else {
x = f2; x = f2;
if (flag & STB_EXT_NO_PERIOD) if (flag & STB_EXT_NO_PERIOD)
if (buffer[x] == '.') if (path[x] == '.')
++x; ++x;
} }
@ -2454,8 +2455,7 @@ static char *stb__splitpath_raw(char *buffer, char *path, int flag)
} }
if (len) { stb_p_strcpy_s(buffer, sizeof(buffer), "./"); return buffer; } if (len) { stb_p_strcpy_s(buffer, sizeof(buffer), "./"); return buffer; }
stb_p_strncpy_s(buffer, sizeof(buffer),path+x, y-x); stb_strncpy(buffer, path+int(x), int(y-x));
buffer[y-x] = 0;
return buffer; return buffer;
} }