dtwm: fixes to make it build
authorJon Trulson <jon@radscan.com>
Wed, 30 Oct 2019 18:17:32 +0000 (12:17 -0600)
committerJon Trulson <jon@radscan.com>
Wed, 30 Oct 2019 18:17:32 +0000 (12:17 -0600)
Removed PORT_NOFORK define in favor of autotools vfork availablility
checking. Use vfork if present.

Got rid of getenv/putenv definitions in favor of including correct
system headers.

Use FD_CLOEXEC in fcntl() call rather than hardcoded '1'.

Added -lm check to configure so dtwm will build.

Renamed internal round() function to wmround() to fix warning about
redefinition of builtin.

Fixed missing backslash in Makefile.am that prevented half the sources
from building.

cde/programs/dtwm/Clock.c
cde/programs/dtwm/Makefile.am
cde/programs/dtwm/README
cde/programs/dtwm/WmFunction.c

index 5dc7785dd7de6d998f0b0f3c92c0a6f9d52a7e13..d653bea73571a08d3343b83a87cb88f82599d82e 100644 (file)
@@ -145,7 +145,7 @@ static void SetSegment(
                         int y1,
                         int x2,
                         int y2) ;
-static int round( 
+static int wmround( 
                         double x) ;
 static void DrawClockFace( 
                         DtClockGadget g) ;
@@ -535,13 +535,13 @@ DrawHand(
        wc = width * cosangle;
        ws = width * sinangle;
        SetSegment (w,
-                  x = w->clock.centerX + round (length * sinangle),
-                  y = w->clock.centerY - round (length * cosangle),
-                  x1 = w->clock.centerX - round (ws + wc), 
-                  y1 = w->clock.centerY + round (wc - ws));  /* 1 ---- 2 */
+                  x = w->clock.centerX + wmround (length * sinangle),
+                  y = w->clock.centerY - wmround (length * cosangle),
+                  x1 = w->clock.centerX - wmround (ws + wc), 
+                  y1 = w->clock.centerY + wmround (wc - ws));  /* 1 ---- 2 */
        SetSegment (w, x1, y1, 
-                  x2 = w->clock.centerX - round (ws - wc), 
-                  y2 = w->clock.centerY + round (wc + ws));  /* 2 ----- 3 */
+                  x2 = w->clock.centerX - wmround (ws - wc), 
+                  y2 = w->clock.centerY + wmround (wc + ws));  /* 2 ----- 3 */
        SetSegment (w, x2, y2, x, y);   /* 3 ----- 1 (4) */
 }
 
@@ -572,7 +572,7 @@ SetSegment(
 **             round integer.
 */
 static int 
-round(
+wmround(
         double x )
 {
        return (x >= 0.0 ? (int) (x + .5) : (int) (x - .5));
index 675a1449ea2c6e59d16c33ddb4a5a7a48a45efb9..3c6ca1db94437837c136f7bc5cf6a49c69dc53c9 100644 (file)
@@ -2,22 +2,20 @@ configdir = ${prefix}/config/C
 
 bin_PROGRAMS = dtwm dtfplist
 
-dist_config_DATA = sys.dtwmrc
+dist_config_DATA = sys.dtwmrc Dtwm.defs
+BUILT_SOURCES = sys.dtwmrc Dtwm.defs
 
 AM_CPPFLAGS = -DLARGECURSORS -DR2_COMPAT -DOPAQUE -DSHAPE -DUNMAP_ON_RESTART \
              -DBATCH_DRAG_REQUESTS -DCDE_INSTALLATION_TOP=\"${prefix}\" \
              -DCDE_CONFIGURATION_TOP=\"$(CDE_CONFIGURATION_TOP)\" \
-             -I$(TIRPCINC)
+             $(TIRPCINC)
 
-AM_LDADD = $(LIBXIN) -lXinerama $(LIBPRINT) $(LIBHELP) $(LIBWIDGET) \
-          $(LIBSVC) $(LIBTT) -lXm $(XTOOLLIB) ${X_LIBS}
+dtwm_LDADD = @DTCLIENTLIBS@ $(TIRPCLIB) -lXm -lXext $(XTOOLLIB)
+dtfplist_LDADD = @DTCLIENTLIBS@ $(TIRPCLIB) -lXm -lXext $(XTOOLLIB)
 
 if SOLARIS
-AM_LDADD += -lintl -lresolv
-endif
-
-if HPUX
-AM_CFLAGS += -D_HPUX_SOURCE
+dtwm_LDADD += -lintl -lresolv
+dtfplist_LDADD += -lintl -lresolv
 endif
 
 dtwm_SOURCES = WmCDInfo.c      WmCDecor.c      WmCEvent.c \
@@ -29,7 +27,7 @@ dtwm_SOURCES = WmCDInfo.c      WmCDecor.c      WmCEvent.c \
                WmMenu.c        WmProperty.c    WmProtocol.c \
                WmResCvt.c      WmResParse.c    WmResource.c \
                WmSignal.c      WmWinConf.c     WmWinInfo.c \
-               WmWinList.c     WmWinState.c    WmMultiHead.c
+               WmWinList.c     WmWinState.c    WmMultiHead.c \
               Button.c        Callback.c      Clock.c \
                DataBaseLoad.c  PanelS.c        Parse.c \
                PopupMenu.c     Session.c       UI.c \
@@ -43,10 +41,12 @@ dtfplist_SOURCES = Print.c Parse.c DataBaseLoad.c WmParse.c Session.c
 SCRIPTFLAGS = -DCDE_INSTALLATION_TOP=${prefix} \
               -DCDE_CONFIGURATION_TOP=$(CDE_CONFIGURATION_TOP)
 
-CPPSRC = Dtwm.defs.src
-CPPTARGET = Dtwm.defs
-include $(srcdir)/include/cppfile.tmpl
+Dtwm.defs: Dtwm.defs.src
+       $(RM) $@
+       $(CPP) -P -DXCOMM=# $(AM_CPPFLAGS) - < $< > $@
 
 CPPSRC = sys.dtwmrc.src
-CPPTARGET = sys.dtwmrc
-include $(srcdir)/include/cppfile.tmpl
+sys.dtwmrc: sys.dtwmrc.src
+       $(RM) $@
+       $(CPP) -P -DXCOMM=# $(AM_CPPFLAGS) - < $< > $@
+
index 8c0b66db94bff393e021defa39c68f9f120e17ce..2b50a9da70527b3447c944256f532286f9b4f9f8 100644 (file)
@@ -44,9 +44,6 @@ header file include flags, and macros (e.g. ABS).
     OLD_CODE
        Vestigal code.
 
-    PORT_NOVFORK
-       Enable for systems that don't have the vfork() call.
-
     R2_COMPAT
        Enables support for old clients that still pass window geometry
        hint information in WM_NORMAL_HINTS.
index 4ab4446e8ad193941cf317ffe7c7b99d3e1568d6..3f52e2c31d8db509bbaad75fcb8b67a05a7b801b 100644 (file)
 #include <Xm/RowColumnP.h> /* for MS_LastManagedMenuTime */
 extern XmMenuState _XmGetMenuState();
 
-extern int putenv ();
-extern char * getenv ();
-#ifndef PORT_NOVFORK
-extern pid_t vfork();
-#endif /* PORT_NOVFORK */
+#if defined(HAVE_CONFIG_H)
+#include <autotools_config.h>
+#endif
+
+#if defined(HAVE_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+
+#if defined(HAVE_VFORK) && defined(HAVE_VFORK_H)
+#include <vfork.h>
+#endif
 
 static unsigned int GetEventInverseMask(XEvent *event);
 
 #if (defined(__linux__) || defined(sun) || defined(CSRG_BASED)) && !defined(_NFILE)
 #define _NFILE FOPEN_MAX
 #endif
+
 #define CLOSE_FILES_ON_EXEC() \
-{int ifx; for (ifx=3; ifx < _NFILE; ifx++) (void) fcntl (ifx, F_SETFD, 1);}
+{int ifx; for (ifx=3; ifx < _NFILE; ifx++) (void) fcntl (ifx, F_SETFD, FD_CLOEXEC);}
 
 /*
  * Global Variables:
@@ -948,10 +958,10 @@ Boolean F_Exec (String args, ClientData *pCD, XEvent *event)
      * Fork a process to exec a shell to run the specified command:
      */
 
-#ifdef PORT_NOVFORK
-    if ((pid = fork ()) == 0)
-#else
+#if defined(HAVE_VFORK)
     if ((pid = vfork ()) == 0)
+#else
+    if ((pid = fork ()) == 0)
 #endif
     {