unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Ian Price <ianprice90@googlemail.com>
To: guile-devel@gnu.org
Subject: WRITE & linefeed
Date: Sun, 19 Jun 2011 22:27:49 +0100	[thread overview]
Message-ID: <m3ei2pmrze.fsf@Kagami.home> (raw)

[-- Attachment #1: Type: text/plain, Size: 578 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix write --]
[-- Type: text/x-patch, Size: 1222 bytes --]

From 81bf0d0a4c47b1146395fd9282c1fc2ac3d495d4 Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@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


             reply	other threads:[~2011-06-19 21:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-19 21:27 Ian Price [this message]
2011-06-22 21:49 ` WRITE & linefeed Neil Jerram
2011-12-04 21:37   ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ei2pmrze.fsf@Kagami.home \
    --to=ianprice90@googlemail.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).