mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
* Avoid redundant casting of argument numbers to char* and vice versa.
This commit is contained in:
parent
40f83c3e1b
commit
e4b265d817
15 changed files with 87 additions and 61 deletions
|
@ -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>
|
2001-04-09 Neil Jerram <neil@ossau.uklinux.net>
|
||||||
|
|
||||||
* strings.c (scm_read_only_string_p): Update docstring to reflect
|
* strings.c (scm_read_only_string_p): Update docstring to reflect
|
||||||
|
|
|
@ -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
|
* 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
|
* 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))
|
if (!SCM_ENVIRONMENT_BOUND_P (local, symbol))
|
||||||
{
|
{
|
||||||
SCM proc_as_nr = SCM_CADR (extended_data);
|
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_environment_folder proc = (scm_environment_folder) proc_as_ul;
|
||||||
SCM data = SCM_CDDR (extended_data);
|
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 imported_env = SCM_CADR (extended_data);
|
||||||
SCM owner = import_environment_lookup (import_env, symbol);
|
SCM owner = import_environment_lookup (import_env, symbol);
|
||||||
SCM proc_as_nr = SCM_CADDR (extended_data);
|
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_environment_folder proc = (scm_environment_folder) proc_as_ul;
|
||||||
SCM data = SCM_CDDDR (extended_data);
|
SCM data = SCM_CDDDR (extended_data);
|
||||||
|
|
||||||
|
|
|
@ -229,18 +229,18 @@ gh_scm2bool (SCM obj)
|
||||||
unsigned long
|
unsigned long
|
||||||
gh_scm2ulong (SCM obj)
|
gh_scm2ulong (SCM obj)
|
||||||
{
|
{
|
||||||
return scm_num2ulong (obj, (char *) SCM_ARG1, "gh_scm2ulong");
|
return scm_num2ulong (obj, SCM_ARG1, "gh_scm2ulong");
|
||||||
}
|
}
|
||||||
long
|
long
|
||||||
gh_scm2long (SCM obj)
|
gh_scm2long (SCM obj)
|
||||||
{
|
{
|
||||||
return scm_num2long (obj, (char *) SCM_ARG1, "gh_scm2long");
|
return scm_num2long (obj, SCM_ARG1, "gh_scm2long");
|
||||||
}
|
}
|
||||||
int
|
int
|
||||||
gh_scm2int (SCM obj)
|
gh_scm2int (SCM obj)
|
||||||
{
|
{
|
||||||
/* NOTE: possible loss of precision here */
|
/* 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
|
double
|
||||||
gh_scm2double (SCM obj)
|
gh_scm2double (SCM obj)
|
||||||
|
@ -395,7 +395,9 @@ gh_scm2longs (SCM obj, long *m)
|
||||||
for (i = 0; i < n; ++i)
|
for (i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
val = SCM_VELTS (obj)[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;
|
break;
|
||||||
#ifdef HAVE_ARRAYS
|
#ifdef HAVE_ARRAYS
|
||||||
|
@ -447,7 +449,7 @@ gh_scm2floats (SCM obj, float *m)
|
||||||
if (SCM_INUMP (val))
|
if (SCM_INUMP (val))
|
||||||
m[i] = SCM_INUM (val);
|
m[i] = SCM_INUM (val);
|
||||||
else if (SCM_BIGP (val))
|
else if (SCM_BIGP (val))
|
||||||
m[i] = scm_num2long (val, 0, 0);
|
m[i] = scm_num2long (val, 0, NULL);
|
||||||
else
|
else
|
||||||
m[i] = SCM_REAL_VALUE (val);
|
m[i] = SCM_REAL_VALUE (val);
|
||||||
}
|
}
|
||||||
|
@ -510,7 +512,7 @@ gh_scm2doubles (SCM obj, double *m)
|
||||||
if (SCM_INUMP (val))
|
if (SCM_INUMP (val))
|
||||||
m[i] = SCM_INUM (val);
|
m[i] = SCM_INUM (val);
|
||||||
else if (SCM_BIGP (val))
|
else if (SCM_BIGP (val))
|
||||||
m[i] = scm_num2long (val, 0, 0);
|
m[i] = scm_num2long (val, 0, NULL);
|
||||||
else
|
else
|
||||||
m[i] = SCM_REAL_VALUE (val);
|
m[i] = SCM_REAL_VALUE (val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* "net_db.c" network database support
|
/* "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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -4358,7 +4358,7 @@ scm_ulong2num (unsigned long sl)
|
||||||
|
|
||||||
|
|
||||||
long
|
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)) {
|
if (SCM_INUMP (num)) {
|
||||||
return SCM_INUM (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);
|
scm_out_of_range (s_caller, num);
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
#endif
|
||||||
|
|
||||||
long_long
|
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)) {
|
if (SCM_INUMP (num)) {
|
||||||
return SCM_INUM (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);
|
scm_out_of_range (s_caller, num);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scm_wrong_type_arg (s_caller, (int) pos, num);
|
scm_wrong_type_arg (s_caller, pos, num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ulong_long
|
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))
|
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);
|
scm_out_of_range (s_caller, num);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
scm_wrong_type_arg (s_caller, (int) pos, num);
|
scm_wrong_type_arg (s_caller, pos, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_LONG_LONGS */
|
#endif /* HAVE_LONG_LONGS */
|
||||||
|
|
||||||
|
|
||||||
unsigned long
|
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)) {
|
if (SCM_INUMP (num)) {
|
||||||
long nnum = SCM_INUM (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);
|
scm_out_of_range (s_caller, num);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scm_wrong_type_arg (s_caller, (int) pos, num);
|
scm_wrong_type_arg (s_caller, pos, num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#ifndef NUMBERSH
|
#ifndef NUMBERSH
|
||||||
#define 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
|
* 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
|
* 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 double scm_big2dbl (SCM b);
|
||||||
extern SCM scm_long2num (long sl);
|
extern SCM scm_long2num (long sl);
|
||||||
extern SCM scm_ulong2num (unsigned 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
|
#ifdef HAVE_LONG_LONGS
|
||||||
extern SCM scm_long_long2num (long_long sl);
|
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);
|
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);
|
const char *s_caller);
|
||||||
#endif
|
#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);
|
const char *s_caller);
|
||||||
extern void scm_init_numbers (void);
|
extern void scm_init_numbers (void);
|
||||||
|
|
||||||
|
|
|
@ -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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -426,7 +426,7 @@ scm_fill_sockaddr (int fam, SCM address, SCM *args, int which_arg,
|
||||||
memset (soka, 0, sizeof (struct sockaddr_in));
|
memset (soka, 0, sizeof (struct sockaddr_in));
|
||||||
soka->sin_family = AF_INET;
|
soka->sin_family = AF_INET;
|
||||||
soka->sin_addr.s_addr =
|
soka->sin_addr.s_addr =
|
||||||
htonl (scm_num2ulong (address, (char *) which_arg, proc));
|
htonl (scm_num2ulong (address, which_arg, proc));
|
||||||
*args = SCM_CDR (*args);
|
*args = SCM_CDR (*args);
|
||||||
soka->sin_port = htons (SCM_INUM (isport));
|
soka->sin_port = htons (SCM_INUM (isport));
|
||||||
*size = sizeof (struct sockaddr_in);
|
*size = sizeof (struct sockaddr_in);
|
||||||
|
|
|
@ -1317,10 +1317,10 @@ SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1,
|
||||||
((char *) SCM_UVECTOR_BASE (v))[pos] = SCM_INUM (obj);
|
((char *) SCM_UVECTOR_BASE (v))[pos] = SCM_INUM (obj);
|
||||||
break;
|
break;
|
||||||
case scm_tc7_uvect:
|
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;
|
break;
|
||||||
case scm_tc7_ivect:
|
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;
|
break;
|
||||||
case scm_tc7_svect:
|
case scm_tc7_svect:
|
||||||
SCM_ASRTGO (SCM_INUMP (obj), badobj);
|
SCM_ASRTGO (SCM_INUMP (obj), badobj);
|
||||||
|
@ -1328,7 +1328,7 @@ SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1,
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_LONG_LONGS
|
#ifdef HAVE_LONG_LONGS
|
||||||
case scm_tc7_llvect:
|
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;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* $Id: validate.h,v 1.30 2001-03-17 13:34:21 dirk Exp $ */
|
/* $Id: validate.h,v 1.31 2001-04-10 07:57:05 dirk Exp $ */
|
||||||
/* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -61,15 +61,15 @@
|
||||||
#define SCM_WRONG_TYPE_ARG(pos, obj) \
|
#define SCM_WRONG_TYPE_ARG(pos, obj) \
|
||||||
do { scm_wrong_type_arg (FUNC_NAME, pos, obj); } while (0)
|
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) \
|
#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) \
|
#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) \
|
#define SCM_OUT_OF_RANGE(pos, arg) \
|
||||||
do { scm_out_of_range_pos (FUNC_NAME, arg, SCM_MAKINUM (pos)); } while (0)
|
do { scm_out_of_range_pos (FUNC_NAME, arg, SCM_MAKINUM (pos)); } while (0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue