1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 19:50:24 +02:00

Range check octal-escaped characters

* libguile/read.c (scm_read_character): range check octal escapes
This commit is contained in:
Michael Gran 2009-08-29 07:14:49 -07:00
parent 6c2353e1d5
commit 0ffc78e384

View file

@ -848,12 +848,18 @@ scm_read_character (scm_t_wchar chr, SCM port)
{ {
/* Dirk:FIXME:: This type of character syntax is not R5RS /* Dirk:FIXME:: This type of character syntax is not R5RS
* compliant. Further, it should be verified that the constant * compliant. Further, it should be verified that the constant
* does only consist of octal digits. Finally, it should be * does only consist of octal digits. */
* checked whether the resulting fixnum is in the range of
* characters. */
SCM p = scm_string_to_number (charname, scm_from_uint (8)); SCM p = scm_string_to_number (charname, scm_from_uint (8));
if (SCM_I_INUMP (p)) if (SCM_I_INUMP (p))
return SCM_MAKE_CHAR (SCM_I_INUM (p)); {
scm_t_wchar c = SCM_I_INUM (p);
if (SCM_IS_UNICODE_CHAR (c))
return SCM_MAKE_CHAR (c);
else
scm_i_input_error (FUNC_NAME, port,
"out-of-range octal character escape: ~a",
scm_list_1 (charname));
}
} }
/* The names of characters should never have non-Latin1 /* The names of characters should never have non-Latin1