# Unexpected ‘Undefined control sequence’ in XeTeX, but not in TeX

When trying to do grid typesetting in plain TeX I stumbled upon old upages, which looks very promising (see also this introduction). So I opened upages-20001214.tar.gz and put everything in uplain/upages/ in a directory.

To test the package, I created a minimal file saying

\input upages
bla bla bla
\bye


and tried to compile this. However, XeTeX chokes on a certain line:

This is XeTeX, Version 3.14159265-2.6-0.99991 (TeX Live 2014/Arch Linux) (preloaded format=xetex)
restricted \write18 enabled.
entering extended mode
(./gridtest.tex (./upages.tex (./umaster.tex
! Undefined control sequence.
l.519 \def\@innernewread
{\alloc@6\read\chardef\fift@@n}
?
! Emergency stop.
l.519 \def\@innernewread
{\alloc@6\read\chardef\fift@@n}
No pages of output.
Transcript written on gridtest.log.


Why does it say ‘Undefined control sequence’ if that macro is just to be \defined? The strange thing is: I remember using upages years ago and it compiled just fine. Even now, when trying just tex gridtest, it compiles fine, but using pdfTeX or XeTeX, it spits out this error.

## 1 Answer

The exact error is pretty arbitrary, it's just that the expansion has taken a wrong path and so generates an error first time it tries something really illegal.

You see the error by changing from tex to etex in formats with the etex extensions activated (except latex, oddly enough) the register allocation macros are updated because there are 32768 rather than 256 registers. The macros are designed to patch those allocations and basically aren't expecting the new forms.

With xetex there are additional problems in that some of the files are using non ascii characters not in utf8 encoding The log shows several instances of

Invalid UTF-8 byte or sequence at line 2 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 3 replaced by U+FFFD.
Invalid UTF-8 byte or sequence at line 3 replaced by U+FFFD.