From a6e0744338666a88d31953bf56fbe876a47a5815 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 10 Oct 1990 06:30:35 +0000 Subject: [PATCH] Fix parsing of octal escape sequences in strings. --- v7/src/runtime/parse.scm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/v7/src/runtime/parse.scm b/v7/src/runtime/parse.scm index 1d8f1f1da..92cbcbe84 100644 --- a/v7/src/runtime/parse.scm +++ b/v7/src/runtime/parse.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/parse.scm,v 14.11 1990/10/10 06:15:56 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/parse.scm,v 14.12 1990/10/10 06:30:35 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -434,13 +434,16 @@ MIT in each case. |# (loop))))))) (define (octal->char c1 c2 c3) - (let ((sum - (+ (* #o100 (char->digit c1 8)) - (* #o10 (char->digit c2 8)) - (char->digit c3 8)))) - (if (>= sum 256) - (error "Octal string escape exceeds ASCII range:" (string c1 c2 c3))) - (ascii->char sum))) + (let ((d1 (char->digit c1 8)) + (d2 (char->digit c2 8)) + (d3 (char->digit c3 8))) + (if (not (and d1 d2 d3)) + (error "Badly formed octal string escape:" (string #\\ c1 c2 c3))) + (let ((sum (+ (* #o100 d1) (* #o10 d2) d3))) + (if (>= sum 256) + (error "Octal string escape exceeds ASCII range:" + (string #\\ c1 c2 c3))) + (ascii->char sum)))) (define (parse-object/char-quote) (discard-char) -- 2.25.1