summaryrefslogtreecommitdiff
path: root/src/fl_utf8.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/fl_utf8.cxx')
-rw-r--r--src/fl_utf8.cxx108
1 files changed, 54 insertions, 54 deletions
diff --git a/src/fl_utf8.cxx b/src/fl_utf8.cxx
index 9a2cfc720..cf43556dd 100644
--- a/src/fl_utf8.cxx
+++ b/src/fl_utf8.cxx
@@ -242,8 +242,8 @@ int fl_utf_strncasecmp(const char *s1, const char *s2, int n)
*/
int fl_utf_strcasecmp(const char *s1, const char *s2)
{
- int s1_l = strlen(s1);
- int s2_l = strlen(s2);
+ int s1_l = (int) strlen(s1);
+ int s2_l = (int) strlen(s2);
if (s1_l < s2_l) {
return -1;
@@ -469,19 +469,19 @@ char * fl_utf2mbcs(const char *s)
{
if (!s) return NULL;
#if defined(WIN32) && !defined(__CYGWIN__)
- int l = strlen(s);
+ size_t l = strlen(s);
static char *buf = NULL;
// mbwbuf = (xchar*)realloc(mbwbuf, (l+6) * sizeof(xchar));
// l = fl_utf2unicode((unsigned char*)s, l, mbwbuf);
// mbwbuf[l] = 0;
- unsigned wn = fl_utf8toUtf16(s, 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);
- l = fl_utf8toUtf16(s, l, (unsigned short *)mbwbuf, wn); // Convert string
+ l = fl_utf8toUtf16(s, (unsigned) l, (unsigned short *)mbwbuf, wn); // Convert string
mbwbuf[l] = 0;
- buf = (char*)realloc(buf, l * 6 + 1);
- l = wcstombs(buf, mbwbuf, l * 6);
+ buf = (char*)realloc(buf, (unsigned) (l * 6 + 1));
+ l = (unsigned) wcstombs(buf, mbwbuf, (unsigned) l * 6);
buf[l] = 0;
return buf;
#else
@@ -522,22 +522,22 @@ static xchar *wbuf1 = NULL;
char *fl_getenv(const char* v)
{
#if defined (WIN32) && !defined(__CYGWIN__)
- int l = strlen(v);
+ size_t l = strlen(v);
// static xchar* wbuf = NULL;
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)v, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(v, 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);
- wn = fl_utf8toUtf16(v, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(v, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
xchar *ret = _wgetenv(wbuf);
static char *buf = NULL;
if (ret) {
- l = wcslen(ret);
- wn = fl_utf8fromwc(NULL, 0, ret, l) + 1; // query length
+ l = (unsigned) wcslen(ret);
+ wn = fl_utf8fromwc(NULL, 0, ret, (unsigned) l) + 1; // query length
buf = (char*) realloc(buf, wn);
// buf[fl_unicode2utf(ret, l, buf)] = 0;
- wn = fl_utf8fromwc(buf, wn, ret, l); // convert string
+ wn = fl_utf8fromwc(buf, wn, ret, (unsigned) l); // convert string
buf[wn] = 0;
return buf;
} else {
@@ -556,7 +556,7 @@ int fl_open(const char* f, int oflags, ...)
pmode = va_arg (ap, int);
va_end(ap);
#if defined (WIN32) && !defined(__CYGWIN__)
- int l = strlen(f);
+ unsigned l = (unsigned) strlen(f);
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)f, l, wbuf)] = 0;
unsigned wn = fl_utf8toUtf16(f, l, NULL, 0) + 1; // Query length
@@ -574,19 +574,19 @@ int fl_open(const char* f, int oflags, ...)
FILE *fl_fopen(const char* f, const char *mode)
{
#if defined (WIN32) && !defined(__CYGWIN__)
- int l = strlen(f);
+ size_t l = strlen(f);
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)f, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(f, 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);
- wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
l = strlen(mode);
// wbuf1 = (xchar*)realloc(wbuf1, sizeof(xchar) * (l+1));
// wbuf1[fl_utf2unicode((const unsigned char*)mode, l, wbuf1)] = 0;
- wn = fl_utf8toUtf16(mode, l, NULL, 0) + 1; // Query length
+ wn = fl_utf8toUtf16(mode, (unsigned) l, NULL, 0) + 1; // Query length
wbuf1 = (xchar*)realloc(wbuf1, sizeof(xchar)*wn);
- wn = fl_utf8toUtf16(mode, l, (unsigned short *)wbuf1, wn); // Convert string
+ wn = fl_utf8toUtf16(mode, (unsigned) l, (unsigned short *)wbuf1, wn); // Convert string
wbuf1[wn] = 0;
return _wfopen(wbuf, wbuf1);
#else
@@ -600,12 +600,12 @@ int fl_system(const char* f)
# ifdef __MINGW32__
return system(fl_utf2mbcs(f));
# else
- int l = strlen(f);
+ size_t l = strlen(f);
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)f, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(f, 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);
- wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
return _wsystem(wbuf);
# endif
@@ -620,14 +620,14 @@ int fl_execvp(const char *file, char *const *argv)
#ifdef __MINGW32__
return _execvp(fl_utf2mbcs(file), argv);
#else
- int l = strlen(file);
+ size_t l = strlen(file);
int i, n, ret;
xchar **ar;
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)file, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(file, 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);
- wn = fl_utf8toUtf16(file, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(file, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
i = 0; n = 0;
@@ -639,9 +639,9 @@ int fl_execvp(const char *file, char *const *argv)
l = strlen(argv[i]);
// ar[i] = (xchar *)malloc(sizeof(xchar) * (l+1));
// ar[i][fl_utf2unicode((const unsigned char*)argv[i], l, ar[i])] = 0;
- wn = fl_utf8toUtf16(argv[i], 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);
- wn = fl_utf8toUtf16(argv[i], 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;
i++;
}
@@ -665,12 +665,12 @@ int fl_execvp(const char *file, char *const *argv)
int fl_chmod(const char* f, int mode)
{
#if defined (WIN32) && !defined(__CYGWIN__)
- int l = strlen(f);
+ size_t l = strlen(f);
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)f, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(f, 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);
- wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
return _wchmod(wbuf, mode);
#else
@@ -681,12 +681,12 @@ int fl_chmod(const char* f, int mode)
int fl_access(const char* f, int mode)
{
#if defined (WIN32) && !defined(__CYGWIN__)
- int l = strlen(f);
+ size_t l = strlen(f);
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)f, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(f, 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);
- wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
return _waccess(wbuf, mode);
#else
@@ -698,12 +698,12 @@ int fl_access(const char* f, int mode)
int fl_stat(const char* f, struct stat *b)
{
#if defined(WIN32) && !defined(__CYGWIN__)
- int l = strlen(f);
+ size_t l = strlen(f);
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)f, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(f, 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);
- wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
return _wstat(wbuf, (struct _stat*)b);
#else
@@ -723,9 +723,9 @@ char *fl_getcwd(char* b, int l)
xchar *ret = _wgetcwd(wbuf, l);
if (ret) {
unsigned dstlen = l;
- l = wcslen(wbuf);
+ l = (int) wcslen(wbuf);
// b[fl_unicode2utf(wbuf, l, b)] = 0;
- dstlen = fl_utf8fromwc(b, dstlen, wbuf, l);
+ dstlen = fl_utf8fromwc(b, dstlen, wbuf, (unsigned) l);
b[dstlen] = 0;
return b;
} else {
@@ -740,12 +740,12 @@ char *fl_getcwd(char* b, int l)
int fl_unlink(const char* f)
{
#if defined(WIN32) && !defined(__CYGWIN__)
- int l = strlen(f);
+ size_t l = strlen(f);
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)f, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(f, 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);
- wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
return _wunlink(wbuf);
#else
@@ -756,12 +756,12 @@ int fl_unlink(const char* f)
int fl_mkdir(const char* f, int mode)
{
#if defined(WIN32) && !defined(__CYGWIN__)
- int l = strlen(f);
+ size_t l = strlen(f);
// wbuf = (xchar*)realloc(wbuf, sizeof(short) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)f, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(f, 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);
- wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
return _wmkdir(wbuf);
#else
@@ -773,12 +773,12 @@ int fl_mkdir(const char* f, int mode)
int fl_rmdir(const char* f)
{
#if defined (WIN32) && !defined(__CYGWIN__)
- int l = strlen(f);
+ size_t l = strlen(f);
// wbuf = (xchar*)realloc(wbuf, sizeof(xchar) * (l+1));
// wbuf[fl_utf2unicode((const unsigned char*)f, l, wbuf)] = 0;
- unsigned wn = fl_utf8toUtf16(f, 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);
- wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
return _wrmdir(wbuf);
#else
@@ -789,15 +789,15 @@ int fl_rmdir(const char* f)
int fl_rename(const char* f, const char *n)
{
#if defined (WIN32) && !defined(__CYGWIN__)
- int l = strlen(f);
- unsigned wn = fl_utf8toUtf16(f, l, NULL, 0) + 1; // Query length
+ size_t l = strlen(f);
+ unsigned wn = fl_utf8toUtf16(f, (unsigned) l, NULL, 0) + 1; // Query length
wbuf = (xchar*)realloc(wbuf, sizeof(xchar)*wn);
- wn = fl_utf8toUtf16(f, l, (unsigned short *)wbuf, wn); // Convert string
+ wn = fl_utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf, wn); // Convert string
wbuf[wn] = 0;
l = strlen(n);
- wn = fl_utf8toUtf16(n, l, NULL, 0) + 1; // Query length
+ wn = fl_utf8toUtf16(n, (unsigned) l, NULL, 0) + 1; // Query length
wbuf1 = (xchar*)realloc(wbuf1, sizeof(xchar)*wn);
- wn = fl_utf8toUtf16(n, l, (unsigned short *)wbuf1, wn); // Convert string
+ wn = fl_utf8toUtf16(n, (unsigned) l, (unsigned short *)wbuf1, wn); // Convert string
wbuf1[wn] = 0;
return _wrename(wbuf, wbuf1);
#else
@@ -810,7 +810,7 @@ char fl_make_path( const char *path ) {
if (fl_access(path, 0)) {
const char *s = strrchr( path, '/' );
if ( !s ) return 0;
- int len = s-path;
+ size_t len = (size_t) (s-path);
char *p = (char*)malloc( len+1 );
memcpy( p, path, len );
p[len] = 0;
@@ -826,7 +826,7 @@ void fl_make_path_for_file( const char *path )
{
const char *s = strrchr( path, '/' );
if ( !s ) return;
- int len = s-path;
+ size_t len = (s-path);
char *p = (char*)malloc( len+1 );
memcpy( p, path, len );
p[len] = 0;