From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: prj@po.cwru.edu (Paul Jarc) Newsgroups: gmane.lisp.guile.devel Subject: Re: patch: (read "\x1b") => #\esc Date: Tue, 25 Nov 2003 12:12:59 -0500 Organization: What did you have in mind? A short, blunt, human pyramid? Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: References: <87n0b0uj0z.fsf@zagadka.ping.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_55/G3/JM61lTuhNOS8cMcg)" X-Trace: sea.gmane.org 1069780763 12183 80.91.224.253 (25 Nov 2003 17:19:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 25 Nov 2003 17:19:23 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Nov 25 18:19:20 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AOgqN-0007e9-00 for ; Tue, 25 Nov 2003 18:19:20 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AOhje-0000az-FJ for guile-devel@m.gmane.org; Tue, 25 Nov 2003 13:16:26 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AOhiM-0000Pe-8P for guile-devel@gnu.org; Tue, 25 Nov 2003 13:15:06 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AOhhn-0000FE-Pc for guile-devel@gnu.org; Tue, 25 Nov 2003 13:15:04 -0500 Original-Received: from [129.22.104.63] (helo=harris.CNS.CWRU.Edu) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AOhhn-0000Er-0E for guile-devel@gnu.org; Tue, 25 Nov 2003 13:14:31 -0500 Original-Received: from conversion-daemon.smtp-a.cwru.edu by smtp-a.cwru.edu (iPlanet Messaging Server 5.2 HotFix 1.14 (built Mar 18 2003)) id <0HOX00E013P8Y7@smtp-a.cwru.edu> for guile-devel@gnu.org; Tue, 25 Nov 2003 12:13:01 -0500 (EST) Original-Received: from multivac.cwru.edu (multivac.ITS.CWRU.Edu [129.22.114.26]) by smtp-a.cwru.edu (iPlanet Messaging Server 5.2 HotFix 1.14 (built Mar 18 2003)) with SMTP id <0HOX00B9G3TPHD@smtp-a.cwru.edu> for guile-devel@gnu.org; Tue, 25 Nov 2003 12:13:01 -0500 (EST) Original-Received: (qmail 32757 invoked by uid 500); Tue, 25 Nov 2003 17:13:23 +0000 In-reply-to: <87n0b0uj0z.fsf@zagadka.ping.de> Original-To: Marius Vollmer Mail-followup-to: Marius Vollmer , guile-devel@gnu.org Mail-Copies-To: nobody User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) Original-Lines: 14 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:3088 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3088 --Boundary_(ID_55/G3/JM61lTuhNOS8cMcg) Content-type: TEXT/PLAIN Content-transfer-encoding: 7BIT Marius Vollmer 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 --Boundary_(ID_55/G3/JM61lTuhNOS8cMcg) Content-type: text/x-patch; NAME=read-string-error.patch Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=read-string-error.patch 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; --Boundary_(ID_55/G3/JM61lTuhNOS8cMcg) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --Boundary_(ID_55/G3/JM61lTuhNOS8cMcg)--