Fixes more misery in function skipstr, where pointers were incremented
authorDavid van der Spoel <spoel@xray.bmc.uu.se>
Thu, 19 Aug 2010 20:20:00 +0000 (22:20 +0200)
committerDavid van der Spoel <spoel@xray.bmc.uu.se>
Thu, 19 Aug 2010 20:20:00 +0000 (22:20 +0200)
and then realloced. This had implications only for readin xpm files.

src/gmxlib/matio.c

index d27ffedd08d74be2ce9be2f03a6bc809db3e0159..68b65c76175e02cc8b23f8fb94e25cf4dbf6e769 100644 (file)
@@ -203,11 +203,21 @@ static char *fgetline(char **line,int llmax,int *llalloc,FILE *in)
   return fg;
 }
 
-void skipstr(char **line)
+void skipstr(char *line)
 {
-  ltrim(*line);
-  while((*line[0] != ' ') && (*line[0] != '\0'))
-    (*line)++;
+  int i,c;
+  
+  ltrim(line);
+  c=0;
+  while((line[c] != ' ') && (line[c] != '\0'))
+    c++;
+  i=c; 
+  while(line[c] != '\0')
+    {
+      line[c-i] = line[c];
+      c++;
+    }
+  line[i-c] = '\0';
 }
 
 char *line2string(char **line)
@@ -365,7 +375,7 @@ void read_xpm_entry(FILE *in,t_matrix *mm)
   do {
     if (strstr(line,"x-axis")) {
       line=strstr(line,"x-axis");
-      skipstr(&line);
+      skipstr(line);
       if (mm->axis_x==NULL)
        snew(mm->axis_x,mm->nx + 1);
       while (sscanf(line,"%lf",&u)==1) {
@@ -376,12 +386,12 @@ void read_xpm_entry(FILE *in,t_matrix *mm)
        }
        mm->axis_x[n_axis_x] = u;
        n_axis_x++;
-       skipstr(&line);
+       skipstr(line);
       }
     }
     else if (strstr(line,"y-axis")) {
       line=strstr(line,"y-axis");
-      skipstr(&line);
+      skipstr(line);
       if (mm->axis_y==NULL)
        snew(mm->axis_y,mm->ny + 1);
       while (sscanf(line,"%lf",&u)==1) {
@@ -392,7 +402,7 @@ void read_xpm_entry(FILE *in,t_matrix *mm)
        }
        mm->axis_y[n_axis_y] = u;
        n_axis_y++;
-       skipstr(&line);
+       skipstr(line);
       }
     }
   } while ((line[0] != '\"') && (NULL != fgetline(&line,llmax,&llalloc,in)));