1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

* Avoid redundant casting of argument numbers to char* and vice versa.

This commit is contained in:
Dirk Herrmann 2001-04-10 07:57:05 +00:00
parent 40f83c3e1b
commit e4b265d817
15 changed files with 87 additions and 61 deletions

View file

@ -1,3 +1,26 @@
2001-04-10 Dirk Herrmann <D.Herrmann@tu-bs.de>
* numbers.[ch] (scm_num2long, scm_num2long_long,
scm_num2ulong_long, scm_num2ulong): Argument position is an
unsigned integer.
* environments.c (eval_environment_folder,
import_environment_folder), gh_data.c (gh_scm2longs,
gh_scm2floats, gh_scm2doubles): Distinguish between 0 and NULL
for integers and pointers, respectively.
* gh_data.c (gh_scm2ulong, gh_scm2long, gh_scm2int), socket.c
(scm_fill_sockaddr), unif.c (scm_array_set_x), validate.h
(SCM_NUM2ULONG, SCM_NUM2LONG, SCM_NUM2LONG_DEF,
SCM_NUM2LONG_LONG): Don't pass argument positions as pointers.
* filesys.c (scm_open_fdes, scm_open), net_db (scm_inet_ntoa,
scm_inet_netof, scm_lnaof, scm_gethost, scm_getproto), posix.c
(scm_utime), ramap.c (scm_array_fill_int), scmsigs.c
(scm_sigaction), socket.c (scm_htonl, scm_ntohl, scm_sendto),
stime.c (scm_localtime, scm_gmtime), struct.c (scm_struct_set_x),
validate.h (SCM_VALIDATE_LONG_COPY): Whitespace fixes.
2001-04-09 Neil Jerram <neil@ossau.uklinux.net>
* strings.c (scm_read_only_string_p): Update docstring to reflect

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
/* Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1246,7 +1246,7 @@ eval_environment_folder (SCM extended_data, SCM symbol, SCM value, SCM tail)
if (!SCM_ENVIRONMENT_BOUND_P (local, symbol))
{
SCM proc_as_nr = SCM_CADR (extended_data);
unsigned long int proc_as_ul = scm_num2ulong (proc_as_nr, NULL, NULL);
unsigned long int proc_as_ul = scm_num2ulong (proc_as_nr, 0, NULL);
scm_environment_folder proc = (scm_environment_folder) proc_as_ul;
SCM data = SCM_CDDR (extended_data);
@ -1652,7 +1652,7 @@ import_environment_folder (SCM extended_data, SCM symbol, SCM value, SCM tail)
SCM imported_env = SCM_CADR (extended_data);
SCM owner = import_environment_lookup (import_env, symbol);
SCM proc_as_nr = SCM_CADDR (extended_data);
unsigned long int proc_as_ul = scm_num2ulong (proc_as_nr, NULL, NULL);
unsigned long int proc_as_ul = scm_num2ulong (proc_as_nr, 0, NULL);
scm_environment_folder proc = (scm_environment_folder) proc_as_ul;
SCM data = SCM_CDDDR (extended_data);

View file

@ -229,18 +229,18 @@ gh_scm2bool (SCM obj)
unsigned long
gh_scm2ulong (SCM obj)
{
return scm_num2ulong (obj, (char *) SCM_ARG1, "gh_scm2ulong");
return scm_num2ulong (obj, SCM_ARG1, "gh_scm2ulong");
}
long
gh_scm2long (SCM obj)
{
return scm_num2long (obj, (char *) SCM_ARG1, "gh_scm2long");
return scm_num2long (obj, SCM_ARG1, "gh_scm2long");
}
int
gh_scm2int (SCM obj)
{
/* NOTE: possible loss of precision here */
return (int) scm_num2long (obj, (char *) SCM_ARG1, "gh_scm2int");
return (int) scm_num2long (obj, SCM_ARG1, "gh_scm2int");
}
double
gh_scm2double (SCM obj)
@ -395,7 +395,9 @@ gh_scm2longs (SCM obj, long *m)
for (i = 0; i < n; ++i)
{
val = SCM_VELTS (obj)[i];
m[i] = SCM_INUMP (val) ? SCM_INUM (val) : scm_num2long (val, 0, 0);
m[i] = SCM_INUMP (val)
? SCM_INUM (val)
: scm_num2long (val, 0, NULL);
}
break;
#ifdef HAVE_ARRAYS
@ -447,7 +449,7 @@ gh_scm2floats (SCM obj, float *m)
if (SCM_INUMP (val))
m[i] = SCM_INUM (val);
else if (SCM_BIGP (val))
m[i] = scm_num2long (val, 0, 0);
m[i] = scm_num2long (val, 0, NULL);
else
m[i] = SCM_REAL_VALUE (val);
}
@ -510,7 +512,7 @@ gh_scm2doubles (SCM obj, double *m)
if (SCM_INUMP (val))
m[i] = SCM_INUM (val);
else if (SCM_BIGP (val))
m[i] = scm_num2long (val, 0, 0);
m[i] = scm_num2long (val, 0, NULL);
else
m[i] = SCM_REAL_VALUE (val);
}

View file

@ -1,5 +1,5 @@
/* "net_db.c" network database support
* Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc.
* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -4358,7 +4358,7 @@ scm_ulong2num (unsigned long sl)
long
scm_num2long (SCM num, char *pos, const char *s_caller)
scm_num2long (SCM num, unsigned long int pos, const char *s_caller)
{
if (SCM_INUMP (num)) {
return SCM_INUM (num);
@ -4402,7 +4402,7 @@ scm_num2long (SCM num, char *pos, const char *s_caller)
scm_out_of_range (s_caller, num);
}
} else {
scm_wrong_type_arg (s_caller, (int) pos, num);
scm_wrong_type_arg (s_caller, pos, num);
}
}
@ -4414,7 +4414,7 @@ scm_num2long (SCM num, char *pos, const char *s_caller)
#endif
long_long
scm_num2long_long (SCM num, char *pos, const char *s_caller)
scm_num2long_long (SCM num, unsigned long int pos, const char *s_caller)
{
if (SCM_INUMP (num)) {
return SCM_INUM (num);
@ -4453,12 +4453,12 @@ scm_num2long_long (SCM num, char *pos, const char *s_caller)
scm_out_of_range (s_caller, num);
}
} else {
scm_wrong_type_arg (s_caller, (int) pos, num);
scm_wrong_type_arg (s_caller, pos, num);
}
}
ulong_long
scm_num2ulong_long (SCM num, char *pos, const char *s_caller)
scm_num2ulong_long (SCM num, unsigned long int pos, const char *s_caller)
{
if (SCM_INUMP (num))
{
@ -4493,14 +4493,14 @@ scm_num2ulong_long (SCM num, char *pos, const char *s_caller)
scm_out_of_range (s_caller, num);
}
else
scm_wrong_type_arg (s_caller, (int) pos, num);
scm_wrong_type_arg (s_caller, pos, num);
}
#endif /* HAVE_LONG_LONGS */
unsigned long
scm_num2ulong (SCM num, char *pos, const char *s_caller)
scm_num2ulong (SCM num, unsigned long int pos, const char *s_caller)
{
if (SCM_INUMP (num)) {
long nnum = SCM_INUM (num);
@ -4531,7 +4531,7 @@ scm_num2ulong (SCM num, char *pos, const char *s_caller)
scm_out_of_range (s_caller, num);
}
} else {
scm_wrong_type_arg (s_caller, (int) pos, num);
scm_wrong_type_arg (s_caller, pos, num);
}
}

View file

@ -2,7 +2,7 @@
#ifndef NUMBERSH
#define NUMBERSH
/* Copyright (C) 1995, 1996, 1998, 2000 Free Software Foundation, Inc.
/* Copyright (C) 1995,1996,1998,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -290,15 +290,16 @@ extern SCM scm_dbl2big (double d);
extern double scm_big2dbl (SCM b);
extern SCM scm_long2num (long sl);
extern SCM scm_ulong2num (unsigned long sl);
extern long scm_num2long (SCM num, char *pos, const char *s_caller);
extern long scm_num2long (SCM num, unsigned long int pos,
const char *s_caller);
#ifdef HAVE_LONG_LONGS
extern SCM scm_long_long2num (long_long sl);
extern long_long scm_num2long_long (SCM num, char *pos,
extern long_long scm_num2long_long (SCM num, unsigned long int pos,
const char *s_caller);
extern ulong_long scm_num2ulong_long (SCM num, char *pos,
extern ulong_long scm_num2ulong_long (SCM num, unsigned long int pos,
const char *s_caller);
#endif
extern unsigned long scm_num2ulong (SCM num, char *pos,
extern unsigned long scm_num2ulong (SCM num, unsigned long int pos,
const char *s_caller);
extern void scm_init_numbers (void);

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001 Free Software Foundation, Inc.
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -426,7 +426,7 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
memset (soka, 0, sizeof (struct sockaddr_in));
soka->sin_family = AF_INET;
soka->sin_addr.s_addr =
htonl (scm_num2ulong (address, (char *) which_arg, proc));
htonl (scm_num2ulong (address, which_arg, proc));
*args = SCM_CDR (*args);
soka->sin_port = htons (SCM_INUM (isport));
*size = sizeof (struct sockaddr_in);

View file

@ -1317,10 +1317,10 @@ SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1,
((char *) SCM_UVECTOR_BASE (v))[pos] = SCM_INUM (obj);
break;
case scm_tc7_uvect:
SCM_VELTS(v)[pos] = SCM_PACK (scm_num2ulong(obj, (char *)SCM_ARG2, FUNC_NAME));
SCM_VELTS(v)[pos] = SCM_PACK (scm_num2ulong(obj, SCM_ARG2, FUNC_NAME));
break;
case scm_tc7_ivect:
SCM_VELTS(v)[pos] = SCM_PACK (scm_num2long(obj, (char *)SCM_ARG2, FUNC_NAME));
SCM_VELTS(v)[pos] = SCM_PACK (scm_num2long (obj, SCM_ARG2, FUNC_NAME));
break;
case scm_tc7_svect:
SCM_ASRTGO (SCM_INUMP (obj), badobj);
@ -1328,7 +1328,7 @@ SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1,
break;
#ifdef HAVE_LONG_LONGS
case scm_tc7_llvect:
((long_long *) SCM_CELL_WORD_1 (v))[pos] = scm_num2long_long (obj, (char *)SCM_ARG2, FUNC_NAME);
((long_long *) SCM_CELL_WORD_1 (v))[pos] = scm_num2long_long (obj, SCM_ARG2, FUNC_NAME);
break;
#endif

View file

@ -1,5 +1,5 @@
/* $Id: validate.h,v 1.30 2001-03-17 13:34:21 dirk Exp $ */
/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
/* $Id: validate.h,v 1.31 2001-04-10 07:57:05 dirk Exp $ */
/* Copyright (C) 1999,2000,2001 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -61,15 +61,15 @@
#define SCM_WRONG_TYPE_ARG(pos, obj) \
do { scm_wrong_type_arg (FUNC_NAME, pos, obj); } while (0)
#define SCM_NUM2ULONG(pos, arg) (scm_num2ulong (arg, (char *) pos, FUNC_NAME))
#define SCM_NUM2ULONG(pos, arg) (scm_num2ulong (arg, pos, FUNC_NAME))
#define SCM_NUM2LONG(pos, arg) (scm_num2long (arg, (char *) pos, FUNC_NAME))
#define SCM_NUM2LONG(pos, arg) (scm_num2long (arg, pos, FUNC_NAME))
#define SCM_NUM2LONG_DEF(pos, arg, def) \
(SCM_UNBNDP (arg) ? def : scm_num2long (arg, (char *) pos, FUNC_NAME))
(SCM_UNBNDP (arg) ? def : scm_num2long (arg, pos, FUNC_NAME))
#define SCM_NUM2LONG_LONG(pos, arg) \
(scm_num2long_long (arg, (char *) pos, FUNC_NAME))
(scm_num2long_long (arg, pos, FUNC_NAME))
#define SCM_OUT_OF_RANGE(pos, arg) \
do { scm_out_of_range_pos (FUNC_NAME, arg, SCM_MAKINUM (pos)); } while (0)