[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [PATCH?] kfontinst on FreeBSD
From:       Adriaan de Groot <adridg () cs ! kun ! nl>
Date:       2003-10-30 0:18:00
[Download RAW message or body]

kfontinst #includes a C (GetPid.c) file from inside a C++ file (XConfig.cpp). 
This means that the C file is interpreted as C++ -- which has stricter typing 
rules &c. In particular, the system headers that get included by the C file 
are interpreted as C++ as well. Unfortunately, some FreeBSD system headers 
contain (void *)0 where they should be writing NULL. The latter is legal C++, 
the former isn't always (there's stricter pointer conversion rules). So 
kfontinst doesn't compile.

The attached patch breaks kfontinst for everyone except FreeBSD. That patch 
could go into our ports system, though. I'm wondering, though, _why_ exactly 
this whole construction is used. Why not just link in GetPid.o? What's the 
deal with the "want this function to be static"? If there's namespace 
collisions, the function could be renamed. The code in GetPid.c doesn't rely 
on Qt's OS-determining macros, so it could just as easily be compiled as C.

Oh, I realize that the _real_ problem is lousy system headers. Unfortunately, 
those are harder to change than KDE source :)

["kfontinst.diff" (text/x-diff)]

? kfontinst/docs/Makefile
? kfontinst/docs/Makefile.in
? kfontinst/docs/en/Makefile
? kfontinst/docs/en/Makefile.in
? other/Makefile.in
? other/StarOffice/Makefile.in
Index: lib/GetPid.c
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kfontinst/lib/GetPid.c,v
retrieving revision 1.4
diff -u -3 -p -r1.4 GetPid.c
--- lib/GetPid.c	1 Oct 2003 20:48:42 -0000	1.4
+++ lib/GetPid.c	30 Oct 2003 00:12:20 -0000
@@ -166,7 +166,7 @@ static unsigned int getPid(const char *p
 #include <sys/time.h>
 #include <sys/user.h>
 #include <unistd.h>
-static unsigned int getPid(const char *proc, unsigned int ppid)
+/* static */ unsigned int getPid(const char *proc, unsigned int ppid)
 {
     bool              error=false;
     unsigned int      pid=0;
@@ -235,7 +235,7 @@ static unsigned int getPid(const char *p
 #else
 #include <sys/procfs.h>
 #include <sys/sysmp.h>
-#endif 
+#endif
 #include <sys/sysinfo.h>
 
 static unsigned int getPid(const char *proc, pid_t ppid)
Index: lib/Makefile.am
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kfontinst/lib/Makefile.am,v
retrieving revision 1.3
diff -u -3 -p -r1.3 Makefile.am
--- lib/Makefile.am	22 Aug 2003 13:52:43 -0000	1.3
+++ lib/Makefile.am	30 Oct 2003 00:12:20 -0000
@@ -8,7 +8,8 @@ FontEngine.cpp \
 Fontmap.cpp \
 Global.cpp \
 Misc.cpp \
-XConfig.cpp
+XConfig.cpp \
+GetPid.c
 
 noinst_HEADERS = \
 CompressedFile.h \
Index: lib/XConfig.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/kfontinst/lib/XConfig.cpp,v
retrieving revision 1.4
diff -u -3 -p -r1.4 XConfig.cpp
--- lib/XConfig.cpp	1 Oct 2003 22:26:54 -0000	1.4
+++ lib/XConfig.cpp	30 Oct 2003 00:12:22 -0000
@@ -26,6 +26,18 @@
 // (C) Craig Drummond, 2001, 2002, 2003
 ////////////////////////////////////////////////////////////////////////////////
 
+
+#include <sys/types.h>
+
+// Get the Q_OS_ defines
+#include <qglobal.h>
+
+#ifdef Q_OS_FREEBSD
+// Needed for vm_map.h, included from somewhere
+#include <sys/lock.h>
+extern "C" unsigned int getPid(const char *, unsigned int);
+#endif
+
 #include "XConfig.h"
 #include "Global.h"
 #include "FontEngine.h"
@@ -35,7 +47,7 @@
 #include <klocale.h>
 
 #include "kxftconfig.cpp" // CPD: HACK!!! How to sym-link in CVS???
-#include "GetPid.c"  // #included as want function to be static...
+// #include "GetPid.c"  // #included as want function to be static...
 
 static const QCString constFontpaths ("# KFontinst fontpaths file -- DO NOT EDIT");
 #define UNSCALED ":unscaled"


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic