X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/ddfe426573957fa52102832a51582bb134ee7b42..020b9e2b4364c61a668d47c4c5405295349817d8:/doc/sod.sty

diff --git a/doc/sod.sty b/doc/sod.sty
index acc4370..1f653c9 100644
--- a/doc/sod.sty
+++ b/doc/sod.sty
@@ -7,7 +7,7 @@
 
 %%%----- Licensing notice ---------------------------------------------------
 %%%
-%%% This file is part of the Sensble Object Design, an object system for C.
+%%% This file is part of the Sensible Object Design, an object system for C.
 %%%
 %%% SOD is free software; you can redistribute it and/or modify
 %%% it under the terms of the GNU General Public License as published by
@@ -62,7 +62,7 @@
 \let\syntright\empty
 
 %% Literal code is in sans face.
-\let\codeface\sffamily
+\def\codeface{\upshape\sffamily}
 \DeclareRobustCommand\code[1]{%
   \ifmmode\hbox\else\leavevmode\fi%
   {\normalfont\codeface\/#1\/}%
@@ -79,7 +79,7 @@
 \atdef <#1>{\synt{#1}\@scripts}
 \atdef "#1"{\lit*{#1}\@scripts}
 \atdef `#1'{\lit{#1}\@scripts}
-\atdef |#1|{\textsf{#1}\@scripts}
+\atdef |#1|{\lit*{#1}\@scripts}
 
 %% A handy abbreviation; `\\' itself is too good to steal.
 \atdef \\{\textbackslash}
@@ -116,17 +116,42 @@
 \atdef !{\m@maybe|\@scripts}
 \def\returns{\m@maybe\longrightarrow\m@maybe@end\hspace{0.5em}\ignorespaces}
 \atdef >{\leavevmode\unskip\hspace{0.5em}\returns}
-\atdef -#1{\if>#1{\ensuremath\rightarrow}\fi}
+\atdef -#1{\if>#1\hbox{--\raisebox{.4pt}{>}}\penalty200\relax\fi}
 
 %% Comment setting.
-\atdef ;#1\\{\normalfont\itshape;#1\\}
+\def\comment#1{\mbox{\normalfont\itshape\/#1\/}}
+\atdef /*#1*/{/*\comment{#1}*/}
+\def\@semis{\@ifnextchar;{;\@semis}\@semicomment}
+\def\@semicomment#1\\{\comment{#1}\\}
+\atdef ;#1\\{;\@semis}
 
 %% Environment for setting programs.  Newlines are explicit, because
 %% otherwise I need comments in weird places to make the vertical spacing
 %% come out properly.  You can write `\obeylines' if you really want to.
-\def\prog{\codeface\quote\tabbing}
+\def\@prog{\let\prog@@cr\@tabcr\let\@tabcr\@progcr\codeface\tabbing}
+\def\prog{\quote\@prog}
 \def\endprog{\endtabbing\endquote}
+\let\nprog\@prog
+\let\endnprog\endtabbing
 \def\ind{\quad\=\+\kill}
+\def\@progcr{\futurelet\@tempa\@progcr@i}
+{\def\:{\gdef\@progcr@sp}\: {\@progcr}}
+\def\@progcr@i{%
+  \ifx\@tempa\@sptoken\let\next@\@progcr@sp\else
+  \if1\ifx\@tempa[1\else
+      \ifx\@tempa*1\else
+      0\fi\fi
+    \let\next@\prog@@cr\else
+  \if1\ifx\@tempa+1\else
+      \ifx\@tempa-1\else
+      0\fi\fi
+    \let\next@\@progcr@ii\else
+  \let\next@\@progcr@a\fi\fi\fi
+  \next@}
+\def\@progcr@a{\prog@@cr*{}\ignorespaces}
+\def\@progcr@ii#1{\csname @progcr@#1\endcsname\ignorespaces}
+\@namedef{@progcr@+}{\prog@@cr[\medskipamount]}
+\@namedef{@progcr@-}{\prog@@cr*[\jot]}
 
 %% Put a chunk of text in a box.
 \newenvironment{boxy}[1][\q@]{%
@@ -151,6 +176,7 @@
 \definedescribecategory{sym}{symbol}
 \definedescribecategory{fun}{function}
 \definedescribecategory{gf}{generic function}
+\definedescribecategory{msg}{message}
 \definedescribecategory{var}{variable}
 \definedescribecategory{modvar}{module variable}
 \definedescribecategory{const}{constant}
@@ -206,10 +232,9 @@
   \if@nobreak\else\par\goodbreak\fi%
   \global\@dheadfirsttrue%
   \begingroup%
-    \codeface%
     \let\@endparenv\relax%
     \clubpenalty\@M \widowpenalty\@M \interlinepenalty50%
-    \tabbing#1\endtabbing%
+    \@prog#1\endtabbing%
   \endgroup%
   \penalty\@M\@afterheading%
   \list{}{\rightmargin\z@\topsep\z@}\item%
@@ -222,5 +247,14 @@
 \def\desc@#1#2#3{\desc@begin{\dhead@{#1}{#2}{#3}}}
 \let\enddescribe\desc@end
 
+\def\descref#1{\@ifnextchar[{\descref@i{#1}}{\descref@ii{#1}{}}}
+\def\descref@i#1[#2]{\descref@ii{#1}{ #2}}
+\def\descref@ii#1#2#3{%
+  \code{#1}#2 (page~%
+  {\let\protect\@empty%
+   \def\@uscore{-\@gobble}\edef\@tempa{\noexpand\pageref{#3:#1}}\@tempa}%
+  )%
+}
+
 %%%----- That's all, folks --------------------------------------------------
 \endinput
