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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 01 Dec 2005 21:11:43 -0000


albertel		Thu Dec  1 16:11:43 2005 EDT

  Modified files:              
    /capa/capa51/pProj	capaParserUtils.c 
  Log:
  - handle the case of no sample points being defined  more correctly
  
  
Index: capa/capa51/pProj/capaParserUtils.c
diff -u capa/capa51/pProj/capaParserUtils.c:1.16 capa/capa51/pProj/capaParserUtils.c:1.17
--- capa/capa51/pProj/capaParserUtils.c:1.16	Fri Jun  1 13:43:25 2001
+++ capa/capa51/pProj/capaParserUtils.c	Thu Dec  1 16:11:41 2005
@@ -1398,7 +1398,7 @@
   }
   capa_mfree((char *)v_ar);
   if( error == 1 ) {
-    return (0);
+    return (-1);
   } else {
     return (v_cnt);
   }
@@ -1473,14 +1473,14 @@
 int
 f_eval_formula(f_val, f_str, v_str, pt_str) double *f_val;char *f_str;char *v_str; char *pt_str;
 {
-  int  no_error;
+  int  var_cnt;
   
   /* before setup formula symbol tree, make sure it is clean */
   
-  no_error = setup_formula_id(v_str,pt_str);
-  /* printf("\nSETUP formula ID (%s),(%s) returned %d\n",v_str,pt_str,no_error); */
+  var_cnt = setup_formula_id(v_str,pt_str);
+  /* printf("\nSETUP formula ID (%s),(%s) returned %d\n",v_str,pt_str,var_cnt); */
   /* copy the formula into lexer buffer */
-  if( no_error ) {
+  if( var_cnt > -1 ) {
     strcpy(Fbuf,f_str);
     Fidx = 0;
     FormulaParseOK = 1;
@@ -1517,7 +1517,10 @@
   double     tmp_farray[ONE_K];
   double    *f_array;
   
-  
+  if (n_str == NULL) {
+    return (0);
+  }
+
   leng = strlen(n_str);
   if( leng > 0 ) {
     for( i=0; i<leng;i++) {
@@ -1571,6 +1574,10 @@
   char       v_str[ONE_K];
   char     **tmp_array;
   
+  if (n_str == NULL) {
+    return (0);
+  }
+
   leng = strlen(n_str);
   if( leng > 0 ) {
     for( i=0; i<leng;i++) {