Fix bugs in ASCII routines
- Segfault due to wrong return type in map_char_int(). - Treat int value -1 as #f instead of a character.
This commit is contained in:
parent
ac2966b78a
commit
150d6ff855
7
c/char.c
7
c/char.c
|
@ -59,13 +59,13 @@ static int32_t must_get_char_as_int(const char *procname, value_t *args,
|
||||||
if (iscprim(args[0])) {
|
if (iscprim(args[0])) {
|
||||||
cp = (struct cprim *)ptr(args[0]);
|
cp = (struct cprim *)ptr(args[0]);
|
||||||
if (cp_class(cp) == wchartype) {
|
if (cp_class(cp) == wchartype) {
|
||||||
return *(int32_t *)cp_data(cp); // TODO: Is this right?
|
return *(int32_t *)cp_data(cp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
type_error(procname, "wchar or fixnum", args[0]);
|
type_error(procname, "wchar or fixnum", args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t map_char_int(const char *procname, int32_t (*mapfun)(int32_t),
|
static value_t map_char_int(const char *procname, int32_t (*mapfun)(int32_t),
|
||||||
value_t *args, uint32_t nargs)
|
value_t *args, uint32_t nargs)
|
||||||
{
|
{
|
||||||
struct cprim *cp;
|
struct cprim *cp;
|
||||||
|
@ -79,7 +79,8 @@ static int32_t map_char_int(const char *procname, int32_t (*mapfun)(int32_t),
|
||||||
cp = (struct cprim *)ptr(args[0]);
|
cp = (struct cprim *)ptr(args[0]);
|
||||||
if (cp_class(cp) == wchartype) {
|
if (cp_class(cp) == wchartype) {
|
||||||
cc = *(int32_t *)cp_data(cp);
|
cc = *(int32_t *)cp_data(cp);
|
||||||
return mk_wchar(mapfun(cc)); // TODO: Is this right?
|
cc = mapfun(cc);
|
||||||
|
return (cc == -1) ? FL_F : mk_wchar(cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
type_error(procname, "wchar or byte", args[0]);
|
type_error(procname, "wchar or byte", args[0]);
|
||||||
|
|
Loading…
Reference in New Issue