Re: Colliding identifiers in MP.W

Andreas Scherer <[email protected]> Tue, 3 Feb 2026 16:53:31 +0100
Newsgroups gmane.comp.tex.metapost
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------4LHex6nbPcy3Hz8Rfz2SIKt5
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Am 10.05.24 um 17:12 schrieb Andreas Scherer:
> CWEB source file MP.W _exports_ 'enum mp_color_model' to MPLIB.H in 
> section [205], but _uses_ macro '@d mp_color_model' from section [462] 
> internally. [Section numbers corrected for MetaPost 3.0a.]
While C doesn't have a problem with this situation (the functional macro 
never overwrites the enum type), CWEB can't cope with the two competing 
identifiers. The 'enum mp_color_model' always is typeset in bold and its 
'ilk' can not be reset, so the macro '#define mp_color_model(A)...' also 
is typeset in bold instead of in italics.

By applying a CWEB coding trick (aka 'kludge'), we can hide the 'enum' 
from the CWEAVE parser, so the secondary 'macro' gets treated correctly. 
With some additional CWEB formatting and an extra index entry, the two 
separate items appear side by side in the index. Only the macro is used 
in multiple sections, the 'enum' is never used per se.

Attached is a small patch that I apply in the larger 'mp.ch' in 
https://github.com/ascherer/mplibdir and later in the 'knuth-pdf' package.

Case closed,
Andreas
--------------4LHex6nbPcy3Hz8Rfz2SIKt5
Content-Type: text/x-patch; charset=UTF-8; name="mp_color_model.diff"
Content-Disposition: attachment; filename="mp_color_model.diff"
Content-Transfer-Encoding: base64

ZGlmZiAtLWdpdCBhL3RleGsvd2ViMmMvbXBsaWJkaXIvbXAudyBiL3RleGsvd2ViMmMvbXBs
aWJkaXIvbXAudwppbmRleCAxNjBlZGQxYzEzLi44YzJjMTQ3NmU0IDEwMDY0NAotLS0gYS90
ZXhrL3dlYjJjL21wbGliZGlyL21wLncKKysrIGIvdGV4ay93ZWIyYy9tcGxpYmRpci9tcC53
CkBAIC00Mzc5LDEzICs0Mzc5LDE0IEBAIHRoZSBmYWN0IHRoYXQgdGhlcmUgaGFzIG5vdCBi
ZWVuIGFueSBraW5kIG9mIGNvbG9yIHNwZWNpZmljYXRpb24gYnkKIHRoZSB1c2VyIHNvIGZh
ciBpbiB0aGUgZ2FtZS4KIAogQDxNUGxpYiBoZWFkZXIgc3R1ZmZAPj0KLWVudW0gbXBfY29s
b3JfbW9kZWwgeworZW51bSBtcEAmX2NvbG9yQCZfbW9kZWwgQCsgeyBAdFwxQD5ALworQDpt
cF9jb2xvcl9tb2RlbH17XGJmIG1wXF9jb2xvclxfbW9kZWxAPgogICBtcF9ub19tb2RlbCA9
IDEsCiAgIG1wX2dyZXlfbW9kZWwgPSAzLAogICBtcF9yZ2JfbW9kZWwgPSA1LAogICBtcF9j
bXlrX21vZGVsID0gNywKICAgbXBfdW5pbml0aWFsaXplZF9tb2RlbCA9IDkKLX07CitAdFwy
QD5AL307CiAKIAogQCBAPEluaXRpYWxpemUgdGFibGUgZW50cmllc0A+PQo=

--------------4LHex6nbPcy3Hz8Rfz2SIKt5
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
http://tug.org/metapost/

--------------4LHex6nbPcy3Hz8Rfz2SIKt5--