diff: another bug in std_util.m

Tyson Dowd trd at cs.mu.OZ.AU
Thu Jun 11 22:43:41 AEST 1998


Hi,

Ahem, well...  lucky last?  Only bootcheck will tell.

===================================================================


Estimated hours taken: 0.5

Fix *another* bug in std_util.

library/std_util.m:
	ML_expand used data_value when it should have used data_word.
	For types such as ints and chars, it was giving the wrong values
	because the tag bits were removed.


Index: library/std_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/std_util.m,v
retrieving revision 1.122
diff -u -t -r1.122 std_util.m
--- std_util.m	1998/06/11 09:14:11	1.122
+++ std_util.m	1998/06/11 12:36:25
@@ -2315,7 +2315,7 @@
                 char buf[500];
                 char *str;
 
-                sprintf(buf, ""%ld"", (long) data_value);
+                sprintf(buf, ""%ld"", (long) data_word);
                 incr_saved_hp_atomic(LVALUE_CAST(Word, str), 
                     (strlen(buf) + sizeof(Word)) / sizeof(Word));
                 strcpy(str, buf);
@@ -2334,7 +2334,7 @@
 
                 incr_saved_hp_atomic(LVALUE_CAST(Word, str), 
                     (3 + sizeof(Word)) / sizeof(Word));
-                    sprintf(str, ""\'%c\'"", (char) data_value);
+                    sprintf(str, ""\'%c\'"", (char) data_word);
                 info->functor = str;
             }
             info->argument_vector = NULL;
@@ -2348,7 +2348,7 @@
                 Float f;
                 char *str;
 
-                f = word_to_float(data_value);
+                f = word_to_float(data_word);
                 sprintf(buf, ""%#.15g"", f);
                 incr_saved_hp_atomic(LVALUE_CAST(Word, str), 
                     (strlen(buf) + sizeof(Word)) / sizeof(Word));
@@ -2366,9 +2366,9 @@
                 char *str;
     
                 incr_saved_hp_atomic(LVALUE_CAST(Word, str),
-                    (strlen((String) data_value) + 2 + sizeof(Word))
+                    (strlen((String) data_word) + 2 + sizeof(Word))
                     / sizeof(Word));
-                sprintf(str, ""%c%s%c"", '""', (String) data_value, '""');
+                sprintf(str, ""%c%s%c"", '""', (String) data_word, '""');
                 info->functor = str;
             }
             info->argument_vector = NULL;
@@ -2391,8 +2391,8 @@
                  * type_info and data.
                  */
             ML_expand((Word *)
-                ((Word *) data_value)[UNIV_OFFSET_FOR_TYPEINFO], 
-                &((Word *) data_value)[UNIV_OFFSET_FOR_DATA], info);
+                ((Word *) data_word)[UNIV_OFFSET_FOR_TYPEINFO], 
+                &((Word *) data_word)[UNIV_OFFSET_FOR_DATA], info);
             break;
         case MR_DATAREP_VOID:
                     fatal_error(""ML_expand: cannot expand void types"");


-- 
       Tyson Dowd           # There isn't any reason why Linux can't be
                            # implemented as an enterprise computing solution.
     trd at cs.mu.oz.au        # Find out what you've been missing while you've
http://www.cs.mu.oz.au/~trd # been rebooting Windows NT. -- InfoWorld, 1998.



More information about the developers mailing list