inchar, outchar and linechar



On Mon, 2004-05-10 at 10:35, Barton Willis wrote:
> The new values for inchar and outchar might break mactex;

Good catch. There seem to be three (potential) problems:

On Mon, 2004-05-10 at 12:00, Jay Belanger wrote: 

> It looks like mactex is treating %o3 as an input line.
> In mactex.lisp, to determine if a label is an input or output line,
> the function tex1 uses 
> 		(eq (getchar $inchar 2) (getchar mexplabel 2)))
> 	       ;; aha, this is a C-line: do the grinding:
> I could be wrong, but it looks like only one character is being
> looked at; so it can't distinguish between %i and %o.

Problem 1: mactex only checks for one character in the prompt. I
modified it to compare the using the length of inchar, as suggested by
Jay. Unfortunately, it still gets the wrong answer when I set inchar to
foo and outchar to foobar. Suggestions welcome.

On Mon, 2004-05-10 at 11:11, Richard Fateman wrote: 
> 1. certainly it would break mactex.  it could be fixed
> by having mactex generate \%o3   instead of %o3.  This
> would probably mean talking about \\%o3, which prints as \%o3.
> Should not be a big deal.

Problem 2: mactex doesn't quote % characters. I modified mactex to quote
them in prompts. I don't see a simple solution to quote all %
characters. Suggestions welcome.

> 2. inchar came out as %I instead of %i. Quirk of having %I defined
> as sqrt(-1). Maybe this will be fixed in the lower-case maxima..

Potential Problem 3: Indeed, this problem will be fixed in lower-case
maxima, aka Maxima 5.9.2+. It really isn't a problem for 5.9.1, either,
because I define inchar in lisp, therefore avoiding the case-guessing
code that spits out %I.

--Jim

P.S. Changes for above:

|addiator>cvs diff commac.lisp
Index: commac.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/commac.lisp,v
retrieving revision 1.13
diff -r1.13 commac.lisp
836a837,842
> (defun getchars (symb start end &aux strin)
>   (setq strin (string symb))
>   (cond ((and (<= start (length strin)) (> start 0))
>        (intern (string (subseq strin (f- start 1) (f- end 1)))))
>       (t nil)))
>

|addiator>cvs diff mactex.lisp
Index: mactex.lisp
===================================================================
RCS file: /cvsroot/maxima/maxima/src/mactex.lisp,v
retrieving revision 1.18
diff -r1.18 mactex.lisp
85c85,91
<
---
> (defun quote-% (sym)
>   (let ((strsym (string sym)))
>     (cond ((position (character "%") strsym)
>          (let ((pos (position (character "%") strsym)))
>            (concatenate 'string (subseq strsym 0 pos) "\\%"
>                         (quote-% (subseq strsym (+ pos 1))))))
>         (t strsym))))
105c111,112
<              (setq mexplabel (concat "(" (stripdollar mexplabel) ")"))
---
>              (setq mexplabel (concat "(" (quote-% (stripdollar
mexplabel))
>                                      ")"))
127c134,135
<               (eq (getchar $inchar 2) (getchar mexplabel 2)))
---
>               (eq (getchars $inchar 2 (length (string $inchar)))
>                   (getchars mexplabel 2 (length (string $inchar)))))