scsh-users
[Top] [All Lists]

Hex escapes in strings

To: scsh-bugs@martigny.ai.mit.edu
Subject: Hex escapes in strings
From: Ian Wild <ian.wild@eurocontrol.be>
Date: Thu, 02 Oct 1997 13:12:41 +0200
Organization: Society for Saying "Java is Cool"
Sender: ian.wild@eurocontrol.be
In scsh 0.5 the string "\x4A" is flagged
as invalid, but "\x4:" is accepted in its
place!

I went back to my earlier (0.4) version,
and found the same thing.

Now, as far as I can tell, in scsh/scsh-read.scm,
you've handled this with:

(lambda (base base-name)
  (let* ((c (readc))
         (d (- (char->ascii c) (char->ascii #\0))))
    (if (and (<= 0 d) (< d base)) d
        (reading-error port
                       (string-append "invalid "
                                      base-name
                                      " code in string.")
                       d))))

where, to my mind, something like:

(lambda (base base-name)
  (let* ((c (readc))
         (asc (char->ascii c))
         (asc0 (char->ascii #\0))
         (asc9 (char->ascii #\9))
         (little-A (char->ascii #\a))
         (big-A (char->ascii #\A))
         (d
          (cond
           ((>= asc little-A) (+ (- asc little-A) 10))
           ((>= asc big-A) (+ (- asc big-A) 10))
           ((<= asc0 asc asc9) (- asc asc0))
           (else (+ base 1)))))
    (if (< d base) d
        (reading-error port
                       (string-append "invalid "
                                      base-name
                                      " code found in string.")
                       asc))))


would be better.  (Apologies for any C flavour
in that code - I'm new to scheme and haven't used
/any/ lisps in many a year.)

However, when I tried making the above changes,
nothing happened.  The code seems to be hard-wired
into initial.image in some way that I can't figure.


BTW - the two calls to read hex digits - shouldn't
they be in a let* rather than a let, like the octal
ones?  Or am I missing something?


imw

<Prev in Thread] Current Thread [Next in Thread>
  • Hex escapes in strings, Ian Wild <=