Source: zdbsp
Version: 1.19+20181027+dfsg.1-5
Severity: normal
Tags: lfs patch

Dear Maintainer,

zdbsp does not build on 32-bit big endian arches.  See for example:
https://buildd.debian.org/status/fetch.php?pkg=zdbsp&arch=hppa&ver=1.19%2B20181027%2Bdfsg.1-5&stamp=1756941003&raw=0

There are no implimentations of LittleShort(int) and LittleLong(long)
for big endian..  ftell returns long but LittleLong is implemented for
int and unsigned int.  I believe this affects LFS support.

The attached patch fixes the build on hppa but it's only a quick hack.

Regards,
Dave Anglin

-- System Information:
Debian Release: forky/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: hppa (parisc64)

Kernel: Linux 6.12.43-dirty (SMP w/4 CPU threads)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_CA:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
--- wad.cpp.save        2025-09-03 20:06:38.695875760 -0400
+++ wad.cpp     2025-09-03 20:07:18.984627648 -0400
@@ -381,7 +381,7 @@
                int32_t head[2];
 
                head[0] = LittleLong(Lumps.Size());
-               head[1] = LittleLong(ftell (File));
+               head[1] = LittleLong((int)ftell (File));
 
                SafeWrite (&Lumps[0], sizeof(WadLump)*Lumps.Size());
                fseek (File, 4, SEEK_SET);
@@ -396,7 +396,7 @@
        WadLump lump;
 
        strncpy (lump.Name, name, 8);
-       lump.FilePos = LittleLong(ftell (File));
+       lump.FilePos = LittleLong((int)ftell (File));
        lump.Size = 0;
        Lumps.Push (lump);
 }
@@ -406,7 +406,7 @@
        WadLump lump;
 
        strncpy (lump.Name, name, 8);
-       lump.FilePos = LittleLong(ftell (File));
+       lump.FilePos = LittleLong((int)ftell (File));
        lump.Size = LittleLong(len);
        Lumps.Push (lump);
 
--- zdbsp.h.save        2025-09-03 19:55:28.829379064 -0400
+++ zdbsp.h     2025-09-03 20:03:30.106356619 -0400
@@ -241,12 +241,12 @@
 
 // Swap 16bit, that is, MSB and LSB byte.
 // No masking with 0xFF should be necessary. 
-inline short LittleShort (short x)
+inline short LittleShort (int x)
 {
        return (short)((((unsigned short)x)>>8) | (((unsigned short)x)<<8));
 }
 
-inline unsigned short LittleShort (unsigned short x)
+inline unsigned short LittleShort (unsigned int x)
 {
        return (unsigned short)((x>>8) | (x<<8));
 }

Reply via email to