Re: Errors in script running with Scsh 0.7 vs. 0.6
Roderic Morris <[email protected]> Mon, 5 Nov 2012 08:47:55 -0500
| Newsgroups | gmane.lisp.scheme.scsh |
|---|---|
| Message-ID | <[email protected]> |
--5097c38b_4ad3afd2_8f
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Should be easy to fix. Could you send a small example it breaks on?
-Roderic
On Sunday, November 4, 2012 at 10:31 PM, Richard Loveland wrote:
> Greetings scsh cognoscenti,
>
> I've got a script throwing errors under Scsh 0.7 that runs under 0.6.
> It's a word counting script that uses the `rx' package (code is below).
>
> * Shell output
>
> Here are the outputs from issuing the script command at the shell. The
> first is for 0.7, the second for 0.6. The file is a plaintext Emacs org
> file.
>
> wc-0.7.scm < jelec-02.org (http://jelec-02.org)
> assertion-violation [ascii->char] with no handler in place: not an ASCII
> code195
> stack template id's: 3016 <- 1720 <- 3015 <- 914 <- <- <- <- <- <-
> <- 1720 <- <- 1720 <- 6624 <- 3309 <-
>
>
> wc-0.6.scm < jelec-02.org (http://jelec-02.org)
> 25337
>
> * Source of the script
>
> ...is as follows (also attached in case it gets garbled -- need to set
> up a plaintext email program, apologies!):
>
> #!/usr/local/bin/scsh \
> -e main -s
> !#
>
> (define wc-rx (rx (: ; begin a matching sequence
> (* whitespace) ; beginning with zero+ spaces,
> (+ alphanumeric) ; match 1 or more [0-9a-zA-Z]
> (? ; then, optionally match:
> (or #\' #\`) ; - apostrophe or backtick
> (* alphanumeric)) ; - 0 or more [0-9a-zA-Z]
> (* whitespace)))) ; finally, 0 or more spaces end
>
> (define (main prog+args)
> (display
> (awk (read-line) (line) ((words 0))
> (#t (+ words
> (length
> (regexp-fold-right wc-rx (lambda (m i lis)
> (cons (match:substring m 0) lis))
> '() line))))))
> (newline))
>
> * Checking `rx' sources
>
> Finally, grepping the rx package's sources provide this output, which
> I'm afraid:
>
> > > grep "ascii->char" *
> parse.scm: ((0) (values (cons (ascii->char from) loose)
> parse.scm: ((1) (values `(,(ascii->char from)
> parse.scm: ,(ascii->char to)
> parse.scm: ((2) (values `(,(ascii->char from)
> parse.scm: ,(ascii->char (+ from 1))
> parse.scm: ,(ascii->char to)
> parse.scm: `((,(ascii->char from) .
> parse.scm: ,(ascii->char to))
> parse.scm: (if (char-set-contains? cset (ascii->char i))
> posixstr.scm:(define *nul* (ascii->char 0))
> posixstr.scm: ((> start end) (values (list (ascii->char c)) '())) ;
> Empty range
> posixstr.scm: (values (list (ascii->char c) (ascii->char start))
> posixstr.scm: (values (list (ascii->char c) (ascii->char start)
> (ascii->char end))
> posixstr.scm: (else (values (list (ascii->char c))
> posixstr.scm: (list (cons (ascii->char start) (ascii->char end)))))))
> rx-lib.scm: (cs cset (char-set-adjoin! cs (ascii->char i))))
> scsh-read.scm:; Ascii stuff: char->ascii, ascii->char,
> ascii-whitespaces, ascii-limit
> scsh-read.scm:(define bel (ascii->char 7))
> scsh-read.scm:(define bs (ascii->char 8))
> scsh-read.scm:(define ff (ascii->char 12))
> scsh-read.scm:(define cr (ascii->char 13))
> scsh-read.scm:(define ht (ascii->char 9))
> scsh-read.scm:(define vt (ascii->char 11))
> scsh-read.scm: (ascii->char (+ (* 64 d1)
> (+ (* 8 d2) d3)))))
> scsh-read.scm: (ascii->char (+ (* 16 d1)
> d2))))
> scsh-read.scm: (string-set! p-c-v i (p-c (ascii->char i)))))
> spencer.scm: (cset cset (char-set-adjoin! cset (ascii->char j))))
>
> My layman's reading of the above is that I should not do any
> regexp-matching on files which contain non-ASCII characters with 0.7. Is
> that correct? Although it's not clear why 0.6 works.
>
> Any help from a kindly Scsh wizard would be much appreciated.
>
> Best,
> Rich
>
>
>
>
> Attachments:
> - wc.scm
>
--5097c38b_4ad3afd2_8f
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
<div>Should be easy to fix. Could you send a small exampl=
e it breaks on=3F
</div><div><br></div><div>-Roderic</div>
<div></div>
=20
<p style=3D=22color: =23A0A0A8;=22>On Sunday, November 4,=
2012 at 10:31 PM, Richard Loveland wrote:</p>
<blockquote type=3D=22cite=22 style=3D=22border-left-styl=
e:solid;border-width:1px;margin-left:0px;padding-left:10px;=22>
<span><div><div><div>Greetings scsh cognoscenti,</div=
><div><br></div><div>I've got a script throwing errors under Scsh 0.7 tha=
t runs under 0.6.</div><div>It's a word counting script that uses the =60=
rx' package (code is below).</div><div><br></div><div>* Shell output</div=
><div><br></div><div>Here are the outputs from issuing the script command=
at the shell. The</div><div>first is for 0.7, the second for 0.6. The fi=
le is a plaintext Emacs org</div><div>file.</div><div><br></div><div>wc-0=
.7.scm < <a href=3D=22http://jelec-02.org=22>jelec-02.org</a></div><di=
v>assertion-violation =5Bascii->char=5D with no handler in place: not =
an ASCII</div><div>code195</div><div>stack template id's: 3016 <- 1720=
<- 3015 <- 914 <- <- <- <- <- <-</div><div>=
<- 1720 <- <- 1720 <- 6624 <- 3309 <-</div><div><br><=
/div><div><br></div><div>wc-0.6.scm < <a href=3D=22http://jelec-02.org=
=22>jelec-02.org</a></div><div>25337</div><div><br></div><div>* Source of=
the script</div><div><br></div><div>...is as follows (also attached in c=
ase it gets garbled -- need to set</div><div>up a plaintext email program=
, apologies=21):</div><div><br></div><div>=23=21/usr/local/bin/scsh =5C</=
div><div>-e main -s</div><div>=21=23</div><div><br></div><div>(define wc-=
rx (rx (: ; begin a matching sequence</div><div> =
(* whitespace) ; beginning with zero+ spaces,</div><div>=
(+ alphanumeric) ; match 1 or more =5B0-9a-zA-Z=5D<=
/div><div> (=3F ; then, optionally mat=
ch:</div><div> (or =23=5C' =23=5C=60) ; - apostr=
ophe or backtick</div><div> (* alphanumeric)) ; - 0 o=
r more =5B0-9a-zA-Z=5D</div><div> (* whitespace)))) ;=
finally, 0 or more spaces end</div><div><br></div><div>(define (main pro=
g+args)</div><div> (display</div><div> (awk (read-line) (line) ((words=
0))</div><div> (=23t (+ words</div><div> (length</div><di=
v> (regexp-fold-right wc-rx (lambda (m i lis)</div><div> =
(cons (match:substring m 0) lis))</div=
><div> '() line))))))</div><div> (newline=
))</div><div><br></div><div>* Checking =60rx' sources</div><div><br></div=
><div>=46inally, grepping the rx package's sources provide this output, w=
hich</div><div>I'm afraid:</div><div><br></div><blockquote type=3D=22cite=
=22><blockquote type=3D=22cite=22><div>grep =22ascii->char=22 *</div><=
/blockquote></blockquote><div>parse.scm: ((0) (values (cons (ascii->=
;char from) loose)</div><div>parse.scm: ((1) (values =60(,(ascii->c=
har from)</div><div>parse.scm: ,(ascii->char to)</div><div>=
parse.scm: ((2) (values =60(,(ascii->char from)</div><div>parse.scm=
: ,(ascii->char (+ from 1))</div><div>parse.scm: =
,(ascii->char to)</div><div>parse.scm: =60((,(ascii->cha=
r from) .</div><div>parse.scm: ,(ascii->char to))</div><div>pars=
e.scm: (if (char-set-contains=3F cset (ascii->char i))</div><div>p=
osixstr.scm:(define *nul* (ascii->char 0))</div><div>posixstr.scm: (=
(> start end) (values (list (ascii->char c)) '())) ;</div><div>Empt=
y range</div><div>posixstr.scm: (values (list (ascii->char c) (asci=
i->char start))</div><div>posixstr.scm: (values (list (ascii->ch=
ar c) (ascii->char start)</div><div>(ascii->char end))</div><div>po=
sixstr.scm: (else (values (list (ascii->char c))</div><div>posixstr.=
scm: (list (cons (ascii->char start) (ascii->char end)))))))</div=
><div>rx-lib.scm: (cs cset (char-set-adjoin=21 cs (ascii->cha=
r i))))</div><div>scsh-read.scm:; Ascii stuff: char->ascii, ascii->=
;char,</div><div>ascii-whitespaces, ascii-limit</div><div>scsh-read.scm:(=
define bel (ascii->char 7))</div><div>scsh-read.scm:(define bs (ascii=
->char 8))</div><div>scsh-read.scm:(define ff (ascii->char 12))</=
div><div>scsh-read.scm:(define cr (ascii->char 13))</div><div>scsh-re=
ad.scm:(define ht (ascii->char 9))</div><div>scsh-read.scm:(define v=
t (ascii->char 11))</div><div>scsh-read.scm: =
(ascii->char (+ (* 64 d1)</div><div>(+ (* 8 d2) d3)))))</div><=
div>scsh-read.scm: (ascii->char (+ (* =
16 d1)</div><div>d2))))</div><div>scsh-read.scm: (string-set=21 p-c-v =
i (p-c (ascii->char i)))))</div><div>spencer.scm: (cset cset (=
char-set-adjoin=21 cset (ascii->char j))))</div><div><br></div><div>My=
layman's reading of the above is that I should not do any</div><div>rege=
xp-matching on files which contain non-ASCII characters with 0.7. Is</div=
><div>that correct=3F Although it's not clear why 0.6 works.</div><div><b=
r></div><div>Any help from a kindly Scsh wizard would be much appreciated=
.</div><div><br></div><div>Best,</div><div>Rich</div></div></div></span>
=20
=20
<div style=3D=22border-bottom: 1px solid =23f0f0f0; heigh=
t: 10px;=22>
</div>
<br>
=20
<div style=3D=22font-weight: bold; font-size: 14px; margi=
n-bottom: 5px;=22>Attachments:</div>
=20
=20
=20
=20
=20
=20
=20
<div>
=20
<div style=3D=22=22>- wc.scm</div>
=20
</div>
=20
=20
=20
</blockquote>
=20
<div>
<br>
</div>
--5097c38b_4ad3afd2_8f--