changeset 5910:eb1e15c9440b

Be less misleading in errors, data.c src/ChangeLog addition: 2015-05-09 Aidan Kehoe <kehoea@parhasard.net> * data.c (Flogand): * data.c (Flogior): * data.c (Frem): * data.c (Flsh): Give less misleading errors in all these functions, e.g. supplying #'integer-char-or-marker as the predicate on wrong-type-argument, when float would not be accepted.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 09 May 2015 10:50:32 +0100
parents d138e600aa3a
children 48386fd60fd0
files src/ChangeLog src/data.c
diffstat 2 files changed, 32 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat May 09 01:23:45 2015 +0100
+++ b/src/ChangeLog	Sat May 09 10:50:32 2015 +0100
@@ -1,3 +1,13 @@
+2015-05-09  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* data.c (Flogand):
+	* data.c (Flogior):
+	* data.c (Frem):
+	* data.c (Flsh):
+	Give less misleading errors in all these functions, e.g. supplying
+	#'integer-char-or-marker as the predicate on wrong-type-argument,
+	when float would not be accepted.
+
 2015-05-09  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* lread.c (read_rational):
--- a/src/data.c	Sat May 09 01:23:45 2015 +0100
+++ b/src/data.c	Sat May 09 10:50:32 2015 +0100
@@ -2695,7 +2695,7 @@
     return make_fixnum (~0);
 
   while (!(CHARP (args[0]) || MARKERP (args[0]) || INTEGERP (args[0])))
-    args[0] = wrong_type_argument (Qnumber_char_or_marker_p, args[0]);
+    args[0] = wrong_type_argument (Qinteger_char_or_marker_p, args[0]);
 
   result = args[0];
   if (CHARP (result))
@@ -2705,7 +2705,7 @@
   for (i = 1; i < nargs; i++)
     {
       while (!(CHARP (args[i]) || MARKERP (args[i]) || INTEGERP (args[i])))
-	args[i] = wrong_type_argument (Qnumber_char_or_marker_p, args[i]);
+	args[i] = wrong_type_argument (Qinteger_char_or_marker_p, args[i]);
       other = args[i];
       switch (promote_args (&result, &other))
 	{
@@ -2747,7 +2747,7 @@
     return make_fixnum (0);
 
   while (!(CHARP (args[0]) || MARKERP (args[0]) || INTEGERP (args[0])))
-    args[0] = wrong_type_argument (Qnumber_char_or_marker_p, args[0]);
+    args[0] = wrong_type_argument (Qinteger_char_or_marker_p, args[0]);
 
   result = args[0];
   if (CHARP (result))
@@ -2757,7 +2757,7 @@
   for (i = 1; i < nargs; i++)
     {
       while (!(CHARP (args[i]) || MARKERP (args[i]) || INTEGERP (args[i])))
-	args[i] = wrong_type_argument (Qnumber_char_or_marker_p, args[i]);
+	args[i] = wrong_type_argument (Qinteger_char_or_marker_p, args[i]);
       other = args[i];
       switch (promote_args (&result, &other))
 	{
@@ -2862,9 +2862,9 @@
 {
 #ifdef HAVE_BIGNUM
   while (!(CHARP (number1) || MARKERP (number1) || INTEGERP (number1)))
-    number1 = wrong_type_argument (Qnumber_char_or_marker_p, number1);
+    number1 = wrong_type_argument (Qinteger_char_or_marker_p, number1);
   while (!(CHARP (number2) || MARKERP (number2) || INTEGERP (number2)))
-    number2 = wrong_type_argument (Qnumber_char_or_marker_p, number2);
+    number2 = wrong_type_argument (Qinteger_char_or_marker_p, number2);
 
   if (promote_args (&number1, &number2) == FIXNUM_T)
     {
@@ -3033,7 +3033,7 @@
 {
 #ifdef HAVE_BIGNUM
   while (!(CHARP (value) || MARKERP (value) || INTEGERP (value)))
-    wrong_type_argument (Qnumber_char_or_marker_p, value);
+    wrong_type_argument (Qinteger_char_or_marker_p, value);
   CONCHECK_INTEGER (count);
 
   if (promote_args (&value, &count) == FIXNUM_T)
@@ -3050,15 +3050,28 @@
       if (bignum_sign (XBIGNUM_DATA (count)) <= 0)
 	{
 	  bignum_neg (scratch_bignum, XBIGNUM_DATA (count));
+          /* Sigh, this won't catch all overflows in the MPZ type under GMP,
+             and there's no way to hook into the library so that an overflow
+             errors rather than aborting. See
+             http://mid.gmane.org/5529.2096.e5823.ccba@parhasard.net . */
 	  if (!bignum_fits_ulong_p (scratch_bignum))
-	    args_out_of_range (Qnumber_char_or_marker_p, count);
+            {
+              args_out_of_range_3 (count,
+				   make_bignum_ll (- (long long)(ULONG_MAX)),
+                                   make_bignum_ll (ULONG_MAX));
+            }
 	  bignum_rshift (scratch_bignum2, XBIGNUM_DATA (value),
 			 bignum_to_ulong (scratch_bignum));
 	}
       else
 	{
+          /* See above re overflow. */
 	  if (!bignum_fits_ulong_p (XBIGNUM_DATA (count)))
-	    args_out_of_range (Qnumber_char_or_marker_p, count);
+            {
+              args_out_of_range_3 (count,
+				   make_bignum_ll (- (long long) (ULONG_MAX)),
+                                   make_bignum_ll (ULONG_MAX));
+            }
 	  bignum_lshift (scratch_bignum2, XBIGNUM_DATA (value),
 			 bignum_to_ulong (XBIGNUM_DATA (count)));
 	}