Moving pathConvCharset to charConv.c so it can be reused for localization.
git-svn-id: https://svn.musicpd.org/mpd/trunk@5226 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
		| @@ -150,6 +150,13 @@ char *convStrDup(char *string) | |||||||
| 	return NULL; | 	return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | char *convCharset(char *to, char *from, char *str, char *ret) | ||||||
|  | { | ||||||
|  | 	if (ret) | ||||||
|  | 		free(ret); | ||||||
|  | 	return setCharSetConversion(to, from) ? NULL : convStrDup(str); | ||||||
|  | } | ||||||
|  |  | ||||||
| static void closeCharSetConversion(void) | static void closeCharSetConversion(void) | ||||||
| { | { | ||||||
| 	if (char_conv_to) { | 	if (char_conv_to) { | ||||||
|   | |||||||
| @@ -25,4 +25,6 @@ int setCharSetConversion(char *to, char *from); | |||||||
|  |  | ||||||
| char *convStrDup(char *string); | char *convStrDup(char *string); | ||||||
|  |  | ||||||
|  | char *convCharset(char *to, char *from, char *str, char *ret); | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								src/path.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/path.c
									
									
									
									
									
								
							| @@ -36,18 +36,11 @@ const char *musicDir; | |||||||
| static const char *playlistDir; | static const char *playlistDir; | ||||||
| static char *fsCharset = NULL; | static char *fsCharset = NULL; | ||||||
|  |  | ||||||
| static char *pathConvCharset(char *to, char *from, char *str, char *ret) |  | ||||||
| { |  | ||||||
| 	if (ret) |  | ||||||
| 		free(ret); |  | ||||||
| 	return setCharSetConversion(to, from) ? NULL : convStrDup(str); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| char *fsCharsetToUtf8(char *str) | char *fsCharsetToUtf8(char *str) | ||||||
| { | { | ||||||
| 	static char *ret = NULL; | 	static char *ret = NULL; | ||||||
|  |  | ||||||
| 	ret = pathConvCharset("UTF-8", fsCharset, str, ret); | 	ret = convCharset("UTF-8", fsCharset, str, ret); | ||||||
|  |  | ||||||
| 	if (ret && !validUtf8String(ret)) { | 	if (ret && !validUtf8String(ret)) { | ||||||
| 		free(ret); | 		free(ret); | ||||||
| @@ -61,7 +54,7 @@ char *utf8ToFsCharset(char *str) | |||||||
| { | { | ||||||
| 	static char *ret = NULL; | 	static char *ret = NULL; | ||||||
|  |  | ||||||
| 	ret = pathConvCharset(fsCharset, "UTF-8", str, ret); | 	ret = convCharset(fsCharset, "UTF-8", str, ret); | ||||||
|  |  | ||||||
| 	if (!ret) | 	if (!ret) | ||||||
| 		ret = xstrdup(str); | 		ret = xstrdup(str); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 J. Alexander Treuman
					J. Alexander Treuman