[LON-CAPA-cvs] cvs: capa /capa51/pProj capaParserUtils.c

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 23 Jan 2007 07:53:17 -0000


albertel		Tue Jan 23 02:53:17 2007 EDT

  Modified files:              
    /capa/capa51/pProj	capaParserUtils.c 
  Log:
  - last of BUG4751, parsing of pts_list was not handling specific numbers
    intermixed with ranges well, and didn't handle trailing ; correctly
  
  
Index: capa/capa51/pProj/capaParserUtils.c
diff -u capa/capa51/pProj/capaParserUtils.c:1.19 capa/capa51/pProj/capaParserUtils.c:1.20
--- capa/capa51/pProj/capaParserUtils.c:1.19	Tue Jan 23 02:10:14 2007
+++ capa/capa51/pProj/capaParserUtils.c	Tue Jan 23 02:53:16 2007
@@ -1527,6 +1527,7 @@
   double     tmp_farray[ONE_K];
   double    *f_array;
   
+  *f_ar = NULL;
   if (n_str == NULL) {
     return (0);
   }
@@ -1880,15 +1881,22 @@
 PointsList_t *
 gen_ptslist_str( range_str ) char *range_str;
 {
-  char         *colon, *pound, *cp;
+  char         *semicolon, *colon, *pound, *cp;
   char          p1[ONE_K], p2[ONE_K], num[ONE_K];
   int           i, pts_cnt;
   PointsList_t *ptp;
   
   ptp = NULL;
-  colon = strchr(range_str,':');
-  pound = strchr(range_str,'#');
-  if( (colon) && (pound)) { /* we must have both ':' and '#' */
+  semicolon = strchr(range_str,';');
+  colon     = strchr(range_str,':');
+  pound     = strchr(range_str,'#');
+  if( (colon) 
+      && (pound) 
+      && (!semicolon 
+	  || ( 
+	      (colon < semicolon)
+	      && (pound < semicolon) ))) { 
+    /* we must have both ':' and '#' and they both must occur before any ';' */
     cp = range_str;
     i  = 0;
     while( isspace(*cp) || (*cp == '"') ) { cp++; }
@@ -1918,10 +1926,12 @@
       p1[i++] =  *cp; cp++;
     }
     p1[i] = 0;
-    ptp = (PointsList_t *)capa_malloc(1,sizeof(PointsList_t)); /* *** */
-    ptp->pts_str   = strsave(p1);
-    ptp->pts_idx   = 1;
-    ptp->pts_next  = NULL;
+    if (i != 0) {
+      ptp = (PointsList_t *)capa_malloc(1,sizeof(PointsList_t)); /* *** */
+      ptp->pts_str   = strsave(p1);
+      ptp->pts_idx   = 1;
+      ptp->pts_next  = NULL;
+    }
   }
   return (ptp);
 }