summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-03-29 09:29:51 +0000
committerManolo Gouy <Manolo>2016-03-29 09:29:51 +0000
commit4fcefc68f8cf9c2648c7140a08fa492c29896c3f (patch)
tree0b21a8db3670e0a410fabb83e0cda5d5fe769b61 /src
parent21655099a71718f7671e634a9b4c4079d135cfaf (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Preferences.cxx8
-rw-r--r--src/Fl_win32.cxx6
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx8
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx2
-rw-r--r--src/fl_call_main.c4
-rw-r--r--src/fl_dnd_win32.cxx6
-rw-r--r--src/fl_utf8.cxx52
-rw-r--r--src/gl_draw.cxx4
8 files changed, 45 insertions, 45 deletions
diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx
index 382186949..2b9473f76 100644
--- a/src/Fl_Preferences.cxx
+++ b/src/Fl_Preferences.cxx
@@ -1010,15 +1010,15 @@ Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, Root root, const char
strcpy(filename, "C:\\FLTK");
} else {
#if 0
- xchar *b = (xchar*)_wcsdup((xchar *)filename);
+ wchar_t *b = (wchar_t*)_wcsdup((wchar_t *)filename);
#else
// cygwin does not come with _wcsdup. Use malloc + wcscpy.
// For implementation of wcsdup functionality See
// - http://linenum.info/p/glibc/2.7/wcsmbs/wcsdup.c
- xchar *b = (xchar*) malloc((wcslen((xchar *) filename) + 1) * sizeof(xchar));
- wcscpy(b, (xchar *) filename);
+ wchar_t *b = (wchar_t*) malloc((wcslen((wchar_t *) filename) + 1) * sizeof(wchar_t));
+ wcscpy(b, (wchar_t *) filename);
#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));
filename[len] = 0;
free(b);
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index d9edce48f..6df0fb769 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -1269,7 +1269,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
static char buffer[1024];
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_utf8fromwc(buffer, 1024, &u, 1);
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) {
#ifdef FLTK_PREVIEW_DEAD_KEYS
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);
buffer[Fl::e_length] = 0;
} else { // set if "extended key" (never printable?)
@@ -1831,7 +1831,7 @@ Fl_X* Fl_X::make(Fl_Window* w) {
if (w->label()) {
size_t l = strlen(w->label());
// 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;
unsigned wlen = fl_utf8toUtf16(w->label(), (unsigned) l, NULL, 0); // Pass NULL to query length
wlen++;
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
index 58049c562..9de668c69 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
@@ -93,10 +93,10 @@ enumcbw(CONST LOGFONTW *lpelf,
if (!p && lpelf->lfCharSet != ANSI_CHARSET) return 1;
char *n = NULL;
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[fl_unicode2utf((xchar*)lpelf->lfFaceName, l, n)] = 0;
- dstlen = fl_utf8fromwc(n, dstlen, (xchar*)lpelf->lfFaceName, (unsigned) l); // convert the string
+//n[fl_unicode2utf((wchar_t*)lpelf->lfFaceName, l, n)] = 0;
+ dstlen = fl_utf8fromwc(n, dstlen, (wchar_t*)lpelf->lfFaceName, (unsigned) l); // convert the string
n[dstlen] = 0;
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;}
@@ -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));
// 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;
size_t len = strlen(s->name+1);
unsigned l = fl_utf8toUtf16(nm, (unsigned) len, NULL, 0); // Pass NULL to query length required
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
index 5c59818a8..d79bc26ae 100644
--- a/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
+++ b/src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
@@ -434,7 +434,7 @@ void Fl_WinAPI_Window_Driver::label(const char *name,const char *iname) {
if (!name) name = "";
size_t l = strlen(name);
// 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
wlen++;
unsigned short * lab = (unsigned short*)malloc(sizeof(unsigned short)*wlen);
diff --git a/src/fl_call_main.c b/src/fl_call_main.c
index 8c21c9307..2f8e6b0d5 100644
--- a/src/fl_call_main.c
+++ b/src/fl_call_main.c
@@ -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)
{
- static xchar *mbwbuf;
+ static wchar_t *mbwbuf;
unsigned dstlen = 0;
if (!s) return 0;
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 = fl_unicode2utf(mbwbuf, l, dst); */
l = fl_utf8fromwc(dst, dstlen, mbwbuf, l);
diff --git a/src/fl_dnd_win32.cxx b/src/fl_dnd_win32.cxx
index 8e0b88f11..35963b9f4 100644
--- a/src/fl_dnd_win32.cxx
+++ b/src/fl_dnd_win32.cxx
@@ -275,8 +275,8 @@ private:
int i, n, nn = 0, nf = DragQueryFileW( hdrop, (UINT)-1, 0, 0 );
for ( i=0; i<nf; i++ ) nn += DragQueryFileW( hdrop, i, 0, 0 );
nn += nf;
- xchar *dst = (xchar *)malloc(nn * sizeof(xchar));
- xchar *bu = dst;
+ wchar_t *dst = (wchar_t *)malloc(nn * sizeof(wchar_t));
+ wchar_t *bu = dst;
for ( i=0; i<nf; i++ ) {
n = DragQueryFileW( hdrop, i, (WCHAR*)dst, nn );
dst += n;
@@ -480,7 +480,7 @@ public:
//
// df->fWide = TRUE;
// 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)));
//
// pMem[l * sizeof(WCHAR) + sizeof(DROPFILES)] = 0;
diff --git a/src/fl_utf8.cxx b/src/fl_utf8.cxx
index 0080cf2e0..cc0a139e0 100644
--- a/src/fl_utf8.cxx
+++ b/src/fl_utf8.cxx
@@ -341,9 +341,9 @@ unsigned int fl_codepage = 0;
// character buffers to support the conversions.
// NOTE: Our re-use of these buffers means this code is not
// going to be thread-safe.
-static xchar *mbwbuf = NULL;
-static xchar *wbuf = NULL;
-static xchar *wbuf1 = NULL;
+static wchar_t *mbwbuf = NULL;
+static wchar_t *wbuf = NULL;
+static wchar_t *wbuf1 = NULL;
static char *buf = NULL;
static int buf_len = 0;
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);
if (l < 0) 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;
return buf;
}
@@ -405,7 +405,7 @@ char * fl_utf2mbcs(const char *s)
static char *buf = NULL;
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
mbwbuf[l] = 0;
@@ -438,10 +438,10 @@ char *fl_getenv(const char* v) {
size_t l = strlen(v);
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
wbuf[wn] = 0;
- xchar *ret = _wgetenv(wbuf);
+ wchar_t *ret = _wgetenv(wbuf);
static char *buf = NULL;
if (ret) {
l = (unsigned) wcslen(ret);
@@ -484,7 +484,7 @@ int fl_open(const char* f, int oflags, ...)
unsigned l = (unsigned) strlen(f);
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
wbuf[wn] = 0;
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);
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
wbuf[wn] = 0;
l = strlen(mode);
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
wbuf1[wn] = 0;
return _wfopen(wbuf, wbuf1);
@@ -559,7 +559,7 @@ int fl_system(const char* cmd)
# else
size_t l = strlen(cmd);
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
wbuf[wn] = 0;
return _wsystem(wbuf);
@@ -579,21 +579,21 @@ int fl_execvp(const char *file, char *const *argv)
# else
size_t l = strlen(file);
int i, n;
- xchar **ar;
+ wchar_t **ar;
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
wbuf[wn] = 0;
i = 0; n = 0;
while (argv[i]) {i++; n++;}
- ar = (xchar**) malloc(sizeof(xchar*) * (n + 1));
+ ar = (wchar_t**) malloc(sizeof(wchar_t*) * (n + 1));
i = 0;
while (i <= n) {
unsigned wn;
l = strlen(argv[i]);
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
ar[i][wn] = 0;
i++;
@@ -636,7 +636,7 @@ int fl_chmod(const char* f, int mode) {
size_t l = strlen(f);
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
wbuf[wn] = 0;
return _wchmod(wbuf, mode);
@@ -671,7 +671,7 @@ int fl_access(const char* f, int mode) {
size_t l = strlen(f);
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
wbuf[wn] = 0;
return _waccess(wbuf, mode);
@@ -706,7 +706,7 @@ int fl_stat(const char* f, struct stat *b) {
size_t l = strlen(f);
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
wbuf[wn] = 0;
return _wstat(wbuf, (struct _stat*)b);
@@ -744,9 +744,9 @@ char *fl_getcwd(char* b, int l) {
#if defined(WIN32) && !defined(__CYGWIN__) // Windows
- static xchar *wbuf = NULL;
- wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
- xchar *ret = _wgetcwd(wbuf, l);
+ static wchar_t *wbuf = NULL;
+ wbuf = (wchar_t*)realloc(wbuf, sizeof(wchar_t) * (l+1));
+ wchar_t *ret = _wgetcwd(wbuf, l);
if (ret) {
unsigned dstlen = l;
l = (int) wcslen(wbuf);
@@ -786,7 +786,7 @@ int fl_unlink(const char* f) {
size_t l = strlen(f);
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
wbuf[wn] = 0;
return _wunlink(wbuf);
@@ -821,7 +821,7 @@ int fl_mkdir(const char* f, int mode) {
size_t l = strlen(f);
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
wbuf[wn] = 0;
return _wmkdir(wbuf);
@@ -855,7 +855,7 @@ int fl_rmdir(const char* f) {
size_t l = strlen(f);
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
wbuf[wn] = 0;
return _wrmdir(wbuf);
@@ -890,12 +890,12 @@ int fl_rename(const char* f, const char *n) {
size_t l = strlen(f);
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
wbuf[wn] = 0;
l = strlen(n);
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
wbuf1[wn] = 0;
return _wrename(wbuf, wbuf1);
diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx
index 10801ae40..4e1612c6e 100644
--- a/src/gl_draw.cxx
+++ b/src/gl_draw.cxx
@@ -192,11 +192,11 @@ void gl_draw(const char* str, int n) {
#ifdef __APPLE__
gl_draw_textures(str, n);
#else
- static xchar *buf = NULL;
+ static unsigned short *buf = NULL;
static int l = 0;
int wn = fl_utf8toUtf16(str, n, (unsigned short*)buf, 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;
wn = fl_utf8toUtf16(str, n, (unsigned short*)buf, l);
}