Subject: | Tk/MakeDepend.pm cannot handle /usr/include/pngconf.h on Fedora Core 3 x86_64 |
During a build, I get:
Finding dependencies for imgPNG.c
Missing ')'
trailing: L) && defined(PNG_MAX_MALLOC_64K) at /home/hugh/rpmbuilds/BUILD/Tk-804.027/Tk/MakeDepend.pm line 104, </usr/include/pngconf.h> line 1388.
It seems to me that trying to write a perl script to evaluate C preprocessor expressions accurately is very tough, but that appears to be what Tk/MakeDepend.pm attempting. The expression upon which it chokes is:
#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
This appears to be valid C. MakeDepend.pm does not understand the L suffix on the integer constant. (The suffix isn't necessary, but it is legal).
I have included a quick and dirty patch that seems to work. It does not exactly match the C standard since it allows arbitrary repetitions of u (only one is allowed) and l (perhaps only two are allowed). Seems to fix the problem with this particular header.
This is perl, v5.8.5 built for x86_64-linux-thread-multi
===================================================================
RCS file: /home/hugh/rpmbuilds/BUILD/Tk-804.027/Tk/RCS/MakeDepend.pm,v
retrieving revision 1.1
diff -u -r1.1 /home/hugh/rpmbuilds/BUILD/Tk-804.027/Tk/MakeDepend.pm
--- /home/hugh/rpmbuilds/BUILD/Tk-804.027/Tk/MakeDepend.pm 2005/02/27 20:50:43 1.1
+++ /home/hugh/rpmbuilds/BUILD/Tk-804.027/Tk/MakeDepend.pm 2005/02/27 22:08:01
@@ -44,7 +44,7 @@
return exists($define{$1}) if s/^\s*defined\s*\(([_A-Za-z][_\w]*)\s*\)//;
return exists($define{$1}) if s/^\s*defined\s*([_A-Za-z][_\w]*)//;
return eval "$1" if s/^\s*(0x[0-9a-f]+)//i;
- return $1 if s/^\s*(\d+)//;
+ return $1 if s/^\s*(\d+)[lLuU]*//;
return $define{$1} || 0 if s/^\s*([_A-Za-z][_\w]*)//;
if (s/^\s*\(//)
{