Fix two bugs: (1) `unsigned-integer->bit-string' was not clearing out
authorChris Hanson <org/chris-hanson/cph>
Sat, 9 May 1987 04:51:32 +0000 (04:51 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sat, 9 May 1987 04:51:32 +0000 (04:51 +0000)
those parts of the result which were not filled in by copying from a
bignum.  (2) `bit-substring-find-next-set-bit' was not correctly
advancing the scan pointer for the last word of a multi-word string.

v7/src/microcode/bitstr.c
v7/src/microcode/version.h
v8/src/microcode/version.h

index 3f7f30830958aba62b7054187a1cac40c8fb5481..35b1e91dd157ea0b668989df6da1cdc8d366d2dc 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/bitstr.c,v 9.26 1987/04/25 20:25:54 cph Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/bitstr.c,v 9.27 1987/05/09 04:50:56 cph Exp $
 
    Bit string primitives. */
 \f
@@ -186,7 +186,7 @@ Built_In_Primitive (Prim_bit_string_length, 1, "BIT-STRING-LENGTH", 0xD4)
     Primitive_Error (ERR_ARG_2_BAD_RANGE);                     \
                                                                \
   word = (index_to_word (Arg1, index));                                \
-  mask = (1 << (index % POINTER_LENGTH));
+  mask = (1 << (index % POINTER_LENGTH))
 
 /* (BIT-STRING-REF bit-string index)
    Returns the boolean value of the indexed bit. */
@@ -657,36 +657,40 @@ long_to_bit_string( length, number)
 }
 \f
 Pointer
-bignum_to_bit_stringlength, bignum)
+bignum_to_bit_string (length, bignum)
      long length;
      Pointer bignum;
 {
   bigdigit *bigptr;
   long ndigits;
 
-  bigptr = BIGNUM( Get_Pointer( bignum));
-  if (NEG_BIGNUMbigptr))
-    Primitive_ErrorERR_ARG_2_BAD_RANGE);
-  ndigits = LEN( bigptr);
+  bigptr = (BIGNUM (Get_Pointer (bignum)));
+  if (NEG_BIGNUM (bigptr))
+    Primitive_Error (ERR_ARG_2_BAD_RANGE);
+  ndigits = (LEN (bigptr));
   if (ndigits == 0)
-    zero_to_bit_stringlength);
+    zero_to_bit_string (length);
   else
     {
       if (length <
-         (count_significant_bits( *(Bignum_Top( bigptr)), SHIFT)
+         (count_significant_bits ((*(Bignum_Top (bigptr))), SHIFT)
           + (SHIFT * (ndigits - 1))))
-       Primitive_ErrorERR_ARG_2_BAD_RANGE)
+       Primitive_Error (ERR_ARG_2_BAD_RANGE)
       else
        {
          Pointer result;
          bigdigit *scan1, *scan2;
+         long extra;
 
-         result = allocate_bit_string( length);
-         scan1 = Bignum_Bottom( bigptr);
-         scan2 = ((bigdigit *) bit_string_end_ptr( result));
+         result = (allocate_bit_string (length));
+         scan1 = (Bignum_Bottom (bigptr));
+         scan2 = ((bigdigit *) (bit_string_end_ptr (result)));
+         extra = (((length + (SHIFT - 1)) / SHIFT) - ndigits);
          for (; (ndigits > 0); ndigits -= 1)
            *--scan2 = *scan1++;
-         return result;
+         for (; (extra > 0); extra -= 1)
+           *--scan2 = 0;
+         return (result);
        }
     }
 }
@@ -861,16 +865,15 @@ Built_In_Primitive (Prim_bit_substring_find_next_set_bit, 3,
        find_next_set_loop (bit);
       return (NIL);
     }
-  else if (((bit == 0) && *scan)
-          || (*scan & (any_mask ((POINTER_LENGTH - bit), bit))))
+  else if (*scan &
+          ((bit == 0) ? ~0 : (any_mask ((POINTER_LENGTH - bit), bit))))
     find_next_set_loop (bit);
 
   while (--word > end_word)
     if (*--scan)
       find_next_set_loop (0);
 
-  if (((end_bit == POINTER_LENGTH) && *scan)
-      || (*--scan & (low_mask (end_bit))))
+  if (*--scan & ((end_bit == POINTER_LENGTH) ? ~0 : (low_mask (end_bit))))
     find_next_set_loop (0);
 
   return (NIL);
index 31ff117e83d2f2938b7358c7f74e88b3174a52e4..0b35296bdf59557ef761c94784fd1cb64515e73d 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 9.48 1987/04/30 22:56:49 cph Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 9.49 1987/05/09 04:51:32 cph Exp $
 
 This file contains version information for the microcode. */
 \f
@@ -46,7 +46,7 @@ This file contains version information for the microcode. */
 #define VERSION                9
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     48
+#define SUBVERSION     49
 #endif
 
 #ifndef UCODE_TABLES_FILENAME
index 0d2ff74dda48be495da38f0852055da1fedb62c9..3e6b6f01977f85a743d0fee06f074f20081249d0 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 9.48 1987/04/30 22:56:49 cph Exp $
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 9.49 1987/05/09 04:51:32 cph Exp $
 
 This file contains version information for the microcode. */
 \f
@@ -46,7 +46,7 @@ This file contains version information for the microcode. */
 #define VERSION                9
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     48
+#define SUBVERSION     49
 #endif
 
 #ifndef UCODE_TABLES_FILENAME