mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-07 18:30:25 +02:00
* read.c (scm_lreadr): When reading a hash token, check for a
user-defined hash procedure first, so that overriding the builtin hash characters is possible (this was needed for implementing SRFI-4's read synax `f32(...)'). * num2integral.i.c: Use scm_t_signed_bits instead of scm_t_bits, because the latter is unsigned now and breaks comparisons like (n < (scm_t_signed_bits)MIN_VALUE).
This commit is contained in:
parent
dbfadc8588
commit
b858464a0a
3 changed files with 59 additions and 27 deletions
|
@ -1,3 +1,14 @@
|
||||||
|
2001-06-27 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
|
||||||
|
|
||||||
|
* read.c (scm_lreadr): When reading a hash token, check for a
|
||||||
|
user-defined hash procedure first, so that overriding the builtin
|
||||||
|
hash characters is possible (this was needed for implementing
|
||||||
|
SRFI-4's read synax `f32(...)').
|
||||||
|
|
||||||
|
* num2integral.i.c: Use scm_t_signed_bits instead of scm_t_bits,
|
||||||
|
because the latter is unsigned now and breaks comparisons like
|
||||||
|
(n < (scm_t_signed_bits)MIN_VALUE).
|
||||||
|
|
||||||
2001-06-26 Neil Jerram <neil@ossau.uklinux.net>
|
2001-06-26 Neil Jerram <neil@ossau.uklinux.net>
|
||||||
|
|
||||||
* eval.h, eval.c (scm_call_4): New function.
|
* eval.h, eval.c (scm_call_4): New function.
|
||||||
|
|
|
@ -6,22 +6,22 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller)
|
||||||
if (SCM_INUMP (num))
|
if (SCM_INUMP (num))
|
||||||
{ /* immediate */
|
{ /* immediate */
|
||||||
|
|
||||||
scm_t_bits n = SCM_INUM (num);
|
scm_t_signed_bits n = SCM_INUM (num);
|
||||||
|
|
||||||
#ifdef UNSIGNED
|
#ifdef UNSIGNED
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
scm_out_of_range (s_caller, num);
|
scm_out_of_range (s_caller, num);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sizeof (ITYPE) >= sizeof (scm_t_bits))
|
if (sizeof (ITYPE) >= sizeof (scm_t_signed_bits))
|
||||||
/* can't fit anything too big for this type in an inum
|
/* can't fit anything too big for this type in an inum
|
||||||
anyway */
|
anyway */
|
||||||
return (ITYPE) n;
|
return (ITYPE) n;
|
||||||
else
|
else
|
||||||
{ /* an inum can be out of range, so check */
|
{ /* an inum can be out of range, so check */
|
||||||
if (n > (scm_t_bits)MAX_VALUE
|
if (n > (scm_t_signed_bits)MAX_VALUE
|
||||||
#ifndef UNSIGNED
|
#ifndef UNSIGNED
|
||||||
|| n < (scm_t_bits)MIN_VALUE
|
|| n < (scm_t_signed_bits)MIN_VALUE
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
scm_out_of_range (s_caller, num);
|
scm_out_of_range (s_caller, num);
|
||||||
|
@ -84,7 +84,7 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller)
|
||||||
SCM
|
SCM
|
||||||
INTEGRAL2NUM (ITYPE n)
|
INTEGRAL2NUM (ITYPE n)
|
||||||
{
|
{
|
||||||
if (sizeof (ITYPE) < sizeof (scm_t_bits)
|
if (sizeof (ITYPE) < sizeof (scm_t_signed_bits)
|
||||||
||
|
||
|
||||||
#ifndef UNSIGNED
|
#ifndef UNSIGNED
|
||||||
SCM_FIXABLE (n)
|
SCM_FIXABLE (n)
|
||||||
|
|
|
@ -289,9 +289,9 @@ scm_lreadr (SCM *tok_buf,SCM port,SCM *copy)
|
||||||
size_t j;
|
size_t j;
|
||||||
SCM p;
|
SCM p;
|
||||||
|
|
||||||
tryagain:
|
tryagain:
|
||||||
c = scm_flush_ws (port, s_scm_read);
|
c = scm_flush_ws (port, s_scm_read);
|
||||||
tryagain_no_flush_ws:
|
tryagain_no_flush_ws:
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case EOF:
|
case EOF:
|
||||||
|
@ -339,6 +339,27 @@ tryagain_no_flush_ws:
|
||||||
return p;
|
return p;
|
||||||
case '#':
|
case '#':
|
||||||
c = scm_getc (port);
|
c = scm_getc (port);
|
||||||
|
|
||||||
|
{
|
||||||
|
/* Check for user-defined hash procedure first, to allow
|
||||||
|
overriding of builtin hash read syntaxes. */
|
||||||
|
SCM sharp = scm_get_hash_procedure (c);
|
||||||
|
if (!SCM_FALSEP (sharp))
|
||||||
|
{
|
||||||
|
int line = SCM_LINUM (port);
|
||||||
|
int column = SCM_COL (port) - 2;
|
||||||
|
SCM got;
|
||||||
|
|
||||||
|
got = scm_call_2 (sharp, SCM_MAKE_CHAR (c), port);
|
||||||
|
if (SCM_EQ_P (got, SCM_UNSPECIFIED))
|
||||||
|
goto unkshrp;
|
||||||
|
if (SCM_RECORD_POSITIONS_P)
|
||||||
|
return *copy = recsexpr (got, line, column,
|
||||||
|
SCM_FILENAME (port));
|
||||||
|
else
|
||||||
|
return got;
|
||||||
|
}
|
||||||
|
}
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '(':
|
case '(':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue