X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/ea214e5e3cb0bd99a1fb4e1a49652f0dcbc5fdde..5ffbe7949e61a61451bb6ebedc5482e8568d7421:/doc/sod.sty?ds=sidebyside

diff --git a/doc/sod.sty b/doc/sod.sty
index ffe2b9a..0452348 100644
--- a/doc/sod.sty
+++ b/doc/sod.sty
@@ -362,6 +362,13 @@
 }
 \def\desc@end{\endlist\after@desc\global\let\after@desc\saved@after@desc}
 
+\def\@ifnextchar@preserve#1#2#3{%
+  \let\want@= #1\def\@tempa{#2}\def\@tempb{#3}%
+  \futurelet\nch@\@ifnch@p%
+}
+\def\@ifnch@p{%
+  \ifx\want@\nch@\expandafter\@tempa\else\expandafter\@tempb\fi}
+
 \@namedef{describe*}#1{\desc@begin{#1}}
 \expandafter\let\csname enddescribe*\endcsname\desc@end
 \def\describe{\parse@dhd\desc@}
@@ -371,21 +378,21 @@
 \def\descref{\@ifstar%
   {\descref@i{}\@gobble{}}%
   {\descref@i{ (}{\noexpand\autopageref}{)}}}
-\def\descref@i#1#2#3#4{\@ifnextchar[%
-  {\descref@ii{#1}{#2}{#3}{#4}}%
-  {\descref@iii{#1}{#2}{#3}{#4}{}}}
-\def\descref@ii#1#2#3#4[#5]{\descref@iii{#1}{#2}{#3}{#4}{ #5}}
+\def\descref@i#1#2#3#4#5{\@ifnextchar@preserve[%
+  {\descref@ii{#1}{#2}{#3}{#4}{#5}}%
+  {\descref@iii{#1}{#2}{#3}{#4}{#5}{}}}
+\def\descref@ii#1#2#3#4#5[#6]{\descref@iii{#1}{#2}{#3}{#4}{#5}{ #6}}
 \def\descref@iii#1#2#3#4#5#6{%
   \begingroup%
     \let\protect\@empty%
     \def\@uscore{-\@gobble}%
     \edef\@tempa##1{%
       \endgroup%
-      \noexpand\hyperref[#6:#4]%
+      \noexpand\hyperref[#4:#5]%
       ##1%
-      #2{#6:#4}%
+      #2{#4:#5}%
     }%
-  \@tempa{{\code{#4}}#5#1}#3%
+  \@tempa{{\code{#5}}#6#1}#3%
 }
 
 %%%----- That's all, folks --------------------------------------------------
