comparison src/data.c @ 1995:4e6a63799f08

[xemacs-hg @ 2004-04-07 03:48:58 by james] Fix various ICC warnings and compilation errors.
author james
date Wed, 07 Apr 2004 03:49:00 +0000
parents cb7f3be19e9f
children cc5b615380f8
comparison
equal deleted inserted replaced
1994:cb7f3be19e9f 1995:4e6a63799f08
1235 BASE must be an integer between 2 and 16 (inclusive). 1235 BASE must be an integer between 2 and 16 (inclusive).
1236 Floating point numbers always use base 10. 1236 Floating point numbers always use base 10.
1237 */ 1237 */
1238 (string, base)) 1238 (string, base))
1239 { 1239 {
1240 char *p; 1240 Ibyte *p;
1241 int b; 1241 int b;
1242 1242
1243 CHECK_STRING (string); 1243 CHECK_STRING (string);
1244 1244
1245 if (NILP (base)) 1245 if (NILP (base))
1249 CHECK_INT (base); 1249 CHECK_INT (base);
1250 b = XINT (base); 1250 b = XINT (base);
1251 check_int_range (b, 2, 16); 1251 check_int_range (b, 2, 16);
1252 } 1252 }
1253 1253
1254 p = (char *) XSTRING_DATA (string); 1254 p = XSTRING_DATA (string);
1255 1255
1256 /* Skip any whitespace at the front of the number. Some versions of 1256 /* Skip any whitespace at the front of the number. Some versions of
1257 atoi do this anyway, so we might as well make Emacs lisp consistent. */ 1257 atoi do this anyway, so we might as well make Emacs lisp consistent. */
1258 while (*p == ' ' || *p == '\t') 1258 while (*p == ' ' || *p == '\t')
1259 p++; 1259 p++;
1260 1260
1261 if (isfloat_string (p) && b == 10) 1261 if (isfloat_string ((const char *) p) && b == 10)
1262 { 1262 {
1263 #ifdef HAVE_BIGFLOAT 1263 #ifdef HAVE_BIGFLOAT
1264 if (ZEROP (Vdefault_float_precision)) 1264 if (ZEROP (Vdefault_float_precision))
1265 #endif 1265 #endif
1266 return make_float (atof (p)); 1266 return make_float (atof ((const char *) p));
1267 #ifdef HAVE_BIGFLOAT 1267 #ifdef HAVE_BIGFLOAT
1268 else 1268 else
1269 { 1269 {
1270 bigfloat_set_prec (scratch_bigfloat, bigfloat_get_default_prec ()); 1270 bigfloat_set_prec (scratch_bigfloat, bigfloat_get_default_prec ());
1271 bigfloat_set_string (scratch_bigfloat, p, b); 1271 bigfloat_set_string (scratch_bigfloat, (const char *) p, b);
1272 return make_bigfloat_bf (scratch_bigfloat); 1272 return make_bigfloat_bf (scratch_bigfloat);
1273 } 1273 }
1274 #endif 1274 #endif
1275 } 1275 }
1276 1276
1277 #ifdef HAVE_RATIO 1277 #ifdef HAVE_RATIO
1278 if (qxestrchr (p, '/') != NULL) 1278 if (qxestrchr (p, '/') != NULL)
1279 { 1279 {
1280 ratio_set_string (scratch_ratio, p, b); 1280 ratio_set_string (scratch_ratio, (const char *) p, b);
1281 return make_ratio_rt (scratch_ratio); 1281 return make_ratio_rt (scratch_ratio);
1282 } 1282 }
1283 #endif /* HAVE_RATIO */ 1283 #endif /* HAVE_RATIO */
1284 1284
1285 #ifdef HAVE_BIGNUM 1285 #ifdef HAVE_BIGNUM
1286 /* GMP bignum_set_string returns random values when fed an empty string */ 1286 /* GMP bignum_set_string returns random values when fed an empty string */
1287 if (*p == '\0') 1287 if (*p == '\0')
1288 return make_int (0); 1288 return make_int (0);
1289 bignum_set_string (scratch_bignum, p, b); 1289 bignum_set_string (scratch_bignum, (const char *) p, b);
1290 return Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 1290 return Fcanonicalize_number (make_bignum_bg (scratch_bignum));
1291 #else 1291 #else
1292 if (b == 10) 1292 if (b == 10)
1293 { 1293 {
1294 /* Use the system-provided functions for base 10. */ 1294 /* Use the system-provided functions for base 10. */
1793 args[0] = make_int (XCHAR (args[0])); 1793 args[0] = make_int (XCHAR (args[0]));
1794 else if (MARKERP (args[0])) 1794 else if (MARKERP (args[0]))
1795 args[0] = make_int (marker_position (args[0])); 1795 args[0] = make_int (marker_position (args[0]));
1796 for (i = 1; i < nargs; i++) 1796 for (i = 1; i < nargs; i++)
1797 { 1797 {
1798 retry:
1799 comp1 = args[maxindex]; 1798 comp1 = args[maxindex];
1800 comp2 = args[i]; 1799 comp2 = args[i];
1801 switch (promote_args (&comp1, &comp2)) 1800 switch (promote_args (&comp1, &comp2))
1802 { 1801 {
1803 case FIXNUM_T: 1802 case FIXNUM_T:
1990 for (i = 1; i < nargs; i++) 1989 for (i = 1; i < nargs; i++)
1991 { 1990 {
1992 while (!(CHARP (args[i]) || MARKERP (args[i]) || INTEGERP (args[i]))) 1991 while (!(CHARP (args[i]) || MARKERP (args[i]) || INTEGERP (args[i])))
1993 args[i] = wrong_type_argument (Qnumber_char_or_marker_p, args[i]); 1992 args[i] = wrong_type_argument (Qnumber_char_or_marker_p, args[i]);
1994 other = args[i]; 1993 other = args[i];
1995 switch (promote_args (&result & &other)) 1994 switch (promote_args (&result, &other))
1996 { 1995 {
1997 case FIXNUM_T: 1996 case FIXNUM_T:
1998 result = make_int (XREALINT (result), XREALINT (other)); 1997 result = make_int (XREALINT (result) & XREALINT (other));
1999 break; 1998 break;
2000 case BIGNUM_T: 1999 case BIGNUM_T:
2001 bignum_and (scratch_bignum, XBIGNUM_DATA (result), 2000 bignum_and (scratch_bignum, XBIGNUM_DATA (result),
2002 XBIGNUM_DATA (other)); 2001 XBIGNUM_DATA (other));
2003 result = make_bignum_bg (scratch_bignum); 2002 result = make_bignum_bg (scratch_bignum);