[Xy-pic] Small bug in xygraph

Daniel A. Steffen steffen@ics.mq.edu.au
Fri, 17 Jan 2003 12:21:27 +1100


Found a problem in \newgraphescape when used with the graphics
package under recent tetex latex:

The following testcase exhibits the problem

     \documentclass{article}
     \usepackage{graphics}
     \usepackage[graph]{xy}
     \newgraphescape{p}#1{#1}
     \begin{document}
     \end{document}

this will fail in \begin{document} with the following error

     ! Illegal parameter number in definition of \dodohandletokens.
     <to be read again>
                        \end
     l.621   {\ifx\next\end
                            \else

(\dodohandletokens is defined in tex/context/base/supp-mis.tex)

if the \newgraphescape line is changed to
     \newgraphescape{p}{}
the problem goes away (i.e. the #1 form of newgraphescape is what
causes the error).

Ross Moore helped me trace the problem, we found that the root cause
was that \newgraphescape was leaving \next defined to "#" after its
execution.

The patch below fixes this by resetting \next to \relax
at the end of \newgraphescape.

Note that similar fixes could be needed elsewhere in xypic:

On Thursday, Jan 16, 2003, at 18:21 Australia/Sydney, Ross Moore wrote:

> The patch will fix the problem with \newgraphescape ,
> but there could be other places in Xy-pic where something
> similar is needed.
>
> Those parsers should not leave dirty side-effects, even after
> incorrect tokens for a diagram: a parser should either fail itself,
> or complete cleanly.

Cheers,

Daniel

--
** Daniel A. Steffen     **  "And now to something completely
** Dept. of Mathematics  **   different"    Monty Python
** Macquarie University  **  <mailto:steffen@maths.mq.edu.au>
** NSW 2109 Australia    **  <http://www.maths.mq.edu.au/~steffen/>

------------------------------------------------------------------------ 
--
diff -u -r orig/xygraph.doc fix/xygraph.doc
--- orig/xygraph.doc    Wed Feb 17 01:25:00 1999
+++ fix/xygraph.doc     Fri Jan 17 12:10:46 2003
@@ -1,4 +1,4 @@
-%% $Id: xygraph.doc,v 3.7 1999/02/16 15:12:50 krisrose Exp $
+%% $Id: xygraph.doc,v 3.8 2003/01/16 18:00:00 krisrose Exp $
  %%
  %% Xy-pic ``Graph Combinator feature'' option.
  %% Copyright (c) 1994-1997     Kristoffer H. Rose       
<krisrose@brics.dk>
@@ -23,7 +23,7 @@
  %%
  \ifx\xyloaded\undefined \input xy \fi

-\xyprovide{graph}{Graph feature}{\stripRCS$Revision: 3.7 $}%
+\xyprovide{graph}{Graph feature}{\stripRCS$Revision: 3.8 $}%
   {Kristoffer H.~Rose}{krisrose@brics.dk}%
   {BRICS/Computer Science, University of Aarhus, Ny Munkegade, building  
540,
    DK--8000 Aarhus~C}
@@ -609,7 +609,7 @@
    \ifx\newcommand\undefined \xyerror@{[n] only with LaTeX}%
    \else
     \def\nextiv@{\expandafter\newcommand\expandafter{\csname  
G!#1\endcsname}}\fi
- \else \def\nextiv@{\expandafter\gdef\csname G!#1\endcsname}\fi  
\nextiv@}
+ \else \def\nextiv@{\expandafter\gdef\csname G!#1\endcsname}\fi  
\let\next\relax\nextiv@}

  \xydef@\rungraphescape@#1{%
   \expandafter\let\expandafter\next\csname graph !#1\endcsname
diff -u -r orig/xygraph.tex fix/xygraph.tex
--- orig/xygraph.tex    Wed Feb 17 01:25:00 1999
+++ fix/xygraph.tex     Fri Jan 17 12:11:38 2003
@@ -1,4 +1,4 @@
-%% xygraph.tex from $Id: xygraph.doc,v 3.7 1999/02/16 15:12:50  
krisrose Exp $
+%% xygraph.tex from $Id: xygraph.doc,v 3.8 2003/01/16 18:00:00  
krisrose Exp $
  %%
  %% Xy-pic ``Graph Combinator feature'' option.
  %% Copyright (c) 1994-1997 Kristoffer H. Rose <krisrose@brics.dk>
@@ -22,7 +22,7 @@
  %% 675 Mass Ave, Cambridge, MA 02139, USA.
  %%
  \ifx\xyloaded\undefined \input xy \fi
-\xyprovide{graph}{Graph feature}{\stripRCS$Revision: 3.7 $}%
+\xyprovide{graph}{Graph feature}{\stripRCS$Revision: 3.8 $}%
   {Kristoffer H.~Rose}{krisrose@brics.dk}%
   {BRICS/Computer Science, University of Aarhus, Ny Munkegade, building  
540,
   DK--8000 Aarhus~C}
@@ -214,7 +214,7 @@
   \ifx\newcommand\undefined \xyerror@{[n] only with LaTeX}%
   \else
   \def\nextiv@{\expandafter\newcommand\expandafter{\csname  
G!#1\endcsname}}\fi
- \else \def\nextiv@{\expandafter\gdef\csname G!#1\endcsname}\fi  
\nextiv@}
+ \else \def\nextiv@{\expandafter\gdef\csname G!#1\endcsname}\fi  
\let\next\relax\nextiv@}
  \xydef@\rungraphescape@#1{%
   \expandafter\let\expandafter\next\csname graph !#1\endcsname
   \ifx\next\relax \xyerror@{Undefined graph <escape> !#1}\fi \next}