Commit f765c262 authored by Warren Dukes's avatar Warren Dukes

fix a small booboo and add some debugging stuff

git-svn-id: https://svn.musicpd.org/mpd/trunk@708 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 375e3ffe
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "aac_decode.h" #include "aac_decode.h"
#include "utils.h" #include "utils.h"
#include "utf8.h" #include "utf8.h"
#include "log.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -61,6 +62,7 @@ void printMpdTag(FILE * fp, MpdTag * tag) { ...@@ -61,6 +62,7 @@ void printMpdTag(FILE * fp, MpdTag * tag) {
#define fixUtf8(str) { \ #define fixUtf8(str) { \
if(str && !validUtf8String(str)) { \ if(str && !validUtf8String(str)) { \
char * temp; \ char * temp; \
DEBUG("not valid utf8 in tag: %s\n",str); \
temp = asciiStrToUtf8Dup(str); \ temp = asciiStrToUtf8Dup(str); \
free(str); \ free(str); \
str = temp; \ str = temp; \
......
...@@ -59,7 +59,7 @@ int validateUtf8Char(unsigned char * utf8Char) { ...@@ -59,7 +59,7 @@ int validateUtf8Char(unsigned char * utf8Char) {
if(utf8Char[0]>=0xC0 && utf8Char[0]<=0xFD) { if(utf8Char[0]>=0xC0 && utf8Char[0]<=0xFD) {
int count = 1; int count = 1;
unsigned char t = 0x20; unsigned char t = 1 << 5;
int i; int i;
while(count < 6 && (t & utf8Char[0])) { while(count < 6 && (t & utf8Char[0])) {
t = (t >> 1); t = (t >> 1);
...@@ -69,7 +69,7 @@ int validateUtf8Char(unsigned char * utf8Char) { ...@@ -69,7 +69,7 @@ int validateUtf8Char(unsigned char * utf8Char) {
for(i=1;i<=count;i++) { for(i=1;i<=count;i++) {
if(utf8Char[i] < 0x80 || utf8Char[i] > 0xBF) return 0; if(utf8Char[i] < 0x80 || utf8Char[i] > 0xBF) return 0;
} }
return count; return count+1;
} }
else return 0; else return 0;
} }
...@@ -79,7 +79,7 @@ int validUtf8String(unsigned char * string) { ...@@ -79,7 +79,7 @@ int validUtf8String(unsigned char * string) {
while(*string) { while(*string) {
ret = validateUtf8Char(string); ret = validateUtf8Char(string);
if(!ret) return 0; if(0==ret) return 0;
string+= ret; string+= ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment