Cleaner version of fixSymbol

git-svn-id: svn://kolibrios.org@6383 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
guillem 2016-03-27 12:42:19 +00:00
parent b36d7e5a1c
commit a71fccce10

View File

@ -178,7 +178,6 @@ char *unicode_tags[]={
// function to be called to fix the special symbols // function to be called to fix the special symbols
void _text::fixSpecial(dword text) { void _text::fixSpecial(dword text) {
//dword text = start;
byte ch; byte ch;
int i , j, z; int i , j, z;
dword aux; dword aux;
@ -195,28 +194,30 @@ void _text::fixSpecial(dword text) {
if (ch == ';') { if (ch == ';') {
z = get_symbol(#str); z = get_symbol(#str);
//debugval("z: ", z); //debugval("z: ", z);
aux = unicode_tags[z]; if (z == -1) { // not found
strtrim(aux); ch = ' ';
debugln(aux);
ch = ESBYTE[aux];
while (ch) {
ESBYTE[text2] = ch;
aux++;
text2++;
ch = ESBYTE[aux];
} }
ch = ESBYTE[text2]; else { // tag found
//debugval("i: ", i); aux = unicode_tags[z];
strtrim(aux);
debugln(aux);
ch = ESBYTE[aux];
// copy the special symbol found
while (ch) {
ESBYTE[text2] = ch;
aux++;
text2++;
ch = ESBYTE[aux];
}
ch = ESBYTE[text2];
}
// clean the old symbol
while (ch != ';') { while (ch != ';') {
//debugval("j: ", j); ESBYTE[text2] = ' ';// should be (char) 0;
ESBYTE[text2] = ' ';
text2++; text2++;
ch = ESBYTE[text2]; ch = ESBYTE[text2];
} }
ESBYTE[text2] = ' '; ESBYTE[text2] = ' '; // should be '' or char 0
//for (j=0;j<i;j++) text--;
//debugln(#str);
//clean_str();
break; break;
} }
str[i] = ch; str[i] = ch;
@ -224,7 +225,7 @@ void _text::fixSpecial(dword text) {
text++; text++;
i++; i++;
} }
for (i=0; i < 7; i++) str[i] = 0; for (i=0; i < 7; i++) str[i] = 0; // clean str
} }
text++; text++;
text2++; text2++;
@ -233,21 +234,17 @@ void _text::fixSpecial(dword text) {
// function to look for the conversion od special characters // function to look for the conversion of special characters
// if not found--> return 0 // if not found--> return -1
int get_symbol(char *str2) { int get_symbol(char *str2) {
int i,j; int i,j;
//debugln(#str2); //debugln(#str2);
for (i=0; unicode_tags[i]!=0; i+=2) { for (i=0; unicode_tags[i]!=0; i+=2) {
if (strcmp(str2, unicode_tags[i]) == 0) { if (strcmp(str2, unicode_tags[i]) == 0) {
//j = strlen(unicode_tags[i+1]); return (i+1);
//debugval("i: ", i);
//strcat(text2, unicode_tags[i+1]);
i++;
return i;
} }
} }
return ' '; return -1;
} }