mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-07 13:16:34 +02:00
Issue #90 - modify write to print string escapes
This commit is contained in:
parent
64d39650fb
commit
99dce9d628
1 changed files with 23 additions and 3 deletions
24
runtime.c
24
runtime.c
|
@ -825,9 +825,29 @@ static object _Cyc_write(object x, FILE * port)
|
||||||
return quote_void;
|
return quote_void;
|
||||||
}
|
}
|
||||||
switch (type_of(x)) {
|
switch (type_of(x)) {
|
||||||
case string_tag:
|
case string_tag: {
|
||||||
fprintf(port, "\"%s\"", ((string_type *) x)->str);
|
//fprintf(port, "\"%s\"", ((string_type *) x)->str);
|
||||||
|
char *s = string_str(x);
|
||||||
|
fputc('"', port);
|
||||||
|
while (*s){
|
||||||
|
switch(*s){
|
||||||
|
case '\a': fprintf(port, "\\a"); break;
|
||||||
|
case '\b': fprintf(port, "\\b"); break;
|
||||||
|
case '\f': fprintf(port, "\\f"); break;
|
||||||
|
case '\n': fprintf(port, "\\n"); break;
|
||||||
|
case '\r': fprintf(port, "\\r"); break;
|
||||||
|
case '\t': fprintf(port, "\\t"); break;
|
||||||
|
case '\v': fprintf(port, "\\v"); break;
|
||||||
|
case '\\': fprintf(port, "\\\\"); break;
|
||||||
|
default:
|
||||||
|
fputc(*s, port);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
fputc('"', port);
|
||||||
|
break;
|
||||||
|
}
|
||||||
// TODO: what about a list? contents should be displayed per (write)
|
// TODO: what about a list? contents should be displayed per (write)
|
||||||
case vector_tag:
|
case vector_tag:
|
||||||
fprintf(port, "#(");
|
fprintf(port, "#(");
|
||||||
|
|
Loading…
Add table
Reference in a new issue