[tex-eplain] Warnings about redefinition of xref labels

Oleg Katsitadze olegkat at gmail.com
Tue Feb 28 21:06:55 CET 2006


Hi,

Tomas Penicka (CC'd) provided me with code to issue warnings
about redefined cross-reference labels.  Here is the changed
definition of \@definelabel:

  \def\@definelabel#1#2#3{%
    %warn about multiple defined references. By Tomas Penicka, tom.penicka at centrum.cz
    \expandafter\ifx\csname\xrlabel{#1}\endcsname\relax
    \else
      \edef\oldvalue{\csname\xrlabel{#1}\endcsname}%
      \edef\newvalue{#2}%
      \ifx\oldvalue\newvalue
      \else
        \message{\linenumber Label '#1' '\csname#3word\endcsname'
                 '#2' already defined with a value
                 \csname\xrlabel{#1}\endcsname}%
      \fi
    \fi
    %end of warning
    % Define the control sequence.
    \expandafter\gdef\csname\xrlabel{#1}\endcsname{#2}%
    %
    % Remember what kind of label this is, so \ref will know what to do.
  %  \global\setproperty{\xrlabel{#1}}{class}{#3}%
    \setpropertyglobal{\xrlabel{#1}}{class}{#3}%
  }%


If it is indeed workable, I guess it would outdate this note
in xeplain.tex:

% [...] I
% would like to check for labels being defined twice, but I don't know
% how to do that.  If the cross-reference file has been read in, many
% cross-references will be defined that I don't want to complain about.
% It is only if two \xrdef commands are given to the same string that I
% want to complain.  I could define a new control sequence for each
% cross-reference, and check that, but that seems like too high of a
% price to pay.

I can't see any such problems with the above code (maybe I
am overlooking something?).  If somebody can think of any
problems, please let us know.  Otherwise it'll go into the
next release :).

Thanks,
Oleg



More information about the tex-eplain mailing list