Skip to content

Patches Applied

Retro-Jack edited this page Mar 29, 2026 · 1 revision

Patches Applied

This fork applies the following fixes to the original source to allow compilation with modern GCC on 64-bit Linux. No functional behaviour has been changed.


1. libres/resmkch.c — Missing return type

Problem: static res_get_list() had no return type, which is illegal in C99 and later. GCC 14+ treats this as a hard error.

/* Before */
static res_get_list(RES_LIST *rl, char *msgbuf)

/* After */
static int res_get_list(RES_LIST *rl, char *msgbuf)

2. libsys/sys_defs.h — Unsafe 64-bit offset macro

Problem: The X_OFFSET_OF macro cast a pointer to int, which truncates the value on 64-bit platforms and produces incorrect struct field offsets.

/* Before */
#define X_OFFSET_OF(t,f)  ( (int)&(((t *)0)->f) )

/* After */
#  include <stddef.h>
#  define X_OFFSET_OF(t,f)  ( (int)offsetof(t,f) )

The standard offsetof() macro from <stddef.h> is the correct way to compute field offsets portably.


3. libtcap/tctermcap.c — Discarded const qualifier

Problem: A local variable char *p was assigned from strchr() called on a const char * argument, discarding the const qualifier. GCC emits a warning for this.

/* Before */
char *p;

/* After */
const char *p;

4. libxvt/xvtx.h + libxvt/xvtxevent.c — Deprecated X11 API

Problem: XKeycodeToKeysym() was deprecated in X11R7.6 and removed in later releases.

/* xvtx.h — added include */
#include <X11/XKBlib.h>

/* xvtxevent.c — before */
KeySym k = XKeycodeToKeysym(tw->X->display, m, 0);

/* xvtxevent.c — after */
KeySym k = XkbKeycodeToKeysym(tw->X->display, m, 0, 0);

The replacement XkbKeycodeToKeysym() takes an additional group parameter (set to 0 for the default group).


5. termfiles/xterm-256color.trm — New terminal definition

Problem: The original source only ships xterm.trm. Most modern terminal emulators report TERM=xterm-256color, causing xt to fail at startup with:

No term file or database entry found for term 'xterm-256color'
xt: cannot initialize terminal.

Fix: Added xterm-256color.trm as a copy of xterm.trm. The 256-colour escape sequences are handled by the terminal emulator itself; the .trm file only needs to describe the basic terminal capabilities that xt uses.

Clone this wiki locally