Diff for /Amaya/amaya/styleparser.c between versions 1.81 and 1.82

version 1.81, 2001/02/12 11:32:38 version 1.82, 2001/03/02 16:19:21
Line 10 Line 10
  * be contained in this module.   * be contained in this module.
  *   *
  * Author: I. Vatton   * Author: I. Vatton
  *         R. Guetari: Unicode.  
  *   *
  */   */
   
Line 22 Line 21
 #include "registry.h"  #include "registry.h"
 #include "fetchHTMLname.h"  #include "fetchHTMLname.h"
 #include "GraphML.h"  #include "GraphML.h"
 #include "uaccess.h"  
   
 typedef struct _BackgroundImageCallbackBlock  typedef struct _BackgroundImageCallbackBlock
 {  {
Line 75  struct unit_def Line 73  struct unit_def
   
 static struct unit_def CSSUnitNames[] =  static struct unit_def CSSUnitNames[] =
 {  {
    {TEXT("pt"), STYLE_UNIT_PT},     {"pt", STYLE_UNIT_PT},
    {TEXT("pc"), STYLE_UNIT_PC},     {"pc", STYLE_UNIT_PC},
    {TEXT("in"), STYLE_UNIT_IN},     {"in", STYLE_UNIT_IN},
    {TEXT("cm"), STYLE_UNIT_CM},     {"cm", STYLE_UNIT_CM},
    {TEXT("mm"), STYLE_UNIT_MM},     {"mm", STYLE_UNIT_MM},
    {TEXT("em"), STYLE_UNIT_EM},     {"em", STYLE_UNIT_EM},
    {TEXT("px"), STYLE_UNIT_PX},     {"px", STYLE_UNIT_PX},
    {TEXT("ex"), STYLE_UNIT_XHEIGHT},     {"ex", STYLE_UNIT_XHEIGHT},
    {TEXT("%"), STYLE_UNIT_PERCENT}     {"%", STYLE_UNIT_PERCENT}
 };  };
   
 #define NB_UNITS (sizeof(CSSUnitNames) / sizeof(struct unit_def))  #define NB_UNITS (sizeof(CSSUnitNames) / sizeof(struct unit_def))
Line 96  static char *SkipWord (char *ptr) Line 94  static char *SkipWord (char *ptr)
 # ifdef _WINDOWS  # ifdef _WINDOWS
   /* iswalnum is supposed to be supported by the i18n veriosn of libc     /* iswalnum is supposed to be supported by the i18n veriosn of libc 
      use it when available */       use it when available */
   while (iswalnum (*ptr) || *ptr == TEXT('-') || *ptr == TEXT('%'))    while (iswalnum (*ptr) || *ptr == '-' || *ptr == '%')
 # else  /* !_WINDOWS */  # else  /* !_WINDOWS */
   while (isalnum((int)*ptr) || *ptr == TEXT('-') || *ptr == TEXT('%'))    while (isalnum((int)*ptr) || *ptr == '-' || *ptr == '%')
 # endif /* !_WINDOWS */  # endif /* !_WINDOWS */
         ptr++;          ptr++;
   return (ptr);    return (ptr);
Line 107  static char *SkipWord (char *ptr) Line 105  static char *SkipWord (char *ptr)
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    SkipBlanksAndComments:                                                       SkipBlanksAndComments:                                                  
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 char        *SkipBlanksAndComments (char *ptr)  char *SkipBlanksAndComments (char *ptr)
 {  {
   ptr = TtaSkipBlanks (ptr);    ptr = TtaSkipBlanks (ptr);
   while (ptr[0] == '/' && ptr[1] == '*')    while (ptr[0] == '/' && ptr[1] == '*')
Line 123  char        *SkipBlanksAndComments (char Line 121  char        *SkipBlanksAndComments (char
   return (ptr);    return (ptr);
 }  }
   
 /*----------------------------------------------------------------------  
    SkipWCBlanksAndComments:                                                    
   ----------------------------------------------------------------------*/  
 char *SkipWCBlanksAndComments (char *ptr)  
 {  
   ptr = TtaSkipWCBlanks (ptr);  
   while (ptr[0] == TEXT('/') && ptr[1] == TEXT('*'))  
     {  
       /* look for the end of the comment */  
       ptr = &ptr[2];  
       while (ptr[0] != WC_EOS && (ptr[0] != TEXT('*') || ptr[1] != TEXT('/')))  
         ptr++;  
       if (ptr[0] != WC_EOS)  
         ptr = &ptr[2];  
       ptr = TtaSkipWCBlanks (ptr);  
     }  
   return (ptr);  
 }  
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    SkipQuotedString:                                                       SkipQuotedString:                                                  
Line 157  static char *SkipQuotedString (char *ptr Line 137  static char *SkipQuotedString (char *ptr
        ptr++;         ptr++;
        stop = TRUE;         stop = TRUE;
        }         }
     else if (*ptr == WC_EOS)      else if (*ptr == EOS)
        stop = TRUE;         stop = TRUE;
     else if (*ptr == TEXT('\\'))      else if (*ptr == '\\')
        /* escape character */         /* escape character */
        {         {
        ptr++;         ptr++;
        if ((*ptr >= TEXT('0') && *ptr <= TEXT('9')) || (*ptr >= TEXT('A') && *ptr <= TEXT('F')) ||         if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
            (*ptr >= TEXT('a') && *ptr <= TEXT('f')))             (*ptr >= 'a' && *ptr <= 'f'))
           {            {
           ptr++;            ptr++;
           if ((*ptr >= TEXT('0') && *ptr <= TEXT('9')) || (*ptr >= TEXT('A') && *ptr <= TEXT('F')) ||            if ((*ptr >= '0' && *ptr <= '9') || (*ptr >= 'A' && *ptr <= 'F') ||
               (*ptr >= TEXT('a') && *ptr <= TEXT('f')))                (*ptr >= 'a' && *ptr <= 'f'))
              ptr++;               ptr++;
           }            }
        else         else
Line 185  static char *SkipQuotedString (char *ptr Line 165  static char *SkipQuotedString (char *ptr
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 char *SkipProperty (char *ptr)  char *SkipProperty (char *ptr)
 {  {
   while (*ptr != WC_EOS && *ptr != TEXT(';') && *ptr != TEXT('}'))    while (*ptr != EOS && *ptr != ';' && *ptr != '}')
     ptr++;      ptr++;
   return (ptr);    return (ptr);
 }  }
Line 204  char *ParseNumber (char *cssRule, Presen Line 184  char *ParseNumber (char *cssRule, Presen
   
   pval->typed_data.unit = STYLE_UNIT_REL;    pval->typed_data.unit = STYLE_UNIT_REL;
   pval->typed_data.real = FALSE;    pval->typed_data.real = FALSE;
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   if (*cssRule == TEXT('-'))    if (*cssRule == '-')
     {      {
       minus = 1;        minus = 1;
       cssRule++;        cssRule++;
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   
   if (*cssRule == TEXT('+'))    if (*cssRule == '+')
     {      {
       cssRule++;        cssRule++;
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   
   while ((*cssRule >= TEXT('0')) && (*cssRule <= TEXT('9')))    while ((*cssRule >= '0') && (*cssRule <= '9'))
     {      {
       val *= 10;        val *= 10;
       val += *cssRule - TEXT('0');        val += *cssRule - '0';
       cssRule++;        cssRule++;
       valid = 1;        valid = 1;
     }      }
   
   if (*cssRule == TEXT('.'))    if (*cssRule == '.')
     {      {
       real = TRUE;        real = TRUE;
       f = val;        f = val;
       val = 0;        val = 0;
       cssRule++;        cssRule++;
       /* keep only 3 digits */        /* keep only 3 digits */
       if (*cssRule >= TEXT('0') && *cssRule <= TEXT('9'))        if (*cssRule >= '0' && *cssRule <= '9')
         {          {
           val = (*cssRule - TEXT('0')) * 100;            val = (*cssRule - '0') * 100;
           cssRule++;            cssRule++;
           if (*cssRule >= TEXT('0') && *cssRule <= TEXT('9'))            if (*cssRule >= '0' && *cssRule <= '9')
             {              {
               val += (*cssRule - TEXT('0')) * 10;                val += (*cssRule - '0') * 10;
               cssRule++;                cssRule++;
               if ((*cssRule >= TEXT('0')) && (*cssRule <= TEXT('9')))                if ((*cssRule >= '0') && (*cssRule <= '9'))
                 {                  {
                   val += *cssRule - TEXT('0');                    val += *cssRule - '0';
                   cssRule++;                    cssRule++;
                 }                  }
             }              }
   
           while (*cssRule >= TEXT('0') && *cssRule <= TEXT('9'))            while (*cssRule >= '0' && *cssRule <= '9')
             cssRule++;              cssRule++;
           valid = 1;            valid = 1;
         }          }
Line 285  char *ParseNumber (char *cssRule, Presen Line 265  char *ParseNumber (char *cssRule, Presen
    parse a CSS Unit substring and returns the corresponding           parse a CSS Unit substring and returns the corresponding      
    value and its unit.                                                value and its unit.                                           
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 char            *ParseCSSUnit (char *cssRule, PresentationValue *pval)  char *ParseCSSUnit (char *cssRule, PresentationValue *pval)
 {  {
   unsigned int        uni;    unsigned int        uni;
   
Line 295  char            *ParseCSSUnit (char *css Line 275  char            *ParseCSSUnit (char *css
       cssRule = SkipWord (cssRule);        cssRule = SkipWord (cssRule);
   else    else
     {      {
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
       for (uni = 0; uni < NB_UNITS; uni++)        for (uni = 0; uni < NB_UNITS; uni++)
         {          {
           if (!ustrncasecmp (CSSUnitNames[uni].sign, cssRule,            if (!strncasecmp (CSSUnitNames[uni].sign, cssRule,
                              ustrlen (CSSUnitNames[uni].sign)))                               strlen (CSSUnitNames[uni].sign)))
             {              {
               pval->typed_data.unit = CSSUnitNames[uni].unit;                pval->typed_data.unit = CSSUnitNames[uni].unit;
               return (cssRule + ustrlen (CSSUnitNames[uni].sign));                return (cssRule + strlen (CSSUnitNames[uni].sign));
             }              }
         }          }
       /* not in the list of predefined units */        /* not in the list of predefined units */
Line 320  static char *ParseBorderValue (char *css Line 300  static char *ParseBorderValue (char *css
    border->typed_data.value = 0;     border->typed_data.value = 0;
    border->typed_data.unit = STYLE_UNIT_INVALID;     border->typed_data.unit = STYLE_UNIT_INVALID;
    border->typed_data.real = FALSE;     border->typed_data.real = FALSE;
    if (!ustrncasecmp (cssRule, TEXT("thin"), 4))     if (!strncasecmp (cssRule, "thin", 4))
      {       {
        border->typed_data.unit = STYLE_UNIT_PX;         border->typed_data.unit = STYLE_UNIT_PX;
        border->typed_data.value = 1;         border->typed_data.value = 1;
        cssRule = SkipWord (cssRule);         cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("medium"), 6))     else if (!strncasecmp (cssRule, "medium", 6))
      {       {
        border->typed_data.unit = STYLE_UNIT_PX;         border->typed_data.unit = STYLE_UNIT_PX;
        border->typed_data.value = 3;         border->typed_data.value = 3;
        cssRule = SkipWord (cssRule);         cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("thick"), 5))     else if (!strncasecmp (cssRule, "thick", 5))
      {       {
        border->typed_data.unit = STYLE_UNIT_PX;         border->typed_data.unit = STYLE_UNIT_PX;
        border->typed_data.value = 5;         border->typed_data.value = 5;
        cssRule = SkipWord (cssRule);         cssRule = SkipWord (cssRule);
      }       }
    else if (TtaIsDigit (*cssRule))     else if (isdigit (*cssRule))
      cssRule = ParseCSSUnit (cssRule, border);       cssRule = ParseCSSUnit (cssRule, border);
    return (cssRule);     return (cssRule);
 }  }
Line 352  static char *ParseBorderStyle (char *css Line 332  static char *ParseBorderStyle (char *css
    border->typed_data.value = 0;     border->typed_data.value = 0;
    border->typed_data.unit = STYLE_UNIT_PX;     border->typed_data.unit = STYLE_UNIT_PX;
    border->typed_data.real = FALSE;     border->typed_data.real = FALSE;
    if (!ustrncasecmp (cssRule, TEXT("none"), 4))     if (!strncasecmp (cssRule, "none", 4))
      border->typed_data.value = STYLE_BORDERNONE;       border->typed_data.value = STYLE_BORDERNONE;
    else if (!ustrncasecmp (cssRule, TEXT("hidden"), 6))     else if (!strncasecmp (cssRule, "hidden", 6))
      border->typed_data.value = STYLE_BORDERHIDDEN;       border->typed_data.value = STYLE_BORDERHIDDEN;
    else if (!ustrncasecmp (cssRule, TEXT("dotted"), 6))     else if (!strncasecmp (cssRule, "dotted", 6))
      border->typed_data.value = STYLE_BORDERDOTTED;       border->typed_data.value = STYLE_BORDERDOTTED;
    else if (!ustrncasecmp (cssRule, TEXT("dashed"), 6))     else if (!strncasecmp (cssRule, "dashed", 6))
      border->typed_data.value = STYLE_BORDERDASHED;       border->typed_data.value = STYLE_BORDERDASHED;
    else if (!ustrncasecmp (cssRule, TEXT("solid"), 5))     else if (!strncasecmp (cssRule, "solid", 5))
      border->typed_data.value = STYLE_BORDERSOLID;       border->typed_data.value = STYLE_BORDERSOLID;
    else if (!ustrncasecmp (cssRule, TEXT("double"), 6))     else if (!strncasecmp (cssRule, "double", 6))
      border->typed_data.value = STYLE_BORDERDOUBLE;       border->typed_data.value = STYLE_BORDERDOUBLE;
    else if (!ustrncasecmp (cssRule, TEXT("groove"), 6))     else if (!strncasecmp (cssRule, "groove", 6))
      border->typed_data.value = STYLE_BORDERGROOVE;       border->typed_data.value = STYLE_BORDERGROOVE;
    else if (!ustrncasecmp (cssRule, TEXT("ridge"), 5))     else if (!strncasecmp (cssRule, "ridge", 5))
      border->typed_data.value = STYLE_BORDERRIDGE;       border->typed_data.value = STYLE_BORDERRIDGE;
    else if (!ustrncasecmp (cssRule, TEXT("inset"), 5))     else if (!strncasecmp (cssRule, "inset", 5))
      border->typed_data.value = STYLE_BORDERINSET;       border->typed_data.value = STYLE_BORDERINSET;
    else if (!ustrncasecmp (cssRule, TEXT("outset"), 6))     else if (!strncasecmp (cssRule, "outset", 6))
      border->typed_data.value = STYLE_BORDEROUTSET;       border->typed_data.value = STYLE_BORDEROUTSET;
    else     else
      {       {
Line 398  static char *ParseCSSColor (char *cssRul Line 378  static char *ParseCSSColor (char *cssRul
   unsigned short      blueval = 0;      /* default to red if unknown ! */    unsigned short      blueval = 0;      /* default to red if unknown ! */
   int                 best = 0; /* best color in list found */    int                 best = 0; /* best color in list found */
   
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   val->typed_data.unit = STYLE_UNIT_INVALID;    val->typed_data.unit = STYLE_UNIT_INVALID;
   val->typed_data.real = FALSE;    val->typed_data.real = FALSE;
   val->typed_data.value = 0;    val->typed_data.value = 0;
Line 431  static char *ParseCSSBorderTopWidth (Ele Line 411  static char *ParseCSSBorderTopWidth (Ele
 {  {
   PresentationValue   border;    PresentationValue   border;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   cssRule = ParseBorderValue (cssRule, &border);    cssRule = ParseBorderValue (cssRule, &border);
   if (border.typed_data.unit != STYLE_UNIT_INVALID)    if (border.typed_data.unit != STYLE_UNIT_INVALID)
     {      {
Line 453  static char *ParseCSSBorderBottomWidth ( Line 433  static char *ParseCSSBorderBottomWidth (
 {  {
   PresentationValue   border;    PresentationValue   border;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseBorderValue (cssRule, &border);    cssRule = ParseBorderValue (cssRule, &border);
   if (border.typed_data.unit != STYLE_UNIT_INVALID)    if (border.typed_data.unit != STYLE_UNIT_INVALID)
Line 476  static char *ParseCSSBorderLeftWidth (El Line 456  static char *ParseCSSBorderLeftWidth (El
 {  {
   PresentationValue   border;    PresentationValue   border;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseBorderValue (cssRule, &border);    cssRule = ParseBorderValue (cssRule, &border);
   if (border.typed_data.unit != STYLE_UNIT_INVALID)    if (border.typed_data.unit != STYLE_UNIT_INVALID)
Line 499  static char *ParseCSSBorderRightWidth (E Line 479  static char *ParseCSSBorderRightWidth (E
 {  {
   PresentationValue   border;    PresentationValue   border;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseBorderValue (cssRule, &border);    cssRule = ParseBorderValue (cssRule, &border);
   if (border.typed_data.unit != STYLE_UNIT_INVALID)    if (border.typed_data.unit != STYLE_UNIT_INVALID)
Line 522  static char *ParseCSSBorderWidth (Elemen Line 502  static char *ParseCSSBorderWidth (Elemen
 {  {
   char *ptrT, *ptrR, *ptrB, *ptrL;    char *ptrT, *ptrR, *ptrB, *ptrL;
   
   ptrT = SkipWCBlanksAndComments (cssRule);    ptrT = SkipBlanksAndComments (cssRule);
   /* First parse Border-Top */    /* First parse Border-Top */
   ptrR = ParseCSSBorderTopWidth (element, tsch, context, ptrT, css, isHTML);    ptrR = ParseCSSBorderTopWidth (element, tsch, context, ptrT, css, isHTML);
   ptrR = SkipWCBlanksAndComments (ptrR);    ptrR = SkipBlanksAndComments (ptrR);
   if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))    if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
     {      {
       cssRule = ptrR;        cssRule = ptrR;
       /* apply the Border-Top to all */        /* apply the Border-Top to all */
Line 538  static char *ParseCSSBorderWidth (Elemen Line 518  static char *ParseCSSBorderWidth (Elemen
     {      {
       /* parse Border-Right */        /* parse Border-Right */
       ptrB = ParseCSSBorderRightWidth (element, tsch, context, ptrR, css, isHTML);        ptrB = ParseCSSBorderRightWidth (element, tsch, context, ptrR, css, isHTML);
       ptrB = SkipWCBlanksAndComments (ptrB);        ptrB = SkipBlanksAndComments (ptrB);
       if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))        if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
         {          {
           cssRule = ptrB;            cssRule = ptrB;
           /* apply the Border-Top to Border-Bottom */            /* apply the Border-Top to Border-Bottom */
Line 551  static char *ParseCSSBorderWidth (Elemen Line 531  static char *ParseCSSBorderWidth (Elemen
         {          {
           /* parse Border-Bottom */            /* parse Border-Bottom */
           ptrL = ParseCSSBorderBottomWidth (element, tsch, context, ptrB, css, isHTML);            ptrL = ParseCSSBorderBottomWidth (element, tsch, context, ptrB, css, isHTML);
           ptrL = SkipWCBlanksAndComments (ptrL);            ptrL = SkipBlanksAndComments (ptrL);
           if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))            if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
             {              {
               cssRule = ptrL;                cssRule = ptrL;
               /* apply the Border-Right to Border-Left */                /* apply the Border-Right to Border-Left */
Line 561  static char *ParseCSSBorderWidth (Elemen Line 541  static char *ParseCSSBorderWidth (Elemen
           else            else
             /* parse Border-Left */              /* parse Border-Left */
             cssRule = ParseCSSBorderLeftWidth (element, tsch, context, ptrL, css, isHTML);              cssRule = ParseCSSBorderLeftWidth (element, tsch, context, ptrL, css, isHTML);
           cssRule = SkipWCBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
         }          }
     }      }
   return (cssRule);    return (cssRule);
Line 650  static char *ParseCSSBorderColor (Elemen Line 630  static char *ParseCSSBorderColor (Elemen
 {  {
   char *ptrT, *ptrR, *ptrB, *ptrL;    char *ptrT, *ptrR, *ptrB, *ptrL;
   
   ptrT = SkipWCBlanksAndComments (cssRule);    ptrT = SkipBlanksAndComments (cssRule);
   /* First parse Border-Top */    /* First parse Border-Top */
   ptrR = ParseCSSBorderColorTop (element, tsch, context, ptrT, css, isHTML);    ptrR = ParseCSSBorderColorTop (element, tsch, context, ptrT, css, isHTML);
   ptrR = SkipWCBlanksAndComments (ptrR);    ptrR = SkipBlanksAndComments (ptrR);
   if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))    if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
     {      {
       cssRule = ptrR;        cssRule = ptrR;
       /* apply the Border-Top to all */        /* apply the Border-Top to all */
Line 666  static char *ParseCSSBorderColor (Elemen Line 646  static char *ParseCSSBorderColor (Elemen
     {      {
       /* parse Border-Right */        /* parse Border-Right */
       ptrB = ParseCSSBorderColorRight (element, tsch, context, ptrR, css, isHTML);        ptrB = ParseCSSBorderColorRight (element, tsch, context, ptrR, css, isHTML);
       ptrB = SkipWCBlanksAndComments (ptrB);        ptrB = SkipBlanksAndComments (ptrB);
       if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))        if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
         {          {
           cssRule = ptrB;            cssRule = ptrB;
           /* apply the Border-Top to Border-Bottom */            /* apply the Border-Top to Border-Bottom */
Line 679  static char *ParseCSSBorderColor (Elemen Line 659  static char *ParseCSSBorderColor (Elemen
         {          {
           /* parse Border-Bottom */            /* parse Border-Bottom */
           ptrL = ParseCSSBorderColorBottom (element, tsch, context, ptrB, css, isHTML);            ptrL = ParseCSSBorderColorBottom (element, tsch, context, ptrB, css, isHTML);
           ptrL = SkipWCBlanksAndComments (ptrL);            ptrL = SkipBlanksAndComments (ptrL);
           if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))            if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
             {              {
               cssRule = ptrL;                cssRule = ptrL;
               /* apply the Border-Right to Border-Left */                /* apply the Border-Right to Border-Left */
Line 689  static char *ParseCSSBorderColor (Elemen Line 669  static char *ParseCSSBorderColor (Elemen
           else            else
             /* parse Border-Left */              /* parse Border-Left */
             cssRule = ParseCSSBorderColorLeft (element, tsch, context, ptrL, css, isHTML);              cssRule = ParseCSSBorderColorLeft (element, tsch, context, ptrL, css, isHTML);
           cssRule = SkipWCBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
         }          }
     }      }
   return (cssRule);    return (cssRule);
Line 706  static char *ParseCSSBorderStyleTop (Ele Line 686  static char *ParseCSSBorderStyleTop (Ele
 {  {
   PresentationValue   border;    PresentationValue   border;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   cssRule = ParseBorderStyle (cssRule, &border);    cssRule = ParseBorderStyle (cssRule, &border);
   if (border.typed_data.unit != STYLE_UNIT_INVALID)    if (border.typed_data.unit != STYLE_UNIT_INVALID)
     TtaSetStylePresentation (PRBorderTopStyle, element, tsch, context, border);      TtaSetStylePresentation (PRBorderTopStyle, element, tsch, context, border);
Line 724  static char *ParseCSSBorderStyleLeft (El Line 704  static char *ParseCSSBorderStyleLeft (El
 {  {
   PresentationValue   border;    PresentationValue   border;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   cssRule = ParseBorderStyle (cssRule, &border);    cssRule = ParseBorderStyle (cssRule, &border);
   if (border.typed_data.unit != STYLE_UNIT_INVALID)    if (border.typed_data.unit != STYLE_UNIT_INVALID)
     TtaSetStylePresentation (PRBorderLeftStyle, element, tsch, context, border);      TtaSetStylePresentation (PRBorderLeftStyle, element, tsch, context, border);
Line 742  static char *ParseCSSBorderStyleBottom ( Line 722  static char *ParseCSSBorderStyleBottom (
 {  {
   PresentationValue   border;    PresentationValue   border;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   cssRule = ParseBorderStyle (cssRule, &border);    cssRule = ParseBorderStyle (cssRule, &border);
   if (border.typed_data.unit != STYLE_UNIT_INVALID)    if (border.typed_data.unit != STYLE_UNIT_INVALID)
     TtaSetStylePresentation (PRBorderBottomStyle, element, tsch, context, border);      TtaSetStylePresentation (PRBorderBottomStyle, element, tsch, context, border);
Line 760  static char *ParseCSSBorderStyleRight (E Line 740  static char *ParseCSSBorderStyleRight (E
 {  {
   PresentationValue   border;    PresentationValue   border;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   cssRule = ParseBorderStyle (cssRule, &border);    cssRule = ParseBorderStyle (cssRule, &border);
   if (border.typed_data.unit != STYLE_UNIT_INVALID)    if (border.typed_data.unit != STYLE_UNIT_INVALID)
     TtaSetStylePresentation (PRBorderRightStyle, element, tsch, context, border);      TtaSetStylePresentation (PRBorderRightStyle, element, tsch, context, border);
Line 778  static char *ParseCSSBorderStyle (Elemen Line 758  static char *ParseCSSBorderStyle (Elemen
 {  {
   char *ptrT, *ptrR, *ptrB, *ptrL;    char *ptrT, *ptrR, *ptrB, *ptrL;
   
   ptrT = SkipWCBlanksAndComments (cssRule);    ptrT = SkipBlanksAndComments (cssRule);
   /* First parse Border-Top */    /* First parse Border-Top */
   ptrR = ParseCSSBorderStyleTop (element, tsch, context, ptrT, css, isHTML);    ptrR = ParseCSSBorderStyleTop (element, tsch, context, ptrT, css, isHTML);
   ptrR = SkipWCBlanksAndComments (ptrR);    ptrR = SkipBlanksAndComments (ptrR);
   if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))    if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
     {      {
       cssRule = ptrR;        cssRule = ptrR;
       /* apply the Border-Top to all */        /* apply the Border-Top to all */
Line 794  static char *ParseCSSBorderStyle (Elemen Line 774  static char *ParseCSSBorderStyle (Elemen
     {      {
       /* parse Border-Right */        /* parse Border-Right */
       ptrB = ParseCSSBorderStyleRight (element, tsch, context, ptrR, css, isHTML);        ptrB = ParseCSSBorderStyleRight (element, tsch, context, ptrR, css, isHTML);
       ptrB = SkipWCBlanksAndComments (ptrB);        ptrB = SkipBlanksAndComments (ptrB);
       if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))        if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
         {          {
           cssRule = ptrB;            cssRule = ptrB;
           /* apply the Border-Top to Border-Bottom */            /* apply the Border-Top to Border-Bottom */
Line 807  static char *ParseCSSBorderStyle (Elemen Line 787  static char *ParseCSSBorderStyle (Elemen
         {          {
           /* parse Border-Bottom */            /* parse Border-Bottom */
           ptrL = ParseCSSBorderStyleBottom (element, tsch, context, ptrB, css, isHTML);            ptrL = ParseCSSBorderStyleBottom (element, tsch, context, ptrB, css, isHTML);
           ptrL = SkipWCBlanksAndComments (ptrL);            ptrL = SkipBlanksAndComments (ptrL);
           if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))            if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
             {              {
               cssRule = ptrL;                cssRule = ptrL;
               /* apply the Border-Right to Border-Left */                /* apply the Border-Right to Border-Left */
Line 817  static char *ParseCSSBorderStyle (Elemen Line 797  static char *ParseCSSBorderStyle (Elemen
           else            else
             /* parse Border-Left */              /* parse Border-Left */
             cssRule = ParseCSSBorderStyleLeft (element, tsch, context, ptrL, css, isHTML);              cssRule = ParseCSSBorderStyleLeft (element, tsch, context, ptrL, css, isHTML);
           cssRule = SkipWCBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
         }          }
     }      }
   return (cssRule);    return (cssRule);
Line 833  static char *ParseCSSBorderTop (Element Line 813  static char *ParseCSSBorderTop (Element
 {  {
   char           *ptr;    char           *ptr;
   
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))    while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
     {      {
       ptr = cssRule;        ptr = cssRule;
       cssRule = ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML);        cssRule = ParseCSSBorderStyleTop (element, tsch, context, cssRule, css, isHTML);
Line 845  static char *ParseCSSBorderTop (Element Line 825  static char *ParseCSSBorderTop (Element
       if (ptr == cssRule)        if (ptr == cssRule)
         /* rule not found */          /* rule not found */
         cssRule = SkipProperty (cssRule);          cssRule = SkipProperty (cssRule);
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   return (cssRule);    return (cssRule);
 }  }
Line 860  static char *ParseCSSBorderLeft (Element Line 840  static char *ParseCSSBorderLeft (Element
 {  {
   char           *ptr;    char           *ptr;
   
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))    while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
     {      {
       ptr = cssRule;        ptr = cssRule;
       cssRule = ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML);        cssRule = ParseCSSBorderStyleLeft (element, tsch, context, cssRule, css, isHTML);
Line 872  static char *ParseCSSBorderLeft (Element Line 852  static char *ParseCSSBorderLeft (Element
       if (ptr == cssRule)        if (ptr == cssRule)
         /* rule not found */          /* rule not found */
         cssRule = SkipProperty (cssRule);          cssRule = SkipProperty (cssRule);
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   return (cssRule);    return (cssRule);
 }  }
Line 887  static char *ParseCSSBorderBottom (Eleme Line 867  static char *ParseCSSBorderBottom (Eleme
 {  {
   char           *ptr;    char           *ptr;
   
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))    while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
     {      {
       ptr = cssRule;        ptr = cssRule;
       cssRule = ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML);        cssRule = ParseCSSBorderStyleBottom (element, tsch, context, cssRule, css, isHTML);
Line 899  static char *ParseCSSBorderBottom (Eleme Line 879  static char *ParseCSSBorderBottom (Eleme
       if (ptr == cssRule)        if (ptr == cssRule)
         /* rule not found */          /* rule not found */
         cssRule = SkipProperty (cssRule);          cssRule = SkipProperty (cssRule);
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   return (cssRule);    return (cssRule);
 }  }
Line 914  static char *ParseCSSBorderRight (Elemen Line 894  static char *ParseCSSBorderRight (Elemen
 {  {
   char            *ptr;    char            *ptr;
   
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))    while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
     {      {
       ptr = cssRule;        ptr = cssRule;
       cssRule = ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML);        cssRule = ParseCSSBorderStyleRight (element, tsch, context, cssRule, css, isHTML);
Line 926  static char *ParseCSSBorderRight (Elemen Line 906  static char *ParseCSSBorderRight (Elemen
       if (ptr == cssRule)        if (ptr == cssRule)
         /* rule not found */          /* rule not found */
         cssRule = SkipProperty (cssRule);          cssRule = SkipProperty (cssRule);
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   return (cssRule);    return (cssRule);
 }  }
Line 941  static char *ParseCSSBorder (Element ele Line 921  static char *ParseCSSBorder (Element ele
 {  {
   char *ptrT, *ptrR;    char *ptrT, *ptrR;
   
   ptrT = SkipWCBlanksAndComments (cssRule);    ptrT = SkipBlanksAndComments (cssRule);
   /* First parse Border-Top */    /* First parse Border-Top */
   ptrR = ParseCSSBorderTop (element, tsch, context, ptrT, css, isHTML);    ptrR = ParseCSSBorderTop (element, tsch, context, ptrT, css, isHTML);
   ptrR = SkipWCBlanksAndComments (ptrR);    ptrR = SkipBlanksAndComments (ptrR);
   if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))    if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
     {      {
       cssRule = ptrR;        cssRule = ptrR;
       /* apply the Border-Top to all */        /* apply the Border-Top to all */
Line 978  static char *ParseCSSDisplay (Element el Line 958  static char *ParseCSSDisplay (Element el
   
    pval.typed_data.unit = STYLE_UNIT_REL;     pval.typed_data.unit = STYLE_UNIT_REL;
    pval.typed_data.real = FALSE;     pval.typed_data.real = FALSE;
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    if (!ustrncasecmp (cssRule, TEXT("block"), 5))     if (!strncasecmp (cssRule, "block", 5))
      {       {
        /* pval.typed_data.value = STYLE_INLINE;         /* pval.typed_data.value = STYLE_INLINE;
         TtaSetStylePresentation (PRLine, element, tsch, context, pval);          TtaSetStylePresentation (PRLine, element, tsch, context, pval);
         cssRule = SkipWord (cssRule); */          cssRule = SkipWord (cssRule); */
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("inline"), 6))     else if (!strncasecmp (cssRule, "inline", 6))
      {       {
        /* pval.typed_data.value = STYLE_INLINE;         /* pval.typed_data.value = STYLE_INLINE;
         TtaSetStylePresentation (PRLine, element, tsch, context, pval);          TtaSetStylePresentation (PRLine, element, tsch, context, pval);
         cssRule = SkipWord (cssRule); */          cssRule = SkipWord (cssRule); */
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("none"), 4))     else if (!strncasecmp (cssRule, "none", 4))
      {       {
         pval.typed_data.value = STYLE_HIDE;          pval.typed_data.value = STYLE_HIDE;
         TtaSetStylePresentation (PRVisibility, element, tsch, context, pval);          TtaSetStylePresentation (PRVisibility, element, tsch, context, pval);
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("list-item"), 9))     else if (!strncasecmp (cssRule, "list-item", 9))
      cssRule = SkipProperty (cssRule);       cssRule = SkipProperty (cssRule);
    else     else
      fprintf (stderr, "invalid display value %s\n", cssRule);       fprintf (stderr, "invalid display value %s\n", cssRule);
Line 1091  static char *ParseCSSTextAlign (Element Line 1071  static char *ParseCSSTextAlign (Element
    align.typed_data.unit = STYLE_UNIT_REL;     align.typed_data.unit = STYLE_UNIT_REL;
    align.typed_data.real = FALSE;     align.typed_data.real = FALSE;
   
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    if (!ustrncasecmp (cssRule, TEXT("left"), 4))     if (!strncasecmp (cssRule, "left", 4))
      {       {
         align.typed_data.value = AdjustLeft;          align.typed_data.value = AdjustLeft;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("right"), 5))     else if (!strncasecmp (cssRule, "right", 5))
      {       {
         align.typed_data.value = AdjustRight;          align.typed_data.value = AdjustRight;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("center"), 6))     else if (!strncasecmp (cssRule, "center", 6))
      {       {
         align.typed_data.value = Centered;          align.typed_data.value = Centered;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("justify"), 7))     else if (!strncasecmp (cssRule, "justify", 7))
      {       {
         align.typed_data.value = Justify;          align.typed_data.value = Justify;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
Line 1136  static char *ParseCSSTextIndent (Element Line 1116  static char *ParseCSSTextIndent (Element
 {  {
    PresentationValue   pval;     PresentationValue   pval;
   
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    cssRule = ParseCSSUnit (cssRule, &pval);     cssRule = ParseCSSUnit (cssRule, &pval);
    if (pval.typed_data.unit == STYLE_UNIT_INVALID)     if (pval.typed_data.unit == STYLE_UNIT_INVALID)
      return (cssRule);       return (cssRule);
Line 1177  static char *ParseCSSWhiteSpace (Element Line 1157  static char *ParseCSSWhiteSpace (Element
                                  PresentationContext context, char *cssRule,                                   PresentationContext context, char *cssRule,
                                  CSSInfoPtr css, ThotBool isHTML)                                   CSSInfoPtr css, ThotBool isHTML)
 {  {
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    if (!ustrncasecmp (cssRule, TEXT("normal"), 6))     if (!strncasecmp (cssRule, "normal", 6))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
    else if (!ustrncasecmp (cssRule, TEXT("pre"), 3))     else if (!strncasecmp (cssRule, "pre", 3))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
    else     else
      return (cssRule);       return (cssRule);
Line 1236  static char *ParseCSSFontSize (Element e Line 1216  static char *ParseCSSFontSize (Element e
    ThotBool            real;     ThotBool            real;
   
    pval.typed_data.real = FALSE;     pval.typed_data.real = FALSE;
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    if (!ustrncasecmp (cssRule, TEXT("larger"), 6))     if (!strncasecmp (cssRule, "larger", 6))
      {       {
         pval.typed_data.unit = STYLE_UNIT_PERCENT;          pval.typed_data.unit = STYLE_UNIT_PERCENT;
         pval.typed_data.value = 130;          pval.typed_data.value = 130;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("smaller"), 7))     else if (!strncasecmp (cssRule, "smaller", 7))
      {       {
         pval.typed_data.unit = STYLE_UNIT_PERCENT;          pval.typed_data.unit = STYLE_UNIT_PERCENT;
         pval.typed_data.value = 80;          pval.typed_data.value = 80;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("xx-small"), 8))     else if (!strncasecmp (cssRule, "xx-small", 8))
      {       {
         pval.typed_data.unit = STYLE_UNIT_REL;          pval.typed_data.unit = STYLE_UNIT_REL;
         pval.typed_data.value = 1;          pval.typed_data.value = 1;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("x-small"), 7))     else if (!strncasecmp (cssRule, "x-small", 7))
      {       {
         pval.typed_data.unit = STYLE_UNIT_REL;          pval.typed_data.unit = STYLE_UNIT_REL;
         pval.typed_data.value = 2;          pval.typed_data.value = 2;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("small"), 5))     else if (!strncasecmp (cssRule, "small", 5))
      {       {
         pval.typed_data.unit = STYLE_UNIT_REL;          pval.typed_data.unit = STYLE_UNIT_REL;
         pval.typed_data.value = 3;          pval.typed_data.value = 3;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("medium"), 6))     else if (!strncasecmp (cssRule, "medium", 6))
      {       {
         pval.typed_data.unit = STYLE_UNIT_REL;          pval.typed_data.unit = STYLE_UNIT_REL;
         pval.typed_data.value = 4;          pval.typed_data.value = 4;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("large"), 5))     else if (!strncasecmp (cssRule, "large", 5))
      {       {
         pval.typed_data.unit = STYLE_UNIT_REL;          pval.typed_data.unit = STYLE_UNIT_REL;
         pval.typed_data.value = 5;          pval.typed_data.value = 5;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("x-large"), 7))     else if (!strncasecmp (cssRule, "x-large", 7))
      {       {
         pval.typed_data.unit = STYLE_UNIT_REL;          pval.typed_data.unit = STYLE_UNIT_REL;
         pval.typed_data.value = 6;          pval.typed_data.value = 6;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("xx-large"), 8))     else if (!strncasecmp (cssRule, "xx-large", 8))
      {       {
         pval.typed_data.unit = STYLE_UNIT_REL;          pval.typed_data.unit = STYLE_UNIT_REL;
         pval.typed_data.value = 7;          pval.typed_data.value = 7;
Line 1294  static char *ParseCSSFontSize (Element e Line 1274  static char *ParseCSSFontSize (Element e
    else     else
      {       {
        /* look for a '/' within the current cssRule */         /* look for a '/' within the current cssRule */
        ptr = ustrchr (cssRule, TEXT('/'));         ptr = strchr (cssRule, '/');
        if (ptr != NULL)         if (ptr != NULL)
          {           {
            /* keep the line spacing rule */             /* keep the line spacing rule */
            ptr[0] = WC_EOS;             ptr[0] = EOS;
            ptr = &ptr[1];             ptr = &ptr[1];
          }           }
        cssRule = ParseCSSUnit (cssRule, &pval);         cssRule = ParseCSSUnit (cssRule, &pval);
Line 1350  static char *ParseCSSFontFamily (Element Line 1330  static char *ParseCSSFontFamily (Element
   font.typed_data.value = 0;    font.typed_data.value = 0;
   font.typed_data.unit = STYLE_UNIT_REL;    font.typed_data.unit = STYLE_UNIT_REL;
   font.typed_data.real = FALSE;    font.typed_data.real = FALSE;
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   if (*cssRule == TEXT('"') || *cssRule == TEXT('\''))    if (*cssRule == '"' || *cssRule == '\'')
      {       {
      quoteChar = *cssRule;       quoteChar = *cssRule;
      cssRule++;       cssRule++;
      }       }
   else    else
      quoteChar = WC_EOS;       quoteChar = EOS;
   
   if (!ustrncasecmp (cssRule, TEXT("times"), 5))    if (!strncasecmp (cssRule, "times", 5))
       font.typed_data.value = STYLE_FONT_TIMES;        font.typed_data.value = STYLE_FONT_TIMES;
   else if (!ustrncasecmp (cssRule, TEXT("serif"), 5))    else if (!strncasecmp (cssRule, "serif", 5))
       font.typed_data.value = STYLE_FONT_TIMES;        font.typed_data.value = STYLE_FONT_TIMES;
   else if (!ustrncasecmp (cssRule, TEXT("helvetica"), 9) ||    else if (!strncasecmp (cssRule, "helvetica", 9) ||
            !ustrncasecmp (cssRule, TEXT("verdana"), 7))             !strncasecmp (cssRule, "verdana", 7))
       font.typed_data.value = STYLE_FONT_HELVETICA;        font.typed_data.value = STYLE_FONT_HELVETICA;
   else if (!ustrncasecmp (cssRule, TEXT("sans-serif"), 10))    else if (!strncasecmp (cssRule, "sans-serif", 10))
       font.typed_data.value = STYLE_FONT_HELVETICA;        font.typed_data.value = STYLE_FONT_HELVETICA;
   else if (!ustrncasecmp (cssRule, TEXT("courier"), 7))    else if (!strncasecmp (cssRule, "courier", 7))
       font.typed_data.value = STYLE_FONT_COURIER;        font.typed_data.value = STYLE_FONT_COURIER;
   else if (!ustrncasecmp (cssRule, TEXT("monospace"), 9))    else if (!strncasecmp (cssRule, "monospace", 9))
       font.typed_data.value = STYLE_FONT_COURIER;        font.typed_data.value = STYLE_FONT_COURIER;
   else    else
     /* unknown font name.  Skip it */      /* unknown font name.  Skip it */
Line 1379  static char *ParseCSSFontFamily (Element Line 1359  static char *ParseCSSFontFamily (Element
          cssRule = SkipQuotedString (cssRule, quoteChar);           cssRule = SkipQuotedString (cssRule, quoteChar);
       } else        } else
          cssRule = SkipWord (cssRule);           cssRule = SkipWord (cssRule);
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
       if (*cssRule == TEXT(','))        if (*cssRule == ',')
         {          {
         cssRule++;          cssRule++;
         cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);          cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
Line 1411  static char *ParseCSSFontWeight (Element Line 1391  static char *ParseCSSFontWeight (Element
    weight.typed_data.value = 0;     weight.typed_data.value = 0;
    weight.typed_data.unit = STYLE_UNIT_REL;     weight.typed_data.unit = STYLE_UNIT_REL;
    weight.typed_data.real = FALSE;     weight.typed_data.real = FALSE;
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    if (!ustrncasecmp (cssRule, TEXT("100"), 3) && !TtaIsAlpha (cssRule[3]))     if (!strncasecmp (cssRule, "100", 3) && !isalpha (cssRule[3]))
      {       {
         weight.typed_data.value = -3;          weight.typed_data.value = -3;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("200"), 3) && !TtaIsAlpha (cssRule[3]))     else if (!strncasecmp (cssRule, "200", 3) && !isalpha (cssRule[3]))
      {       {
         weight.typed_data.value = -2;          weight.typed_data.value = -2;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("300"), 3) && !TtaIsAlpha (cssRule[3]))     else if (!strncasecmp (cssRule, "300", 3) && ! isalpha(cssRule[3]))
      {       {
         weight.typed_data.value = -1;          weight.typed_data.value = -1;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("normal"), 6) || (!ustrncasecmp (cssRule, TEXT("400"), 3) && !TtaIsAlpha (cssRule[3])))     else if (!strncasecmp (cssRule, "normal", 6) || (!strncasecmp (cssRule, "400", 3) && !isalpha (cssRule[3])))
      {       {
         weight.typed_data.value = 0;          weight.typed_data.value = 0;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("500"), 3) && !TtaIsAlpha (cssRule[3]))     else if (!strncasecmp (cssRule, "500", 3) && !isalpha (cssRule[3]))
      {       {
         weight.typed_data.value = +1;          weight.typed_data.value = +1;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("600"), 3) && !TtaIsAlpha (cssRule[3]))     else if (!strncasecmp (cssRule, "600", 3) && !isalpha (cssRule[3]))
      {       {
         weight.typed_data.value = +2;          weight.typed_data.value = +2;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("bold"), 4) || (!ustrncasecmp (cssRule, TEXT("700"), 3) && !TtaIsAlpha (cssRule[3])))     else if (!strncasecmp (cssRule, "bold", 4) || (!strncasecmp (cssRule, "700", 3) && !isalpha (cssRule[3])))
      {       {
         weight.typed_data.value = +3;          weight.typed_data.value = +3;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("800"), 3) && !TtaIsAlpha (cssRule[3]))     else if (!strncasecmp (cssRule, "800", 3) && !isalpha (cssRule[3]))
      {       {
         weight.typed_data.value = +4;          weight.typed_data.value = +4;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("900"), 3) && !TtaIsAlpha (cssRule[3]))     else if (!strncasecmp (cssRule, "900", 3) && !isalpha (cssRule[3]))
      {       {
         weight.typed_data.value = +5;          weight.typed_data.value = +5;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7) || !ustrncasecmp (cssRule, TEXT("bolder"), 6) || !ustrncasecmp (cssRule, TEXT("lighter"), 7))     else if (!strncasecmp (cssRule, "inherit", 7) || !strncasecmp (cssRule, "bolder", 6) || !strncasecmp (cssRule, "lighter", 7))
      {       {
      /* not implemented */       /* not implemented */
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
Line 1494  static char *ParseCSSFontVariant (Elemen Line 1474  static char *ParseCSSFontVariant (Elemen
    style.typed_data.value = 0;     style.typed_data.value = 0;
    style.typed_data.unit = STYLE_UNIT_REL;     style.typed_data.unit = STYLE_UNIT_REL;
    style.typed_data.real = FALSE;     style.typed_data.real = FALSE;
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    if (!ustrncasecmp (cssRule, TEXT("small-caps"), 10))     if (!strncasecmp (cssRule, "small-caps", 10))
      {       {
        /* Not supported yet */         /* Not supported yet */
        cssRule = SkipWord (cssRule);         cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("normal"), 6))     else if (!strncasecmp (cssRule, "normal", 6))
      {       {
        /* Not supported yet */         /* Not supported yet */
        cssRule = SkipWord (cssRule);         cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))     else if (!strncasecmp (cssRule, "inherit", 7))
      {       {
        /* Not supported yet */         /* Not supported yet */
        cssRule = SkipWord (cssRule);         cssRule = SkipWord (cssRule);
Line 1535  static char *ParseCSSFontStyle (Element Line 1515  static char *ParseCSSFontStyle (Element
    size.typed_data.value = 0;     size.typed_data.value = 0;
    size.typed_data.unit = STYLE_UNIT_REL;     size.typed_data.unit = STYLE_UNIT_REL;
    size.typed_data.real = FALSE;     size.typed_data.real = FALSE;
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    if (!ustrncasecmp (cssRule, TEXT("italic"), 6))     if (!strncasecmp (cssRule, "italic", 6))
      {       {
         style.typed_data.value = STYLE_FONT_ITALICS;          style.typed_data.value = STYLE_FONT_ITALICS;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("oblique"), 7))     else if (!strncasecmp (cssRule, "oblique", 7))
      {       {
         style.typed_data.value = STYLE_FONT_OBLIQUE;          style.typed_data.value = STYLE_FONT_OBLIQUE;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("normal"), 6))     else if (!strncasecmp (cssRule, "normal", 6))
      {       {
         style.typed_data.value = STYLE_FONT_ROMAN;          style.typed_data.value = STYLE_FONT_ROMAN;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
Line 1592  static char *ParseCSSFont (Element eleme Line 1572  static char *ParseCSSFont (Element eleme
 {  {
   char           *ptr;    char           *ptr;
   
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   if (!ustrncasecmp (cssRule, TEXT("caption"), 7))    if (!strncasecmp (cssRule, "caption", 7))
     ;      ;
   else if (!ustrncasecmp (cssRule, TEXT("icon"), 4))    else if (!strncasecmp (cssRule, "icon", 4))
     ;      ;
   else if (!ustrncasecmp (cssRule, TEXT("menu"), 4))    else if (!strncasecmp (cssRule, "menu", 4))
     ;      ;
   else if (!ustrncasecmp (cssRule, TEXT("message-box"), 11))    else if (!strncasecmp (cssRule, "message-box", 11))
     ;      ;
   else if (!ustrncasecmp (cssRule, TEXT("small-caption"), 13))    else if (!strncasecmp (cssRule, "small-caption", 13))
     ;      ;
   else if (!ustrncasecmp (cssRule, TEXT("status-bar"), 10))    else if (!strncasecmp (cssRule, "status-bar", 10))
     ;      ;
   else    else
     {      {
       while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))        while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
         {          {
           ptr = cssRule;            ptr = cssRule;
           cssRule = ParseCSSFontStyle (element, tsch, context, cssRule, css, isHTML);            cssRule = ParseCSSFontStyle (element, tsch, context, cssRule, css, isHTML);
Line 1619  static char *ParseCSSFont (Element eleme Line 1599  static char *ParseCSSFont (Element eleme
             cssRule = ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML);              cssRule = ParseCSSFontSize (element, tsch, context, cssRule, css, isHTML);
           if (ptr == cssRule)            if (ptr == cssRule)
             cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);              cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
           cssRule = SkipWCBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
         }          }
     }      }
   return (cssRule);    return (cssRule);
Line 1640  static char *ParseCSSTextDecoration (Ele Line 1620  static char *ParseCSSTextDecoration (Ele
    decor.typed_data.value = 0;     decor.typed_data.value = 0;
    decor.typed_data.unit = STYLE_UNIT_REL;     decor.typed_data.unit = STYLE_UNIT_REL;
    decor.typed_data.real = FALSE;     decor.typed_data.real = FALSE;
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    if (!ustrncasecmp (cssRule, TEXT("underline"), strlen ("underline")))     if (!strncasecmp (cssRule, "underline", strlen ("underline")))
      {       {
         decor.typed_data.value = Underline;          decor.typed_data.value = Underline;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("overline"), strlen ("overline")))     else if (!strncasecmp (cssRule, "overline", strlen ("overline")))
      {       {
         decor.typed_data.value = Overline;          decor.typed_data.value = Overline;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("line-through"), strlen ("line-through")))     else if (!strncasecmp (cssRule, "line-through", strlen ("line-through")))
      {       {
         decor.typed_data.value = CrossOut;          decor.typed_data.value = CrossOut;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("box"), strlen ("box")))     else if (!strncasecmp (cssRule, "box", strlen ("box")))
      {       {
        /* the box text-decoration attribute is not yet supported */         /* the box text-decoration attribute is not yet supported */
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("boxshadow"), strlen ("boxshadow")))     else if (!strncasecmp (cssRule, "boxshadow", strlen ("boxshadow")))
      {       {
        /* the boxshadow text-decoration attribute is not yet supported */         /* the boxshadow text-decoration attribute is not yet supported */
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("box3d"), strlen ("box3d")))     else if (!strncasecmp (cssRule, "box3d", strlen ("box3d")))
      {       {
        /* the box3d text-decoration attribute is not yet supported */         /* the box3d text-decoration attribute is not yet supported */
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("cartouche"), strlen ("cartouche")))     else if (!strncasecmp (cssRule, "cartouche", strlen ("cartouche")))
      {       {
         /*the cartouche text-decoration attribute is not yet supported */          /*the cartouche text-decoration attribute is not yet supported */
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("blink"), strlen ("blink")))     else if (!strncasecmp (cssRule, "blink", strlen ("blink")))
      {       {
         /*the blink text-decoration attribute will not be supported */          /*the blink text-decoration attribute will not be supported */
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
      }       }
    else if (!ustrncasecmp (cssRule, TEXT("none"), strlen ("none")))     else if (!strncasecmp (cssRule, "none", strlen ("none")))
      {       {
         decor.typed_data.value = NoUnderline;          decor.typed_data.value = NoUnderline;
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
Line 1708  static char *ParseCSSTextDecoration (Ele Line 1688  static char *ParseCSSTextDecoration (Ele
 static char *ParseCSSHeight (Element element, PSchema tsch,  static char *ParseCSSHeight (Element element, PSchema tsch,
                                  PresentationContext context, char *cssRule, CSSInfoPtr css, ThotBool isHTML)                                   PresentationContext context, char *cssRule, CSSInfoPtr css, ThotBool isHTML)
 {  {
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
   
    /* first parse the attribute string */     /* first parse the attribute string */
    if (!ustrcasecmp (cssRule, TEXT("auto")))     if (!strcasecmp (cssRule, "auto"))
      {       {
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
         /* ParseCSSHeight: auto */          /* ParseCSSHeight: auto */
Line 1730  static char *ParseCSSWidth (Element elem Line 1710  static char *ParseCSSWidth (Element elem
                               char *cssRule, CSSInfoPtr css,                                char *cssRule, CSSInfoPtr css,
                               ThotBool isHTML)                                ThotBool isHTML)
 {  {
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
   
    /* first parse the attribute string */     /* first parse the attribute string */
    if (!ustrcasecmp (cssRule, TEXT("auto")))     if (!strcasecmp (cssRule, "auto"))
      {       {
         cssRule = SkipWord (cssRule);          cssRule = SkipWord (cssRule);
         return (cssRule);          return (cssRule);
Line 1753  static char *ParseCSSMarginTop (Element Line 1733  static char *ParseCSSMarginTop (Element
 {  {
   PresentationValue   margin;    PresentationValue   margin;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseCSSUnit (cssRule, &margin);    cssRule = ParseCSSUnit (cssRule, &margin);
   if (margin.typed_data.unit != STYLE_UNIT_INVALID)    if (margin.typed_data.unit != STYLE_UNIT_INVALID)
Line 1775  static char *ParseCSSMarginBottom (Eleme Line 1755  static char *ParseCSSMarginBottom (Eleme
 {  {
   PresentationValue   margin;    PresentationValue   margin;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseCSSUnit (cssRule, &margin);    cssRule = ParseCSSUnit (cssRule, &margin);
   if (margin.typed_data.unit != STYLE_UNIT_INVALID)    if (margin.typed_data.unit != STYLE_UNIT_INVALID)
Line 1793  static char *ParseCSSMarginLeft (Element Line 1773  static char *ParseCSSMarginLeft (Element
 {  {
   PresentationValue   margin;    PresentationValue   margin;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseCSSUnit (cssRule, &margin);    cssRule = ParseCSSUnit (cssRule, &margin);
   if (margin.typed_data.unit != STYLE_UNIT_INVALID)    if (margin.typed_data.unit != STYLE_UNIT_INVALID)
Line 1815  static char *ParseCSSMarginRight (Elemen Line 1795  static char *ParseCSSMarginRight (Elemen
 {  {
   PresentationValue   margin;    PresentationValue   margin;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseCSSUnit (cssRule, &margin);    cssRule = ParseCSSUnit (cssRule, &margin);
   if (margin.typed_data.unit != STYLE_UNIT_INVALID)    if (margin.typed_data.unit != STYLE_UNIT_INVALID)
Line 1833  static char *ParseCSSMargin (Element ele Line 1813  static char *ParseCSSMargin (Element ele
 {  {
   char *ptrT, *ptrR, *ptrB, *ptrL;    char *ptrT, *ptrR, *ptrB, *ptrL;
   
   ptrT = SkipWCBlanksAndComments (cssRule);    ptrT = SkipBlanksAndComments (cssRule);
   /* First parse Margin-Top */    /* First parse Margin-Top */
   ptrR = ParseCSSMarginTop (element, tsch, context, ptrT, css, isHTML);    ptrR = ParseCSSMarginTop (element, tsch, context, ptrT, css, isHTML);
   ptrR = SkipWCBlanksAndComments (ptrR);    ptrR = SkipBlanksAndComments (ptrR);
   if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))    if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
     {      {
       cssRule = ptrR;        cssRule = ptrR;
       /* apply the Margin-Top to all */        /* apply the Margin-Top to all */
Line 1849  static char *ParseCSSMargin (Element ele Line 1829  static char *ParseCSSMargin (Element ele
     {      {
       /* parse Margin-Right */        /* parse Margin-Right */
       ptrB = ParseCSSMarginRight (element, tsch, context, ptrR, css, isHTML);        ptrB = ParseCSSMarginRight (element, tsch, context, ptrR, css, isHTML);
       ptrB = SkipWCBlanksAndComments (ptrB);        ptrB = SkipBlanksAndComments (ptrB);
       if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))        if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
         {          {
           cssRule = ptrB;            cssRule = ptrB;
           /* apply the Margin-Top to Margin-Bottom */            /* apply the Margin-Top to Margin-Bottom */
Line 1862  static char *ParseCSSMargin (Element ele Line 1842  static char *ParseCSSMargin (Element ele
         {          {
           /* parse Margin-Bottom */            /* parse Margin-Bottom */
           ptrL = ParseCSSMarginBottom (element, tsch, context, ptrB, css, isHTML);            ptrL = ParseCSSMarginBottom (element, tsch, context, ptrB, css, isHTML);
           ptrL = SkipWCBlanksAndComments (ptrL);            ptrL = SkipBlanksAndComments (ptrL);
           if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))            if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
             {              {
               cssRule = ptrL;                cssRule = ptrL;
               /* apply the Margin-Right to Margin-Left */                /* apply the Margin-Right to Margin-Left */
Line 1872  static char *ParseCSSMargin (Element ele Line 1852  static char *ParseCSSMargin (Element ele
           else            else
             /* parse Margin-Left */              /* parse Margin-Left */
             cssRule = ParseCSSMarginLeft (element, tsch, context, ptrL, css, isHTML);              cssRule = ParseCSSMarginLeft (element, tsch, context, ptrL, css, isHTML);
           cssRule = SkipWCBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
         }          }
     }      }
   return (cssRule);    return (cssRule);
Line 1888  static char *ParseCSSPaddingTop (Element Line 1868  static char *ParseCSSPaddingTop (Element
 {  {
   PresentationValue   padding;    PresentationValue   padding;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseCSSUnit (cssRule, &padding);    cssRule = ParseCSSUnit (cssRule, &padding);
   if (padding.typed_data.unit != STYLE_UNIT_INVALID)    if (padding.typed_data.unit != STYLE_UNIT_INVALID)
Line 1906  static char *ParseCSSPaddingBottom (Elem Line 1886  static char *ParseCSSPaddingBottom (Elem
 {  {
   PresentationValue   padding;    PresentationValue   padding;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseCSSUnit (cssRule, &padding);    cssRule = ParseCSSUnit (cssRule, &padding);
   if (padding.typed_data.unit != STYLE_UNIT_INVALID)    if (padding.typed_data.unit != STYLE_UNIT_INVALID)
Line 1924  static char *ParseCSSPaddingLeft (Elemen Line 1904  static char *ParseCSSPaddingLeft (Elemen
 {  {
   PresentationValue   padding;    PresentationValue   padding;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseCSSUnit (cssRule, &padding);    cssRule = ParseCSSUnit (cssRule, &padding);
   if (padding.typed_data.unit != STYLE_UNIT_INVALID)    if (padding.typed_data.unit != STYLE_UNIT_INVALID)
Line 1942  static char *ParseCSSPaddingRight (Eleme Line 1922  static char *ParseCSSPaddingRight (Eleme
 {  {
   PresentationValue   padding;    PresentationValue   padding;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   /* first parse the attribute string */    /* first parse the attribute string */
   cssRule = ParseCSSUnit (cssRule, &padding);    cssRule = ParseCSSUnit (cssRule, &padding);
   if (padding.typed_data.unit != STYLE_UNIT_INVALID)    if (padding.typed_data.unit != STYLE_UNIT_INVALID)
Line 1960  static char *ParseCSSPadding (Element el Line 1940  static char *ParseCSSPadding (Element el
 {  {
   char *ptrT, *ptrR, *ptrB, *ptrL;    char *ptrT, *ptrR, *ptrB, *ptrL;
   
   ptrT = SkipWCBlanksAndComments (cssRule);    ptrT = SkipBlanksAndComments (cssRule);
   /* First parse Padding-Top */    /* First parse Padding-Top */
   ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);    ptrR = ParseCSSPaddingTop (element, tsch, context, ptrT, css, isHTML);
   ptrR = SkipWCBlanksAndComments (ptrR);    ptrR = SkipBlanksAndComments (ptrR);
   if (*ptrR == TEXT(';') || *ptrR == WC_EOS || *ptrR == TEXT(','))    if (*ptrR == ';' || *ptrR == EOS || *ptrR == ',')
     {      {
       cssRule = ptrR;        cssRule = ptrR;
       /* apply the Padding-Top to all */        /* apply the Padding-Top to all */
Line 1976  static char *ParseCSSPadding (Element el Line 1956  static char *ParseCSSPadding (Element el
     {      {
       /* parse Padding-Right */        /* parse Padding-Right */
       ptrB = ParseCSSPaddingRight (element, tsch, context, ptrR, css, isHTML);        ptrB = ParseCSSPaddingRight (element, tsch, context, ptrR, css, isHTML);
       ptrB = SkipWCBlanksAndComments (ptrB);        ptrB = SkipBlanksAndComments (ptrB);
       if (*ptrB == TEXT(';') || *ptrB == WC_EOS || *ptrB == TEXT(','))        if (*ptrB == ';' || *ptrB == EOS || *ptrB == ',')
         {          {
           cssRule = ptrB;            cssRule = ptrB;
           /* apply the Padding-Top to Padding-Bottom */            /* apply the Padding-Top to Padding-Bottom */
Line 1989  static char *ParseCSSPadding (Element el Line 1969  static char *ParseCSSPadding (Element el
         {          {
           /* parse Padding-Bottom */            /* parse Padding-Bottom */
           ptrL = ParseCSSPaddingBottom (element, tsch, context, ptrB, css, isHTML);            ptrL = ParseCSSPaddingBottom (element, tsch, context, ptrB, css, isHTML);
           ptrL = SkipWCBlanksAndComments (ptrL);            ptrL = SkipBlanksAndComments (ptrL);
           if (*ptrL == TEXT(';') || *ptrL == WC_EOS || *ptrL == TEXT(','))            if (*ptrL == ';' || *ptrL == EOS || *ptrL == ',')
             {              {
               cssRule = ptrL;                cssRule = ptrL;
               /* apply the Padding-Right to Padding-Left */                /* apply the Padding-Right to Padding-Left */
Line 1999  static char *ParseCSSPadding (Element el Line 1979  static char *ParseCSSPadding (Element el
           else            else
             /* parse Padding-Left */              /* parse Padding-Left */
             cssRule = ParseCSSPaddingLeft (element, tsch, context, ptrL, css, isHTML);              cssRule = ParseCSSPaddingLeft (element, tsch, context, ptrL, css, isHTML);
           cssRule = SkipWCBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
         }          }
     }      }
   return (cssRule);    return (cssRule);
Line 2049  static char *ParseCSSBackgroundColor (El Line 2029  static char *ParseCSSBackgroundColor (El
   
   best.typed_data.unit = STYLE_UNIT_INVALID;    best.typed_data.unit = STYLE_UNIT_INVALID;
   best.typed_data.real = FALSE;    best.typed_data.real = FALSE;
   if (!ustrncasecmp (cssRule, TEXT("transparent"), strlen ("transparent")))    if (!strncasecmp (cssRule, "transparent", strlen ("transparent")))
     {      {
       best.typed_data.value = STYLE_PATTERN_NONE;        best.typed_data.value = STYLE_PATTERN_NONE;
       best.typed_data.unit = STYLE_UNIT_REL;        best.typed_data.unit = STYLE_UNIT_REL;
Line 2091  static char *ParseSVGStroke (Element ele Line 2071  static char *ParseSVGStroke (Element ele
   
   best.typed_data.unit = STYLE_UNIT_INVALID;    best.typed_data.unit = STYLE_UNIT_INVALID;
   best.typed_data.real = FALSE;    best.typed_data.real = FALSE;
   if (!ustrncasecmp (cssRule, TEXT("none"), 4))    if (!strncasecmp (cssRule, "none", 4))
     {      {
       best.typed_data.value = -2;  /* -2 means transparent */        best.typed_data.value = -2;  /* -2 means transparent */
       best.typed_data.unit = STYLE_UNIT_REL;        best.typed_data.unit = STYLE_UNIT_REL;
Line 2119  static char *ParseSVGFill (Element eleme Line 2099  static char *ParseSVGFill (Element eleme
   
   best.typed_data.unit = STYLE_UNIT_INVALID;    best.typed_data.unit = STYLE_UNIT_INVALID;
   best.typed_data.real = FALSE;    best.typed_data.real = FALSE;
   if (!ustrncasecmp (cssRule, TEXT("none"), 4))    if (!strncasecmp (cssRule, "none", 4))
     {      {
       best.typed_data.value = STYLE_PATTERN_NONE;        best.typed_data.value = STYLE_PATTERN_NONE;
       best.typed_data.unit = STYLE_UNIT_REL;        best.typed_data.unit = STYLE_UNIT_REL;
Line 2146  static char *ParseSVGFill (Element eleme Line 2126  static char *ParseSVGFill (Element eleme
   ParseCSSBackgroundImageCallback: Callback called asynchronously by    ParseCSSBackgroundImageCallback: Callback called asynchronously by
   FetchImage when a background image has been fetched.    FetchImage when a background image has been fetched.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 void ParseCSSBackgroundImageCallback (Document doc, Element element, STRING file, void *extra)  void ParseCSSBackgroundImageCallback (Document doc, Element element,
                                         char *file, void *extra)
 {  {
   DisplayMode         dispMode;    DisplayMode                dispMode;
   BackgroundImageCallbackPtr callblock = (BackgroundImageCallbackPtr) extra;    BackgroundImageCallbackPtr callblock;
   Element             el;    Element                    el;
   PSchema             tsch;    PSchema                    tsch;
   PresentationContext context;    PresentationContext        context;
   PresentationValue   image;    PresentationValue          image;
   PresentationValue   value;    PresentationValue          value;
   
     callblock = (BackgroundImageCallbackPtr) extra;
   if (callblock == NULL)    if (callblock == NULL)
     return;      return;
   
Line 2196  char *GetCSSBackgroundURL (char *styleSt Line 2178  char *GetCSSBackgroundURL (char *styleSt
   int              len;    int              len;
   
   ptr = NULL;    ptr = NULL;
   b = ustrstr (styleString, TEXT("url"));    b = strstr (styleString, "url");
   if (b != NULL)    if (b != NULL)
     {      {
       b += 3;        b += 3;
       b = SkipWCBlanksAndComments (b);        b = SkipBlanksAndComments (b);
       if (*b == TEXT('('))        if (*b == '(')
         {          {
           b++;            b++;
           b = SkipWCBlanksAndComments (b);            b = SkipBlanksAndComments (b);
           /*** Caution: Strings can either be written with double quotes or            /*** Caution: Strings can either be written with double quotes or
                with single quotes. Only double quotes are handled here.                 with single quotes. Only double quotes are handled here.
                Escaped quotes are not handled. See function SkipQuotedString */                 Escaped quotes are not handled. See function SkipQuotedString */
           if (*b == TEXT('"'))            if (*b == '"')
             {              {
               b++;                b++;
               /* search the url end */                /* search the url end */
               e = b;                e = b;
               while (*e != WC_EOS && *e != TEXT('"'))                while (*e != EOS && *e != '"')
                 e++;                  e++;
             }              }
           else            else
             {              {
               /* search the url end */                /* search the url end */
               e = b;                e = b;
               while (*e != WC_EOS && *e != TEXT(')'))                while (*e != EOS && *e != ')')
                 e++;                  e++;
             }              }
           if (*e != WC_EOS)            if (*e != EOS)
             {              {
               len = (int)(e - b);                len = (int)(e - b);
               ptr = (char*) TtaAllocString (len+1);                ptr = (char*) TtaGetMemory (len+1);
               ustrncpy (ptr, b, len);                strncpy (ptr, b, len);
               ptr[len] = WC_EOS;                ptr[len] = EOS;
             }              }
         }          }
     }      }
Line 2250  static char *ParseCSSBackgroundImage (El Line 2232  static char *ParseCSSBackgroundImage (El
   BackgroundImageCallbackPtr callblock;    BackgroundImageCallbackPtr callblock;
   PresentationValue          image, value;    PresentationValue          image, value;
   char                      *url;    char                      *url;
   STRING                     bg_image;    char                      *bg_image;
   char                       saved;    char                       saved;
   char                      *base;    char                      *base;
   char                       tempname[MAX_LENGTH];    char                       tempname[MAX_LENGTH];
Line 2276  static char *ParseCSSBackgroundImage (El Line 2258  static char *ParseCSSBackgroundImage (El
     el = element;      el = element;
   
   url = NULL;    url = NULL;
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   if (!ustrncasecmp (cssRule, TEXT("url"), 3))    if (!strncasecmp (cssRule, "url", 3))
     {        {  
       cssRule += 3;        cssRule += 3;
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
       if (*cssRule == '(')        if (*cssRule == '(')
         {          {
           cssRule++;            cssRule++;
           cssRule = SkipWCBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
           /*** Caution: Strings can either be written with double quotes or            /*** Caution: Strings can either be written with double quotes or
             with single quotes. Only double quotes are handled here.              with single quotes. Only double quotes are handled here.
             Escaped quotes are not handled. See function SkipQuotedString */              Escaped quotes are not handled. See function SkipQuotedString */
Line 2292  static char *ParseCSSBackgroundImage (El Line 2274  static char *ParseCSSBackgroundImage (El
             {              {
               cssRule++;                cssRule++;
               base = cssRule;                base = cssRule;
               while (*cssRule != WC_EOS && *cssRule != TEXT('"'))                while (*cssRule != EOS && *cssRule != '"')
                 cssRule++;                  cssRule++;
             }              }
           else            else
Line 2302  static char *ParseCSSBackgroundImage (El Line 2284  static char *ParseCSSBackgroundImage (El
                 cssRule++;                  cssRule++;
             }              }
           saved = *cssRule;            saved = *cssRule;
           *cssRule = WC_EOS;            *cssRule = EOS;
           url = TtaWCSdup (base);            url = TtaStrdup (base);
           *cssRule = saved;            *cssRule = saved;
           if (saved == '"')            if (saved == '"')
             /* we need to skip two characters */              /* we need to skip two characters */
Line 2328  static char *ParseCSSBackgroundImage (El Line 2310  static char *ParseCSSBackgroundImage (El
       else if (url)        else if (url)
         {          {
           bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");            bg_image = TtaGetEnvString ("ENABLE_BG_IMAGES");
           if (bg_image == NULL || !ustrcasecmp (bg_image, TEXT("yes")))            if (bg_image == NULL || !strcasecmp (bg_image, "yes"))
             {              {
               callblock = (BackgroundImageCallbackPtr) TtaGetMemory(sizeof(BackgroundImageCallbackBlock));                callblock = (BackgroundImageCallbackPtr) TtaGetMemory(sizeof(BackgroundImageCallbackBlock));
               if (callblock != NULL)                if (callblock != NULL)
Line 2397  static char *ParseCSSBackgroundRepeat (E Line 2379  static char *ParseCSSBackgroundRepeat (E
   repeat.typed_data.value = STYLE_REALSIZE;    repeat.typed_data.value = STYLE_REALSIZE;
   repeat.typed_data.unit = STYLE_UNIT_REL;    repeat.typed_data.unit = STYLE_UNIT_REL;
   repeat.typed_data.real = FALSE;    repeat.typed_data.real = FALSE;
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   if (!ustrncasecmp (cssRule, TEXT("no-repeat"), 9))    if (!strncasecmp (cssRule, "no-repeat", 9))
     repeat.typed_data.value = STYLE_REALSIZE;      repeat.typed_data.value = STYLE_REALSIZE;
   else if (!ustrncasecmp (cssRule, TEXT("repeat-y"), 8))    else if (!strncasecmp (cssRule, "repeat-y", 8))
     repeat.typed_data.value = STYLE_VREPEAT;      repeat.typed_data.value = STYLE_VREPEAT;
   else if (!ustrncasecmp (cssRule, TEXT("repeat-x"), 8))    else if (!strncasecmp (cssRule, "repeat-x", 8))
     repeat.typed_data.value = STYLE_HREPEAT;      repeat.typed_data.value = STYLE_HREPEAT;
   else if (!ustrncasecmp (cssRule, TEXT("repeat"), 6))    else if (!strncasecmp (cssRule, "repeat", 6))
     repeat.typed_data.value = STYLE_REPEAT;      repeat.typed_data.value = STYLE_REPEAT;
   else    else
     return (cssRule);      return (cssRule);
Line 2444  static char *ParseCSSBackgroundAttachmen Line 2426  static char *ParseCSSBackgroundAttachmen
         }          }
     }      }
   
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    if (!ustrncasecmp (cssRule, TEXT("scroll"), 6))     if (!strncasecmp (cssRule, "scroll", 6))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
    else if (!ustrncasecmp (cssRule, TEXT("fixed"), 5))     else if (!strncasecmp (cssRule, "fixed", 5))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
   
   /* restore the refered element */    /* restore the refered element */
Line 2483  static char *ParseCSSBackgroundPosition Line 2465  static char *ParseCSSBackgroundPosition
         }          }
     }      }
   
    cssRule = SkipWCBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
    ok = TRUE;     ok = TRUE;
    if (!ustrncasecmp (cssRule, TEXT("left"), 4))     if (!strncasecmp (cssRule, "left", 4))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
    else if (!ustrncasecmp (cssRule, TEXT("right"), 5))     else if (!strncasecmp (cssRule, "right", 5))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
    else if (!ustrncasecmp (cssRule, TEXT("center"), 6))     else if (!strncasecmp (cssRule, "center", 6))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
    else if (!ustrncasecmp (cssRule, TEXT("top"), 3))     else if (!strncasecmp (cssRule, "top", 3))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
    else if (!ustrncasecmp (cssRule, TEXT("bottom"), 6))     else if (!strncasecmp (cssRule, "bottom", 6))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
    else if (TtaIsDigit (*cssRule))     else if (isdigit (*cssRule))
      cssRule = SkipWord (cssRule);       cssRule = SkipWord (cssRule);
    else     else
      ok = FALSE;       ok = FALSE;
Line 2524  static char *ParseCSSBackground (Element Line 2506  static char *ParseCSSBackground (Element
 {  {
   char     *ptr;    char     *ptr;
   
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   while (*cssRule != TEXT(';') && *cssRule != WC_EOS && *cssRule != TEXT(','))    while (*cssRule != ';' && *cssRule != EOS && *cssRule != ',')
     {      {
       /* perhaps a Background Image */        /* perhaps a Background Image */
       if (!ustrncasecmp (cssRule, TEXT("url"), 3))        if (!strncasecmp (cssRule, "url", 3))
          cssRule = ParseCSSBackgroundImage (element, tsch, context, cssRule,           cssRule = ParseCSSBackgroundImage (element, tsch, context, cssRule,
                                             css, isHTML);                                              css, isHTML);
       /* perhaps a Background Attachment */        /* perhaps a Background Attachment */
       else if (!ustrncasecmp (cssRule, TEXT("scroll"), 6) ||        else if (!strncasecmp (cssRule, "scroll", 6) ||
                !ustrncasecmp (cssRule, TEXT("fixed"), 5))                 !strncasecmp (cssRule, "fixed", 5))
         cssRule = ParseCSSBackgroundAttachment (element, tsch, context,          cssRule = ParseCSSBackgroundAttachment (element, tsch, context,
                                                 cssRule, css, isHTML);                                                  cssRule, css, isHTML);
       /* perhaps a Background Repeat */        /* perhaps a Background Repeat */
       else if (!ustrncasecmp (cssRule, TEXT("no-repeat"), 9) ||        else if (!strncasecmp (cssRule, "no-repeat", 9) ||
                !ustrncasecmp (cssRule, TEXT("repeat-y"), 8)  ||                 !strncasecmp (cssRule, "repeat-y", 8)  ||
                !ustrncasecmp (cssRule, TEXT("repeat-x"), 8)  ||                 !strncasecmp (cssRule, "repeat-x", 8)  ||
                !ustrncasecmp (cssRule, TEXT("repeat"), 6))                 !strncasecmp (cssRule, "repeat", 6))
         cssRule = ParseCSSBackgroundRepeat (element, tsch, context, cssRule,          cssRule = ParseCSSBackgroundRepeat (element, tsch, context,
                                             css, isHTML);                                              cssRule, css, isHTML);
       /* perhaps a Background Position */        /* perhaps a Background Position */
       else if (!ustrncasecmp (cssRule, TEXT("left"), 4)   ||        else if (!strncasecmp (cssRule, "left", 4)   ||
                !ustrncasecmp (cssRule, TEXT("right"), 5)  ||                 !strncasecmp (cssRule, "right", 5)  ||
                !ustrncasecmp (cssRule, TEXT("center"), 6) ||                 !strncasecmp (cssRule, "center", 6) ||
                !ustrncasecmp (cssRule, TEXT("top"), 3)    ||                 !strncasecmp (cssRule, "top", 3)    ||
                !ustrncasecmp (cssRule, TEXT("bottom"), 6) ||                 !strncasecmp (cssRule, "bottom", 6) ||
                TtaIsDigit (*cssRule))                 isdigit (*cssRule))
            cssRule = ParseCSSBackgroundPosition (element, tsch, context,             cssRule = ParseCSSBackgroundPosition (element, tsch, context,
                                                  cssRule, css, isHTML);                                                   cssRule, css, isHTML);
       /* perhaps a Background Color */        /* perhaps a Background Color */
Line 2557  static char *ParseCSSBackground (Element Line 2539  static char *ParseCSSBackground (Element
         {          {
           /* check if the rule has been found */            /* check if the rule has been found */
           ptr = cssRule;            ptr = cssRule;
           cssRule = ParseCSSBackgroundColor (element, tsch, context, cssRule,            cssRule = ParseCSSBackgroundColor (element, tsch, context,
                                              css, isHTML);                                               cssRule, css, isHTML);
           if (ptr == cssRule)            if (ptr == cssRule)
             /* rule not found */              /* rule not found */
             cssRule = SkipProperty (cssRule);              cssRule = SkipProperty (cssRule);
         }          }
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
    return (cssRule);     return (cssRule);
 }  }
Line 2579  static char *ParseCSSPageBreakBefore (El Line 2561  static char *ParseCSSPageBreakBefore (El
   
   page.typed_data.unit = STYLE_UNIT_INVALID;    page.typed_data.unit = STYLE_UNIT_INVALID;
   page.typed_data.real = FALSE;    page.typed_data.real = FALSE;
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   if (!ustrncasecmp (cssRule, TEXT("auto"), 4))    if (!strncasecmp (cssRule, "auto", 4))
     {      {
       /*page.typed_data.unit = STYLE_UNIT_REL;*/        /*page.typed_data.unit = STYLE_UNIT_REL;*/
       page.typed_data.value = STYLE_AUTO;        page.typed_data.value = STYLE_AUTO;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("always"), 6))    else if (!strncasecmp (cssRule, "always", 6))
     {      {
       page.typed_data.unit = STYLE_UNIT_REL;        page.typed_data.unit = STYLE_UNIT_REL;
       page.typed_data.value = STYLE_ALWAYS;        page.typed_data.value = STYLE_ALWAYS;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("avoid"), 5))    else if (!strncasecmp (cssRule, "avoid", 5))
     {      {
       page.typed_data.unit = STYLE_UNIT_REL;        page.typed_data.unit = STYLE_UNIT_REL;
       page.typed_data.value = STYLE_AVOID;        page.typed_data.value = STYLE_AVOID;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("left"), 4))    else if (!strncasecmp (cssRule, "left", 4))
     {      {
       page.typed_data.unit = STYLE_UNIT_REL;        page.typed_data.unit = STYLE_UNIT_REL;
       page.typed_data.value = STYLE_PAGELEFT;        page.typed_data.value = STYLE_PAGELEFT;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("right"), 5))    else if (!strncasecmp (cssRule, "right", 5))
     {      {
       page.typed_data.unit = STYLE_UNIT_REL;        page.typed_data.unit = STYLE_UNIT_REL;
       page.typed_data.value = STYLE_PAGERIGHT;        page.typed_data.value = STYLE_PAGERIGHT;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))    else if (!strncasecmp (cssRule, "inherit", 7))
     {      {
       /*page.typed_data.unit = STYLE_UNIT_REL;*/        /*page.typed_data.unit = STYLE_UNIT_REL;*/
       page.typed_data.value = STYLE_INHERIT;        page.typed_data.value = STYLE_INHERIT;
Line 2630  static char *ParseCSSPageBreakAfter (Ele Line 2612  static char *ParseCSSPageBreakAfter (Ele
   
   page.typed_data.unit = STYLE_UNIT_INVALID;    page.typed_data.unit = STYLE_UNIT_INVALID;
   page.typed_data.real = FALSE;    page.typed_data.real = FALSE;
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   if (!ustrncasecmp (cssRule, TEXT("auto"), 4))    if (!strncasecmp (cssRule, "auto", 4))
     {      {
       /*page.typed_data.unit = STYLE_UNIT_REL;*/        /*page.typed_data.unit = STYLE_UNIT_REL;*/
       page.typed_data.value = STYLE_AUTO;        page.typed_data.value = STYLE_AUTO;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("always"), 6))    else if (!strncasecmp (cssRule, "always", 6))
     {      {
       page.typed_data.unit = STYLE_UNIT_REL;        page.typed_data.unit = STYLE_UNIT_REL;
       page.typed_data.value = STYLE_ALWAYS;        page.typed_data.value = STYLE_ALWAYS;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("avoid"), 5))    else if (!strncasecmp (cssRule, "avoid", 5))
     {      {
       page.typed_data.unit = STYLE_UNIT_REL;        page.typed_data.unit = STYLE_UNIT_REL;
       page.typed_data.value = STYLE_AVOID;        page.typed_data.value = STYLE_AVOID;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("left"), 4))    else if (!strncasecmp (cssRule, "left", 4))
     {      {
       page.typed_data.unit = STYLE_UNIT_REL;        page.typed_data.unit = STYLE_UNIT_REL;
       page.typed_data.value = STYLE_PAGELEFT;        page.typed_data.value = STYLE_PAGELEFT;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("right"), 5))    else if (!strncasecmp (cssRule, "right", 5))
     {      {
       page.typed_data.unit = STYLE_UNIT_REL;        page.typed_data.unit = STYLE_UNIT_REL;
       page.typed_data.value = STYLE_PAGERIGHT;        page.typed_data.value = STYLE_PAGERIGHT;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))    else if (!strncasecmp (cssRule, "inherit", 7))
     {      {
       /*page.typed_data.unit = STYLE_UNIT_REL;*/        /*page.typed_data.unit = STYLE_UNIT_REL;*/
       page.typed_data.value = STYLE_INHERIT;        page.typed_data.value = STYLE_INHERIT;
Line 2680  static char *ParseCSSPageBreakInside (El Line 2662  static char *ParseCSSPageBreakInside (El
   
   page.typed_data.unit = STYLE_UNIT_INVALID;    page.typed_data.unit = STYLE_UNIT_INVALID;
   page.typed_data.real = FALSE;    page.typed_data.real = FALSE;
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   if (!ustrncasecmp (cssRule, TEXT("auto"), 4))    if (!strncasecmp (cssRule, "auto", 4))
     {      {
       /*page.typed_data.unit = STYLE_UNIT_REL;*/        /*page.typed_data.unit = STYLE_UNIT_REL;*/
       page.typed_data.value = STYLE_AUTO;        page.typed_data.value = STYLE_AUTO;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("avoid"), 5))    else if (!strncasecmp (cssRule, "avoid", 5))
     {      {
       page.typed_data.unit = STYLE_UNIT_REL;        page.typed_data.unit = STYLE_UNIT_REL;
       page.typed_data.value = STYLE_AVOID;        page.typed_data.value = STYLE_AVOID;
     }      }
   else if (!ustrncasecmp (cssRule, TEXT("inherit"), 7))    else if (!strncasecmp (cssRule, "inherit", 7))
     {      {
       /*page.typed_data.unit = STYLE_UNIT_REL;*/        /*page.typed_data.unit = STYLE_UNIT_REL;*/
       page.typed_data.value = STYLE_INHERIT;        page.typed_data.value = STYLE_INHERIT;
Line 2714  static char *ParseSVGStrokeWidth (Elemen Line 2696  static char *ParseSVGStrokeWidth (Elemen
 {  {
   PresentationValue   width;    PresentationValue   width;
       
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   width.typed_data.value = 0;    width.typed_data.value = 0;
   width.typed_data.unit = STYLE_UNIT_INVALID;    width.typed_data.unit = STYLE_UNIT_INVALID;
   width.typed_data.real = FALSE;    width.typed_data.real = FALSE;
   if (TtaIsDigit (*cssRule))    if (isdigit (*cssRule))
      cssRule = ParseCSSUnit (cssRule, &width);       cssRule = ParseCSSUnit (cssRule, &width);
   if (width.typed_data.unit != STYLE_UNIT_INVALID)    if (width.typed_data.unit != STYLE_UNIT_INVALID)
      {       {
Line 2740  static char *ParseSVGStrokeWidth (Elemen Line 2722  static char *ParseSVGStrokeWidth (Elemen
  */   */
 static CSSProperty CSSProperties[] =  static CSSProperty CSSProperties[] =
 {  {
    {TEXT("font-family"), ParseCSSFontFamily},     {"font-family", ParseCSSFontFamily},
    {TEXT("font-style"), ParseCSSFontStyle},     {"font-style", ParseCSSFontStyle},
    {TEXT("font-variant"), ParseCSSFontVariant},     {"font-variant", ParseCSSFontVariant},
    {TEXT("font-weight"), ParseCSSFontWeight},     {"font-weight", ParseCSSFontWeight},
    {TEXT("font-size"), ParseCSSFontSize},     {"font-size", ParseCSSFontSize},
    {TEXT("font"), ParseCSSFont},     {"font", ParseCSSFont},
   
    {TEXT("color"), ParseCSSForeground},     {"color", ParseCSSForeground},
    {TEXT("background-color"), ParseCSSBackgroundColor},     {"background-color", ParseCSSBackgroundColor},
    {TEXT("background-image"), ParseCSSBackgroundImage},     {"background-image", ParseCSSBackgroundImage},
    {TEXT("background-repeat"), ParseCSSBackgroundRepeat},     {"background-repeat", ParseCSSBackgroundRepeat},
    {TEXT("background-attachment"), ParseCSSBackgroundAttachment},     {"background-attachment", ParseCSSBackgroundAttachment},
    {TEXT("background-position"), ParseCSSBackgroundPosition},     {"background-position", ParseCSSBackgroundPosition},
    {TEXT("background"), ParseCSSBackground},     {"background", ParseCSSBackground},
   
    {TEXT("word-spacing"), ParseCSSWordSpacing},     {"word-spacing", ParseCSSWordSpacing},
    {TEXT("letter-spacing"), ParseCSSLetterSpacing},     {"letter-spacing", ParseCSSLetterSpacing},
    {TEXT("text-decoration"), ParseCSSTextDecoration},     {"text-decoration", ParseCSSTextDecoration},
    {TEXT("vertical-align"), ParseCSSVerticalAlign},     {"vertical-align", ParseCSSVerticalAlign},
    {TEXT("text-transform"), ParseCSSTextTransform},     {"text-transform", ParseCSSTextTransform},
    {TEXT("text-align"), ParseCSSTextAlign},     {"text-align", ParseCSSTextAlign},
    {TEXT("text-indent"), ParseCSSTextIndent},     {"text-indent", ParseCSSTextIndent},
    {TEXT("line-height"), ParseCSSLineSpacing},     {"line-height", ParseCSSLineSpacing},
   
    {TEXT("margin-top"), ParseCSSMarginTop},     {"margin-top", ParseCSSMarginTop},
    {TEXT("margin-right"), ParseCSSMarginRight},     {"margin-right", ParseCSSMarginRight},
    {TEXT("margin-bottom"), ParseCSSMarginBottom},     {"margin-bottom", ParseCSSMarginBottom},
    {TEXT("margin-left"), ParseCSSMarginLeft},     {"margin-left", ParseCSSMarginLeft},
    {TEXT("margin"), ParseCSSMargin},     {"margin", ParseCSSMargin},
   
    {TEXT("padding-top"), ParseCSSPaddingTop},     {"padding-top", ParseCSSPaddingTop},
    {TEXT("padding-right"), ParseCSSPaddingRight},     {"padding-right", ParseCSSPaddingRight},
    {TEXT("padding-bottom"), ParseCSSPaddingBottom},     {"padding-bottom", ParseCSSPaddingBottom},
    {TEXT("padding-left"), ParseCSSPaddingLeft},     {"padding-left", ParseCSSPaddingLeft},
    {TEXT("padding"), ParseCSSPadding},     {"padding", ParseCSSPadding},
   
    {TEXT("border-top-width"), ParseCSSBorderTopWidth},     {"border-top-width", ParseCSSBorderTopWidth},
    {TEXT("border-right-width"), ParseCSSBorderRightWidth},     {"border-right-width", ParseCSSBorderRightWidth},
    {TEXT("border-bottom-width"), ParseCSSBorderBottomWidth},     {"border-bottom-width", ParseCSSBorderBottomWidth},
    {TEXT("border-left-width"), ParseCSSBorderLeftWidth},     {"border-left-width", ParseCSSBorderLeftWidth},
    {TEXT("border-width"), ParseCSSBorderWidth},     {"border-width", ParseCSSBorderWidth},
    {TEXT("border-top-color"), ParseCSSBorderColorTop},     {"border-top-color", ParseCSSBorderColorTop},
    {TEXT("border-right-color"), ParseCSSBorderColorRight},     {"border-right-color", ParseCSSBorderColorRight},
    {TEXT("border-bottom-color"), ParseCSSBorderColorBottom},     {"border-bottom-color", ParseCSSBorderColorBottom},
    {TEXT("border-left-color"), ParseCSSBorderColorLeft},     {"border-left-color", ParseCSSBorderColorLeft},
    {TEXT("border-color"), ParseCSSBorderColor},     {"border-color", ParseCSSBorderColor},
    {TEXT("border-top-style"), ParseCSSBorderStyleTop},     {"border-top-style", ParseCSSBorderStyleTop},
    {TEXT("border-right-style"), ParseCSSBorderStyleRight},     {"border-right-style", ParseCSSBorderStyleRight},
    {TEXT("border-bottom-style"), ParseCSSBorderStyleBottom},     {"border-bottom-style", ParseCSSBorderStyleBottom},
    {TEXT("border-left-style"), ParseCSSBorderStyleLeft},     {"border-left-style", ParseCSSBorderStyleLeft},
    {TEXT("border-style"), ParseCSSBorderStyle},     {"border-style", ParseCSSBorderStyle},
    {TEXT("border-top"), ParseCSSBorderTop},     {"border-top", ParseCSSBorderTop},
    {TEXT("border-right"), ParseCSSBorderRight},     {"border-right", ParseCSSBorderRight},
    {TEXT("border-bottom"), ParseCSSBorderBottom},     {"border-bottom", ParseCSSBorderBottom},
    {TEXT("border-left"), ParseCSSBorderLeft},     {"border-left", ParseCSSBorderLeft},
    {TEXT("border"), ParseCSSBorder},     {"border", ParseCSSBorder},
   
    {TEXT("width"), ParseCSSWidth},     {"width", ParseCSSWidth},
    {TEXT("height"), ParseCSSHeight},     {"height", ParseCSSHeight},
    {TEXT("float"), ParseCSSFloat},     {"float", ParseCSSFloat},
    {TEXT("clear"), ParseCSSClear},     {"clear", ParseCSSClear},
   
    {TEXT("display"), ParseCSSDisplay},     {"display", ParseCSSDisplay},
    {TEXT("white-space"), ParseCSSWhiteSpace},     {"white-space", ParseCSSWhiteSpace},
   
    {TEXT("list-style-type"), ParseCSSListStyleType},     {"list-style-type", ParseCSSListStyleType},
    {TEXT("list-style-image"), ParseCSSListStyleImage},     {"list-style-image", ParseCSSListStyleImage},
    {TEXT("list-style-position"), ParseCSSListStylePosition},     {"list-style-position", ParseCSSListStylePosition},
    {TEXT("list-style"), ParseCSSListStyle},     {"list-style", ParseCSSListStyle},
   
    {TEXT("page-break-before"), ParseCSSPageBreakBefore},     {"page-break-before", ParseCSSPageBreakBefore},
    {TEXT("page-break-after"), ParseCSSPageBreakAfter},     {"page-break-after", ParseCSSPageBreakAfter},
    {TEXT("page-break-inside"), ParseCSSPageBreakInside},     {"page-break-inside", ParseCSSPageBreakInside},
   
    /* SVG extensions */     /* SVG extensions */
    {TEXT("stroke-width"), ParseSVGStrokeWidth},     {"stroke-width", ParseSVGStrokeWidth},
    {TEXT("stroke"), ParseSVGStroke},     {"stroke", ParseSVGStroke},
    {TEXT("fill"), ParseSVGFill}     {"fill", ParseSVGFill}
 };  };
 #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))  #define NB_CSSSTYLEATTRIBUTE (sizeof(CSSProperties) / sizeof(CSSProperty))
   
Line 2842  static void  ParseCSSRule (Element eleme Line 2824  static void  ParseCSSRule (Element eleme
   if (dispMode == DisplayImmediately)    if (dispMode == DisplayImmediately)
     TtaSetDisplayMode (context->doc, DeferredDisplay);      TtaSetDisplayMode (context->doc, DeferredDisplay);
   
   while (*cssRule != WC_EOS)    while (*cssRule != EOS)
     {      {
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
               
       found = FALSE;        found = FALSE;
       /* look for the type of property */        /* look for the type of property */
       for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)        for (i = 0; i < NB_CSSSTYLEATTRIBUTE && !found; i++)
         {          {
           lg = ustrlen (CSSProperties[i].name);            lg = strlen (CSSProperties[i].name);
           if (!ustrncasecmp (cssRule, CSSProperties[i].name, lg))            if (!strncasecmp (cssRule, CSSProperties[i].name, lg))
             {              {
               cssRule += lg;                cssRule += lg;
               found = TRUE;                found = TRUE;
Line 2864  static void  ParseCSSRule (Element eleme Line 2846  static void  ParseCSSRule (Element eleme
       else        else
         {          {
           /* update index and skip the ":" indicator if present */            /* update index and skip the ":" indicator if present */
           cssRule = SkipWCBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
           if (*cssRule == TEXT(':'))            if (*cssRule == ':')
             {              {
               cssRule++;                cssRule++;
               cssRule = SkipWCBlanksAndComments (cssRule);                cssRule = SkipBlanksAndComments (cssRule);
               /* try to parse the value associated with this property */                /* try to parse the value associated with this property */
               if (CSSProperties[i].parsing_function != NULL)                if (CSSProperties[i].parsing_function != NULL)
                 {                  {
Line 2882  static void  ParseCSSRule (Element eleme Line 2864  static void  ParseCSSRule (Element eleme
             cssRule = SkipProperty (cssRule);              cssRule = SkipProperty (cssRule);
         }          }
       /* next property */        /* next property */
       cssRule = SkipWCBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
       if (*cssRule == TEXT(',') || *cssRule == TEXT(';'))        if (*cssRule == ',' || *cssRule == ';')
         {          {
           cssRule++;            cssRule++;
           cssRule = SkipWCBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
         }          }
     }      }
   
Line 2915  void PToCss (PresentationSetting setting Line 2897  void PToCss (PresentationSetting setting
   unsigned int        unit, i;    unsigned int        unit, i;
   ThotBool            real = FALSE;    ThotBool            real = FALSE;
   
   buffer[0] = WC_EOS;    buffer[0] = EOS;
   if (len < 40)    if (len < 40)
     return;      return;
   
Line 2935  void PToCss (PresentationSetting setting Line 2917  void PToCss (PresentationSetting setting
       switch (settings->value.typed_data.value)        switch (settings->value.typed_data.value)
         {          {
         case STYLE_FONT_HELVETICA:          case STYLE_FONT_HELVETICA:
           ustrcpy (buffer, TEXT("font-family: helvetica"));            strcpy (buffer, "font-family: helvetica");
           break;            break;
         case STYLE_FONT_TIMES:          case STYLE_FONT_TIMES:
           ustrcpy (buffer, TEXT("font-family: times"));            strcpy (buffer, "font-family: times");
           break;            break;
         case STYLE_FONT_COURIER:          case STYLE_FONT_COURIER:
           ustrcpy (buffer, TEXT("font-family: courier"));            strcpy (buffer, "font-family: courier");
           break;            break;
         }          }
       break;        break;
Line 2949  void PToCss (PresentationSetting setting Line 2931  void PToCss (PresentationSetting setting
       switch (settings->value.typed_data.value)        switch (settings->value.typed_data.value)
         {          {
         case STYLE_FONT_ROMAN:          case STYLE_FONT_ROMAN:
           ustrcpy (buffer, TEXT("font-style: normal"));            strcpy (buffer, "font-style: normal");
           break;            break;
         case STYLE_FONT_ITALICS:          case STYLE_FONT_ITALICS:
           ustrcpy (buffer, TEXT("font-style: italic"));            strcpy (buffer, "font-style: italic");
           break;            break;
         case STYLE_FONT_OBLIQUE:          case STYLE_FONT_OBLIQUE:
           ustrcpy (buffer, TEXT("font-style: oblique"));            strcpy (buffer, "font-style: oblique");
           break;            break;
         }          }
       break;        break;
Line 2963  void PToCss (PresentationSetting setting Line 2945  void PToCss (PresentationSetting setting
       switch (settings->value.typed_data.value)        switch (settings->value.typed_data.value)
         {          {
         case STYLE_WEIGHT_BOLD:          case STYLE_WEIGHT_BOLD:
           ustrcpy (buffer, TEXT("font-weight: bold"));            strcpy (buffer, "font-weight: bold");
           break;            break;
         case STYLE_WEIGHT_NORMAL:          case STYLE_WEIGHT_NORMAL:
           ustrcpy (buffer, TEXT("font-weight: normal"));            strcpy (buffer, "font-weight: normal");
           break;            break;
         }          }
       break;        break;
Line 2975  void PToCss (PresentationSetting setting Line 2957  void PToCss (PresentationSetting setting
         {          {
           if (real)            if (real)
             {              {
               usprintf (buffer, TEXT("font-size: %g"), fval);                sprintf (buffer, "font-size: %g", fval);
               add_unit = 1;                add_unit = 1;
             }              }
           else            else
             switch (settings->value.typed_data.value)              switch (settings->value.typed_data.value)
               {                {
               case 1:                case 1:
                 ustrcpy (buffer, TEXT("font-size: xx-small"));                  strcpy (buffer, "font-size: xx-small");
                 break;                  break;
               case 2:                case 2:
                 ustrcpy (buffer, TEXT("font-size: x-small"));                  strcpy (buffer, "font-size: x-small");
                 break;                  break;
               case 3:                case 3:
                 ustrcpy (buffer, TEXT("font-size: small"));                  strcpy (buffer, "font-size: small");
                 break;                  break;
               case 4:                case 4:
                 ustrcpy (buffer, TEXT("font-size: medium"));                  strcpy (buffer, "font-size: medium");
                 break;                  break;
               case 5:                case 5:
                 ustrcpy (buffer, TEXT("font-size: large"));                  strcpy (buffer, "font-size: large");
                 break;                  break;
               case 6:                case 6:
                 ustrcpy (buffer, TEXT("font-size: x-large"));                  strcpy (buffer, "font-size: x-large");
                 break;                  break;
               case 7:                case 7:
               case 8:                case 8:
Line 3005  void PToCss (PresentationSetting setting Line 2987  void PToCss (PresentationSetting setting
               case 10:                case 10:
               case 11:                case 11:
               case 12:                case 12:
                 ustrcpy (buffer, TEXT("font-size: xx-large"));                  strcpy (buffer, "font-size: xx-large");
                 break;                  break;
               }                }
         }          }
       else        else
         {          {
           if (real)            if (real)
             usprintf (buffer, TEXT("font-size: %g"), fval);              sprintf (buffer, "font-size: %g", fval);
           else            else
             usprintf (buffer, TEXT("font-size: %d"),              sprintf (buffer, "font-size: %d",
                       settings->value.typed_data.value);                        settings->value.typed_data.value);
           add_unit = 1;            add_unit = 1;
         }          }
Line 3023  void PToCss (PresentationSetting setting Line 3005  void PToCss (PresentationSetting setting
       switch (settings->value.typed_data.value)        switch (settings->value.typed_data.value)
         {          {
         case STYLE_UNDERLINE:          case STYLE_UNDERLINE:
           ustrcpy (buffer, TEXT("text-decoration: underline"));            strcpy (buffer, "text-decoration: underline");
           break;            break;
         case STYLE_OVERLINE:          case STYLE_OVERLINE:
           ustrcpy (buffer, TEXT("text-decoration: overline"));            strcpy (buffer, "text-decoration: overline");
           break;            break;
         case STYLE_CROSSOUT:          case STYLE_CROSSOUT:
           ustrcpy (buffer, TEXT("text-decoration: line-through"));            strcpy (buffer, "text-decoration: line-through");
           break;            break;
         }          }
       break;        break;
     case PRIndent:      case PRIndent:
       if (real)        if (real)
         usprintf (buffer, TEXT("text-indent: %g"), fval);          sprintf (buffer, "text-indent: %g", fval);
       else        else
         usprintf (buffer, TEXT("text-indent: %d"),          sprintf (buffer, "text-indent: %d",
                   settings->value.typed_data.value);                    settings->value.typed_data.value);
       add_unit = 1;        add_unit = 1;
       break;        break;
     case PRLineSpacing:      case PRLineSpacing:
       if (real)        if (real)
         usprintf (buffer, TEXT("line-height: %g"), fval);          sprintf (buffer, "line-height: %g", fval);
       else        else
         usprintf (buffer, TEXT("line-height: %d"),          sprintf (buffer, "line-height: %d",
                   settings->value.typed_data.value);                    settings->value.typed_data.value);
       add_unit = 1;        add_unit = 1;
       break;        break;
Line 3053  void PToCss (PresentationSetting setting Line 3035  void PToCss (PresentationSetting setting
       switch (settings->value.typed_data.value)        switch (settings->value.typed_data.value)
         {          {
         case STYLE_ADJUSTLEFT:          case STYLE_ADJUSTLEFT:
           ustrcpy (buffer, TEXT("text-align: left"));            strcpy (buffer, "text-align: left");
           break;            break;
         case STYLE_ADJUSTRIGHT:          case STYLE_ADJUSTRIGHT:
           ustrcpy (buffer, TEXT("text-align: right"));            strcpy (buffer, "text-align: right");
           break;            break;
         case STYLE_ADJUSTCENTERED:          case STYLE_ADJUSTCENTERED:
           ustrcpy (buffer, TEXT("text-align: center"));            strcpy (buffer, "text-align: center");
           break;            break;
         case STYLE_ADJUSTLEFTWITHDOTS:          case STYLE_ADJUSTLEFTWITHDOTS:
           ustrcpy (buffer, TEXT("text-align: left"));            strcpy (buffer, "text-align: left");
           break;            break;
         case STYLE_ADJUSTJUSTIFY:          case STYLE_ADJUSTJUSTIFY:
           ustrcpy (buffer, TEXT("text-align: justify"));            strcpy (buffer, "text-align: justify");
           break;            break;
         }          }
       break;        break;
Line 3077  void PToCss (PresentationSetting setting Line 3059  void PToCss (PresentationSetting setting
       TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);        TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
       elType = TtaGetElementType(el);        elType = TtaGetElementType(el);
 #ifdef GRAPHML  #ifdef GRAPHML
       if (ustrcmp(TtaGetSSchemaName (elType.ElSSchema), TEXT("GraphML")) == 0)        if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "GraphML") == 0)
         usprintf (buffer, TEXT("fill: #%02X%02X%02X"), red, green, blue);          sprintf (buffer, "fill: #%02X%02X%02X", red, green, blue);
       else        else
 #endif /* GRAPHML */  #endif /* GRAPHML */
          usprintf (buffer, TEXT("background-color: #%02X%02X%02X"), red, green,           sprintf (buffer, "background-color: #%02X%02X%02X", red, green,
                    blue);                     blue);
       break;        break;
     case PRForeground:      case PRForeground:
       TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);        TtaGiveThotRGB (settings->value.typed_data.value, &red, &green, &blue);
       elType = TtaGetElementType(el);        elType = TtaGetElementType(el);
 #ifdef GRAPHML  #ifdef GRAPHML
       if (ustrcmp(TtaGetSSchemaName (elType.ElSSchema), TEXT("GraphML")) == 0)        if (strcmp(TtaGetSSchemaName (elType.ElSSchema), "GraphML") == 0)
         usprintf (buffer, TEXT("stroke: #%02X%02X%02X"), red, green, blue);          sprintf (buffer, "stroke: #%02X%02X%02X", red, green, blue);
       else        else
 #endif /* GRAPHML */  #endif /* GRAPHML */
         usprintf (buffer, TEXT("color: #%02X%02X%02X"), red, green, blue);          sprintf (buffer, "color: #%02X%02X%02X", red, green, blue);
       break;        break;
     case PRLineWeight:      case PRLineWeight:
       elType = TtaGetElementType(el);        elType = TtaGetElementType(el);
 #ifdef GRAPHML  #ifdef GRAPHML
       if (!ustrcmp(TtaGetSSchemaName (elType.ElSSchema), TEXT("GraphML")))        if (!strcmp(TtaGetSSchemaName (elType.ElSSchema), "GraphML"))
 #endif /* GRAPHML */  #endif /* GRAPHML */
         {          {
           if (real)            if (real)
             usprintf (buffer, TEXT("stroke-width: %g"), fval);              sprintf (buffer, "stroke-width: %g", fval);
           else            else
             usprintf (buffer, TEXT("stroke-width: %d"),              sprintf (buffer, "stroke-width: %d",
                       settings->value.typed_data.value);                        settings->value.typed_data.value);
         }          }
       add_unit = 1;        add_unit = 1;
Line 3111  void PToCss (PresentationSetting setting Line 3093  void PToCss (PresentationSetting setting
   
     case PRMarginTop:      case PRMarginTop:
       if (real)        if (real)
         usprintf (buffer, TEXT("marging-top: %g"), fval);          sprintf (buffer, "marging-top: %g", fval);
       else        else
         usprintf (buffer, TEXT("marging-top: %d"),          sprintf (buffer, "marging-top: %d",
                   settings->value.typed_data.value);                    settings->value.typed_data.value);
       add_unit = 1;        add_unit = 1;
       break;        break;
     case PRMarginLeft:      case PRMarginLeft:
       if (real)        if (real)
         usprintf (buffer, TEXT("margin-left: %g"), fval);          sprintf (buffer, "margin-left: %g", fval);
       else        else
         usprintf (buffer, TEXT("margin-left: %d"),          sprintf (buffer, "margin-left: %d",
                   settings->value.typed_data.value);                    settings->value.typed_data.value);
       add_unit = 1;        add_unit = 1;
       break;        break;
     case PRHeight:      case PRHeight:
       if (real)        if (real)
         usprintf (buffer, TEXT("height: %g"), fval);          sprintf (buffer, "height: %g", fval);
       else        else
         usprintf (buffer, TEXT("height: %d"), settings->value.typed_data.value);          sprintf (buffer, "height: %d", settings->value.typed_data.value);
       add_unit = 1;        add_unit = 1;
       break;        break;
     case PRWidth:      case PRWidth:
       if (real)        if (real)
         usprintf (buffer, TEXT("width: %g"), fval);          sprintf (buffer, "width: %g", fval);
       else        else
         usprintf (buffer, TEXT("width: %d"), settings->value.typed_data.value);          sprintf (buffer, "width: %d", settings->value.typed_data.value);
       add_unit = 1;        add_unit = 1;
       break;        break;
     case PRLine:      case PRLine:
       if (settings->value.typed_data.value == STYLE_INLINE)        if (settings->value.typed_data.value == STYLE_INLINE)
         ustrcpy (buffer, TEXT("display: inline"));          strcpy (buffer, "display: inline");
       else if (settings->value.typed_data.value == STYLE_NOTINLINE)        else if (settings->value.typed_data.value == STYLE_NOTINLINE)
         ustrcpy (buffer, TEXT("display: block"));          strcpy (buffer, "display: block");
       break;        break;
     case PRBackgroundPicture:      case PRBackgroundPicture:
       if (settings->value.pointer != NULL)        if (settings->value.pointer != NULL)
         usprintf (buffer, TEXT("background-image: url(%s)"),          sprintf (buffer, "background-image: url(%s)",
                   (char*)(settings->value.pointer));                    (char*)(settings->value.pointer));
       else        else
         usprintf (buffer, TEXT("background-image: none"));          sprintf (buffer, "background-image: none");
       break;        break;
     case PRPictureMode:      case PRPictureMode:
       switch (settings->value.typed_data.value)        switch (settings->value.typed_data.value)
         {          {
         case STYLE_REALSIZE:          case STYLE_REALSIZE:
           usprintf (buffer, TEXT("background-repeat: no-repeat"));            sprintf (buffer, "background-repeat: no-repeat");
           break;            break;
         case STYLE_REPEAT:          case STYLE_REPEAT:
           usprintf (buffer, TEXT("background-repeat: repeat"));            sprintf (buffer, "background-repeat: repeat");
           break;            break;
         case STYLE_VREPEAT:          case STYLE_VREPEAT:
           usprintf (buffer, TEXT("background-repeat: repeat-y"));            sprintf (buffer, "background-repeat: repeat-y");
           break;            break;
         case STYLE_HREPEAT:          case STYLE_HREPEAT:
           usprintf (buffer, TEXT("background-repeat: repeat-x"));            sprintf (buffer, "background-repeat: repeat-x");
           break;            break;
         }          }
       break;        break;
Line 3180  void PToCss (PresentationSetting setting Line 3162  void PToCss (PresentationSetting setting
         {          {
           if (CSSUnitNames[i].unit == unit)            if (CSSUnitNames[i].unit == unit)
             {              {
               ustrcat (buffer, CSSUnitNames[i].sign);                strcat (buffer, CSSUnitNames[i].sign);
               break;                break;
             }              }
         }          }
Line 3204  void  ParseHTMLSpecificStyle (Element el Line 3186  void  ParseHTMLSpecificStyle (Element el
   
    /*  A rule applying to BODY is really meant to address HTML */     /*  A rule applying to BODY is really meant to address HTML */
    elType = TtaGetElementType (el);     elType = TtaGetElementType (el);
    isHTML = (ustrcmp (TtaGetSSchemaName (elType.ElSSchema), TEXT("HTML")) == 0);     isHTML = (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML") == 0);
    /* create the context of the Specific presentation driver */     /* create the context of the Specific presentation driver */
    context = TtaGetSpecificStyleContext (doc);     context = TtaGetSpecificStyleContext (doc);
    if (context == NULL)     if (context == NULL)
Line 3245  static char *ParseGenericSelector (char Line 3227  static char *ParseGenericSelector (char
   ThotBool           isHTML;    ThotBool           isHTML;
   ThotBool           level;    ThotBool           level;
   
   sel[0] = WC_EOS;    sel[0] = EOS;
   for (i = 0; i < MAX_ANCESTORS; i++)    for (i = 0; i < MAX_ANCESTORS; i++)
     {      {
       names[i] = NULL;        names[i] = NULL;
Line 3265  static char *ParseGenericSelector (char Line 3247  static char *ParseGenericSelector (char
   /* the priority level of the rule depends on the selector */    /* the priority level of the rule depends on the selector */
   ctxt->cssLevel = 0;    ctxt->cssLevel = 0;
       
   selector = SkipWCBlanksAndComments (selector);    selector = SkipBlanksAndComments (selector);
   cur = &sel[0];    cur = &sel[0];
   max = 0; /* number of loops */    max = 0; /* number of loops */
   while (1)    while (1)
Line 3273  static char *ParseGenericSelector (char Line 3255  static char *ParseGenericSelector (char
       deb = cur;        deb = cur;
       /* copy an item of the selector into sel[] */        /* copy an item of the selector into sel[] */
       /* put one word in the sel buffer */        /* put one word in the sel buffer */
       while (*selector != WC_EOS && *selector != TEXT(',') &&        while (*selector != EOS && *selector != ',' &&
              *selector != TEXT('.') && *selector != TEXT(':') &&               *selector != '.' && *selector != ':' &&
              *selector != TEXT('#') && !TtaIsWCBlank (selector))               *selector != '#' && !TtaIsBlank (selector))
             *cur++ = *selector++;              *cur++ = *selector++;
       *cur++ = WC_EOS; /* close the first string  in sel[] */        *cur++ = EOS; /* close the first string  in sel[] */
       if (deb[0] != WC_EOS)        if (deb[0] != EOS)
         names[0] = deb;          names[0] = deb;
       else        else
         names[0] = NULL;          names[0] = NULL;
Line 3290  static char *ParseGenericSelector (char Line 3272  static char *ParseGenericSelector (char
   
       /* now names[0] points to the beginning of the parsed item        /* now names[0] points to the beginning of the parsed item
          and cur to the next chain to be parsed */           and cur to the next chain to be parsed */
       if (*selector == TEXT(':') || *selector == TEXT('.') || *selector == TEXT('#'))        if (*selector == ':' || *selector == '.' || *selector == '#')
         /* keep the element name which precedes the id or          /* keep the element name which precedes the id or
          pseudo class or the class */           pseudo class or the class */
         deb = cur;          deb = cur;
   
       if (*selector == TEXT('.'))        if (*selector == '.')
         {          {
           /* copy into sel[] the class */            /* copy into sel[] the class */
           classes[0] = cur;            classes[0] = cur;
           selector++;            selector++;
           while (*selector != WC_EOS && *selector != TEXT(',') &&            while (*selector != EOS && *selector != ',' &&
                  *selector != TEXT('.') && *selector != TEXT(':') &&                   *selector != '.' && *selector != ':' &&
                  !TtaIsWCBlank (selector))                   !TtaIsBlank (selector))
             *cur++ = *selector++;              *cur++ = *selector++;
           *cur++ = WC_EOS;            *cur++ = EOS;
         }          }
       else if (*selector == TEXT(':'))        else if (*selector == ':')
         {          {
           /* copy into sel[] the pseudoclass */            /* copy into sel[] the pseudoclass */
           pseudoclasses[0]= cur;            pseudoclasses[0]= cur;
           selector++;            selector++;
           while (*selector != WC_EOS && *selector != TEXT(',') &&            while (*selector != EOS && *selector != ',' &&
              *selector != TEXT('.') && *selector != TEXT(':') &&               *selector != '.' && *selector != ':' &&
              !TtaIsWCBlank (selector))               !TtaIsBlank (selector))
             *cur++ = *selector++;              *cur++ = *selector++;
           *cur++ = WC_EOS;            *cur++ = EOS;
         }          }
       else if (*selector == TEXT('#'))        else if (*selector == '#')
         {          {
           /* copy into sel[] the attribute */            /* copy into sel[] the attribute */
           ids[0] = cur;            ids[0] = cur;
           selector++;            selector++;
           while (*selector != WC_EOS && *selector != TEXT(',') &&            while (*selector != EOS && *selector != ',' &&
              *selector != TEXT('.') && *selector != TEXT(':') &&               *selector != '.' && *selector != ':' &&
              !TtaIsWCBlank (selector))               !TtaIsBlank (selector))
             *cur++ = *selector++;              *cur++ = *selector++;
           *cur++ = WC_EOS;            *cur++ = EOS;
         }          }
       else if (*selector == TEXT('['))        else if (*selector == '[')
         {          {
           /* copy into sel[] the attribute */            /* copy into sel[] the attribute */
           attrs[0] = cur;            attrs[0] = cur;
           selector++;            selector++;
           while (*selector != WC_EOS && *selector != TEXT(']') && *selector != TEXT('='))            while (*selector != EOS && *selector != ']' && *selector != '=')
             *cur++ = *selector++;              *cur++ = *selector++;
           if (*cur == TEXT('='))            if (*cur == '=')
             {              {
               /* there is a value "xxxx" */                /* there is a value "xxxx" */
               *cur++ = WC_EOS;                *cur++ = EOS;
               while (*selector != WC_EOS && *selector != TEXT(']') && *selector != TEXT('"'))                while (*selector != EOS && *selector != ']' && *selector != '"')
                 selector++;                  selector++;
               if (*selector != WC_EOS)                if (*selector != EOS)
                 {                  {
                   /* we are now parsing the attribute value */                    /* we are now parsing the attribute value */
                   attrvals[0] = cur;                    attrvals[0] = cur;
                   selector++;                    selector++;
                   while (*selector != WC_EOS && *selector != TEXT('"'))                    while (*selector != EOS && *selector != '"')
                     *cur++ = *selector++;                      *cur++ = *selector++;
                   if (*selector != WC_EOS)                    if (*selector != EOS)
                     selector++;                      selector++;
                 }                  }
             }              }
           *cur++ = WC_EOS;            *cur++ = EOS;
         }          }
   
       selector = SkipWCBlanksAndComments (selector);        selector = SkipBlanksAndComments (selector);
   
       /* is it a multi-level selector? */        /* is it a multi-level selector? */
       if (*selector == WC_EOS)        if (*selector == EOS)
         /* end of the selector */          /* end of the selector */
         break;          break;
       else if (*selector == TEXT(','))        else if (*selector == ',')
         {          {
           /* end of the current selector */            /* end of the current selector */
           selector++;            selector++;
Line 3492  static char *ParseGenericSelector (char Line 3474  static char *ParseGenericSelector (char
   /* Get the schema name of the main element */    /* Get the schema name of the main element */
   if (ctxt->schema == NULL)    if (ctxt->schema == NULL)
     ctxt->schema = TtaGetDocumentSSchema (doc);      ctxt->schema = TtaGetDocumentSSchema (doc);
   isHTML = (ustrcmp (TtaGetSSchemaName (ctxt->schema), TEXT("HTML")) == 0);    isHTML = (strcmp (TtaGetSSchemaName (ctxt->schema), "HTML") == 0);
   tsch = GetPExtension (doc, ctxt->schema, css);    tsch = GetPExtension (doc, ctxt->schema, css);
   structName = TtaGetSSchemaName (ctxt->schema);    structName = TtaGetSSchemaName (ctxt->schema);
   if (cssRule)    if (cssRule)
Line 3518  static void  ParseStyleDeclaration (Elem Line 3500  static void  ParseStyleDeclaration (Elem
   char                saved2;    char                saved2;
   
   /* separate the selectors string */    /* separate the selectors string */
   cssRule = SkipWCBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
   decl_end = cssRule;    decl_end = cssRule;
   while ((*decl_end != WC_EOS) && (*decl_end != TEXT('{')))    while (*decl_end != EOS && *decl_end != '{')
     decl_end++;      decl_end++;
   if (*decl_end == WC_EOS)    if (*decl_end == EOS)
     return;      return;
   /* verify and clean the selector string */    /* verify and clean the selector string */
   sel_end = decl_end - 1;    sel_end = decl_end - 1;
   while (*sel_end == WC_SPACE || *sel_end == WC_BSPACE ||    while (*sel_end == SPACE || *sel_end == BSPACE ||
          *sel_end == WC_EOL || *sel_end == WC_CR)           *sel_end == EOL || *sel_end == CR)
     sel_end--;      sel_end--;
   sel_end++;    sel_end++;
   saved1 = *sel_end;    saved1 = *sel_end;
   *sel_end = WC_EOS;    *sel_end = EOS;
   selector = cssRule;    selector = cssRule;
   
   /* now, deal with the content ... */    /* now, deal with the content ... */
   decl_end++;    decl_end++;
   cssRule = decl_end;    cssRule = decl_end;
   while (*decl_end != WC_EOS && *decl_end != TEXT('}'))    while (*decl_end != EOS && *decl_end != '}')
     decl_end++;      decl_end++;
   if (*decl_end == WC_EOS)    if (*decl_end == EOS)
     {      {
       fprintf (stderr, "Invalid STYLE declaration: %s\n", cssRule);        fprintf (stderr, "Invalid STYLE declaration: %s\n", cssRule);
       return;        return;
     }      }
   saved2 = *decl_end;    saved2 = *decl_end;
   *decl_end = WC_EOS;    *decl_end = EOS;
   
   /*    /*
    * parse the style attribute string and install the corresponding     * parse the style attribute string and install the corresponding
Line 3556  static void  ParseStyleDeclaration (Elem Line 3538  static void  ParseStyleDeclaration (Elem
     return;      return;
   ctxt->destroy = destroy;    ctxt->destroy = destroy;
   
   while ((selector != NULL) && (*selector != WC_EOS))    while ((selector != NULL) && (*selector != EOS))
     selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css);      selector = ParseGenericSelector (selector, cssRule, ctxt, doc, css);
   TtaFreeMemory (ctxt);    TtaFreeMemory (ctxt);
   
Line 3585  int         IsImplicitClassName (char *c Line 3567  int         IsImplicitClassName (char *c
    SSchema      schema;     SSchema      schema;
   
    /* make a local copy */     /* make a local copy */
    ustrncpy (name, class, 199);     strncpy (name, class, 199);
    name[199] = 0;     name[199] = 0;
   
    /* loop looking if each word is a GI */     /* loop looking if each word is a GI */
Line 3601  int         IsImplicitClassName (char *c Line 3583  int         IsImplicitClassName (char *c
              return (0);               return (0);
           }            }
         *cur = save;          *cur = save;
         cur = SkipWCBlanksAndComments (cur);          cur = SkipBlanksAndComments (cur);
      }       }
    return (1);     return (1);
 }  }
Line 3619  void    HTMLSetBackgroundColor (Document Line 3601  void    HTMLSetBackgroundColor (Document
 {  {
    char             css_command[100];     char             css_command[100];
   
    usprintf (css_command, TEXT("background-color: %s"), color);     sprintf (css_command, "background-color: %s", color);
    ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);     ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);
 }  }
   
Line 3633  void HTMLSetBackgroundImage (Document do Line 3615  void HTMLSetBackgroundImage (Document do
    char           css_command[400];     char           css_command[400];
   
    /******* check buffer overflow ********/     /******* check buffer overflow ********/
    usprintf (css_command, TEXT("background-image: url(%s); background-repeat: "), image);     sprintf (css_command, "background-image: url(%s); background-repeat: ", image);
    if (repeat == STYLE_REPEAT)     if (repeat == STYLE_REPEAT)
      ustrcat (css_command, TEXT("repeat"));       strcat (css_command, "repeat");
    else if (repeat == STYLE_HREPEAT)     else if (repeat == STYLE_HREPEAT)
      ustrcat (css_command, TEXT("repeat-x"));       strcat (css_command, "repeat-x");
    else if (repeat == STYLE_VREPEAT)     else if (repeat == STYLE_VREPEAT)
      ustrcat (css_command, TEXT("repeat-y"));       strcat (css_command, "repeat-y");
    else     else
      ustrcat (css_command, TEXT("no-repeat"));       strcat (css_command, "no-repeat");
    ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);     ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);
 }  }
   
Line 3652  void   HTMLSetForegroundColor (Document Line 3634  void   HTMLSetForegroundColor (Document
 {  {
    char           css_command[100];     char           css_command[100];
   
    usprintf (css_command, TEXT("color: %s"), color);     sprintf (css_command, "color: %s", color);
    ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);     ParseHTMLSpecificStyle (el, css_command, doc, 1, FALSE);
 }  }
   
Line 3663  void                HTMLResetBackgroundC Line 3645  void                HTMLResetBackgroundC
 {  {
    char           css_command[100];     char           css_command[100];
   
    usprintf (css_command, TEXT("background: red"));     sprintf (css_command, "background: red");
    ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);     ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);
 }  }
   
Line 3674  void                HTMLResetBackgroundI Line 3656  void                HTMLResetBackgroundI
 {  {
    char           css_command[1000];     char           css_command[1000];
   
    usprintf (css_command, TEXT("background-image: url(xx); background-repeat: repeat"));     sprintf (css_command, "background-image: url(xx); background-repeat: repeat");
    ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);     ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);
 }  }
   
Line 3686  void                HTMLResetForegroundC Line 3668  void                HTMLResetForegroundC
    char           css_command[100];     char           css_command[100];
   
    /* it's not necessary to well know the current color but it must be valid */     /* it's not necessary to well know the current color but it must be valid */
    usprintf (css_command, TEXT("color: red"));     sprintf (css_command, "color: red");
    ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);     ParseHTMLSpecificStyle (el, css_command, doc, 1, TRUE);
 }  }
   
Line 3697  void                HTMLSetAlinkColor (D Line 3679  void                HTMLSetAlinkColor (D
 {  {
    char           css_command[100];     char           css_command[100];
   
    usprintf (css_command, TEXT("a:link { color: %s }"), color);     sprintf (css_command, "a:link { color: %s }", color);
    ApplyCSSRules (NULL, css_command, doc, FALSE);     ApplyCSSRules (NULL, css_command, doc, FALSE);
 }  }
   
Line 3708  void                HTMLSetAactiveColor Line 3690  void                HTMLSetAactiveColor
 {  {
    char           css_command[100];     char           css_command[100];
   
    usprintf (css_command, TEXT("a:active { color: %s }"), color);     sprintf (css_command, "a:active { color: %s }", color);
    ApplyCSSRules (NULL, css_command, doc, FALSE);     ApplyCSSRules (NULL, css_command, doc, FALSE);
 }  }
   
Line 3719  void                HTMLSetAvisitedColor Line 3701  void                HTMLSetAvisitedColor
 {  {
    char           css_command[100];     char           css_command[100];
   
    usprintf (css_command, TEXT("a:visited { color: %s }"), color);     sprintf (css_command, "a:visited { color: %s }", color);
    ApplyCSSRules (NULL, css_command, doc, FALSE);     ApplyCSSRules (NULL, css_command, doc, FALSE);
 }  }
   
Line 3730  void                HTMLResetAlinkColor Line 3712  void                HTMLResetAlinkColor
 {  {
    char           css_command[100];     char           css_command[100];
   
    usprintf (css_command, TEXT("a:link { color: red }"));     sprintf (css_command, "a:link { color: red }");
    ApplyCSSRules (NULL, css_command, doc, TRUE);     ApplyCSSRules (NULL, css_command, doc, TRUE);
 }  }
   
Line 3741  void                HTMLResetAactiveColo Line 3723  void                HTMLResetAactiveColo
 {  {
    char           css_command[100];     char           css_command[100];
   
    usprintf (css_command, TEXT("a:active { color: red }"));     sprintf (css_command, "a:active { color: red }");
    ApplyCSSRules (NULL, css_command, doc, TRUE);     ApplyCSSRules (NULL, css_command, doc, TRUE);
 }  }
   
Line 3752  void                HTMLResetAvisitedCol Line 3734  void                HTMLResetAvisitedCol
 {  {
    char           css_command[100];     char           css_command[100];
   
    usprintf (css_command, TEXT("a:visited { color: red }"));     sprintf (css_command, "a:visited { color: red }");
    ApplyCSSRules (NULL, css_command, doc, TRUE);     ApplyCSSRules (NULL, css_command, doc, TRUE);
 }  }
   
Line 3792  void ApplyCSSRules (Element el, char *cs Line 3774  void ApplyCSSRules (Element el, char *cs
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer, ThotBool withUndo)  char ReadCSSRules (Document docRef, CSSInfoPtr css, char *buffer, ThotBool withUndo)
 {  {
   char              c;  
   char              *cssRule, *base;  
   DisplayMode         dispMode;    DisplayMode         dispMode;
     char                c;
     char               *cssRule, *base;
   int                 index;    int                 index;
   int                 CSSindex;    int                 CSSindex;
   int                 CSScomment;    int                 CSScomment;
Line 3815  char ReadCSSRules (Document docRef, CSSI Line 3797  char ReadCSSRules (Document docRef, CSSI
   import = MAX_CSS_LENGTH;    import = MAX_CSS_LENGTH;
   eof = FALSE;    eof = FALSE;
   openRule = 0;    openRule = 0;
   c = WC_SPACE;    c = SPACE;
   index = 0;    index = 0;
   /* avoid too many redisplay */    /* avoid too many redisplay */
   dispMode = TtaGetDisplayMode (docRef);    dispMode = TtaGetDisplayMode (docRef);
Line 3828  char ReadCSSRules (Document docRef, CSSI Line 3810  char ReadCSSRules (Document docRef, CSSI
   if (css == NULL)    if (css == NULL)
     css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL);      css = AddCSS (docRef, docRef, CSS_DOCUMENT_STYLE, NULL, NULL);
   
   while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof) {    while (CSSindex < MAX_CSS_LENGTH && c != EOS && !eof)
         c = buffer[index++];      {
         eof = (c == WC_EOS);        c = buffer[index++];
         CSSbuffer[CSSindex] = c;        eof = (c == EOS);
         if (CSScomment == MAX_CSS_LENGTH || c == TEXT('*') || c == TEXT('/') || c == TEXT('<')) {        CSSbuffer[CSSindex] = c;
            /* we're not within a comment or we're parsing * or / */        if (CSScomment == MAX_CSS_LENGTH ||
            switch (c) {            c == '*' || c == '/' || c == '<')
                   case TEXT('@'): /* perhaps an import primitive */          {
                        import = CSSindex;            /* we're not within a comment or we're parsing * or / */
                        break;            switch (c)
                   case TEXT(';'):              {
                        if (import != MAX_CSS_LENGTH && !media) {               case '@': /* perhaps an import primitive */
                           if (ustrncasecmp (&CSSbuffer[import+1], TEXT("import"), 6))                import = CSSindex;
                              /* it's not an import */                break;
                              import = MAX_CSS_LENGTH;              case ';':
                          /* save the text */                if (import != MAX_CSS_LENGTH && !media)
                          noRule = TRUE;                  { 
                        }                    if (strncasecmp (&CSSbuffer[import+1], "import", 6))
                        break;                      /* it's not an import */
                   case TEXT('*'):                      import = MAX_CSS_LENGTH;
                        if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 && CSSbuffer[CSSindex - 1] == TEXT('/'))                    /* save the text */
                           /* start a comment */                    noRule = TRUE;
                           CSScomment = CSSindex - 1;                  }
                        break;                break;
                   case TEXT('/'):              case '*':
                        if (CSSindex > 1 && CSScomment != MAX_CSS_LENGTH && CSSbuffer[CSSindex - 1] == TEXT('*')) {                if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
                           /* close a comment:and ignore its contents */                    CSSbuffer[CSSindex - 1] == '/')
                           CSSindex = CSScomment - 1; /* will be incremented later */                  /* start a comment */
                           CSScomment = MAX_CSS_LENGTH;                  CSScomment = CSSindex - 1;
                        } else if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 && CSSbuffer[CSSindex - 1] ==  TEXT('<')) {                break;
                               /* this is the closing tag ! */              case '/':
                               CSSindex -= 2; /* remove </ from the CSS string */                if (CSSindex > 1 && CSScomment != MAX_CSS_LENGTH &&
                               noRule = TRUE;                    CSSbuffer[CSSindex - 1] == '*')
                        }                   {
                        break;                    /* close a comment:and ignore its contents */
                   case TEXT('<'):                    CSSindex = CSScomment - 1; /* will be incremented later */
                        if (CSScomment == MAX_CSS_LENGTH) {                    CSScomment = MAX_CSS_LENGTH;
                           /* only if we're not parsing a comment */                  }
                           c = buffer[index++];                else if (CSScomment == MAX_CSS_LENGTH && CSSindex > 0 &&
                           eof = (c == WC_EOS);                         CSSbuffer[CSSindex - 1] ==  '<')
                           if (c == TEXT('!')) {                  {
                              /* CSS within an HTML comment */                    /* this is the closing tag ! */
                              HTMLcomment = TRUE;                    CSSindex -= 2; /* remove </ from the CSS string */
                              CSSindex++;                    noRule = TRUE;
                              CSSbuffer[CSSindex] = c;                  } 
                           } else if (c == WC_EOS)                break;
                                  CSSindex++;              case '<':
                        }                if (CSScomment == MAX_CSS_LENGTH)
                        break;                  {
                   case TEXT('-'):                    /* only if we're not parsing a comment */
                        if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == TEXT('-') && HTMLcomment)                    c = buffer[index++];
                           /* CSS within an HTML comment */                    eof = (c == EOS);
                           noRule = TRUE;                    if (c == '!')
                        break;                      {
                   case TEXT('>'):                        /* CSS within an HTML comment */
                        if (HTMLcomment)                        HTMLcomment = TRUE;
                           noRule = TRUE;                        CSSindex++;
                        break;                        CSSbuffer[CSSindex] = c;
                   case TEXT(' '):                      }
                        if (import != MAX_CSS_LENGTH && openRule == 0)                    else if (c == EOS)
                           media = !ustrncmp (&CSSbuffer[import+1], TEXT("media"), 5);                      CSSindex++;
                        break;                  }
                   case TEXT('{'):                break;
                        openRule++;              case '-':
                        if (import != MAX_CSS_LENGTH && openRule == 1 && media) {                if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' &&
                           /* is it the screen concerned? */                    HTMLcomment)
                           CSSbuffer[CSSindex+1] = WC_EOS;                  /* CSS within an HTML comment */
                           if (TtaIsPrinting ())                  noRule = TRUE;
                              base = ustrstr (&CSSbuffer[import], TEXT("print"));                break;
                           else              case '>':
                                base = ustrstr (&CSSbuffer[import], TEXT("screen"));                if (HTMLcomment)
                           if (base == NULL)                  noRule = TRUE;
                              ignoreMedia = TRUE;                break;
                           noRule = TRUE;              case ' ':
                        }                if (import != MAX_CSS_LENGTH && openRule == 0)
                        break;                  media = !strncmp (&CSSbuffer[import+1], "media", 5);
                   case TEXT('}'):                break;
                        openRule--;              case '{':
                        if (import != MAX_CSS_LENGTH && openRule == 0) {                openRule++;
                           import = MAX_CSS_LENGTH;                if (import != MAX_CSS_LENGTH && openRule == 1 && media)
                           noRule = TRUE;                  {
                           ignoreMedia = FALSE;                    /* is it the screen concerned? */
                           media = FALSE;                    CSSbuffer[CSSindex+1] = EOS;
                        } else                    if (TtaIsPrinting ())
                               toParse = TRUE;                      base = strstr (&CSSbuffer[import], "print");
                        break;                    else
                   default:                      base = strstr (&CSSbuffer[import], "screen");
                        break;                    if (base == NULL)
            }                      ignoreMedia = TRUE;
         }                        noRule = TRUE;
         if (c != WC_CR)                  }
            CSSindex++;                break;
               case '}':
         if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)                openRule--;
            /* we're still parsing a comment: remove the text comment */                if (import != MAX_CSS_LENGTH && openRule == 0)
            CSSindex = CSScomment;                  {
                     import = MAX_CSS_LENGTH;
         if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule) {                    noRule = TRUE;
            CSSbuffer[CSSindex] = WC_EOS;                    ignoreMedia = FALSE;
            /* parse a not empty string */                    media = FALSE;
            if (CSSindex > 0) {                  }
                 else
                   toParse = TRUE;
                 break;
               default:
                 break;
               }
           }
         if (c != CR)
           CSSindex++;
   
         if (CSSindex >= MAX_CSS_LENGTH && CSScomment < MAX_CSS_LENGTH)
           /* we're still parsing a comment: remove the text comment */
           CSSindex = CSScomment;
   
         if (CSSindex >= MAX_CSS_LENGTH || toParse || noRule)
           {
             CSSbuffer[CSSindex] = EOS;
             /* parse a not empty string */
             if (CSSindex > 0)
               {
               /* apply CSS rule if it's not just a saving of text */                /* apply CSS rule if it's not just a saving of text */
               if (!noRule && !ignoreMedia)                if (!noRule && !ignoreMedia)
                  ParseStyleDeclaration (NULL, CSSbuffer, docRef, css, FALSE);                  ParseStyleDeclaration (NULL, CSSbuffer, docRef, css, FALSE);
               else if (import != MAX_CSS_LENGTH && !ustrncasecmp (&CSSbuffer[import+1], TEXT("import"), 6)) {                else if (import != MAX_CSS_LENGTH &&
                    /* import section */                         !strncasecmp (&CSSbuffer[import+1], "import", 6))
                    cssRule = &CSSbuffer[import+7];                  {
                    cssRule = TtaSkipWCBlanks (cssRule);                    /* import section */
                    if (!ustrncasecmp (cssRule, TEXT("url"), 3)) {                    cssRule = &CSSbuffer[import+7];
                     cssRule = TtaSkipBlanks (cssRule);
                     if (!strncasecmp (cssRule, "url", 3))
                       {
                       cssRule = &cssRule[3];                        cssRule = &cssRule[3];
                       cssRule = TtaSkipWCBlanks (cssRule);                        cssRule = TtaSkipBlanks (cssRule);
                       if (*cssRule == TEXT('(')) {                        if (*cssRule == '(')
                          cssRule++;                          {
                          cssRule = TtaSkipWCBlanks (cssRule);                            cssRule++;
                          base = cssRule;                            cssRule = TtaSkipBlanks (cssRule);
                          while (*cssRule != WC_EOS && *cssRule != TEXT(')'))                            base = cssRule;
                                 cssRule++;                            while (*cssRule != EOS && *cssRule != ')')
                          *cssRule = WC_EOS;                              cssRule++;
                          LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);                            *cssRule = EOS;
                       }                            LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
                    }                          }
                    /*** Caution: Strings can either be written with double quotes or                      }
                         with single quotes. Only double quotes are handled here.                    /*
                         Escaped quotes are not handled. See function SkipQuotedString */                      Caution: Strings can either be written with double quotes or
                    else if (*cssRule == TEXT('"')) {                      with single quotes. Only double quotes are handled here.
                         cssRule++;                      Escaped quotes are not handled. See function SkipQuotedString
                         base = cssRule;                    */
                         while (*cssRule != WC_EOS && *cssRule != TEXT('"'))                    else if (*cssRule == '"')
                               cssRule++;                      {
                         *cssRule = WC_EOS;                        cssRule++;
                         LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);                        base = cssRule;
                    }                        while (*cssRule != EOS && *cssRule != '"')
                    import = MAX_CSS_LENGTH;                          cssRule++;
               }                        *cssRule = EOS;
            }                        LoadStyleSheet (base, docRef, NULL, css, css->media[docRef]);
            toParse = FALSE;                      }
            noRule = FALSE;                    import = MAX_CSS_LENGTH;
            CSSindex = 0;                  }
               }
             toParse = FALSE;
             noRule = FALSE;
             CSSindex = 0;
         }          }
   }      }
   /* restore the display mode */    /* restore the display mode */
   if (dispMode == DisplayImmediately)    if (dispMode == DisplayImmediately)
      TtaSetDisplayMode (docRef, dispMode);      TtaSetDisplayMode (docRef, dispMode);
   return (c);    return (c);
 }  }

Removed from v.1.81  
changed lines
  Added in v.1.82


Webmaster