[Tux4kids-commits] r1509 - tuxtype/trunk/src

Matthew Trey treymd-guest at alioth.debian.org
Thu Sep 10 21:17:55 UTC 2009


Author: treymd-guest
Date: 2009-09-10 21:17:55 +0000 (Thu, 10 Sep 2009)
New Revision: 1509

Modified:
   tuxtype/trunk/src/scripting.c
Log:
Bugfix in comment parsing code

Modified: tuxtype/trunk/src/scripting.c
===================================================================
--- tuxtype/trunk/src/scripting.c	2009-09-10 20:31:14 UTC (rev 1508)
+++ tuxtype/trunk/src/scripting.c	2009-09-10 21:17:55 UTC (rev 1509)
@@ -545,10 +545,12 @@
         do
         {
             // search the current line for comment end
-            for ( tmpStr = str; strlen(tmpStr) >= 3 && !found; ++tmpStr )
+            for ( tmpStr = str; strlen(tmpStr) >= 3 && !found; tmpStr++ )
             {    
                  if (strncmp("-->",tmpStr, 3) == 0)
                  {
+                     // move past the comment end tag
+                     tmpStr += 2;
                      found = 1;
                  }
             }
@@ -563,13 +565,12 @@
             // we did find the end of the comment
             else
             {
-                // move past the comment end tag
-                tmpStr += 3;
  
                 if (strlen(tmpStr) > 0)
                 {
                     // copy the rest of the line into str for processing
                     strncpy(str, tmpStr, strlen(tmpStr));
+                    str[strlen(tmpStr)] = '\0';
                 }
                 else
                 {
@@ -590,7 +591,7 @@
         /* -- if we reached the end of the file and saw no close to the comment, generate a warning -- */
         if ( !found && fscanf_result == EOF )
         {
-            fprintf(stderr, "XML Warning: End of file reached looking for the end of a comment.\n");
+            fprintf(stderr, "XML Warning: End of file reached looking for the end of a comment.\n", fn);
             break;
         }
 




More information about the Tux4kids-commits mailing list