#339683 always (incorrectly) prints trailing whitespace

Package:
mcpp
Source:
mcpp
Description:
Alternative C/C++ preprocessor
Submitter:
Daniel Stone
Date:
2025-01-23 17:51:02 UTC
Severity:
normal
Tags:
#339683#5
Date:
2005-11-17 23:01:00 UTC
From:
To:
mcpp seems to canonicalise all whitespace to TOK_SEP.  The code in
expand.c for dealing with TOK_SEP writes out a space, unless the
previous character was also TOK_SEP.  This means that:
'#define foo bar\n'
will expand to:
'TOK_SEP#defineTOK_SEPfooTOK_SEPbarTOK_SEP'
so, a line containing only 'foo', gets converted to 'bar ', because
the \n is also treated as TOK_SEP.

This breaks things very badly when xrdb uses mcpp; resources change
from 'Foo.bar:\t#123456\nBar.baz:\t#654321\n', to
'Foo.bar:\t#123456 \nBar.baz:\t#654321 \n' (note the extra spaces).
X colour lookups then fail, because it doesn't strip spaces.

The way I 'fixed' this in Ubuntu was to just always skip TOK_SEP, but
this means that:
'#define foo bar \n'
will expand 'foo' to 'bar', instead of to 'bar '.  I don't know if this
behaviour is either desired or correct, however.  So, if always calling
continue in the TOK_SEP case in expand.c is incorrect, then mcpp needs
to differentiate general whitespace from newlines.

Cheers,
Daniel

#339683#10
Date:
2005-11-17 23:12:12 UTC
From:
To:
tags 339683 + patch
kthxbye

So it turns out that cpp also skips trailing whitespace:
'#define FOO bar \n'
turns 'FOO' into 'bar' with the cpp from gcc.  So I'd say that if it's
not *correct* behaviour (which it almost certainly is), then it's
probably expected. ;)

I've also attached a patch which implements this, and works.

Cheers,
Daniel

#339683#19
Date:
2006-10-14 09:21:29 UTC
From:
To:
forwarded 339683 kmatsui@t3.rim.or.jp
thanks

After packaging new release of 2.6.1, I have checked
that this bug has not yet been fixed.  So, I have
forwarded this bug report again, this time in Japanese
(my translation).  Hopefully, it will be fixed soon.

#339683#24
Date:
2006-10-16 08:27:47 UTC
From:
To:
tag 339683 + wontfix
thanks

The upstream auther said, it's not a bug, but a feature.
For use of xrdb, he recommended use of -@old option.

#339683#33
Date:
2025-01-23 17:48:47 UTC
From:
To:
Control: tags 339683 - patch

Untagging patch, thus.