[comp.lang.c] Notes on Writing Portable Programs in C: portableC.sty

gvr@cs.brown.edu (George V. Reilly) (11/30/90)

% conf option for article.sty, created by DCH
% for Maths of Surfaces III, 15 May 89
% only modification: changing III to IV - AB 27 June 1990
%
% modified by ado@sauna.hut.fi for portable C notes.
% Everything was commented out except the page size definitions.
% If one uses art12.sty without these definitions it looks, well, stupid.
% One can format portableC.tex without this file; all you must do is
% remove the reference to portableC.sty in the \documentstyle command.

\typeout{Document Style Option `portable c'.}
\@twosidetrue \@mparswitchtrue
\input art12.sty \relax
 
% for r.h. running head
\def\booktitle{C Portability Notes}
 
\def\sectsize{\Large}
 
\oddsidemargin .25in \evensidemargin .25in
\marginparwidth 1in \marginparsep 7pt
 \topmargin 0in \headheight 12pt \headsep 20pt \footheight 12pt \footskip
30pt
 
\textheight 620pt \textwidth 32.5pc \columnsep 10pt \columnseprule 0pt
 
%\def\@p@rt{\@startsection{part}{0}{\z@}{-3.5ex plus -1ex minus
% -.2ex}{2.3ex plus .2ex}{\noindent\Large\bf\@partapp}}
%\def\part#1{\setcounter{equation}{0} \@p@rt{#1}
% \message{``\@partapp-\thepart. #1'' }\medskip}
 
%\def\@section{\@startsection{section}{1}{\z@}{-3.5ex plus -1ex minus
% -.2ex}{2.3ex plus .2ex}{\sectsize\bf}}
%\def\section#1{\setcounter{equation}{0} \@section{#1}
% }
 
%\def\partmark#1{}
 
%\def\appendix{\clearpage
% \setcounter{part}{0}
% \setcounter{section}{0}
% \def\@partapp{Appendix}\def\sectsize{\large}
% \def\thepart{\Alph{part}}\def\thesection{\thepart.\arabic{section}}
%\message{Appendix }}
 
%\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
%  \def\@citea{}\@cite{\@for\@citeb:=#2\do
%    {\@citea\def\@citea{,\,\linebreak[0]\relax}\@ifundefined
%       {b@\@citeb}{{\bf ?}\@warning
%       {Citation `\@citeb' on page \thepage \space undefined}}%
%\hbox{\csname b@\@citeb\endcsname}}}{#1}}
 
%\@addtoreset{equation}{part}
%\@addtoreset{equation}{section}
%\def\theequation{\thesection.\arabic{equation}}
 
%\def\endtitlepage{\if@restonecol \twocolumn \else \relax \fi}
 
\arraycolsep .5ex \tabcolsep .6ex \arrayrulewidth .04ex \doublerulesep .2ex
\tabbingsep \labelsep
 
\skip\@mpfootins = \skip\footins
\fboxsep = .3ex \fboxrule = .04ex
 
%\def\@partapp{Part}
 
%\def\tableofcontents{\section*{Contents}
% \@starttoc{toc}\message{Contents }}
%\def\listoffigures{\@section*{List of Figures}\@starttoc{lof}}
%\def\listoftables{\@section*{List of Tables}\@starttoc{lot}}
 
% Normally references are to be cited by "[n]",
% and bibliography to be labelled correspondingly.  If cited
% by name and date explicitly, use "\unnumberedbib".
%\newif\ifnumberedbib \numberedbibtrue
%\def\numberedbib{\numberedbibtrue}
%\def\unnumberedbib{\numberedbibfalse}
 
%\def\@biblabel#1{\ifnumberedbib{[#1]}\else\relax\fi}
%\def\thebibliography#1{\setcounter{totalnumber}{0}
%\@section*{References}\message{References }
%\ifnumberedbib
%    \list
%  {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin\labelwidth
%     \advance\leftmargin\labelsep
%     \usecounter{enumi}}
%\else
%    \list{}{}
%\fi
%     \sloppy\clubpenalty4000\widowpenalty4000
%     \sfcode`\.=1000
%\relax}
%\def\endthebibliography{\endlist
%\setcounter{totalnumber}{3}}
 
%\def\theindex{\@restonecoltrue
%\columnseprule \z@
%\columnsep 3.5ex\twocolumn[\@section*{Index}]
% \thispagestyle{plain}\parindent\z@
% \parskip\z@ plus .3pt\relax\let\item\@idxitem}
 
\long\def\@makecaption#1#2{
 \vskip 1ex
 \setbox\@tempboxa\hbox{ {\sc #1.} \strut\ #2}
 \ifdim \wd\@tempboxa >\hsize
   \unhbox\@tempboxa\protect\centering\par
 \else
   \hbox to\hsize{\hfil\box\@tempboxa\hfil}
 \fi}
 
% for left and right captions
\def\halfbox#1{\hfil\parbox[t]{0.475\hsize}{#1}\hfil}
 
\def\fnum@figure{Figure\enskip\thefigure}
\def\fnum@table{Table\enskip\thetable}
 
% title and authors appear on first page
%\def\maketitle{\begin{titlepage}\thispagestyle{plain}
% \let\footnotesize\small \let\footnoterule\relax
%  \null
%  \begin{center}
% { \Large \bf \@title \par}
% \vskip 1em {\large \lineskip .75em
% \begin{tabular}[t]{c}\@author
% \end{tabular}\par}
%  \end{center} \par
%\@thanks
%\null
%\end{titlepage}
%\setcounter{footnote}{0} \let\thanks\relax
%\gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\maketitle\relax \par}
 
%\def\abstract{\message{Abstract}\small
%\begin{center}
%{\bf Abstract\vspace{-.5em}\vspace{0pt}}
%\end{center}
%\quotation}
 
%\def\endabstract{\endquotation}
 
%\mark{{}{}}
 
% \shortauthor{surname(s)} used for l.h. running head
\def\short@uthor{}
\def\shortauthor#1{\def\short@uthor{#1}}
 
% \affil affiliation used below author(s) (like \and)
%\def\affil{\end{tabular}
%\vskip-2ex\begin{tabular}[t]{c}\rule{.9\hsize}{0pt}\\ \em}
 
\if@twoside \def\leftmark{\short@uthor}\def\rightmark{\booktitle}
\def\ps@headings{\def\@oddfoot{}\def\@evenfoot{}\def\@evenhead{\rm
\thepage\hfil \it \leftmark}\def\@oddhead{\hbox{} \it \rightmark \hfil
\rm\thepage}\def\sectionmark##1{}\def\subsectionmark##1{}}
\else \def\rightmark{\short@uthor}
\def\ps@headings{\def\@oddfoot{}\def\@evenfoot{}\def\@oddhead{\hbox
{}\it \rightmark \hfil \rm\thepage}\def\sectionmark##1{\markright
{}}}
\fi
\def\ps@myheadings{\def\@oddhead{\hbox{}\rm\rightmark \hfil
\rm\thepage}\def\@oddfoot{}\def\@evenhead{\rm \thepage\hfil\rm\leftmark\hbox
{}}\def\@evenfoot{}\def\sectionmark##1{}\def\subsectionmark##1{}}
 
\newenvironment{ackn}{\subsection*{}\begin{quotation}\small
\message{Acknowledgments }}{\end{quotation}}
 
% miscellaneous mathematical symbols and forms:
 
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{definition}{Definition}[section]
\newenvironment{proof}{
 \begin{quote}{\bf Proof\ }}{
 \nolinebreak\hbox{\ $\Box$}\end{quote}}
% necessary if special format to be used for theorems, etc.
\newenvironment{corollary}[1]{
\it\trivlist\item[\hskip\labelsep{\bf Corollary\ #1}]}{\endtrivlist}
% NB corollary is not numbered and needs an argument
 
\newcounter{equationgroup}
\newenvironment{eqngroup}{%
\setcounter{equationgroup}{\value{equation}}\setcounter{equation}\z@%
\def\theequationgroup{\thesection.\arabic{equationgroup}}%
\def\theequation{\theequationgroup\alph{equation}}%
\refstepcounter{equationgroup}}{%
\setcounter{equation}{\value{equationgroup}}%
\def\theequation{\thesection.\arabic{equation}}%
\global\@ignoretrue}
 
\def\trace{\mathop{\rm trace}\nolimits} % trace function
\def\sgn{\mathop{\rm sgn}\nolimits} % sign function
\def\cosec{\mathop{\rm cosec}\nolimits} % cosecant function
 
\def\dd{{\rm d}} % roman d for use in derivative and integral
\def\DD{{\rm D}} % roman D for use as total derivative
\def\ee{{\rm e}} % roman e for 2.71828...
\def\ii{{\rm i}} % roman i for sqrt(-1)
 
\def\binom#1#2{{#1\choose#2}} % \binom{n}{r} gives binomial coefficient
 
\def\abs#1{\left|#1\right|} % absolute value, any size
\def\norm#1{\left\|#1\right\|} % norm, any size
 
% incorporate any additional commands I find necessary
 
\def\<#1>{{\tt #1}}		% Fragment of C code
\def\GT{{\tt>}}			% So can have a `>' within \<...>
\def\GE{{\tt>=}}		% So can have a `>=' within \<...>
\def\fe#1{{\it float\_expr#1\/}}% Save a bit of typing
\def\e.g.{{\em e.g.},}		% Save a bit of typing
\def\C++{C\raise.23ex\hbox{++}}	% Looks better as the ++ is too low otherwise
\newcommand{\ng}[1]{{\bf #1}}	% Newsgroup, e.g., comp.lang.c
\newcommand{\id}[1]{{\tt #1}}	% User id, e.g., ado@cs.hut.fi
\newcommand{\cmd}[1]{{\tt #1}}	% Command, e.g., make, ar
\newcommand{\site}[1]{{\tt #1}}	% Site, e.g., cs.washington.edu
\newcommand{\file}[1]{{\rm`\tt#1\rm'}}	% a file name
\chardef\twiddle="7E			% A hack to get the `~' character

% The `big' stuff below is taken from fixup.sty
%        by John Hobby (hobby@research.att.com)
% Fix Plain's \bigl, \Bigl, etc. macros so that they try to scale with
% LaTeX size changes.  This uses the fact that \@setsize sets \ht\strutbox
% to be 70% of the normal unstretched baselineskip.
\def\big#1{{\hbox{$\left#1\vcenter to1.428\ht\strutbox{}\right.\n@space$}}}
\def\Big#1{{\hbox{$\left#1\vcenter to2.142\ht\strutbox{}\right.\n@space$}}}
\def\bigg#1{{\hbox{$\left#1\vcenter to2.857\ht\strutbox{}\right.\n@space$}}}
\def\Bigg#1{{\hbox{$\left#1\vcenter to3.571\ht\strutbox{}\right.\n@space$}}}

\hyphenation{inter-chan-ge-ably}
\hyphenation{com-pi-ler}

%\typein[\firstpage]{Enter first (odd) page number for this contribution!}
\newcounter{firstpage}
\setcounter{firstpage}{1}
 
\clubpenalty=500 \widowpenalty=500
\ps@headings \pagenumbering{arabic} \onecolumn
%\setcounter{page}{1}