% standard macros for CWEB listings (in addition to plain.tex)
% Version 2.0 --- Don Knuth, July 1990
% Version 2.0 [german] --- Carsten Steger, October 1991
% Version 2.0 [german] --- Andreas Scherer, February 1993
% Version 2.7 --- Don Knuth, July 1992
% Version 2.7 [p6c] --- Andreas Scherer, September 1993
% Version 2.8 --- Don Knuth, September 1992
% Version 2.8 [german] --- Carsten Steger, 1993
% Version 2.8 [p7] --- Andreas Scherer, October 1993
% Version 3.0 --- Don Knuth, June 1993
% Version 3.0 [p8e] --- Andreas Scherer, November 1993
% Version 3.1 [p9b] --- Andreas Scherer, January 1994
% Version 3.1 [p9c] --- Andreas Scherer, March 1994
% Version 3.1 [p9d] --- Andreas Scherer, July 1994
% Version 3.2 [p10] --- Andreas Scherer, July 1994
% Version 3.2 [p10a] --- Giuseppe Ghibò, September 1994
% Version 3.2 [p10b] --- Andreas Scherer, October 1994

\input Xcwebmac.tex

% I seguenti file di macro comprendono i segni diacritici e altri caratteri
% speciali per alcuni differenti tipi di codifica. Scegliete quello
% che si adatta meglio al vostro sistema. \`E definita la macro
% `\Cstringchars'.
\input ecma94.sty % ISO 8859-1/ECMA-94/Latin-1
%\input hp8.sty   % HP Roman 8
%\input mac8.sty  % Macintosh 8-bit font
%\input pc850.sty % IBM PC International Codepage 850

\def\.#1{\leavevmode\hbox{\tentex % typewriter type for strings
  \Cstringchars % special characters in a string
  \let\\=\BS % backslash in a string
  \let\{=\LB % left brace in a string
  \let\}=\RB % right brace in a string
  \let\~=\TL % tilde in a string
  \let\ =\SP % space in a string
  \let\_=\UL % underline in a string
  \let\&=\AM % ampersand in a string
  \let\^=\CF % circumflex in a string
  #1\kern.05em}}

\def\postATL#1 #2 {\bf lettera \\{\uppercase{\char"#1}}
   tangles as \tentex "#2"\egroup\par}
\def\ATH{\X\kern-.5em:Definizioni preprocessore\X}

\def\A{\note{Vedi anche sezione}} % xref for doubly defined section name
\def\As{\note{Vedi anche sezioni}} % xref for multiply defined section name

\def\ET{ e~} % conjunction between two section numbers
\def\ETs{ e~} % conjunction between the last two of several section numbers

\def\Q{\note{Questo codice \`e citato nella sezione}} % xref for mention of a section
\def\Qs{\note{Questo codice \`e citato nelle sezioni}} % xref for mentions of a section

\def\U{\note{Questo codice \`e usato nella sezione}} % xref for use of a section
\def\Us{\note{Questo codice \`e usato nelle sezioni}} % xref for uses of a section

\gtitle={Output \.{CWEB}} % this running head is reset by starred sections
\mark{\noexpand\nullsec0{\the\gtitle}}

\def\ch{\note{Le seguenti sezioni sono state modificate tramite il change-file:}
  \let\*=\relax}

\def\inx{\par\vskip6pt plus 1fil % we are beginning the index
  \def\page{\box255 } \normalbottom
  \write\cont{} % ensure that the contents file isn't empty
       \write\cont{\catcode `\noexpand\@=12\relax}   % \makeatother
  \closeout\cont % the contents information has been fully gathered
  \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
    \global\setbox\sbox=\page \global\pagesavedtrue}
  \pagesavedfalse \eject % eject the page-so-far and predecessors
  \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
  \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
  \hsize=.5\pagewidth \advance\hsize by -10pt
    % column width for the index (20pt between cols)
  \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
  \def\lr{L} % this tells whether the left or right column is next
  \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
    \else\normaloutput{\vbox to\pageheight{\box\sbox\vss
        \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
    \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
  \message{Indice Analitico:}
  \parskip 0pt plus .5pt
  \outer\def\I##1, {\par\hangindent2em\noindent##1:\kern1em} % index entry
  \def\[##1]{$\underline{##1}$} % underlined index item
  \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
  \hyphenpenalty 10000 \parindent0pt
  \readindex}

\def\fin{\par\vfill\eject % this is done when we are ending the index
  \ifpagesaved\null\vfill\eject\fi % output a null index column
  \if L\lr\else\null\vfill\eject\fi % finish the current page
  \parfillskip 0pt plus 1fil
  \def\grouptitle{NOMI DELLE SEZIONI}
  \let\topsecno=\nullsec
  \message{Nomi delle sezioni:}
  \output={\normaloutput\page\lheader\rheader}
  \setpage
  \def\note##1##2.{\quad{\eightrm##1~##2.}}
  \def\Q{\note{Citato nella sezione}} % crossref for mention of a section
  \def\Qs{\note{Citato nelle sezioni}} % crossref for mentions of a section
  \def\U{\note{Usato nella sezione}} % crossref for use of a section
  \def\Us{\note{Usato nelle sezioni}} % crossref for uses of a section
  \def\I{\par\hangindent 2em}\let\*=*
  \readsections}
\def\con{\par\vfill\eject % finish the section names
% \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
  \rightskip 0pt \hyphenpenalty 50 \tolerance 200
  \setpage \output={\normaloutput\page\lheader\rheader}
  \titletrue % prepare to output the table of contents
  \pageno=\contentspagenumber
  \def\grouptitle{INDICE}
  \message{Indice:}
  \topofcontents
  \line{\hfil Sezione\hbox to3em{\hss Pag.}}
  \let\ZZ=\contentsline
  \readcontents\relax % read the contents info
  \botofcontents \end} % print the contents page(s) and terminate
\def\today{\number\day\space\ifcase\month\or
  gennaio\or febbraio\or marzo\or aprile\or maggio\or giugno\or
  luglio\or agosto\or settembre\or ottobre\or novembre\or dicembre\fi
  \space\number\year}
\newcount\twodigits
\def\datethis{\def\startsection{\leftline{\sc\today, ore \hours}\bigskip
  \let\startsection=\stsec\stsec}}
  % say `\datethis' in limbo, to get your listing timestamped before section 1
\def\datecontentspage{%
  \def\topofcontents{\leftline{\sc\today, ore \hours}\bigskip
   \centerline{\titlefont\title}\vfill}} % timestamps the contents page
