fix: isprint => canprint

add a canprint() func that return true iif
char is ascii (< 0x80) and not a control char
(> 0x1F), as isprint() seems to be different
under Linux and Windows
This commit is contained in:
Stéphane Lesimple
2020-08-25 13:03:05 +02:00
parent 5ab5f9b0cb
commit 5553ed332f
9 changed files with 65 additions and 18 deletions

View File

@@ -36,6 +36,34 @@
* Also, individual behaviour may deviate from standard functions.
*/
#ifdef SYS_MINGW
#include <windows.h>
#define stat _stati64
#define lseek _lseeki64
/* The original windows ftruncate has off_size (32bit) */
int large_ftruncate(int fd, gint64 size)
{ gint32 handle;
if((handle=_get_osfhandle(fd)) == -1)
return -1;
if(_lseeki64(fd, size, SEEK_SET) == -1)
return -1;
if(SetEndOfFile((HANDLE)handle) == 0)
return -1;
return 0;
}
#else
#define large_ftruncate ftruncate
#endif /* SYS_MINGW */
/*
* convert special chars in file names to correct OS encoding
*/
@@ -279,7 +307,7 @@ int LargeClose(LargeFile *lf)
int LargeTruncate(LargeFile *lf, off_t length)
{ int result;
result = (ftruncate(lf->fileHandle, length) == 0);
result = (large_ftruncate(lf->fileHandle, length) == 0);
if(result)
lf->size = length;
@@ -319,6 +347,19 @@ FILE *portable_fopen(char *path, char *modes)
return file;
}
#ifdef SYS_MINGW
int portable_mkdir(char *path)
{ int status;
char *cp_path;
cp_path = os_path(path);
status = mkdir(cp_path);
g_free(cp_path);
return status;
}
#endif
/***
*** Convenience functions
***/