Remove the platform-dependent type xchar

File fl_utf8.h defines the xchar type with a platform-dependent value (wchar_t or unsigned short).
But it is used exclusively by WIN32 code (0 use in cross-platform code, 0 use in APPLE
or in USE_X11 code).
Thus, we can just get rid of this type and replace it by wchar_t where it is used.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11459 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy
2016-03-29 09:29:51 +00:00
parent 21655099a7
commit 4fcefc68f8
9 changed files with 50 additions and 50 deletions
+5 -5
View File
@@ -47,7 +47,7 @@
# include <sys/stat.h> # include <sys/stat.h>
# include <locale.h> # include <locale.h>
# include <ctype.h> # include <ctype.h>
# define xchar wchar_t //# define xchar wchar_t
# if !defined(FL_DLL) && !defined(__CYGWIN__) # if !defined(FL_DLL) && !defined(__CYGWIN__)
# undef strdup # undef strdup
# define strdup _strdup # define strdup _strdup
@@ -63,13 +63,13 @@
#elif defined(__APPLE__) /* PORTME: should not be in the header */ #elif defined(__APPLE__) /* PORTME: should not be in the header */
# include <wchar.h> # include <wchar.h>
# include <sys/stat.h> # include <sys/stat.h>
# define xchar wchar_t //# define xchar wchar_t
#elif defined(ANDROID) #elif defined(ANDROID)
# include <wchar.h> # include <wchar.h>
# define xchar wchar_t //# define xchar wchar_t
#elif defined(FL_PORTING) #elif defined(FL_PORTING)
# pragma message "FL_PORTING: include UTF-8 support files and define UTF-8 types" # pragma message "FL_PORTING: include UTF-8 support files and define UTF-8 types"
# define xchar unsigned short //# define xchar unsigned short
/* TODO: the condition below is not portable! */ /* TODO: the condition below is not portable! */
#else /* X11 */ #else /* X11 */
# include <sys/types.h> # include <sys/types.h>
@@ -79,7 +79,7 @@
//# include <X11/Xlib.h> //# include <X11/Xlib.h>
# endif /* defined(FL_LIBRARY) -- don't expose X11 headers in user space */ # endif /* defined(FL_LIBRARY) -- don't expose X11 headers in user space */
# include <locale.h> # include <locale.h>
# define xchar unsigned short //# define xchar unsigned short
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
+4 -4
View File
@@ -1010,15 +1010,15 @@ Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, Root root, const char
strcpy(filename, "C:\\FLTK"); strcpy(filename, "C:\\FLTK");
} else { } else {
#if 0 #if 0
xchar *b = (xchar*)_wcsdup((xchar *)filename); wchar_t *b = (wchar_t*)_wcsdup((wchar_t *)filename);
#else #else
// cygwin does not come with _wcsdup. Use malloc + wcscpy. // cygwin does not come with _wcsdup. Use malloc + wcscpy.
// For implementation of wcsdup functionality See // For implementation of wcsdup functionality See
// - http://linenum.info/p/glibc/2.7/wcsmbs/wcsdup.c // - http://linenum.info/p/glibc/2.7/wcsmbs/wcsdup.c
xchar *b = (xchar*) malloc((wcslen((xchar *) filename) + 1) * sizeof(xchar)); wchar_t *b = (wchar_t*) malloc((wcslen((wchar_t *) filename) + 1) * sizeof(wchar_t));
wcscpy(b, (xchar *) filename); wcscpy(b, (wchar_t *) filename);
#endif #endif
// filename[fl_unicode2utf(b, wcslen((xchar*)b), filename)] = 0; // filename[fl_unicode2utf(b, wcslen((wchar_t*)b), filename)] = 0;
unsigned len = fl_utf8fromwc(filename, (FL_PATH_MAX-1), b, (unsigned) wcslen(b)); unsigned len = fl_utf8fromwc(filename, (FL_PATH_MAX-1), b, (unsigned) wcslen(b));
filename[len] = 0; filename[len] = 0;
free(b); free(b);
+3 -3
View File
@@ -1269,7 +1269,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
static char buffer[1024]; static char buffer[1024];
if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR) { if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR) {
xchar u = (xchar) wParam; wchar_t u = (wchar_t) wParam;
// Fl::e_length = fl_unicode2utf(&u, 1, buffer); // Fl::e_length = fl_unicode2utf(&u, 1, buffer);
Fl::e_length = fl_utf8fromwc(buffer, 1024, &u, 1); Fl::e_length = fl_utf8fromwc(buffer, 1024, &u, 1);
buffer[Fl::e_length] = 0; buffer[Fl::e_length] = 0;
@@ -1327,7 +1327,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
} else if ((lParam & (1<<31))==0) { } else if ((lParam & (1<<31))==0) {
#ifdef FLTK_PREVIEW_DEAD_KEYS #ifdef FLTK_PREVIEW_DEAD_KEYS
if ((lParam & (1<<24))==0) { // clear if dead key (always?) if ((lParam & (1<<24))==0) { // clear if dead key (always?)
xchar u = (xchar) wParam; wchar_t u = (wchar_t) wParam;
Fl::e_length = fl_utf8fromwc(buffer, 1024, &u, 1); Fl::e_length = fl_utf8fromwc(buffer, 1024, &u, 1);
buffer[Fl::e_length] = 0; buffer[Fl::e_length] = 0;
} else { // set if "extended key" (never printable?) } else { // set if "extended key" (never printable?)
@@ -1831,7 +1831,7 @@ Fl_X* Fl_X::make(Fl_Window* w) {
if (w->label()) { if (w->label()) {
size_t l = strlen(w->label()); size_t l = strlen(w->label());
// lab = (WCHAR*) malloc((l + 1) * sizeof(short)); // lab = (WCHAR*) malloc((l + 1) * sizeof(short));
// l = fl_utf2unicode((unsigned char*)w->label(), l, (xchar*)lab); // l = fl_utf2unicode((unsigned char*)w->label(), l, (wchar_t*)lab);
// lab[l] = 0; // lab[l] = 0;
unsigned wlen = fl_utf8toUtf16(w->label(), (unsigned) l, NULL, 0); // Pass NULL to query length unsigned wlen = fl_utf8toUtf16(w->label(), (unsigned) l, NULL, 0); // Pass NULL to query length
wlen++; wlen++;
@@ -93,10 +93,10 @@ enumcbw(CONST LOGFONTW *lpelf,
if (!p && lpelf->lfCharSet != ANSI_CHARSET) return 1; if (!p && lpelf->lfCharSet != ANSI_CHARSET) return 1;
char *n = NULL; char *n = NULL;
size_t l = wcslen(lpelf->lfFaceName); size_t l = wcslen(lpelf->lfFaceName);
unsigned dstlen = fl_utf8fromwc(n, 0, (xchar*)lpelf->lfFaceName, (unsigned) l) + 1; // measure the string unsigned dstlen = fl_utf8fromwc(n, 0, (wchar_t*)lpelf->lfFaceName, (unsigned) l) + 1; // measure the string
n = (char*) malloc(dstlen); n = (char*) malloc(dstlen);
//n[fl_unicode2utf((xchar*)lpelf->lfFaceName, l, n)] = 0; //n[fl_unicode2utf((wchar_t*)lpelf->lfFaceName, l, n)] = 0;
dstlen = fl_utf8fromwc(n, dstlen, (xchar*)lpelf->lfFaceName, (unsigned) l); // convert the string dstlen = fl_utf8fromwc(n, dstlen, (wchar_t*)lpelf->lfFaceName, (unsigned) l); // convert the string
n[dstlen] = 0; n[dstlen] = 0;
for (int i=0; i<FL_FREE_FONT; i++) // skip if one of our built-in fonts for (int i=0; i<FL_FREE_FONT; i++) // skip if one of our built-in fonts
if (!strcmp(Fl::get_font_name((Fl_Font)i),n)) {free(n);return 1;} if (!strcmp(Fl::get_font_name((Fl_Font)i),n)) {free(n);return 1;}
@@ -176,7 +176,7 @@ Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
// int l = fl_utf_nb_char((unsigned char*)s->name+1, strlen(s->name+1)); // int l = fl_utf_nb_char((unsigned char*)s->name+1, strlen(s->name+1));
// unsigned short *b = (unsigned short*) malloc((l + 1) * sizeof(short)); // unsigned short *b = (unsigned short*) malloc((l + 1) * sizeof(short));
// fl_utf2unicode((unsigned char*)s->name+1, l, (xchar*)b); // fl_utf2unicode((unsigned char*)s->name+1, l, (wchar_t*)b);
const char *nm = (const char*)s->name+1; const char *nm = (const char*)s->name+1;
size_t len = strlen(s->name+1); size_t len = strlen(s->name+1);
unsigned l = fl_utf8toUtf16(nm, (unsigned) len, NULL, 0); // Pass NULL to query length required unsigned l = fl_utf8toUtf16(nm, (unsigned) len, NULL, 0); // Pass NULL to query length required
@@ -434,7 +434,7 @@ void Fl_WinAPI_Window_Driver::label(const char *name,const char *iname) {
if (!name) name = ""; if (!name) name = "";
size_t l = strlen(name); size_t l = strlen(name);
// WCHAR *lab = (WCHAR*) malloc((l + 1) * sizeof(short)); // WCHAR *lab = (WCHAR*) malloc((l + 1) * sizeof(short));
// l = fl_utf2unicode((unsigned char*)name, l, (xchar*)lab); // l = fl_utf2unicode((unsigned char*)name, l, (wchar_t*)lab);
unsigned wlen = fl_utf8toUtf16(name, (unsigned) l, NULL, 0); // Pass NULL to query length unsigned wlen = fl_utf8toUtf16(name, (unsigned) l, NULL, 0); // Pass NULL to query length
wlen++; wlen++;
unsigned short * lab = (unsigned short*)malloc(sizeof(unsigned short)*wlen); unsigned short * lab = (unsigned short*)malloc(sizeof(unsigned short)*wlen);
+2 -2
View File
@@ -60,11 +60,11 @@ extern int main(int, char *[]);
/* static int mbcs2utf(const char *s, int l, char *dst, unsigned dstlen) */ /* static int mbcs2utf(const char *s, int l, char *dst, unsigned dstlen) */
static int mbcs2utf(const char *s, int l, char *dst) static int mbcs2utf(const char *s, int l, char *dst)
{ {
static xchar *mbwbuf; static wchar_t *mbwbuf;
unsigned dstlen = 0; unsigned dstlen = 0;
if (!s) return 0; if (!s) return 0;
dstlen = (l * 6) + 6; dstlen = (l * 6) + 6;
mbwbuf = (xchar*)malloc(dstlen * sizeof(xchar)); mbwbuf = (wchar_t*)malloc(dstlen * sizeof(wchar_t));
l = (int) mbstowcs(mbwbuf, s, l); l = (int) mbstowcs(mbwbuf, s, l);
/* l = fl_unicode2utf(mbwbuf, l, dst); */ /* l = fl_unicode2utf(mbwbuf, l, dst); */
l = fl_utf8fromwc(dst, dstlen, mbwbuf, l); l = fl_utf8fromwc(dst, dstlen, mbwbuf, l);
+3 -3
View File
@@ -275,8 +275,8 @@ private:
int i, n, nn = 0, nf = DragQueryFileW( hdrop, (UINT)-1, 0, 0 ); int i, n, nn = 0, nf = DragQueryFileW( hdrop, (UINT)-1, 0, 0 );
for ( i=0; i<nf; i++ ) nn += DragQueryFileW( hdrop, i, 0, 0 ); for ( i=0; i<nf; i++ ) nn += DragQueryFileW( hdrop, i, 0, 0 );
nn += nf; nn += nf;
xchar *dst = (xchar *)malloc(nn * sizeof(xchar)); wchar_t *dst = (wchar_t *)malloc(nn * sizeof(wchar_t));
xchar *bu = dst; wchar_t *bu = dst;
for ( i=0; i<nf; i++ ) { for ( i=0; i<nf; i++ ) {
n = DragQueryFileW( hdrop, i, (WCHAR*)dst, nn ); n = DragQueryFileW( hdrop, i, (WCHAR*)dst, nn );
dst += n; dst += n;
@@ -480,7 +480,7 @@ public:
// //
// df->fWide = TRUE; // df->fWide = TRUE;
// l = fl_utf2unicode((unsigned char*)fl_selection_buffer[0], // l = fl_utf2unicode((unsigned char*)fl_selection_buffer[0],
// fl_selection_length[0], (xchar*)(((char*)pMem) // fl_selection_length[0], (wchar_t*)(((char*)pMem)
// + sizeof(DROPFILES))); // + sizeof(DROPFILES)));
// //
// pMem[l * sizeof(WCHAR) + sizeof(DROPFILES)] = 0; // pMem[l * sizeof(WCHAR) + sizeof(DROPFILES)] = 0;
+26 -26
View File
@@ -341,9 +341,9 @@ unsigned int fl_codepage = 0;
// character buffers to support the conversions. // character buffers to support the conversions.
// NOTE: Our re-use of these buffers means this code is not // NOTE: Our re-use of these buffers means this code is not
// going to be thread-safe. // going to be thread-safe.
static xchar *mbwbuf = NULL; static wchar_t *mbwbuf = NULL;
static xchar *wbuf = NULL; static wchar_t *wbuf = NULL;
static xchar *wbuf1 = NULL; static wchar_t *wbuf1 = NULL;
static char *buf = NULL; static char *buf = NULL;
static int buf_len = 0; static int buf_len = 0;
static unsigned short *wbufa = NULL; static unsigned short *wbufa = NULL;
@@ -386,7 +386,7 @@ char *fl_locale_to_utf8(const char *s, int len, UINT codepage)
l = MultiByteToWideChar(codepage, 0, s, len, (WCHAR*)wbufa, buf_len); l = MultiByteToWideChar(codepage, 0, s, len, (WCHAR*)wbufa, buf_len);
if (l < 0) l = 0; if (l < 0) l = 0;
wbufa[l] = 0; wbufa[l] = 0;
l = fl_utf8fromwc(buf, buf_len, (xchar*)wbufa, l); l = fl_utf8fromwc(buf, buf_len, (wchar_t*)wbufa, l);
buf[l] = 0; buf[l] = 0;
return buf; return buf;
} }
@@ -405,7 +405,7 @@ char * fl_utf2mbcs(const char *s)
static char *buf = NULL; static char *buf = NULL;
unsigned wn = fl_utf8toUtf16(s, (unsigned) l, NULL, 0) + 7; // Query length unsigned wn = fl_utf8toUtf16(s, (unsigned) l, NULL, 0) + 7; // Query length
mbwbuf = (xchar*)realloc(mbwbuf, sizeof(xchar)*wn); mbwbuf = (wchar_t*)realloc(mbwbuf, sizeof(wchar_t)*wn);
l = fl_utf8toUtf16(s, (unsigned) l, (unsigned short *)mbwbuf, wn); // Convert string l = fl_utf8toUtf16(s, (unsigned) l, (unsigned short *)mbwbuf, wn); // Convert string
mbwbuf[l] = 0; mbwbuf[l] = 0;
@@ -438,10 +438,10 @@ char *fl_getenv(const char* v) {
size_t l = strlen(v); size_t l = strlen(v);
unsigned wn = fl_utf8toUtf16(v, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(v, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(v, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(v, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
xchar *ret = _wgetenv(wbuf); wchar_t *ret = _wgetenv(wbuf);
static char *buf = NULL; static char *buf = NULL;
if (ret) { if (ret) {
l = (unsigned) wcslen(ret); l = (unsigned) wcslen(ret);
@@ -484,7 +484,7 @@ int fl_open(const char* f, int oflags, ...)
unsigned l = (unsigned) strlen(f); unsigned l = (unsigned) strlen(f);
unsigned wn = fl_utf8toUtf16(f, l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(f, l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
if (pmode == -1) return _wopen(wbuf, oflags); if (pmode == -1) return _wopen(wbuf, oflags);
@@ -520,12 +520,12 @@ FILE *fl_fopen(const char* f, const char *mode) {
size_t l = strlen(f); size_t l = strlen(f);
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
l = strlen(mode); l = strlen(mode);
wn = fl_utf8toUtf16(mode, (unsigned) l, NULL, 0) + 1; // Query length wn = fl_utf8toUtf16(mode, (unsigned) l, NULL, 0) + 1; // Query length
wbuf1 = (xchar*)realloc(wbuf1, sizeof(xchar)*wn); wbuf1 = (wchar_t*)realloc(wbuf1, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(mode, (unsigned) l, (unsigned short *)wbuf1, wn); // Convert string wn = fl_utf8toUtf16(mode, (unsigned) l, (unsigned short *)wbuf1, wn); // Convert string
wbuf1[wn] = 0; wbuf1[wn] = 0;
return _wfopen(wbuf, wbuf1); return _wfopen(wbuf, wbuf1);
@@ -559,7 +559,7 @@ int fl_system(const char* cmd)
# else # else
size_t l = strlen(cmd); size_t l = strlen(cmd);
unsigned wn = fl_utf8toUtf16(cmd, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(cmd, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(cmd, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(cmd, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
return _wsystem(wbuf); return _wsystem(wbuf);
@@ -579,21 +579,21 @@ int fl_execvp(const char *file, char *const *argv)
# else # else
size_t l = strlen(file); size_t l = strlen(file);
int i, n; int i, n;
xchar **ar; wchar_t **ar;
unsigned wn = fl_utf8toUtf16(file, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(file, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(file, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(file, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
i = 0; n = 0; i = 0; n = 0;
while (argv[i]) {i++; n++;} while (argv[i]) {i++; n++;}
ar = (xchar**) malloc(sizeof(xchar*) * (n + 1)); ar = (wchar_t**) malloc(sizeof(wchar_t*) * (n + 1));
i = 0; i = 0;
while (i <= n) { while (i <= n) {
unsigned wn; unsigned wn;
l = strlen(argv[i]); l = strlen(argv[i]);
wn = fl_utf8toUtf16(argv[i], (unsigned) l, NULL, 0) + 1; // Query length wn = fl_utf8toUtf16(argv[i], (unsigned) l, NULL, 0) + 1; // Query length
ar[i] = (xchar *)malloc(sizeof(xchar)*wn); ar[i] = (wchar_t *)malloc(sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(argv[i], (unsigned) l, (unsigned short *)ar[i], wn); // Convert string wn = fl_utf8toUtf16(argv[i], (unsigned) l, (unsigned short *)ar[i], wn); // Convert string
ar[i][wn] = 0; ar[i][wn] = 0;
i++; i++;
@@ -636,7 +636,7 @@ int fl_chmod(const char* f, int mode) {
size_t l = strlen(f); size_t l = strlen(f);
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
return _wchmod(wbuf, mode); return _wchmod(wbuf, mode);
@@ -671,7 +671,7 @@ int fl_access(const char* f, int mode) {
size_t l = strlen(f); size_t l = strlen(f);
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
return _waccess(wbuf, mode); return _waccess(wbuf, mode);
@@ -706,7 +706,7 @@ int fl_stat(const char* f, struct stat *b) {
size_t l = strlen(f); size_t l = strlen(f);
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
return _wstat(wbuf, (struct _stat*)b); return _wstat(wbuf, (struct _stat*)b);
@@ -744,9 +744,9 @@ char *fl_getcwd(char* b, int l) {
#if defined(WIN32) && !defined(__CYGWIN__) // Windows #if defined(WIN32) && !defined(__CYGWIN__) // Windows
static xchar *wbuf = NULL; static wchar_t *wbuf = NULL;
wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1)); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t) * (l+1));
xchar *ret = _wgetcwd(wbuf, l); wchar_t *ret = _wgetcwd(wbuf, l);
if (ret) { if (ret) {
unsigned dstlen = l; unsigned dstlen = l;
l = (int) wcslen(wbuf); l = (int) wcslen(wbuf);
@@ -786,7 +786,7 @@ int fl_unlink(const char* f) {
size_t l = strlen(f); size_t l = strlen(f);
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
return _wunlink(wbuf); return _wunlink(wbuf);
@@ -821,7 +821,7 @@ int fl_mkdir(const char* f, int mode) {
size_t l = strlen(f); size_t l = strlen(f);
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
return _wmkdir(wbuf); return _wmkdir(wbuf);
@@ -855,7 +855,7 @@ int fl_rmdir(const char* f) {
size_t l = strlen(f); size_t l = strlen(f);
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
return _wrmdir(wbuf); return _wrmdir(wbuf);
@@ -890,12 +890,12 @@ int fl_rename(const char* f, const char *n) {
size_t l = strlen(f); size_t l = strlen(f);
unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn); wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0; wbuf[wn] = 0;
l = strlen(n); l = strlen(n);
wn = fl_utf8toUtf16(n, (unsigned) l, NULL, 0) + 1; // Query length wn = fl_utf8toUtf16(n, (unsigned) l, NULL, 0) + 1; // Query length
wbuf1 = (xchar*)realloc(wbuf1, sizeof(xchar)*wn); wbuf1 = (wchar_t*)realloc(wbuf1, sizeof(wchar_t)*wn);
wn = fl_utf8toUtf16(n, (unsigned) l, (unsigned short *)wbuf1, wn); // Convert string wn = fl_utf8toUtf16(n, (unsigned) l, (unsigned short *)wbuf1, wn); // Convert string
wbuf1[wn] = 0; wbuf1[wn] = 0;
return _wrename(wbuf, wbuf1); return _wrename(wbuf, wbuf1);
+2 -2
View File
@@ -192,11 +192,11 @@ void gl_draw(const char* str, int n) {
#ifdef __APPLE__ #ifdef __APPLE__
gl_draw_textures(str, n); gl_draw_textures(str, n);
#else #else
static xchar *buf = NULL; static unsigned short *buf = NULL;
static int l = 0; static int l = 0;
int wn = fl_utf8toUtf16(str, n, (unsigned short*)buf, l); int wn = fl_utf8toUtf16(str, n, (unsigned short*)buf, l);
if(wn >= l) { if(wn >= l) {
buf = (xchar*) realloc(buf, sizeof(xchar) * (wn + 1)); buf = (unsigned short*) realloc(buf, sizeof(unsigned short) * (wn + 1));
l = wn + 1; l = wn + 1;
wn = fl_utf8toUtf16(str, n, (unsigned short*)buf, l); wn = fl_utf8toUtf16(str, n, (unsigned short*)buf, l);
} }