From 50b7ed90e3a8e8c06105d805970461ea0fe766d4 Mon Sep 17 00:00:00 2001 From: guillem Date: Fri, 25 Mar 2016 19:45:01 +0000 Subject: [PATCH] Fix parsing symbols git-svn-id: svn://kolibrios.org@6378 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/aelia/prepare_page.h | 2 +- programs/cmm/aelia/tag.h | 140 ++++++++++++++++-------------- 2 files changed, 77 insertions(+), 65 deletions(-) diff --git a/programs/cmm/aelia/prepare_page.h b/programs/cmm/aelia/prepare_page.h index af1a6f76f..4f0385965 100644 --- a/programs/cmm/aelia/prepare_page.h +++ b/programs/cmm/aelia/prepare_page.h @@ -110,7 +110,7 @@ _tag tag; } strtrim(text.start); // try to change the special symbols that may appear - text.fixSpecial(); + text.fixSpecial(text.start); while (get_label_len(text.start) + stroka_x + 30 > list.w) { diff --git a/programs/cmm/aelia/tag.h b/programs/cmm/aelia/tag.h index f193e39fe..7bcaa61da 100644 --- a/programs/cmm/aelia/tag.h +++ b/programs/cmm/aelia/tag.h @@ -103,50 +103,9 @@ struct _text { dword start; char str[7]; int x, y; - void fixSpecial(); + void fixSpecial(dword text); }; -// function to be called to fix the special symbols -void _text::fixSpecial() { - get_char(start); - clean_str(); -} - -// function that traverse the text in sarch for a special -// character starting with & -// if found, try to look for the conversion -void get_char(dword text) { - byte ch; - int i = 0, j = 0; - dword text2 = text; - loop () { - ch = ESBYTE[text]; - if (!ch) return; - if (ch=='&') { - i = 0; - text++; - while ( i < 7) { - ch = ESBYTE[text]; - if (ch == ';') { - ESBYTE[text2] = get_symbol(); - while (j < i) { - j++; - text2++; - ESBYTE[text2] = 0; - } - //debugln(#str); - break; - } - str[i] = ch; - if (!ch) return; - text++; - i++; - } - } - text++; - text2++; - } -} // unicode conversion for special characters char *unicode_tags[]={ @@ -154,9 +113,9 @@ char *unicode_tags[]={ "#38", " ", "#160", " ", -"ntilde", "ñ", // spanish n special ñ -"#224", 0xC3A0, // spanish a with grove accent 'à' -"#241", 0xC3B1, // spanish symbol +"ntilde", "n", // spanish n special ñ +"#224", "à", // spanish a with grove accent 'à' +"#241", "n", // spanish symbol "copy", "(c)", "#169", "(c)", @@ -215,28 +174,81 @@ char *unicode_tags[]={ "bull", "-", //âîîáùå çäåñü òî÷êà "percnt","%", -0}; +0}; -// function to look for the conversion od special characters -// if not found--> return 0 -char get_symbol() { - int i; - //debugln(#str); - for (i=0; unicode_tags[i]!=0; i+=2) { - if (strcmp(#str, unicode_tags[i]) == 0) { - //debugval("i: ", i); - return unicode_tags[i+1]); +// function to be called to fix the special symbols +void _text::fixSpecial(dword text) { + //dword text = start; + byte ch; + int i , j, z; + dword aux; + dword text2 = text; + loop () { + ch = ESBYTE[text]; + if (!ch) return; + if (ch=='&') { + i = 0; + j = 0; + text++; + while ( i < 7) { + ch = ESBYTE[text]; + if (ch == ';') { + z = get_symbol(#str); + //debugval("z: ", z); + aux = unicode_tags[z]; + strtrim(aux); + debugln(aux); + ch = ESBYTE[aux]; + while (ch) { + ESBYTE[text2] = ch; + aux++; + text2++; + ch = ESBYTE[aux]; + } + ch = ESBYTE[text2]; + //debugval("i: ", i); + while (ch != ';') { + //debugval("j: ", j); + ESBYTE[text2] = ' '; + text2++; + ch = ESBYTE[text2]; + } + ESBYTE[text2] = ' '; + //for (j=0;j return 0 +int get_symbol(char *str2) { + int i,j; + //debugln(#str2); + for (i=0; unicode_tags[i]!=0; i+=2) { + if (strcmp(str2, unicode_tags[i]) == 0) { + //j = strlen(unicode_tags[i+1]); + //debugval("i: ", i); + //strcat(text2, unicode_tags[i+1]); + i++; + return i; + } + } + return ' '; +} + + +