Hello guilers, There's a small aesthetic issue that's been bothering me for a while. Namely, newlines aren't treated like other escape sequences when printed with WRITE.
scheme@(guile-user)> (write "\n") " "scheme@(guile-user)> Now, I can see why this would be useful when printing multiple line strings, but the inconsistency with e.g. "\t\f" irks me. What do the rest of you think? I've also attached the patch I've been using to fix this for me. -- Ian Price "There are only two hard problems in Computer Science: cache invalidation and naming things." - Phil Karlton
>From 81bf0d0a4c47b1146395fd9282c1fc2ac3d495d4 Mon Sep 17 00:00:00 2001 From: Ian Price <ianpric...@googlemail.com> Date: Sun, 19 Jun 2011 12:30:26 +0100 Subject: [PATCH] use escape sequence when printing newlines with 'write' * libguile/print.c (write_character_escaped, write_character): Use '\n' escape sequence rather than the character 0xa0 when printing strings with WRITE. --- libguile/print.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libguile/print.c b/libguile/print.c index 4afd12c..e215f3f 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -1022,7 +1022,7 @@ write_character_escaped (scm_t_wchar ch, int string_escapes_p, SCM port) static const char escapes[7] = "abtnvfr"; char buf[9]; - if (ch >= 0x07 && ch <= 0x0D && ch != 0x0A) + if (ch >= 0x07 && ch <= 0x0D) { /* Use special escapes for some C0 controls. */ buf[0] = '\\'; @@ -1119,7 +1119,7 @@ write_character (scm_t_wchar ch, SCM port, int string_escapes_p) display_character (ch, port, strategy); printed = 1; } - else if (ch == ' ' || ch == '\n') + else if (ch == ' ') { display_character (ch, port, strategy); printed = 1; -- 1.7.5.4