]> skyeroc.xyz Git - dgamelaunch/commitdiff
Here's a better fix
authorJoshua Kwan <joshk@triplehelix.org>
Tue, 6 Jan 2004 02:08:53 +0000 (02:08 +0000)
committerJoshua Kwan <joshk@triplehelix.org>
Tue, 6 Jan 2004 02:08:53 +0000 (02:08 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@100 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

dgamelaunch.c

index 8e76fd1985e4e796cc69bb7d754ba0d94b40076f..2529d9cf85d9c53b4c4f20a6ff90edbf80471a1f 100644 (file)
@@ -274,36 +274,41 @@ loadbanner (struct dg_banner *ban)
 
   while (fgets (buf, 80, bannerfile) != NULL)
     {
-      char *loc;
+      char *loc, *b = buf;
+      char bufnew[80];
+      
+      memset (bufnew, 0, 80);
 
       ban->len++;
       ban->lines = realloc (ban->lines, sizeof (char *) * ban->len);
 
-      if ((loc = strstr (buf, "$VERSION")) != NULL)
-        {
-          char bufnew[80];
-          char *b = buf;
-          int i;
-
-          memset (bufnew, 0, 80);
-
-          for (i = 0; i < 80; i++)
+      if (strstr(b, "$VERSION"))
+      {
+       int i = 0; 
+       while ((loc = strstr (b, "$VERSION")) != NULL)
+       {
+          for (; i < 80; i++)
             {
               if (loc != b)
                 bufnew[i] = *(b++);
               else
                 {
-                  strlcat (bufnew, VERSION, 80 - i);
+                  strlcat (bufnew, VERSION, 80);
                   b += 8;       /* skip the whole $VERSION string */
-                  i += ARRAY_SIZE (VERSION) - 2;
+                  i += ARRAY_SIZE (VERSION) - 1;
+                 break;
                 }
 
               if (strlen (b) == 0)
                 break;
-            }
-
-          ban->lines[ban->len - 1] = strdup (bufnew);
-        }
+           }
+       }
+        
+       if (*b)
+         strlcat(bufnew, b, 80);
+       
+       ban->lines[ban->len - 1] = strdup (bufnew);
+      }
       else
         ban->lines[ban->len - 1] = strdup (buf);