Changeset cd2892e8bb931da59e039f47a6839f8cc13c5636

Show
Ignore:
Timestamp:
18/05/07 17:01:05 (1 year ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1179500465 +0000
git-parent:

[63fb2db1e9f106ffa46ddb46a425b4a07e663c84]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1179500465 +0000
Message:

* src/text/strings.c: Add a lot of entities to the resolve_xml_special_chars function.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/text/strings.c

    rf567b19 rcd2892e  
    247247    while ( *psz_value ) 
    248248    { 
    249         if( !strncmp( psz_value, "&lt;", 4 ) ) 
    250         { 
    251             *p_pos = '<'; 
    252             psz_value += 4; 
    253         } 
    254         else if( !strncmp( psz_value, "&gt;", 4 ) ) 
    255         { 
    256             *p_pos = '>'; 
    257             psz_value += 4; 
    258         } 
    259         else if( !strncmp( psz_value, "&amp;", 5 ) ) 
    260         { 
    261             *p_pos = '&'; 
    262             psz_value += 5; 
    263         } 
    264         else if( !strncmp( psz_value, "&quot;", 6 ) ) 
    265         { 
    266             *p_pos = '\"'; 
    267             psz_value += 6; 
    268         } 
    269         else if( !strncmp( psz_value, "&#039;", 6 ) ) 
    270         { 
    271             *p_pos = '\''; 
    272             psz_value += 6; 
     249        if( *psz_value == '&' ) 
     250        { 
     251#define TRY_CHAR( src, len, dst )                   \ 
     252            if( !strncmp( psz_value, src, len ) )   \ 
     253            {                                       \ 
     254                *p_pos = dst;                       \ 
     255                psz_value += len;                   \ 
     256            } 
     257#define TRY_LONGCHAR( src, len, dst )                   \ 
     258            if( !strncmp( psz_value, src, len ) )       \ 
     259            {                                           \ 
     260                strncpy( p_pos, dst, strlen( dst ) );   \ 
     261                p_pos += strlen( dst ) - 1;             \ 
     262                psz_value += len;                       \ 
     263            } 
     264            TRY_CHAR( "&lt;", 4, '<' ) 
     265            else TRY_CHAR( "&gt;", 4, '>' ) 
     266            else TRY_CHAR( "&amp;", 5, '&' ) 
     267            else TRY_CHAR( "&quot;", 6, '"' ) 
     268            else TRY_CHAR( "&apos;", 6, '\'' ) 
     269            else if( psz_value[1] == '#' ) 
     270            { 
     271                char *psz_end; 
     272                int i = strtol( psz_value+2, &psz_end, 10 ); 
     273                if( *psz_end == ';' ) 
     274                { 
     275                    if( i >= 32 && i <= 126 ) 
     276                    { 
     277                        *p_pos = (char)i; 
     278                        psz_value = psz_end+1; 
     279                    } 
     280                    else 
     281                    { 
     282                        /* Unhandled code, FIXME */ 
     283                        *p_pos = *psz_value; 
     284                        psz_value++; 
     285                    } 
     286                } 
     287                else 
     288                { 
     289                    /* Invalid entity number */ 
     290                    *p_pos = *psz_value; 
     291                    psz_value++; 
     292                } 
     293            } 
     294            else TRY_LONGCHAR( "&Agrave;", 8, "À" ) 
     295            else TRY_LONGCHAR( "&Aacute;", 8, "Á" ) 
     296            else TRY_LONGCHAR( "&Acirc;", 7, "Â" ) 
     297            else TRY_LONGCHAR( "&Atilde;", 8, "Ã" ) 
     298            else TRY_LONGCHAR( "&Auml;", 6, "Ä" ) 
     299            else TRY_LONGCHAR( "&Aring;", 7, "Å" ) 
     300            else TRY_LONGCHAR( "&AElig;", 7, "Æ" ) 
     301            else TRY_LONGCHAR( "&Ccedil;", 8, "Ç" ) 
     302            else TRY_LONGCHAR( "&Egrave;", 8, "È" ) 
     303            else TRY_LONGCHAR( "&Eacute;", 8, "É" ) 
     304            else TRY_LONGCHAR( "&Ecirc;", 7, "Ê" ) 
     305            else TRY_LONGCHAR( "&Euml;", 6, "Ë" ) 
     306            else TRY_LONGCHAR( "&Igrave;", 8, "Ì" ) 
     307            else TRY_LONGCHAR( "&Iacute;", 8, "Í" ) 
     308            else TRY_LONGCHAR( "&Icirc;", 7, "Î" ) 
     309            else TRY_LONGCHAR( "&Iuml;", 6, "Ï" ) 
     310            else TRY_LONGCHAR( "&ETH;", 5, "Ð" ) 
     311            else TRY_LONGCHAR( "&Ntilde;", 8, "Ñ" ) 
     312            else TRY_LONGCHAR( "&Ograve;", 8, "Ò" ) 
     313            else TRY_LONGCHAR( "&Oacute;", 8, "Ó" ) 
     314            else TRY_LONGCHAR( "&Ocirc;", 7, "Ô" ) 
     315            else TRY_LONGCHAR( "&Otilde;", 8, "Õ" ) 
     316            else TRY_LONGCHAR( "&Ouml;", 6, "Ö" ) 
     317            else TRY_LONGCHAR( "&Oslash;", 8, "Ø" ) 
     318            else TRY_LONGCHAR( "&Ugrave;", 8, "Ù" ) 
     319            else TRY_LONGCHAR( "&Uacute;", 8, "Ú" ) 
     320            else TRY_LONGCHAR( "&Ucirc;", 7, "Û" ) 
     321            else TRY_LONGCHAR( "&Uuml;", 6, "Ü" ) 
     322            else TRY_LONGCHAR( "&Yacute;", 8, "Ý" ) 
     323            else TRY_LONGCHAR( "&THORN;", 7, "Þ" ) 
     324            else TRY_LONGCHAR( "&szlig;", 7, "ß" ) 
     325            else TRY_LONGCHAR( "&agrave;", 8, "à" ) 
     326            else TRY_LONGCHAR( "&aacute;", 8, "á" ) 
     327            else TRY_LONGCHAR( "&acirc;", 7, "â" ) 
     328            else TRY_LONGCHAR( "&atilde;", 8, "ã" ) 
     329            else TRY_LONGCHAR( "&auml;", 6, "ä" ) 
     330            else TRY_LONGCHAR( "&aring;", 7, "å" ) 
     331            else TRY_LONGCHAR( "&aelig;", 7, "æ" ) 
     332            else TRY_LONGCHAR( "&ccedil;", 8, "ç" ) 
     333            else TRY_LONGCHAR( "&egrave;", 8, "è" ) 
     334            else TRY_LONGCHAR( "&eacute;", 8, "é" ) 
     335            else TRY_LONGCHAR( "&ecirc;", 7, "ê" ) 
     336            else TRY_LONGCHAR( "&euml;", 6, "ë" ) 
     337            else TRY_LONGCHAR( "&igrave;", 8, "ì" ) 
     338            else TRY_LONGCHAR( "&iacute;", 8, "í" ) 
     339            else TRY_LONGCHAR( "&icirc;", 7, "î" ) 
     340            else TRY_LONGCHAR( "&iuml;", 6, "ï" ) 
     341            else TRY_LONGCHAR( "&eth;", 5, "ð" ) 
     342            else TRY_LONGCHAR( "&ntilde;", 8, "ñ" ) 
     343            else TRY_LONGCHAR( "&ograve;", 8, "ò" ) 
     344            else TRY_LONGCHAR( "&oacute;", 8, "ó" ) 
     345            else TRY_LONGCHAR( "&ocirc;", 7, "ô" ) 
     346            else TRY_LONGCHAR( "&otilde;", 8, "õ" ) 
     347            else TRY_LONGCHAR( "&ouml;", 6, "ö" ) 
     348            else TRY_LONGCHAR( "&oslash;", 8, "ø" ) 
     349            else TRY_LONGCHAR( "&ugrave;", 8, "ù" ) 
     350            else TRY_LONGCHAR( "&uacute;", 8, "ú" ) 
     351            else TRY_LONGCHAR( "&ucirc;", 7, "û" ) 
     352            else TRY_LONGCHAR( "&uuml;", 6, "ü" ) 
     353            else TRY_LONGCHAR( "&yacute;", 8, "ý" ) 
     354            else TRY_LONGCHAR( "&thorn;", 7, "þ" ) 
     355            else TRY_LONGCHAR( "&yuml;", 6, "ÿ" ) 
     356            else TRY_LONGCHAR( "&iexcl;", 7, "¡" ) 
     357            else TRY_LONGCHAR( "&curren;", 8, "¤" ) 
     358            else TRY_LONGCHAR( "&cent;", 6, "¢" ) 
     359            else TRY_LONGCHAR( "&pound;", 7, "£" ) 
     360            else TRY_LONGCHAR( "&yen;", 5, "¥" ) 
     361            else TRY_LONGCHAR( "&brvbar;", 8, "¦" ) 
     362            else TRY_LONGCHAR( "&sect;", 6, "§" ) 
     363            else TRY_LONGCHAR( "&uml;", 5, "¨" ) 
     364            else TRY_LONGCHAR( "&copy;", 6, "©" ) 
     365            else TRY_LONGCHAR( "&ordf;", 6, "ª" ) 
     366            else TRY_LONGCHAR( "&laquo;", 7, "«" ) 
     367            else TRY_LONGCHAR( "&not;", 5, "¬" ) 
     368            else TRY_LONGCHAR( "&shy;", 5, "­" ) 
     369            else TRY_LONGCHAR( "&reg;", 5, "®" ) 
     370            else TRY_LONGCHAR( "&trade;", 7, "™" ) 
     371            else TRY_LONGCHAR( "&macr;", 6, "¯" ) 
     372            else TRY_LONGCHAR( "&deg;", 5, "°" ) 
     373            else TRY_LONGCHAR( "&plusmn;", 8, "±" ) 
     374            else TRY_LONGCHAR( "&sup2;", 6, "²" ) 
     375            else TRY_LONGCHAR( "&sup3;", 6, "³" ) 
     376            else TRY_LONGCHAR( "&acute;", 7, "´" ) 
     377            else TRY_LONGCHAR( "&micro;", 7, "µ" ) 
     378            else TRY_LONGCHAR( "&para;", 6, "¶" ) 
     379            else TRY_LONGCHAR( "&middot;", 8, "·" ) 
     380            else TRY_LONGCHAR( "&cedil;", 7, "¸" ) 
     381            else TRY_LONGCHAR( "&sup1;", 6, "¹" ) 
     382            else TRY_LONGCHAR( "&ordm;", 6, "º" ) 
     383            else TRY_LONGCHAR( "&raquo;", 7, "»" ) 
     384            else TRY_LONGCHAR( "&frac14;", 8, "¼" ) 
     385            else TRY_LONGCHAR( "&frac12;", 8, "½" ) 
     386            else TRY_LONGCHAR( "&frac34;", 8, "¾" ) 
     387            else TRY_LONGCHAR( "&iquest;", 8, "¿" ) 
     388            else TRY_LONGCHAR( "&times;", 7, "×" ) 
     389            else TRY_LONGCHAR( "&divide;", 8, "÷" ) 
     390            else TRY_LONGCHAR( "&OElig;", 7, "Œ" ) 
     391            else TRY_LONGCHAR( "&oelig;", 7, "œ" ) 
     392            else TRY_LONGCHAR( "&Scaron;", 8, "Š" ) 
     393            else TRY_LONGCHAR( "&scaron;", 8, "š" ) 
     394            else TRY_LONGCHAR( "&Yuml;", 6, "Ÿ" ) 
     395            else TRY_LONGCHAR( "&circ;", 6, "ˆ" ) 
     396            else TRY_LONGCHAR( "&tilde;", 7, "˜" ) 
     397            else TRY_LONGCHAR( "&ndash;", 7, "–" ) 
     398            else TRY_LONGCHAR( "&mdash;", 7, "—" ) 
     399            else TRY_LONGCHAR( "&lsquo;", 7, "‘" ) 
     400            else TRY_LONGCHAR( "&rsquo;", 7, "’" ) 
     401            else TRY_LONGCHAR( "&sbquo;", 7, "‚" ) 
     402            else TRY_LONGCHAR( "&ldquo;", 7, "“" ) 
     403            else TRY_LONGCHAR( "&rdquo;", 7, "”" ) 
     404            else TRY_LONGCHAR( "&bdquo;", 7, "„" ) 
     405            else TRY_LONGCHAR( "&dagger;", 8, "†" ) 
     406            else TRY_LONGCHAR( "&Dagger;", 8, "‡" ) 
     407            else TRY_LONGCHAR( "&hellip;", 8, "…" ) 
     408            else TRY_LONGCHAR( "&permil;", 8, "‰" ) 
     409            else TRY_LONGCHAR( "&lsaquo;", 8, "‹" ) 
     410            else TRY_LONGCHAR( "&rsaquo;", 8, "›" ) 
     411            else TRY_LONGCHAR( "&euro;", 6, "€" ) 
     412            else 
     413            { 
     414                *p_pos = *psz_value; 
     415                psz_value++; 
     416            } 
    273417        } 
    274418        else