Hi Alex,

> 1. There was a slight error (still '_xml2' instead of '_xml')

Oops, sorry about that.

> 2. I replaced occurrences like
>
>       (ifn (= '`(chop "DOCTYPE")
>          (list (char) (char) (char) (char) (char) (char) (char)))
>
>    with
>
>       (if (find '((C) (<> C (char))) '`(chop "DOCTYPE"))
>
>    to avoid the excessive 'list'ing.

That's what I was looking for:-)

> 3. The case "??? echo to string?" is a bit cumbersome. There is in fact
>    no proper equivalent of the 'echo' functionality in e.g. 'from'.
>    Using 'pipe' is quite elegant and short, but I'm hesitating to use it
>    is such a context.
>
>       (pipe (echo "]]>") (till NIL T))
>
>    My proposal would be
>
>       (pack
>          (head -3
>             (make
>                (until (= '`(chop "]]>") (tail 3 (made)))
>                   (link (char)) ) ) ) )
>
>    This avoids the overhead of 'pipe', but is longer. Is this OK?

Yes, better solution without pipe.  I think we don't we need prog1 and
(from "]]>") in that case.  It'll take me a while to understand it
though;-)

> BTW, why is the
>
>    (from "]]>") ) ) )
>
> in the following line needed?

(from "]]>") in the original code

(prog1 # ??? echo to string?
   (pipe (echo "]]>") (till NIL T))
   (from "]]>"))

was necessary in the parent process because (echo "]]>") in the child
process did not seem to affect stdin of the parent process and all
those characters had to be read again in the parent process.  I am not
sure why it works this way.

>> 00000000: 3c64 6f63 3ef0 9080 80f4 8fbf bd3c 2f64  <doc>........</d
>> 00000010: 6f63 3e                                  oc>
>
> The first character after the '>' starts with "F0", which is not a legal
> UTF-8 sequence. UTF-8 has the following structure ("doc/utf8"):
>
>    0000 .. 007F   0xxxxxxx
>    0080 .. 07FF   110xxxxx 10xxxxxx
>    0800 .. FFFF   1110xxxx 10xxxxxx 10xxxxxx
>
> The pattern 11110000 is this not possible for any (not just the first)
> UTF-8 character.

Thanks for explanation, I'll ignore the invalid test cases then.

Sorry, I did not send you this, but

(de xml (Lst N)
   (if Lst
      (let Tag (pop 'Lst)
         (space (default N 0))
         (prin "<" Tag)
         (for X (pop 'Lst)
            (prin " " (car X) "=\"")
            (escXml (cdr X))
            (prin "\"") )
         (nond
            (Lst (prinl "/>"))
            ((or (cdr Lst) (pair (car Lst)))
               (prin ">")
               (escXml (car Lst))
               (prinl "</" Tag ">") )
            (NIL
               (prinl ">")
               (for X Lst
                  (if (pair X)
                     (xml X (+ 3 N))
                     (space (+ 3 N))
                     (escXml X)
                     (prinl) ) )
               (space N)
               (prinl "</" Tag ">") ) ) )
      (_xml (till " /<>" T)) ) )

should be just

(de xml (Lst N)
   (if Lst
      (let Tag (pop 'Lst)
         (space (default N 0))
         (prin "<" Tag)
         (for X (pop 'Lst)
            (prin " " (car X) "=\"")
            (escXml (cdr X))
            (prin "\"") )
         (nond
            (Lst (prinl "/>"))
            ((or (cdr Lst) (pair (car Lst)))
               (prin ">")
               (escXml (car Lst))
               (prinl "</" Tag ">") )
            (NIL
               (prinl ">")
               (for X Lst
                  (if (pair X)
                     (xml X (+ 3 N))
                     (space (+ 3 N))
                     (escXml X)
                     (prinl) ) )
               (space N)
               (prinl "</" Tag ">") ) ) )
      (_xml ) ) )

I'll run & test your changed code and let you know.

Cheers,

Tomas
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

Reply via email to