From: prj@po.cwru.edu (Paul Jarc)
Cc: guile-devel@gnu.org
Subject: Re: patch: (read "\x1b") => #\esc
Date: Tue, 25 Nov 2003 12:12:59 -0500 [thread overview]
Message-ID: <m3znekmkwe.fsf@multivac.cwru.edu> (raw)
In-Reply-To: <87n0b0uj0z.fsf@zagadka.ping.de>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 366 bytes --]
Marius Vollmer <mvo@zagadka.de> wrote:
> What about this change, tho: instead of ignoring a \x sequence that
> does not have two hexadecmal digits, we could signal an error.
> Likewise, we could signal errors for all unrecognized \ sequences.
Here it is.
* read.c (scm_lreadr): Signal an error for invalid escape
sequences in strings. Code cleanups too.
paul
[-- Attachment #2: read-string-error.patch --]
[-- Type: text/x-patch, Size: 1775 bytes --]
Index: guile-core/libguile/read.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/read.c,v
retrieving revision 1.92
diff -u -r1.92 read.c
--- guile-core/libguile/read.c 16 Nov 2003 21:01:57 -0000 1.92
+++ guile-core/libguile/read.c 25 Nov 2003 17:06:09 -0000
@@ -524,28 +524,27 @@
break;
case 'x':
{
- int a, b, a_09 = 0, b_09 = 0, a_AF = 0, b_AF = 0, a_af = 0,
- b_af = 0;
+ int a, b;
a = scm_getc (port);
if (a == EOF) goto str_eof;
b = scm_getc (port);
if (b == EOF) goto str_eof;
- if ('0' <= a && a <= '9') a_09 = 1;
- else if ('A' <= a && a <= 'F') a_AF = 1;
- else if ('a' <= a && a <= 'f') a_af = 1;
- if ('0' <= b && b <= '9') b_09 = 1;
- else if ('A' <= b && b <= 'F') b_AF = 1;
- else if ('a' <= b && b <= 'f') b_af = 1;
- if ((a_09 || a_AF || a_af) && (b_09 || b_AF || b_af))
- c = (a_09? a - '0': a_AF? a - 'A' + 10: a - 'a' + 10) * 16
- + (b_09? b - '0': b_AF? b - 'A' + 10: b - 'a' + 10);
- else
- {
- scm_ungetc (b, port);
- scm_ungetc (a, port);
- }
+ if ('0' <= a && a <= '9') a -= '0';
+ else if ('A' <= a && a <= 'F') a = a - 'A' + 10;
+ else if ('a' <= a && a <= 'f') a = a - 'a' + 10;
+ else goto bad_escaped;
+ if ('0' <= b && b <= '9') b -= '0';
+ else if ('A' <= b && b <= 'F') b = b - 'A' + 10;
+ else if ('a' <= b && b <= 'f') b = b - 'a' + 10;
+ else goto bad_escaped;
+ c = a * 16 + b;
break;
}
+ default:
+ bad_escaped:
+ scm_input_error(FUNC_NAME, port,
+ "illegal character in escape sequence: ~S",
+ scm_list_1 (SCM_MAKE_CHAR (c)));
}
SCM_STRING_CHARS (*tok_buf)[j] = c;
++j;
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2003-11-25 17:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-10 22:41 patch: (read "\x1b") => #\esc Paul Jarc
2003-11-10 22:48 ` Paul Jarc
2003-11-10 23:18 ` Kevin Ryde
2003-11-11 2:45 ` Paul Jarc
2003-11-11 21:48 ` Kevin Ryde
2003-11-13 20:10 ` Marius Vollmer
2003-11-18 20:04 ` Paul Jarc
2003-11-19 0:24 ` Paul Jarc
2003-11-29 23:43 ` Marius Vollmer
2003-11-25 17:12 ` Paul Jarc [this message]
2003-11-30 1:05 ` Marius Vollmer
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=m3znekmkwe.fsf@multivac.cwru.edu \
--to=prj@po.cwru.edu \
--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).