mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 22:29:16 +02:00
workaround for bug in fmemopen - open /dev/null instead of empty strings
This commit is contained in:
parent
8946aaca25
commit
8046a3c139
1 changed files with 12 additions and 3 deletions
15
sexp.c
15
sexp.c
|
@ -889,9 +889,18 @@ sexp sexp_make_input_string_port (sexp ctx, sexp str) {
|
|||
sexp res;
|
||||
if (! sexp_stringp(str))
|
||||
return sexp_type_exception(ctx, "open-input-string: not a string", str);
|
||||
in = fmemopen(sexp_string_data(str), sexp_string_length(str), "r");
|
||||
res = sexp_make_input_port(ctx, in, SEXP_FALSE);
|
||||
sexp_port_cookie(res) = str; /* for gc preservation */
|
||||
if (sexp_string_length(str) == 0)
|
||||
in = fopen("/dev/null", "r");
|
||||
else
|
||||
in = fmemopen(sexp_string_data(str), sexp_string_length(str), "r");
|
||||
if (in) {
|
||||
res = sexp_make_input_port(ctx, in, SEXP_FALSE);
|
||||
if (sexp_string_length(str) == 0)
|
||||
sexp_port_name(res) = sexp_c_string(ctx, "/dev/null", -1);
|
||||
sexp_port_cookie(res) = str; /* for gc preservation */
|
||||
} else {
|
||||
res = sexp_user_exception(ctx, SEXP_FALSE, "couldn't open string", str);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue