Dear GPC folks,
I just installed GPC 2.8.1 on my new Linux machine, which is replacing the Sparc that I've been using since 1989. Naturally I want to be able to achieve on my new machine what I could do on my old one; thus it is important to me that I can still compile the absolutely official Pascal-based version of TeX, even though everybody [including me] uses the Web2C-translated version for production runs.
So I began today to look at those old programs and to remind myself about Pascal syntax. When TeX was being developed in the late 70s and early 80s, we chose Pascal for TeX82 because it was the most widely understood language. People told me that the Pascal versions of TeX and METAFONT were ported to more than 100 different platforms. I myself used Pascal-H on a TOPS10 machine, later Berkeley Pascal on an early version of SunOS, later a much better Sun Pascal that was developed I think in Russia.
Since these programs were much larger than typical student-oriented Pascal source code, they tended to find at least one bug in every new Pascal compiler they faced. "New users find new bugs." Sure enough, it seems GNU Pascal is no exception... I believe your otherwise-admirable program is actually otherwise-flaky, in the sense that it fails to parse the "otherwise" keyword for case-statement defaults when the case statement in question includes another (nested) case statement.
For example, gpc does not parse the following program:
---------- cut here for bug.p ------------------------------------- program bug(input,output); var x : integer; begin readln(x); case x mod 2 of 0 : begin case x mod 4 of 2 : writeln('oddly even'); 0 : writeln('evenly even'); end; { case } end; otherwise writeln('odd'); end; { case } end. -------------------------------------------------------------------
On the other hand it handles a similar program with ease:
---------- cut here for nobug.p ----------------------------------- program bug(input,output); var x : integer; begin readln(x); case x mod 2 of 0 : begin if (x mod 4)=2 then writeln('oddly even') else writeln('evenly even'); end; otherwise writeln('odd'); end; { case } end. --------------------------------------------------------------------
To work around this, I had to change nested case statements into programs that used only if-then-else.
Another problem I had was a segmentation fault on F_Flush(Output) after defining procedure F_Flush(var aFile); asmname '_p_f_flush'; as recommended in your documentation. I didn't have time to pursue this to figure out what was failing, because it was easier for me just to say procedure Flushstdout; external; and then load the C routine void Flushstdout(){fflush(stdout)} with the compiled object code.
With these two changes, I successfully got the TANGLE program to reproduce itself, so the first major hurdle towards generating retro-TeX has been passed! If I run into any more bugs, I'll let you know --- the TRIP and TRAP tests of TeX and METAFONT are pretty good test suites.
But let's be optimistic and suppose that everything else works. Then I won't have to write you again.
In any case when the new GNU-Pascal-based port of TeX is ready I will post the sources to the CTAN archives; they will be at labrea.stanford.edu in directory ~ftp/pub/tex/local.
Best wishes on your important project! -- Don Knuth
Dear Maggie McLoughlin, dear Don Knuth,
you wrote:
I believe your otherwise-admirable program is actually otherwise-flaky, in the sense that it fails to parse the "otherwise" keyword for case-statement defaults when the case statement in question includes another (nested) case statement.
For example, gpc does not parse the following program: [...]
This was a bug in older versions of GPC which is fixed meanwhile. Be invited to try a more recent release:
ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/alpha/gpc-19991030.tar.gz
(The next release is being worked on, of course.)
Another problem I had was a segmentation fault on F_Flush(Output) after defining procedure F_Flush(var aFile); asmname '_p_f_flush';
This is clear since '_p_f_flush' is intended to be used only internally.
as recommended in your documentation.
Where do we recommend that? I cannot find it, but if we do, it is a bug in the documentation.
Instead of '_p_f_flush', please use
Flush (Output)
to flush standard output.
With these two changes, I successfully got the TANGLE program to reproduce itself, so the first major hurdle towards generating retro-TeX has been passed!
That's good news. :-)
If I run into any more bugs, I'll let you know --- [...]
Thank you. But then it is even more important to use a more recent version of GPC. Maybe you should observe our (low-traffic) announce list, gpc-announce@gnu.de, to stay up-to-date. To subscribe to the list, write an email with "subscribe gpc-announce" in the body to majordomo@gnu.de. (The subject will be ignored.)
Thank you for your interest in GNU Pascal,
Peter Gerwinski