Diff for /Amaya/amaya/styleparser.c between versions 1.167 and 1.168

version 1.167, 2003/01/07 17:08:18 version 1.168, 2003/01/08 13:19:46
Line 98  static ThotBool      DoApply = TRUE; Line 98  static ThotBool      DoApply = TRUE;
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 static char *SkipWord (char *ptr)  static char *SkipWord (char *ptr)
 {  {
 # ifdef _WINDOWS    while (isalnum((int)*ptr) || *ptr == '-' || *ptr == '#' || *ptr == '%')
   /* iswalnum is supposed to be supported by the i18n veriosn of libc       ptr++;
      use it when available */  
   while (iswalnum (*ptr) || *ptr == '-' || *ptr == '%')  
 # else  /* !_WINDOWS */  
   while (isalnum((int)*ptr) || *ptr == '-' || *ptr == '%')  
 # endif /* !_WINDOWS */  
         ptr++;  
   return (ptr);    return (ptr);
 }  }
   
Line 187  static char *SkipQuotedString (char *ptr Line 181  static char *SkipQuotedString (char *ptr
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    CSSParseError     CSSPrintError
    print the error message msg on stderr.     print the error message msg on stderr.
    When the line is 0 ask to expat the current line number     When the line is 0 ask to expat the current line number
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 static void  CSSParseError (char *msg, char *value)  static void CSSPrintError (char *msg, char *value)
 {  {
   if (!TtaIsPrinting () && ParsedDoc > 0)    if (!TtaIsPrinting () && ParsedDoc > 0)
     {      {
Line 216  static void  CSSParseError (char *msg, c Line 210  static void  CSSParseError (char *msg, c
     }      }
 }  }
   
   /*----------------------------------------------------------------------
      CSSParseError
      print the error message msg on stderr.
      When the line is 0 ask to expat the current line number
     ----------------------------------------------------------------------*/
   static void CSSParseError (char *msg, char *value, char *endvalue)
   {
     char        c = EOS;
   
     if (endvalue)
       {
         /* close the string here */
         c = *endvalue;
         *endvalue = EOS;
       }
     CSSPrintError (msg, value);
     if (endvalue)
       *endvalue = c;
   }
   
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    SkipProperty:                                                       SkipProperty skips a property and display and error message
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 static char *SkipProperty (char *ptr)  static char *SkipProperty (char *ptr)
 {  {
Line 242  static char *SkipProperty (char *ptr) Line 256  static char *SkipProperty (char *ptr)
   *ptr = EOS;    *ptr = EOS;
 #ifdef CSS_WARNING  #ifdef CSS_WARNING
   if (*deb != EOS)    if (*deb != EOS)
     CSSParseError ("CSS property ignored \"", deb);      CSSPrintError ("CSS property ignored", deb);
 #endif /* CSS_WARNING */  #endif /* CSS_WARNING */
   *ptr = c;    *ptr = c;
   return (ptr);    return (ptr);
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    SkipProperty:                                                       SkipValue
      skips the value and display an error message if msg is not NULL
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 static char *SkipValue (char *ptr, ThotBool error)  static char *SkipValue (char *msg, char *ptr)
 {  {
   char       *deb;    char       *deb;
   char        c;    char        c;
Line 271  static char *SkipValue (char *ptr, ThotB Line 286  static char *SkipValue (char *ptr, ThotB
   /* print the skipped property */    /* print the skipped property */
   c = *ptr;    c = *ptr;
   *ptr = EOS;    *ptr = EOS;
   if (*deb != EOS && *deb != ',')    if (msg && *deb != EOS && *deb != ',')
     {      CSSPrintError (msg, deb);
       if (error)  
         CSSParseError ("invalid CSS value \"", deb);  
 #ifdef CSS_WARNING  
       else  
         CSSParseError ("CSS value ignored \"", deb);  
 #endif /* CSS_WARNING */  
     }  
   *ptr = c;    *ptr = c;
   return (ptr);    return (ptr);
 }  }
Line 448  char *ParseCSSUnit (char *cssRule, Prese Line 456  char *ParseCSSUnit (char *cssRule, Prese
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 static char *ParseBorderValue (char *cssRule, PresentationValue *border)  static char *ParseBorderValue (char *cssRule, PresentationValue *border)
 {  {
     char             *ptr;
   
   /* first parse the attribute string */    /* first parse the attribute string */
    border->typed_data.value = 0;     border->typed_data.value = 0;
    border->typed_data.unit = STYLE_UNIT_INVALID;     border->typed_data.unit = STYLE_UNIT_INVALID;
Line 472  static char *ParseBorderValue (char *css Line 482  static char *ParseBorderValue (char *css
      }       }
    else if (isdigit (*cssRule) || *cssRule == '.')     else if (isdigit (*cssRule) || *cssRule == '.')
      {       {
          ptr = cssRule;
        cssRule = ParseCSSUnit (cssRule, border);         cssRule = ParseCSSUnit (cssRule, border);
        if (border->typed_data.unit == STYLE_UNIT_BOX)         if (border->typed_data.value == 0)
          border->typed_data.unit = STYLE_UNIT_EM;           border->typed_data.unit = STYLE_UNIT_PX;
          else if (border->typed_data.unit == STYLE_UNIT_INVALID ||
                   border->typed_data.unit == STYLE_UNIT_BOX)
            {
              border->typed_data.unit = STYLE_UNIT_INVALID;
              border->typed_data.value = 0;
              CSSParseError ("Invalid border-width value", ptr, cssRule);
            }
      }       }
    return (cssRule);     return (cssRule);
 }  }
Line 546  static char *ParseCSSColor (char *cssRul Line 564  static char *ParseCSSColor (char *cssRul
     }      }
   if (ptr == cssRule)    if (ptr == cssRule)
     {      {
       cssRule = SkipValue (cssRule, TRUE);        cssRule = SkipWord (cssRule);
         CSSParseError ("Invalid color value", ptr, cssRule);
       val->typed_data.value = 0;        val->typed_data.value = 0;
       val->typed_data.unit = STYLE_UNIT_INVALID;        val->typed_data.unit = STYLE_UNIT_INVALID;
     }      }
Line 1080  static char *ParseCSSBorderTop (Element Line 1099  static char *ParseCSSBorderTop (Element
         cssRule = ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML);          cssRule = ParseCSSBorderColorTop (element, tsch, context, cssRule, css, isHTML);
       if (ptr == cssRule)        if (ptr == cssRule)
         /* rule not found */          /* rule not found */
         cssRule = SkipValue (cssRule, TRUE);          cssRule = SkipValue ("Invalid border value", cssRule);
       cssRule = SkipBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   return (cssRule);    return (cssRule);
Line 1107  static char *ParseCSSBorderLeft (Element Line 1126  static char *ParseCSSBorderLeft (Element
         cssRule = ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML);          cssRule = ParseCSSBorderColorLeft (element, tsch, context, cssRule, css, isHTML);
       if (ptr == cssRule)        if (ptr == cssRule)
         /* rule not found */          /* rule not found */
         cssRule = SkipValue (cssRule, TRUE);          cssRule = SkipValue ("Invalid border value", cssRule);
       cssRule = SkipBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   return (cssRule);    return (cssRule);
Line 1134  static char *ParseCSSBorderBottom (Eleme Line 1153  static char *ParseCSSBorderBottom (Eleme
         cssRule = ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML);          cssRule = ParseCSSBorderColorBottom (element, tsch, context, cssRule, css, isHTML);
       if (ptr == cssRule)        if (ptr == cssRule)
         /* rule not found */          /* rule not found */
         cssRule = SkipValue (cssRule, TRUE);          cssRule = SkipValue ("Invalid border value", cssRule);
       cssRule = SkipBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   return (cssRule);    return (cssRule);
Line 1161  static char *ParseCSSBorderRight (Elemen Line 1180  static char *ParseCSSBorderRight (Elemen
         cssRule = ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML);          cssRule = ParseCSSBorderColorRight (element, tsch, context, cssRule, css, isHTML);
       if (ptr == cssRule)        if (ptr == cssRule)
         /* rule not found */          /* rule not found */
         cssRule = SkipValue (cssRule, TRUE);          cssRule = SkipValue ("Invalid border value", cssRule);
       cssRule = SkipBlanksAndComments (cssRule);        cssRule = SkipBlanksAndComments (cssRule);
     }      }
   return (cssRule);    return (cssRule);
Line 1203  static char *ParseCSSClear (Element elem Line 1222  static char *ParseCSSClear (Element elem
                             PresentationContext context, char *cssRule,                              PresentationContext context, char *cssRule,
                             CSSInfoPtr css, ThotBool isHTML)                              CSSInfoPtr css, ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1215  static char *ParseCSSDisplay (Element el Line 1234  static char *ParseCSSDisplay (Element el
                               CSSInfoPtr css, ThotBool isHTML)                                CSSInfoPtr css, ThotBool isHTML)
 {  {
    PresentationValue   pval;     PresentationValue   pval;
      char               *ptr;
   
    pval.typed_data.unit = STYLE_UNIT_REL;     pval.typed_data.unit = STYLE_UNIT_REL;
    pval.typed_data.real = FALSE;     pval.typed_data.real = FALSE;
Line 1256  static char *ParseCSSDisplay (Element el Line 1276  static char *ParseCSSDisplay (Element el
                strncasecmp (cssRule, "table-caption", 13) &&                 strncasecmp (cssRule, "table-caption", 13) &&
                strncasecmp (cssRule, "table", 5) &&                 strncasecmp (cssRule, "table", 5) &&
                strncasecmp (cssRule, "inherit", 7))                 strncasecmp (cssRule, "inherit", 7))
            CSSParseError ("Invalid display value", cssRule);               {
            cssRule = SkipWord (cssRule);                 ptr = cssRule;
                  cssRule = SkipWord (cssRule);
                  CSSParseError ("Invalid display value", ptr, cssRule);
                }
            return (cssRule);             return (cssRule);
          }           }
   
Line 1279  static char *ParseCSSFloat (Element elem Line 1302  static char *ParseCSSFloat (Element elem
                             PresentationContext context, char *cssRule,                              PresentationContext context, char *cssRule,
                             CSSInfoPtr css, ThotBool isHTML)                              CSSInfoPtr css, ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1291  static char *ParseCSSLetterSpacing (Elem Line 1314  static char *ParseCSSLetterSpacing (Elem
                                     PresentationContext context, char *cssRule,                                      PresentationContext context, char *cssRule,
                                     CSSInfoPtr css, ThotBool isHTML)                                      CSSInfoPtr css, ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1303  static char *ParseCSSListStyleType (Elem Line 1326  static char *ParseCSSListStyleType (Elem
                                     PresentationContext context, char *cssRule,                                      PresentationContext context, char *cssRule,
                                     CSSInfoPtr css, ThotBool isHTML)                                      CSSInfoPtr css, ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1315  static char *ParseCSSListStyleImage (Ele Line 1338  static char *ParseCSSListStyleImage (Ele
                                      PresentationContext context, char *cssRule,                                       PresentationContext context, char *cssRule,
                                      CSSInfoPtr css, ThotBool isHTML)                                       CSSInfoPtr css, ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1328  static char *ParseCSSListStylePosition ( Line 1351  static char *ParseCSSListStylePosition (
                                         char *cssRule, CSSInfoPtr css,                                          char *cssRule, CSSInfoPtr css,
                                         ThotBool isHTML)                                          ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1340  static char *ParseCSSListStyle (Element Line 1363  static char *ParseCSSListStyle (Element
                                 PresentationContext context, char *cssRule,                                  PresentationContext context, char *cssRule,
                                 CSSInfoPtr css, ThotBool isHTML)                                  CSSInfoPtr css, ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1353  static char *ParseCSSTextAlign (Element Line 1376  static char *ParseCSSTextAlign (Element
                                 CSSInfoPtr css, ThotBool isHTML)                                  CSSInfoPtr css, ThotBool isHTML)
 {  {
    PresentationValue   align;     PresentationValue   align;
      char               *ptr;
   
    align.typed_data.value = 0;     align.typed_data.value = 0;
    align.typed_data.unit = STYLE_UNIT_REL;     align.typed_data.unit = STYLE_UNIT_REL;
Line 1381  static char *ParseCSSTextAlign (Element Line 1405  static char *ParseCSSTextAlign (Element
      }       }
    else     else
      {       {
         CSSParseError ("Invalid align value", cssRule);         ptr = cssRule;
          cssRule = SkipWord (cssRule);
          CSSParseError ("Invalid text-align value", ptr, cssRule);
         return (cssRule);          return (cssRule);
      }       }
   
Line 1405  static char *ParseCSSDirection (Element Line 1431  static char *ParseCSSDirection (Element
                                 CSSInfoPtr css, ThotBool isHTML)                                  CSSInfoPtr css, ThotBool isHTML)
 {  {
    PresentationValue   direction;     PresentationValue   direction;
      char               *ptr;
   
    direction.typed_data.value = 0;     direction.typed_data.value = 0;
    direction.typed_data.unit = STYLE_UNIT_REL;     direction.typed_data.unit = STYLE_UNIT_REL;
Line 1429  static char *ParseCSSDirection (Element Line 1456  static char *ParseCSSDirection (Element
      }       }
    else     else
      {       {
        CSSParseError ("Invalid direction value", cssRule);         ptr = cssRule;
          cssRule = SkipWord (cssRule);
          CSSParseError ("Invalid direction value", ptr, cssRule);
        return (cssRule);         return (cssRule);
      }       }
   
Line 1453  static char *ParseCSSUnicodeBidi (Elemen Line 1482  static char *ParseCSSUnicodeBidi (Elemen
                                   CSSInfoPtr css, ThotBool isHTML)                                    CSSInfoPtr css, ThotBool isHTML)
 {  {
    PresentationValue   bidi;     PresentationValue   bidi;
      char               *ptr;
   
    bidi.typed_data.value = 0;     bidi.typed_data.value = 0;
    bidi.typed_data.unit = STYLE_UNIT_REL;     bidi.typed_data.unit = STYLE_UNIT_REL;
Line 1482  static char *ParseCSSUnicodeBidi (Elemen Line 1512  static char *ParseCSSUnicodeBidi (Elemen
      }       }
    else     else
      {       {
        CSSParseError ("Invalid unicode-bidi value", cssRule);         ptr = cssRule;
          cssRule = SkipWord (cssRule);
          CSSParseError ("Invalid unicode-bidi value", ptr, cssRule);
        return (cssRule);         return (cssRule);
      }       }
   
Line 1499  static char *ParseCSSUnicodeBidi (Elemen Line 1531  static char *ParseCSSUnicodeBidi (Elemen
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    ParseCSSTextIndent: parse a CSS text-indent               ParseCSSTextIndent: parse a CSS text-indent
    attribute string.                                               attribute string.                                          
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 static char *ParseCSSTextIndent (Element element, PSchema tsch,  static char *ParseCSSTextIndent (Element element, PSchema tsch,
Line 1507  static char *ParseCSSTextIndent (Element Line 1539  static char *ParseCSSTextIndent (Element
                                  CSSInfoPtr css, ThotBool isHTML)                                   CSSInfoPtr css, ThotBool isHTML)
 {  {
    PresentationValue   pval;     PresentationValue   pval;
      char               *ptr;
   
    cssRule = SkipBlanksAndComments (cssRule);     cssRule = SkipBlanksAndComments (cssRule);
      ptr = cssRule;
    cssRule = ParseCSSUnit (cssRule, &pval);     cssRule = ParseCSSUnit (cssRule, &pval);
    if (pval.typed_data.unit == STYLE_UNIT_INVALID)     if (pval.typed_data.value == 0)
      return (cssRule);  
    else if (pval.typed_data.unit == STYLE_UNIT_BOX)  
      pval.typed_data.unit = STYLE_UNIT_PX;       pval.typed_data.unit = STYLE_UNIT_PX;
      else if (pval.typed_data.unit == STYLE_UNIT_INVALID ||
          pval.typed_data.unit == STYLE_UNIT_BOX)
        {
          CSSParseError ("Invalid text-indent value", ptr, cssRule);
          return (cssRule);
        }
    /* install the attribute */     /* install the attribute */
    if (DoApply)     if (DoApply)
      {       {
Line 1532  static char *ParseCSSTextTransform (Elem Line 1570  static char *ParseCSSTextTransform (Elem
                                     PresentationContext context, char *cssRule,                                      PresentationContext context, char *cssRule,
                                     CSSInfoPtr css, ThotBool isHTML)                                      CSSInfoPtr css, ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1544  static char *ParseCSSVerticalAlign (Elem Line 1582  static char *ParseCSSVerticalAlign (Elem
                                     PresentationContext context, char *cssRule,                                      PresentationContext context, char *cssRule,
                                     CSSInfoPtr css, ThotBool isHTML)                                      CSSInfoPtr css, ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1574  static char *ParseCSSWordSpacing (Elemen Line 1612  static char *ParseCSSWordSpacing (Elemen
                                   PresentationContext context, char *cssRule,                                    PresentationContext context, char *cssRule,
                                   CSSInfoPtr css, ThotBool isHTML)                                    CSSInfoPtr css, ThotBool isHTML)
 {  {
   cssRule = SkipValue (cssRule, FALSE);    cssRule = SkipValue (NULL, cssRule);
   return (cssRule);    return (cssRule);
 }  }
   
Line 1605  static char *ParseCSSLineHeight (Element Line 1643  static char *ParseCSSLineHeight (Element
     cssRule = ParseCSSUnit (cssRule, &pval);      cssRule = ParseCSSUnit (cssRule, &pval);
   
   if (pval.typed_data.unit == STYLE_UNIT_INVALID)    if (pval.typed_data.unit == STYLE_UNIT_INVALID)
     CSSParseError ("Invalid line-height value", ptr);      CSSParseError ("Invalid line-height value", ptr, cssRule);
   else if (DoApply)    else if (DoApply)
     {      {
       /* install the new presentation */        /* install the new presentation */
Line 1702  static char *ParseCSSFontSize (Element e Line 1740  static char *ParseCSSFontSize (Element e
        else         else
          ptr = NULL;           ptr = NULL;
        cssRule = ParseCSSUnit (cssRule, &pval);         cssRule = ParseCSSUnit (cssRule, &pval);
        if (pval.typed_data.unit == STYLE_UNIT_INVALID ||         if (pval.typed_data.value != 0 &&
            pval.typed_data.value < 0)             (pval.typed_data.unit == STYLE_UNIT_INVALID ||
               pval.typed_data.unit == STYLE_UNIT_BOX ||
               pval.typed_data.value < 0))
            /* not a valid value */
          return (cssRule);           return (cssRule);
        else if (pval.typed_data.unit == STYLE_UNIT_REL && pval.typed_data.value > 0)         else if (pval.typed_data.unit == STYLE_UNIT_REL && pval.typed_data.value > 0)
          /* CSS relative sizes have to be higher than Thot ones */           /* CSS relative sizes have to be higher than Thot ones */
Line 1711  static char *ParseCSSFontSize (Element e Line 1752  static char *ParseCSSFontSize (Element e
        else          else 
          {           {
            real = pval.typed_data.real;             real = pval.typed_data.real;
            if (pval.typed_data.unit == STYLE_UNIT_BOX)             if (pval.typed_data.unit == STYLE_UNIT_EM)
              pval.typed_data.unit = STYLE_UNIT_PX;  
            else if (pval.typed_data.unit == STYLE_UNIT_EM)  
              {               {
                if (real)                 if (real)
                  {                   {
Line 1743  static char *ParseCSSFontSize (Element e Line 1782  static char *ParseCSSFontSize (Element e
                pval.typed_data.unit = STYLE_UNIT_PERCENT;                 pval.typed_data.unit = STYLE_UNIT_PERCENT;
              }               }
          }           }
   
      }       }
   
    /* install the presentation style */     /* install the presentation style */
Line 1858  static char *ParseCSSFontFamily (Element Line 1896  static char *ParseCSSFontFamily (Element
       if (*cssRule == ',')        if (*cssRule == ',')
         {          {
           cssRule++;            cssRule++;
           cssRule = SkipValue (cssRule, FALSE);            cssRule = SkipValue (NULL, cssRule);
         }          }
        /* install the new presentation */         /* install the new presentation */
        if (DoApply)         if (DoApply)
Line 2123  static char *ParseCSSFont (Element eleme Line 2161  static char *ParseCSSFont (Element eleme
               cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);                cssRule = ParseCSSFontFamily (element, tsch, context, cssRule, css, isHTML);
             }              }
           if (ptr == cssRule)            if (ptr == cssRule)
             cssRule = SkipValue (cssRule, TRUE);              cssRule = SkipValue ("Invalid font value", cssRule);
           cssRule = SkipBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
         }          }
     }      }
Line 2140  static char *ParseCSSTextDecoration (Ele Line 2178  static char *ParseCSSTextDecoration (Ele
                                      CSSInfoPtr css, ThotBool isHTML)                                       CSSInfoPtr css, ThotBool isHTML)
 {  {
    PresentationValue   decor;     PresentationValue   decor;
      char               *ptr;
   
    decor.typed_data.value = 0;     decor.typed_data.value = 0;
    decor.typed_data.unit = STYLE_UNIT_REL;     decor.typed_data.unit = STYLE_UNIT_REL;
Line 2177  static char *ParseCSSTextDecoration (Ele Line 2216  static char *ParseCSSTextDecoration (Ele
      }       }
    else     else
      {       {
         CSSParseError ("Invalid text decoration", cssRule);         ptr = cssRule;
          cssRule = SkipWord (cssRule);
          CSSParseError ("Invalid text-decoration value", ptr, cssRule);
         return (cssRule);          return (cssRule);
      }       }
   
Line 2201  static char *ParseCSSHeight (Element ele Line 2242  static char *ParseCSSHeight (Element ele
                              CSSInfoPtr css, ThotBool isHTML)                               CSSInfoPtr css, ThotBool isHTML)
 {  {
   PresentationValue   val;    PresentationValue   val;
     char               *ptr;
   
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = cssRule;
   /* first parse the attribute string */    /* first parse the attribute string */
   if (!strncasecmp (cssRule, "auto", 4))    if (!strncasecmp (cssRule, "auto", 4))
     {      {
Line 2212  static char *ParseCSSHeight (Element ele Line 2255  static char *ParseCSSHeight (Element ele
       cssRule = SkipWord (cssRule);        cssRule = SkipWord (cssRule);
     }      }
   else    else
     {      cssRule = ParseCSSUnit (cssRule, &val);
       cssRule = ParseCSSUnit (cssRule, &val);    if (val.typed_data.value != 0 &&
       if (val.typed_data.unit == STYLE_UNIT_BOX)        (val.typed_data.unit == STYLE_UNIT_INVALID ||
         val.typed_data.unit = STYLE_UNIT_PX;         val.typed_data.unit == STYLE_UNIT_BOX))
     }      CSSParseError ("height value", ptr, cssRule);
   if (val.typed_data.unit != STYLE_UNIT_INVALID && DoApply)    else if (DoApply)
     {      {
       if (tsch)        if (tsch)
         cssRule = CheckImportantRule (cssRule, context);          cssRule = CheckImportantRule (cssRule, context);
Line 2236  static char *ParseCSSWidth (Element elem Line 2279  static char *ParseCSSWidth (Element elem
                               ThotBool isHTML)                                ThotBool isHTML)
 {  {
   PresentationValue   val;    PresentationValue   val;
     char               *ptr;
   
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = cssRule;
   /* first parse the attribute string */    /* first parse the attribute string */
   if (!strncasecmp (cssRule, "auto", 4))    if (!strncasecmp (cssRule, "auto", 4))
     {      {
Line 2247  static char *ParseCSSWidth (Element elem Line 2292  static char *ParseCSSWidth (Element elem
       cssRule = SkipWord (cssRule);        cssRule = SkipWord (cssRule);
     }      }
   else    else
     {  
       cssRule = ParseCSSUnit (cssRule, &val);        cssRule = ParseCSSUnit (cssRule, &val);
       if (val.typed_data.unit == STYLE_UNIT_BOX)    if (val.typed_data.value != 0 &&
         val.typed_data.unit = STYLE_UNIT_PX;        (val.typed_data.unit == STYLE_UNIT_INVALID ||
     }         val.typed_data.unit == STYLE_UNIT_BOX))
   if (val.typed_data.unit != STYLE_UNIT_INVALID && DoApply)      CSSParseError ("Invalid width value", ptr, cssRule);
     else if (DoApply)
     {      {
       if (tsch)        if (tsch)
         cssRule = CheckImportantRule (cssRule, context);          cssRule = CheckImportantRule (cssRule, context);
Line 2271  static char *ParseCSSMarginTop (Element Line 2316  static char *ParseCSSMarginTop (Element
                                   ThotBool isHTML)                                    ThotBool isHTML)
 {  {
   PresentationValue   margin;    PresentationValue   margin;
     char               *ptr;
       
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = cssRule;
   /* first parse the attribute string */    /* first parse the attribute string */
   if (!strncasecmp (cssRule, "auto", 4))    if (!strncasecmp (cssRule, "auto", 4))
     {      {
Line 2282  static char *ParseCSSMarginTop (Element Line 2329  static char *ParseCSSMarginTop (Element
       cssRule = SkipWord (cssRule);        cssRule = SkipWord (cssRule);
     }      }
   else    else
     {      cssRule = ParseCSSUnit (cssRule, &margin);
       cssRule = ParseCSSUnit (cssRule, &margin);    if (margin.typed_data.value != 0 &&
       if (margin.typed_data.unit == STYLE_UNIT_BOX)        (margin.typed_data.unit == STYLE_UNIT_INVALID ||
         margin.typed_data.unit = STYLE_UNIT_EM;         margin.typed_data.unit == STYLE_UNIT_BOX))
     }      CSSParseError ("Invalid top-margin value", ptr, cssRule);
   if (margin.typed_data.unit != STYLE_UNIT_INVALID && DoApply)    else if (DoApply)
      {       {
        if (tsch)         if (tsch)
          cssRule = CheckImportantRule (cssRule, context);           cssRule = CheckImportantRule (cssRule, context);
Line 2305  static char *ParseCSSMarginBottom (Eleme Line 2352  static char *ParseCSSMarginBottom (Eleme
                                      ThotBool isHTML)                                       ThotBool isHTML)
 {  {
   PresentationValue   margin;    PresentationValue   margin;
     char               *ptr;
       
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = cssRule;
   /* first parse the attribute string */    /* first parse the attribute string */
   if (!strncasecmp (cssRule, "auto", 4))    if (!strncasecmp (cssRule, "auto", 4))
     {      {
Line 2316  static char *ParseCSSMarginBottom (Eleme Line 2365  static char *ParseCSSMarginBottom (Eleme
       cssRule = SkipWord (cssRule);        cssRule = SkipWord (cssRule);
     }      }
   else    else
     {      cssRule = ParseCSSUnit (cssRule, &margin);
       cssRule = ParseCSSUnit (cssRule, &margin);    if (margin.typed_data.value != 0 &&
       if (margin.typed_data.unit == STYLE_UNIT_BOX)        (margin.typed_data.unit == STYLE_UNIT_INVALID ||
         margin.typed_data.unit = STYLE_UNIT_EM;         margin.typed_data.unit == STYLE_UNIT_BOX))
     }      CSSParseError ("Invalid bottom-margin value", ptr, cssRule);
   if (margin.typed_data.unit != STYLE_UNIT_INVALID && DoApply)    else if (DoApply)
      {       {
        if (tsch)         if (tsch)
          cssRule = CheckImportantRule (cssRule, context);           cssRule = CheckImportantRule (cssRule, context);
Line 2339  static char *ParseCSSMarginLeft (Element Line 2388  static char *ParseCSSMarginLeft (Element
                                    ThotBool isHTML)                                     ThotBool isHTML)
 {  {
   PresentationValue   margin;    PresentationValue   margin;
     char               *ptr;
       
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = cssRule;
   /* first parse the attribute string */    /* first parse the attribute string */
   if (!strncasecmp (cssRule, "auto", 4))    if (!strncasecmp (cssRule, "auto", 4))
     {      {
Line 2350  static char *ParseCSSMarginLeft (Element Line 2401  static char *ParseCSSMarginLeft (Element
       cssRule = SkipWord (cssRule);        cssRule = SkipWord (cssRule);
     }      }
   else    else
     {      cssRule = ParseCSSUnit (cssRule, &margin);
       cssRule = ParseCSSUnit (cssRule, &margin);    if (margin.typed_data.value != 0 &&
       if (margin.typed_data.unit == STYLE_UNIT_BOX)        (margin.typed_data.unit == STYLE_UNIT_INVALID ||
         margin.typed_data.unit = STYLE_UNIT_EM;         margin.typed_data.unit == STYLE_UNIT_BOX))
     }      CSSParseError ("Invalid left-margin value", ptr, cssRule);
     else if (DoApply)
   if (margin.typed_data.unit != STYLE_UNIT_INVALID && DoApply)    if (margin.typed_data.unit != STYLE_UNIT_INVALID && DoApply)
      {       {
        if (tsch)         if (tsch)
Line 2373  static char *ParseCSSMarginRight (Elemen Line 2425  static char *ParseCSSMarginRight (Elemen
                                     ThotBool isHTML)                                      ThotBool isHTML)
 {  {
   PresentationValue   margin;    PresentationValue   margin;
     char               *ptr;
       
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = cssRule;
   /* first parse the attribute string */    /* first parse the attribute string */
   if (!strncasecmp (cssRule, "auto", 4))    if (!strncasecmp (cssRule, "auto", 4))
     {      {
Line 2384  static char *ParseCSSMarginRight (Elemen Line 2438  static char *ParseCSSMarginRight (Elemen
       cssRule = SkipWord (cssRule);        cssRule = SkipWord (cssRule);
     }      }
   else    else
     {      cssRule = ParseCSSUnit (cssRule, &margin);
       cssRule = ParseCSSUnit (cssRule, &margin);    if (margin.typed_data.value != 0 &&
       if (margin.typed_data.unit == STYLE_UNIT_BOX)        (margin.typed_data.unit == STYLE_UNIT_INVALID ||
         margin.typed_data.unit = STYLE_UNIT_EM;         margin.typed_data.unit == STYLE_UNIT_BOX))
     }      CSSParseError ("Invalid right-margin value", ptr, cssRule);
   if (margin.typed_data.unit != STYLE_UNIT_INVALID && DoApply)    else if (DoApply)
      {       {
        if (tsch)         if (tsch)
          cssRule = CheckImportantRule (cssRule, context);           cssRule = CheckImportantRule (cssRule, context);
Line 2468  static char *ParseCSSPaddingTop (Element Line 2522  static char *ParseCSSPaddingTop (Element
                                    ThotBool isHTML)                                     ThotBool isHTML)
 {  {
   PresentationValue   padding;    PresentationValue   padding;
     char               *ptr;
       
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = 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_BOX)    if (padding.typed_data.value != 0 &&
     padding.typed_data.unit = STYLE_UNIT_EM;        (padding.typed_data.unit == STYLE_UNIT_INVALID ||
   if (padding.typed_data.unit != STYLE_UNIT_INVALID && DoApply)         padding.typed_data.unit == STYLE_UNIT_BOX))
       {
         CSSParseError ("Invalid top-padding value", ptr, cssRule);
         padding.typed_data.value = 0;
       }
     else if (DoApply)
      {       {
        if (tsch)         if (tsch)
          cssRule = CheckImportantRule (cssRule, context);           cssRule = CheckImportantRule (cssRule, context);
Line 2492  static char *ParseCSSPaddingBottom (Elem Line 2553  static char *ParseCSSPaddingBottom (Elem
                                       ThotBool isHTML)                                        ThotBool isHTML)
 {  {
   PresentationValue   padding;    PresentationValue   padding;
     char               *ptr;
       
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = 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_BOX)    if (padding.typed_data.value == 0)
     padding.typed_data.unit = STYLE_UNIT_EM;      padding.typed_data.unit = STYLE_UNIT_EM;
   if (padding.typed_data.unit != STYLE_UNIT_INVALID && DoApply)    if (padding.typed_data.value != 0 &&
         (padding.typed_data.unit == STYLE_UNIT_INVALID ||
          padding.typed_data.unit == STYLE_UNIT_BOX))
       {
         CSSParseError ("Invalid bottom-padding value", ptr, cssRule);
         padding.typed_data.value = 0;
       }
     else if (DoApply)
      {       {
        if (tsch)         if (tsch)
          cssRule = CheckImportantRule (cssRule, context);           cssRule = CheckImportantRule (cssRule, context);
Line 2516  static char *ParseCSSPaddingLeft (Elemen Line 2586  static char *ParseCSSPaddingLeft (Elemen
                                     ThotBool isHTML)                                      ThotBool isHTML)
 {  {
   PresentationValue   padding;    PresentationValue   padding;
     char               *ptr;
       
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = 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_BOX)    if (padding.typed_data.value == 0)
     padding.typed_data.unit = STYLE_UNIT_EM;      padding.typed_data.unit = STYLE_UNIT_EM;
   if (padding.typed_data.unit != STYLE_UNIT_INVALID && DoApply)    if (padding.typed_data.value != 0 &&
         (padding.typed_data.unit == STYLE_UNIT_INVALID ||
          padding.typed_data.unit == STYLE_UNIT_BOX))
       {
         CSSParseError ("Invalid left-padding value", ptr, cssRule);
         padding.typed_data.value = 0;
       }
     else if (DoApply)
     {      {
       if (tsch)        if (tsch)
         cssRule = CheckImportantRule (cssRule, context);          cssRule = CheckImportantRule (cssRule, context);
Line 2540  static char *ParseCSSPaddingRight (Eleme Line 2619  static char *ParseCSSPaddingRight (Eleme
                                      ThotBool isHTML)                                       ThotBool isHTML)
 {  {
   PresentationValue   padding;    PresentationValue   padding;
     char               *ptr;
       
   cssRule = SkipBlanksAndComments (cssRule);    cssRule = SkipBlanksAndComments (cssRule);
     ptr = 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_BOX)    if (padding.typed_data.value == 0)
     padding.typed_data.unit = STYLE_UNIT_EM;      padding.typed_data.unit = STYLE_UNIT_EM;
   if (padding.typed_data.unit != STYLE_UNIT_INVALID && DoApply)    if (padding.typed_data.value != 0 &&
         (padding.typed_data.unit == STYLE_UNIT_INVALID ||
          padding.typed_data.unit == STYLE_UNIT_BOX))
       {
         CSSParseError ("Invalid right-padding value", ptr, cssRule);
         padding.typed_data.value = 0;
       }
     else if (DoApply)
     {      {
       if (tsch)        if (tsch)
         cssRule = CheckImportantRule (cssRule, context);          cssRule = CheckImportantRule (cssRule, context);
Line 3513  static void  ParseCSSRule (Element eleme Line 3601  static void  ParseCSSRule (Element eleme
       if (*cssRule == '}')        if (*cssRule == '}')
         {          {
           cssRule++;            cssRule++;
           CSSParseError ("Invalid character", "}");            CSSPrintError ("Invalid character", "}");
           cssRule = SkipBlanksAndComments (cssRule);            cssRule = SkipBlanksAndComments (cssRule);
         }          }
       if (*cssRule == ',' ||        if (*cssRule == ',' ||
Line 4174  static char *ParseGenericSelector (char Line 4262  static char *ParseGenericSelector (char
             /* point to the class in sel[] if it's valid name */              /* point to the class in sel[] if it's valid name */
             if (deb[0] <= 64)              if (deb[0] <= 64)
               {                {
                 CSSParseError ("Invalid class", deb);                  CSSPrintError ("Invalid class", deb);
                 DoApply = FALSE;                  DoApply = FALSE;
               }                }
             else              else
Line 4195  static char *ParseGenericSelector (char Line 4283  static char *ParseGenericSelector (char
             /* point to the pseudoclass in sel[] if it's valid name */              /* point to the pseudoclass in sel[] if it's valid name */
             if (deb[0] <= 64)              if (deb[0] <= 64)
               {                {
                 CSSParseError ("Invalid pseudoclass", deb);                  CSSPrintError ("Invalid pseudoclass", deb);
                 DoApply = FALSE;                  DoApply = FALSE;
               }                }
             else              else
Line 4223  static char *ParseGenericSelector (char Line 4311  static char *ParseGenericSelector (char
             /* point to the attribute in sel[] if it's valid name */              /* point to the attribute in sel[] if it's valid name */
             if (deb[0] <= 64)              if (deb[0] <= 64)
               {                {
                 CSSParseError ("Invalid id", deb);                  CSSPrintError ("Invalid id", deb);
                 DoApply = FALSE;                  DoApply = FALSE;
               }                }
             else              else
Line 4258  static char *ParseGenericSelector (char Line 4346  static char *ParseGenericSelector (char
             /* point to the attribute in sel[] if it's valid name */              /* point to the attribute in sel[] if it's valid name */
             if (deb[0] <= 64)              if (deb[0] <= 64)
               {                {
                 CSSParseError ("Invalid attribute", deb);                  CSSPrintError ("Invalid attribute", deb);
                 DoApply = FALSE;                  DoApply = FALSE;
               }                }
             else              else
Line 4272  static char *ParseGenericSelector (char Line 4360  static char *ParseGenericSelector (char
                 selector++;                  selector++;
                 if (*selector != '"')                  if (*selector != '"')
                   {                    {
                     CSSParseError ("Invalid attribute value", deb);                      CSSPrintError ("Invalid attribute value", deb);
                     DoApply = FALSE;                      DoApply = FALSE;
                   }                    }
                 else                  else
Line 4284  static char *ParseGenericSelector (char Line 4372  static char *ParseGenericSelector (char
                       {                        {
                         if (*selector == EOS)                          if (*selector == EOS)
                           {                            {
                             CSSParseError ("Invalid attribute value", deb);                              CSSPrintError ("Invalid attribute value", deb);
                             DoApply = FALSE;                              DoApply = FALSE;
                           }                            }
                         else                          else
Line 4306  static char *ParseGenericSelector (char Line 4394  static char *ParseGenericSelector (char
             if (*selector != ']')              if (*selector != ']')
               {                {
                 selector[1] = EOS;                  selector[1] = EOS;
                 CSSParseError ("Not supported selector", selector);                  CSSPrintError ("Not supported selector", selector);
                 selector += 2;                  selector += 2;
                 DoApply = FALSE;                  DoApply = FALSE;
               }                }
Line 4322  static char *ParseGenericSelector (char Line 4410  static char *ParseGenericSelector (char
               *cur++ = *selector++;                *cur++ = *selector++;
             /* close the word */              /* close the word */
             *cur++ = EOS;              *cur++ = EOS;
             CSSParseError ("Not supported selector", deb);              CSSPrintError ("Not supported selector", deb);
             DoApply = FALSE;                      DoApply = FALSE;        
           }            }
       }        }
Line 4714  static void  ParseStyleDeclaration (Elem Line 4802  static void  ParseStyleDeclaration (Elem
     decl_end++;      decl_end++;
   if (*decl_end == EOS)    if (*decl_end == EOS)
     {      {
       CSSParseError ("Invalid selector", cssRule);        CSSPrintError ("Invalid selector", cssRule);
       return;        return;
     }      }
   /* verify and clean the selector string */    /* verify and clean the selector string */

Removed from v.1.167  
changed lines
  Added in v.1.168


Webmaster