Re: bug report: crm114 'eval' throws error depending on *value* being 'eval'-ed (demo script included)

Paolo <[email protected]>
Newsgroups gmane.mail.spam.crm114
Message-ID <20081006214315.GL26719@localhost>
On Sat, Oct 04, 2008 at 02:48:10AM +0200, Ger Hobbelt wrote:
> Ladies & Gentlemen,
> 
> eval b0rks on empty value: run this demo script to see what I mean:
> 

yep. Attached diff seems to do the trick. FWIF it passes megatest.
The important stuff is just the test  'if (itercount == 1)', but I've
augumented the trace part, and long -> int isn't important here.

-- 
paolo

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Crm114-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crm114-general
crm_expr_alter.c.diff (text/plain, 1.9 KB)
--- crm_expr_alter.c.old	Sat Oct  4 23:31:30 2008
+++ crm_expr_alter.c	Mon Oct  6 22:58:05 2008
@@ -52,11 +52,11 @@
   long newvallen;
   unsigned long long ihash;
   unsigned long long ahash [MAX_EVAL_ITERATIONS];
-  long ahindex;
-  long itercount;
-  long loop_abort;
+  int ahindex;
+  int itercount;
+  int loop_abort;
   long qex_stat;
-  long has_output_var;
+  int has_output_var;
   // should use tempbuf for this instead.
   //   char newstr [MAX_PATTERN];
   if (user_trace)
@@ -119,19 +119,29 @@
       //
       if (newvallen > 3) 
 	ihash = (ihash << 30) + strnhash (&tempbuf[1], newvallen - 2); 
-      if (internal_trace)
-	fprintf (stderr, "Eval ihash = %lld\n", ihash);
-      for (i = 0;  i < itercount; i++)
-	if (ahash[i] == ihash)
-	  {
-	    loop_abort = 1;
-	    if ( i != itercount - 1)
-	      loop_abort = 2;
-	  };
+      if (internal_trace) {
+	fprintf (stderr, 
+	  "Eval ihash = %lld, newvallen=%ld, itercount=%d\n", 
+	  ihash, newvallen, itercount);
+	for (i = 0;  i < itercount; i++)
+	  fprintf (stderr,"  ahash[%d]=%lld\n", i, ahash[i]);
+      }
+      if (itercount == 1)
+        i = 0;
+      else
+        for (i = 0;  i < itercount; i++)
+	  if (ahash[i] == ihash)
+	    {
+	      loop_abort = 1;
+	      if ( i != itercount - 1)
+	        loop_abort = 2;
+	    };
       ahash[i] = ihash;
       newvallen = crm_qexpandvar (tempbuf, newvallen, 
 				  data_window_size, &qex_stat );
     };
+  if (internal_trace)
+    fprintf (stderr, "Eval: loop_abort=%d\n", loop_abort);
    
   if (itercount == MAX_EVAL_ITERATIONS )
     {
@@ -143,7 +153,7 @@
     }
   if (loop_abort == 2)
     {
-      nonfatalerror5 ("The variable you're attempting to EVAL seemes to return "
+      nonfatalerror5 ("The variable you're attempting to EVAL seems to return "
 		     "to the same value after a number of iterations, "
 		     "so it is probably an "
 		     "infinite loop.  I think I should give up.  I got this "
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.