path.*: cleanups
utf8.c: add some static's git-svn-id: https://svn.musicpd.org/mpd/trunk@4311 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
19
src/path.c
19
src/path.c
@@ -42,23 +42,16 @@ char * playlistDir;
|
|||||||
|
|
||||||
char * fsCharset = NULL;
|
char * fsCharset = NULL;
|
||||||
|
|
||||||
char * pathConvCharset(char * to, char * from, char * str, char * ret) {
|
static char * pathConvCharset(char * to, char * from, char * str) {
|
||||||
if(ret) {
|
|
||||||
free(ret);
|
|
||||||
ret = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(setCharSetConversion(to,from)==0) {
|
if(setCharSetConversion(to,from)==0) {
|
||||||
ret = convStrDup(str);
|
return convStrDup(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * fsCharsetToUtf8(char * str) {
|
char * fsCharsetToUtf8(char * str) {
|
||||||
static char * ret = NULL;
|
char * ret = pathConvCharset("UTF-8",fsCharset,str);
|
||||||
|
|
||||||
ret = pathConvCharset("UTF-8",fsCharset,str,ret);
|
|
||||||
|
|
||||||
if(ret && !validUtf8String(ret)) {
|
if(ret && !validUtf8String(ret)) {
|
||||||
free(ret);
|
free(ret);
|
||||||
@@ -69,9 +62,7 @@ char * fsCharsetToUtf8(char * str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char * utf8ToFsCharset(char * str) {
|
char * utf8ToFsCharset(char * str) {
|
||||||
static char * ret = NULL;
|
char * ret = pathConvCharset(fsCharset,"UTF-8",str);
|
||||||
|
|
||||||
ret = pathConvCharset(fsCharset,"UTF-8",str,ret);
|
|
||||||
|
|
||||||
if(!ret) ret = strdup(str);
|
if(!ret) ret = strdup(str);
|
||||||
|
|
||||||
|
@@ -51,6 +51,4 @@ char * parentPath(char * path);
|
|||||||
/* strips extra "///" and leading "/" and trailing "/" */
|
/* strips extra "///" and leading "/" and trailing "/" */
|
||||||
char * sanitizePathDup(char * path);
|
char * sanitizePathDup(char * path);
|
||||||
|
|
||||||
char * prependCwdToPathDup(char * path);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
unsigned char * latin1ToUtf8(unsigned char c) {
|
static unsigned char * latin1ToUtf8(unsigned char c) {
|
||||||
static unsigned char utf8[3];
|
static unsigned char utf8[3];
|
||||||
|
|
||||||
memset(utf8,0,3);
|
memset(utf8,0,3);
|
||||||
@@ -63,7 +63,7 @@ unsigned char * latin1StrToUtf8Dup(unsigned char * latin1) {
|
|||||||
return realloc(ret,len+1);
|
return realloc(ret,len+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char utf8ToLatin1(unsigned char * utf8) {
|
static unsigned char utf8ToLatin1(unsigned char * utf8) {
|
||||||
unsigned char c = 0;
|
unsigned char c = 0;
|
||||||
|
|
||||||
if(utf8[0]<128) return utf8[0];
|
if(utf8[0]<128) return utf8[0];
|
||||||
@@ -72,7 +72,7 @@ unsigned char utf8ToLatin1(unsigned char * utf8) {
|
|||||||
return c+utf8[1];
|
return c+utf8[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
int validateUtf8Char(unsigned char * utf8Char) {
|
static int validateUtf8Char(unsigned char * utf8Char) {
|
||||||
if(utf8Char[0]<0x80) return 1;
|
if(utf8Char[0]<0x80) return 1;
|
||||||
|
|
||||||
if(utf8Char[0]>=0xC0 && utf8Char[0]<=0xFD) {
|
if(utf8Char[0]>=0xC0 && utf8Char[0]<=0xFD) {
|
||||||
|
Reference in New Issue
Block a user