🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #11460

Re: TeX macros to format C without outside assistance

#11460
From: Eamonn McManus
Date: Mon, 05 Mar 1990 23:19
66 lines
2400 bytes
As promised, here is the test input I use for testing the C program macros.
I've tried to put instances of most tricky cases here, so that people
tweaking the macros can make sure they don't break anything.  There are
also enough examples that you can get an idea of what C programs look like
in general.  You can see from the three #defines that non-initial tabs
don't work very well.


% tcprog.tex - LaTeX test file for cprog.sty
% This isn't a valid C program, it just tests the cprog macros.
\documentstyle[cprog]{article}	% Plain TeX: \input cprog
\beforecprogskip=0.3in
\aftercprogskip=0.3in
\cprogindent=1in
\begin{document}		% Plain TeX: remove this line.
% Ensure it can be input multiple times; plain TeX: \input cprog
\input cprog.sty
% Paragraph so we can be sure \beforeprogskip works properly.
hello, world
% Start cprog environment.  Plain TeX: \cprog
\begin{cprog}
/* t.c - test file for cprog macros. */

/* This is a comment
 * extending over
 * several lines.
 */

	/* Indented comment,
	 * ditto.
	 */

/**** Yukky comment! ****/

"Funny string, with ', \\, \", etc."
"Funny and \
continued string."

#define ONE	1	/* Unit. */
#define TWO	2	/* Two units. */
#define THREE	3	/* Three units. */

if (!(x & ONE)) {
	foo(a % 5); foo('a'); foo('\'');
	foo(a * 5); foo(a + 5); foo2(a, b);
	foo((int)2.3); foo(a / 5); foo(a ? a : 5);
	if (a < b || a > c) range(a);
	if (a == b) a = c;
	while (p[a] != p[i]) a++;
#define macro (1 + \
		1)
	foo(something_else);
	foo(~a);
	if (a <= b || a >= b || a != b) {
		a <<= b;
		b = a << 5;
		b >>= a;
	}
}
\end{cprog}
% Another paragraph, for \aftercprogskip.
hello again
\end{document}	% Plain TeX: \bye
--
Eamonn McManus <emcmanus@cs.tcd.ie>	<emcmanus%cs.tcd.ie@cunyvm.cuny.edu>
	  One of the 0% of Americans who are not Americans.
Technical Details
Message-ID: <1706@tws8.cs.tcd.ie>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!emcmanus
References: <4354@jhunix.HCF.JHU.EDU> <1704@tws8.cs.tcd.ie> <1705@tws8.cs.tcd.ie>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!emcmanus
From: emcmanus@cs.tcd.ie (Eamonn McManus)
Newsgroups: comp.text.tex
Subject: Re: TeX macros to format C without outside assistance
Summary: Test input for the macros
Keywords: TeX, LaTeX, C
Message-ID: <1706@tws8.cs.tcd.ie>
Date: 5 Mar 90 23:19:03 GMT
References: <4354@jhunix.HCF.JHU.EDU> <1704@tws8.cs.tcd.ie> <1705@tws8.cs.tcd.ie>
Organization: Computer Science Department, Trinity College Dublin
Lines: 66
Fcc: comp/text/tex