* PGP 5.0i compile problem - LOCATED
@ 1999-01-19 5:00 Nikola Milutinovic
1999-01-20 5:00 ` Andrew Moar
0 siblings, 1 reply; 5+ messages in thread
From: Nikola Milutinovic @ 1999-01-19 5:00 UTC (permalink / raw)
Hi all.
There was a post, a week or two ago, regarding problems when compiling
Preaty Good Privacy 5.0i on Digital UNIX. The error message was about
lines with "BIG", "LITTLE" and "BIGLITTLE" macros, which were taken as
functions.
LOCATION (so far)
-----------------
The problem lies in several files, this particular in
"./src/lib/bn/bni.h". There are problems in "bngermain.c" and "bni32.c",
in the same directory, as well.
PROBLEM
-------
Several lines containing conditional pre-processor directives "#if",
"#ifdef", "#ifndef" and "#endif" were not placed in the 1st column of
the line, they were in. In other words, they were indented. This caused
cpp to drop them from compiling, causing "a lot of fun" for the cc.
I.e.:
/* Do we want bnYield()? */
#ifndef BNYIELD
#define BNYIELD 0
#endif
instead of
/* Do we want bnYield()? */
#ifndef BNYIELD
#define BNYIELD 0
#endif
I'm not sure what the standard says about CPP directives. I remember
reading that NewLines, Tabs and Spaces are treated as WhiteSpace and
that you can write the whole program in a single line, if you like.
Well, not with Digital, apparently. This problem is totaly the "feature"
of cpp.
This problem manifested itself on both 4.0D and 3.2G versions of Digital
UNIX.
WORKAROUND
----------
Since this feature of cpp persists in both 3.2 and in 4.0 versions, it
is highly unlikely we'll see it changed. The only thing that you can do
is delete all such indentations from the code. The cc (cpp) will issue a
warning on every such line, so it shouldn't be too difficult.
Any feedback, sugestions and advice is welcome.
Nix.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PGP 5.0i compile problem - LOCATED
1999-01-19 5:00 PGP 5.0i compile problem - LOCATED Nikola Milutinovic
@ 1999-01-20 5:00 ` Andrew Moar
1999-01-20 5:00 ` Ray Bellis
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Moar @ 1999-01-20 5:00 UTC (permalink / raw)
In article <36A4749D.37F4F8D4@ev.co.yu>,
Nikola Milutinovic <Nikola.Milutinovic@ev.co.yu> writes:
[ -snip- ]
> PROBLEM
> -------
> Several lines containing conditional pre-processor directives "#if",
> "#ifdef", "#ifndef" and "#endif" were not placed in the 1st column of
> the line, they were in. In other words, they were indented. This caused
> cpp to drop them from compiling, causing "a lot of fun" for the cc.
I've seen similar problems in other freeware source code and have used
the following perl script to fix it.
#!/usr/local/bin/perl
$file = @ARGV[0];
$filetmp = "$file.xxx";
open(OUTFILE, ">$filetmp") || die "$0: can't open $filetmp\n";
select(OUTFILE);
#printf "%s\n", $file;
while (<>)
{
$a = $_;
if ($a =~ /#/) {
$a =~ s/^ +//;
$a =~ s/^\t+//;
}
print $a;
}
rename($filetmp,$file);
(perl isn't my strongest language so it's probably a pretty average script.
Looking back at it, I'm not even sure how it works!)
You could then run it something like:
find . -exec fixdefines.pl {} \;
under the source code directory.
Cheers
--
Andrew Moar : Ph +61 3 9479 1505 email A.Moar@latrobe.edu.au
Unix Environment Manager, Information Technology Services
La Trobe University, Melbourne
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PGP 5.0i compile problem - LOCATED
1999-01-20 5:00 ` Andrew Moar
@ 1999-01-20 5:00 ` Ray Bellis
1999-01-20 5:00 ` John Parks
1999-01-21 5:00 ` Martin Vorlaender
0 siblings, 2 replies; 5+ messages in thread
From: Ray Bellis @ 1999-01-20 5:00 UTC (permalink / raw)
>I've seen similar problems in other freeware source code and have used
>the following perl script to fix it.
[script deleted]
>(perl isn't my strongest language so it's probably a pretty average script.
>Looking back at it, I'm not even sure how it works!)
Here's the quick and dirty way [see perlfaq5(1)].
perl -pi -e 's/^\s+#/#/' *.c
Ray.
--
Ray Bellis, MA(Oxon) - Technical Director - Oxford CommUnity Internet plc
Windsor House, 12 High Street, Kidlington, OXFORD OX5 2PJ UK
Telephone: +44-1865-856000 Fax: +44-1865-856001
Email: ray.bellis@community.net.uk URL: http://www.community.co.uk/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PGP 5.0i compile problem - LOCATED
1999-01-20 5:00 ` Ray Bellis
@ 1999-01-20 5:00 ` John Parks
1999-01-21 5:00 ` Martin Vorlaender
1 sibling, 0 replies; 5+ messages in thread
From: John Parks @ 1999-01-20 5:00 UTC (permalink / raw)
Nikola Milutinovic wrote:
>> I'm not sure what the standard says about CPP directives. I remember
>> reading that NewLines, Tabs and Spaces are treated as WhiteSpace and
>> that you can write the whole program in a single line, if you like.
>> Well, not with Digital, apparently. This problem is totaly the "feature"
>> of cpp.
The ANSI standard says that cpp directives can begin in any column -- so long
as the initiating # is the first non-whitespace character on the line.
Indentation is cool then -- so long as you preprocess the input in an
ANSI-compliant cpp mode. Those modes include -std and -std1 but NOT -std0
which is the default.
>> This problem is totaly the "feature" of cpp.
Right. -std0 mode is "K&R compatibility" mode and Kernighan and Ritchie
insisted that cpp directives begin in column 1.
One could argue that the K&R behavior is a feature, not a bug. It allows
for faster preprocessing than the ANSI model (since the cpp can do a fast
scan down column 1 rather than have to consider whitespace). It also improves
the cpp's ability to preprocess general text input (fortran, makefiles, etc.)
since #'s that aren't in column 1 are not an issue.
>> Since this feature of cpp persists in both 3.2 and in 4.0 versions, it
>> is highly unlikely we'll see it changed.
Right. Too many users rely on the K&R behavior to change it.
>> Any feedback, sugestions and advice is welcome.
Sure. Add -std to your command-line. That'll change modes from "K&R" to
"relaxed ANSI" and your code work without modification.
Hope this helps.
\John Parks (Digital UNIX cpp author)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PGP 5.0i compile problem - LOCATED
1999-01-20 5:00 ` Ray Bellis
1999-01-20 5:00 ` John Parks
@ 1999-01-21 5:00 ` Martin Vorlaender
1 sibling, 0 replies; 5+ messages in thread
From: Martin Vorlaender @ 1999-01-21 5:00 UTC (permalink / raw)
Ray Bellis (Ray.Bellis@community.net.uk) wrote:
: >I've seen similar problems in other freeware source code and have used
: >the following perl script to fix it.
: [script deleted]
: >(perl isn't my strongest language so it's probably a pretty average script.
: >Looking back at it, I'm not even sure how it works!)
:
: Here's the quick and dirty way [see perlfaq5(1)].
:
: perl -pi -e 's/^\s+#/#/' *.c
Or, if you want to keep the indentation:
perl -pi -e 's/^(\s+)#/#$1/' *.c
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
VMS is today what | work: mv@pdv-systeme.de
Microsoft wants | http://www.pdv-systeme.de/users/martinv/
Windows NT 8.0 to be! | home: martin@radiogaga.harz.de
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1999-01-21 5:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-01-19 5:00 PGP 5.0i compile problem - LOCATED Nikola Milutinovic
1999-01-20 5:00 ` Andrew Moar
1999-01-20 5:00 ` Ray Bellis
1999-01-20 5:00 ` John Parks
1999-01-21 5:00 ` Martin Vorlaender
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox