Subject: pkg/18841: Fix for x11/xfstt on Solaris.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <sketch@rd.bbc.co.uk>
List: netbsd-bugs
Date: 10/28/2002 07:56:05
>Number:         18841
>Category:       pkg
>Synopsis:       Fix for x11/xfstt on Solaris.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 28 07:57:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Jonathan Perkin
>Release:        1.6
>Organization:
British Broadcasting Corporation
>Environment:
SunOS desk06 5.9 Generic_112233-01 sun4u sparc SUNW,Ultra-5_10
>Description:
Solaris (at least 9) takes caddr_t argument to m{,un}map, which breaks
this package quite severely.

This probably isn't a correct fix.  But hey, "it works" [tm] (apart from
the fact this package actually requires XFree and won't build with
Open Windows, but that is a separate issue which may be resolved in a
separate PR.)
>How-To-Repeat:

>Fix:
Index: Makefile
===================================================================
RCS file: /cache/ncvs/pkgsrc/x11/xfstt/Makefile,v
retrieving revision 1.11
diff -u -r1.11 Makefile
--- Makefile    2002/09/29 12:58:37     1.11
+++ Makefile    2002/10/28 15:23:17
@@ -12,6 +12,14 @@
 COMMENT=               TrueType font server for X11
 
 CXXFLAGS+=             -fomit-frame-pointer -ffast-math
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${OPSYS} == "SunOS"
+CXXFLAGS+=             -DSOLARIS
+LDFLAGS+=              -lsocket -lnsl
+.endif
+
 MAKE_ENV+=             CXXFLAGS="${CXXFLAGS}"
 
 USE_X11BASE=           YES
Index: distinfo
===================================================================
RCS file: /cache/ncvs/pkgsrc/x11/xfstt/distinfo,v
retrieving revision 1.5
diff -u -r1.5 distinfo
--- distinfo    2002/09/27 17:03:21     1.5
+++ distinfo    2002/10/28 15:16:57
@@ -7,3 +7,6 @@
 SHA1 (patch-ac) = 1fa14e6211a742936eae7c9282499ae66e6c5258
 SHA1 (patch-ad) = 7ad47d5a06570fa866b47e453cbcaea8af7f187d
 SHA1 (patch-ae) = 4296c1a666b60548d432217c7fe03c9eccf5ea87
+SHA1 (patch-af) = af15b16947cdd00e85e1414fffff53aa33de1711
+SHA1 (patch-ag) = 3df06d9a49db4c02b1d400c013d6754e4743805e
+SHA1 (patch-ah) = 152b8ae54b3e0f8958ad90a3e5efcd5fb4099dee

--- /dev/null   Mon Oct 28 15:25:32 2002
+++ patch-af    Mon Oct 28 13:35:29 2002
@@ -0,0 +1,48 @@
+$NetBSD$
+
+--- TTFont.cpp.orig    Thu Jan 11 01:58:31 2001
++++ TTFont.cpp
+@@ -272,11 +272,19 @@ int TTFont::patchGlyphCode( GlyphTable* 
+       return 0;
+ }
+ 
++#ifdef SOLARIS
++int TTFont::checksum(char *buf, int len)
++#else
+ int TTFont::checksum( U8* buf, int len)
++#endif
+ {
+       len = (len + 3) >> 2;
+       int sum = 0;
++#ifdef SOLARIS
++      for(char *p = buf; --len >= 0; p += 4) {
++#else
+       for( U8* p = buf; --len >= 0; p += 4) {
++#endif
+               int val = (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3];
+               sum += val;
+       }
+@@ -285,13 +293,22 @@ int TTFont::checksum( U8* buf, int len)
+ 
+ void TTFont::updateChecksums()
+ {
++#ifdef SOLARIS
++      char *buf = base;
++      char *headTable = 0;
++#else
+       U8* buf = base;
++      U8* headTable = 0;
++#endif
+ 
+       int nTables = (buf[4] << 8) + buf[5];
+       //printf( "nTables = %d\n", nTables);
+-      U8* headTable = 0;
+       for( int i = 0; i < nTables; ++i) {
++#ifdef SOLARIS
++              char *b = &buf[ 12 + i * 16];
++#else
+               U8* b = &buf[ 12 + i * 16];
++#endif
+               int name = (b[0]<<24) + (b[1]<<16) + (b[2]<<8) + b[3];
+               int offset = (b[8]<<24) + (b[9]<<16) + (b[10]<<8) + b[11];
+               int length = (b[12]<<24) + (b[13]<<16) + (b[14]<<8) + b[15];

--- /dev/null   Mon Oct 28 15:25:32 2002
+++ patch-ag    Mon Oct 28 13:23:46 2002
@@ -0,0 +1,28 @@
+$NetBSD$
+
+--- RAFile.cpp.orig    Thu May  6 06:26:06 1999
++++ RAFile.cpp
+@@ -164,7 +164,11 @@ RandomAccessFile::RandomAccessFile( char
+       struct stat st;
+       fstat( fd, &st);
+       length = st.st_size;
++#ifdef SOLARIS
++      base = (char *) mmap( 0L, length, PROT_READ, MAP_SHARED, fd, 0L);
++#else
+       base = (U8*) mmap( 0L, length, PROT_READ, MAP_SHARED, fd, 0L);
++#endif
+       close( fd);
+ #endif
+       ptr = absbase = base;
+@@ -184,7 +188,11 @@ void RandomAccessFile::closeRAFile()
+ U32 RandomAccessFile::calcChecksum()
+ {
+       U32 checksum = 0;
++#ifdef SOLARIS
++      char *saveptr = ptr;
++#else
+       U8* saveptr = ptr;
++#endif
+       for( int len = length >> 2; --len >= 0;)
+               checksum += readUInt();
+       if( length & 3)

--- /dev/null   Mon Oct 28 15:25:32 2002
+++ patch-ah    Mon Oct 28 13:36:55 2002
@@ -0,0 +1,34 @@
+$NetBSD$
+
+--- ttf.h.orig Wed Mar 13 17:28:31 2002
++++ ttf.h
+@@ -49,9 +49,17 @@
+ class RandomAccessFile
+ {
+ protected:
++#ifdef SOLARIS
++      char *ptr, *base;
++#else
+       U8 *ptr, *base;         // low offset for frequently used members
++#endif
+ private:
++#ifdef SOLARIS
++      char *absbase;
++#else
+       U8* absbase;            //### hack for fileOffset();
++#endif
+       int length;
+ public:
+       RandomAccessFile( char* fileName);
+@@ -265,7 +273,11 @@ public:
+ 
+       // for comparing with reference implementation
+       int patchGlyphCode( GlyphTable* glyph, int instruction);
++#ifdef SOLARIS
++      int checksum(char *buf, int len);
++#else
+       int checksum( U8* buf, int len);
++#endif
+       void updateChecksums();
+       int write2File( char* filename);
+       void patchName( U8* patchData, int patchLength);
>Release-Note:
>Audit-Trail:
>Unformatted: