]> granicus.if.org Git - imagemagick/commitdiff
Improve MVG macro parser
authorCristy <urban-warrior@imagemagick.org>
Sun, 22 Jul 2018 23:55:56 +0000 (19:55 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sun, 22 Jul 2018 23:55:56 +0000 (19:55 -0400)
MagickCore/draw.c
coders/svg.c

index 8884f64935057bbd95f79abaed63098b82dc3e7f..d3cde469e092f14ceef245fd156c3a1ba07a2780 100644 (file)
@@ -2261,15 +2261,6 @@ static SplayTreeInfo *GetMVGMacros(const char *primitive)
     GetNextToken(q,&q,extent,token);
     if (*token == '\0')
       break;
-    if (*token == '#')
-      {
-        /*
-          Skip comment.
-        */
-        while ((*q != '\n') && (*q != '\0'))
-          q++;
-        continue;
-      }
     if (LocaleCompare("push",token) == 0)
       {
         register const char
@@ -2295,21 +2286,12 @@ static SplayTreeInfo *GetMVGMacros(const char *primitive)
             start=q;
             end=q;
             (void) CopyMagickString(name,token,MagickPathExtent);
-            n=0;
-            for (p=q; *q != '\0'; )
+            n=1;
+            for (p=q; *p != '\0'; )
             {
               GetNextToken(p,&p,extent,token);
               if (*token == '\0')
                 break;
-              if (*token == '#')
-                {
-                  /*
-                    Skip comment.
-                  */
-                  while ((*p != '\n') && (*p != '\0'))
-                    p++;
-                  continue;
-                }
               if (LocaleCompare(token,"pop") == 0)
                 {
                   end=p-strlen(token)-1;
@@ -2317,7 +2299,7 @@ static SplayTreeInfo *GetMVGMacros(const char *primitive)
                 }
               if (LocaleCompare(token,"push") == 0)
                 n++;
-              if ((n < 0) && (end > start))
+              if ((n == 0) && (end > start))
                 {
                   char
                     *macro;
index bc0b21446dbdbf5330617aa46b82178eb80610bd..4505bb48325e31b43eae4edd640ab0b0440ae517 100644 (file)
@@ -2664,8 +2664,6 @@ static void SVGEndElement(void *context,const xmlChar *name)
             SVGProcessStyleElement(context,name,value);
             (void) FormatLocaleFile(svg_info->file,"pop class\n");
           }
-          (void) FormatLocaleFile(svg_info->file,"push class \"\"\n");
-          (void) FormatLocaleFile(svg_info->file,"pop class\n");
           break;
         }
       if (LocaleCompare((const char *) name,"svg") == 0)