From 451e1b036d3dd0fddcf54733b5616169ed5ad570 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sun, 3 Mar 2024 12:55:11 +0100 Subject: Provide defaults for externally defined symbols AM_CPPFLAGS defines several symbols that do not have to be there. By providing default values in twm.h, this list can be reduced in size while still allowing to override these values. Signed-off-by: Tim Wiederhake --- src/Makefile.am | 6 +----- src/menus.c | 4 ++-- src/parse.c | 5 +---- src/twm.c | 2 +- src/twm.h | 20 ++++++++++++++++++++ 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index bb45b53..96fa621 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,12 +28,8 @@ rcdir = ${datadir}/X11/twm dist_rc_DATA = system.twmrc AM_CPPFLAGS = \ - -DAPP_NAME=\"twm\" \ - -DAPP_CLASS=\"twm\" \ -DAPP_VERSION=\"$(VERSION)\" \ - -DXVENDORNAME=\"The\ X.Org\ Foundation\" \ - -DXORG_RELEASE=\"Release\ $(VERSION)\" \ - -DSYSTEM_INIT_FILE=\"${rcdir}/system.twmrc\" + -DDATADIR=\"${datadir}\" AM_CFLAGS = $(TWM_CFLAGS) $(XRANDR_CFLAGS) $(CWARNFLAGS) twm_LDADD = $(TWM_LIBS) $(XRANDR_LIBS) diff --git a/src/menus.c b/src/menus.c index 9b4ecd3..41f5bad 100644 --- a/src/menus.c +++ b/src/menus.c @@ -2529,8 +2529,8 @@ Identify(TwmWindow *t) Window wdummy = None; n = 0; - snprintf(Info[n++], INFO_SIZE, "Twm version: %s, %s", - XVENDORNAME, XORG_RELEASE); + snprintf(Info[n++], INFO_SIZE, "Twm version: %s, Release %s", + XVENDORNAME, APP_VERSION); Info[n++][0] = '\0'; if (t) { diff --git a/src/parse.c b/src/parse.c index c659e53..c841489 100644 --- a/src/parse.c +++ b/src/parse.c @@ -71,9 +71,6 @@ in this Software without prior written authorization from The Open Group. #include #include -#ifndef SYSTEM_INIT_FILE -#define SYSTEM_INIT_FILE "/usr/lib/X11/twm/system.twmrc" -#endif #define BUF_LEN 300 static FILE *twmrc; @@ -200,7 +197,7 @@ ParseTwmrc(char *filename) break; case 3: /* system.twmrc */ - cp = SYSTEM_INIT_FILE; + cp = DATADIR "/X11/twm/system.twmrc"; break; } diff --git a/src/twm.c b/src/twm.c index a5e93bc..4be177c 100644 --- a/src/twm.c +++ b/src/twm.c @@ -316,7 +316,7 @@ main(int argc, char *argv[]) si = XtAppAddSignal(appContext, Done, NULL); - if (!(dpy = XtOpenDisplay(appContext, display_name, "twm", "twm", + if (!(dpy = XtOpenDisplay(appContext, display_name, APP_NAME, APP_CLASS, NULL, 0, &zero, NULL))) { twmError("unable to open display \"%s\"", XDisplayName(display_name)); } diff --git a/src/twm.h b/src/twm.h index 46ddd2a..db55a32 100644 --- a/src/twm.h +++ b/src/twm.h @@ -74,6 +74,26 @@ from The Open Group. #include #include +#ifndef APP_NAME +#define APP_NAME "twm" +#endif + +#ifndef APP_CLASS +#define APP_CLASS "twm" +#endif + +#ifndef APP_VERSION +#define APP_VERSION "unknown" +#endif + +#ifndef DATADIR +#define DATADIR "/usr/local/share" +#endif + +#ifndef XVENDORNAME +#define XVENDORNAME "The X.Org Foundation" +#endif + #ifndef WithdrawnState #define WithdrawnState 0 #endif -- cgit v1.2.3