From f426fa565397b4df53f3f534d3c2bc7bc5857f59 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Wed, 27 Dec 2023 23:08:57 +0100 Subject: Remove always-true ifndef TOM Signed-off-by: Tim Wiederhake --- src/util.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index d89dcfe..d45a8a2 100644 --- a/src/util.c +++ b/src/util.c @@ -478,10 +478,8 @@ GetColor(int kind, Pixel *what, const char *name) Status stat = 0; Colormap cmap = Scr->TwmRoot.cmaps.cwins[0]->colormap->c; -#ifndef TOM if (!Scr->FirstTime) return; -#endif if (Scr->Monochrome != kind) return; @@ -553,10 +551,8 @@ GetColorValue(int kind, XColor *what, const char *name) XColor junkcolor; Colormap cmap = Scr->TwmRoot.cmaps.cwins[0]->colormap->c; -#ifndef TOM if (!Scr->FirstTime) return; -#endif if (Scr->Monochrome != kind) return; -- cgit v1.2.3 From 6ea386bd98a737a9f54e2ca4216adf45868fd6e4 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Remove global variables JunkRoot, JunkChild Replace with a local variable following the naming scheme from Identify() in src/menus.c. Signed-off-by: Tim Wiederhake --- src/util.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index d45a8a2..e634e7f 100644 --- a/src/util.c +++ b/src/util.c @@ -209,6 +209,7 @@ Zoom(Window wf, Window wt) long dx, dy, dw, dh; long z; int j; + Window wdummy = None; if (!Scr->DoZoom || Scr->ZoomCount < 1) return; @@ -216,8 +217,8 @@ Zoom(Window wf, Window wt) if (wf == None || wt == None) return; - XGetGeometry(dpy, wf, &JunkRoot, &fx, &fy, &fw, &fh, &JunkBW, &JunkDepth); - XGetGeometry(dpy, wt, &JunkRoot, &tx, &ty, &tw, &th, &JunkBW, &JunkDepth); + XGetGeometry(dpy, wf, &wdummy, &fx, &fy, &fw, &fh, &JunkBW, &JunkDepth); + XGetGeometry(dpy, wt, &wdummy, &tx, &ty, &tw, &th, &JunkBW, &JunkDepth); dx = ((long) (tx - fx)); /* going from -> to */ dy = ((long) (ty - fy)); /* going from -> to */ @@ -278,8 +279,10 @@ ExpandFilename(const char *name) void GetUnknownIcon(const char *name) { + Window wdummy = None; + if ((Scr->UnknownPm = GetBitmap(name)) != None) { - XGetGeometry(dpy, Scr->UnknownPm, &JunkRoot, &JunkX, &JunkY, + XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &JunkX, &JunkY, (unsigned int *) &Scr->UnknownWidth, (unsigned int *) &Scr->UnknownHeight, &JunkBW, &JunkDepth); } -- cgit v1.2.3 From c5a63751f8b4eab72794e56365ead929023f2b94 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Remove global variables JunkX, JunkY Replace with a local variable following the naming scheme from Identify() in src/menus.c. Signed-off-by: Tim Wiederhake --- src/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index e634e7f..edf93a9 100644 --- a/src/util.c +++ b/src/util.c @@ -279,10 +279,11 @@ ExpandFilename(const char *name) void GetUnknownIcon(const char *name) { + int dummy = 0; Window wdummy = None; if ((Scr->UnknownPm = GetBitmap(name)) != None) { - XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &JunkX, &JunkY, + XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &dummy, &dummy, (unsigned int *) &Scr->UnknownWidth, (unsigned int *) &Scr->UnknownHeight, &JunkBW, &JunkDepth); } -- cgit v1.2.3 From 783b31821d87ea551457f4700f796a51f359cfd1 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 20 Jan 2024 16:07:00 +0100 Subject: Remove global variables JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask Replace with a local variable following the naming scheme from Identify() in src/menus.c. Signed-off-by: Tim Wiederhake --- src/util.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index edf93a9..a3673e3 100644 --- a/src/util.c +++ b/src/util.c @@ -209,6 +209,7 @@ Zoom(Window wf, Window wt) long dx, dy, dw, dh; long z; int j; + unsigned udummy = 0; Window wdummy = None; if (!Scr->DoZoom || Scr->ZoomCount < 1) @@ -217,8 +218,8 @@ Zoom(Window wf, Window wt) if (wf == None || wt == None) return; - XGetGeometry(dpy, wf, &wdummy, &fx, &fy, &fw, &fh, &JunkBW, &JunkDepth); - XGetGeometry(dpy, wt, &wdummy, &tx, &ty, &tw, &th, &JunkBW, &JunkDepth); + XGetGeometry(dpy, wf, &wdummy, &fx, &fy, &fw, &fh, &udummy, &udummy); + XGetGeometry(dpy, wt, &wdummy, &tx, &ty, &tw, &th, &udummy, &udummy); dx = ((long) (tx - fx)); /* going from -> to */ dy = ((long) (ty - fy)); /* going from -> to */ @@ -280,12 +281,13 @@ void GetUnknownIcon(const char *name) { int dummy = 0; + unsigned udummy = 0; Window wdummy = None; if ((Scr->UnknownPm = GetBitmap(name)) != None) { XGetGeometry(dpy, Scr->UnknownPm, &wdummy, &dummy, &dummy, (unsigned int *) &Scr->UnknownWidth, - (unsigned int *) &Scr->UnknownHeight, &JunkBW, &JunkDepth); + (unsigned int *) &Scr->UnknownHeight, &udummy, &udummy); } } @@ -379,7 +381,9 @@ FindBitmap(const char *name, unsigned *widthp, unsigned *heightp) Pixmap GetBitmap(const char *name) { - return FindBitmap(name, &JunkWidth, &JunkHeight); + unsigned udummy = 0; + + return FindBitmap(name, &udummy, &udummy); } void -- cgit v1.2.3 From a0a4604cab350eb6a8bd3cc56cfb35d534fa344b Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Remove storage specifier 'register' 'register' is an optimization hint to the compiler that is generally not necessary and needlessly prevents using a c++ compiler to compile twm. Signed-off-by: Tim Wiederhake --- src/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index a3673e3..f77b0b6 100644 --- a/src/util.c +++ b/src/util.c @@ -96,7 +96,7 @@ MoveOutline(Window root, int x, int y, int width, int height, int bw, int th) int xl, xr, yt, yb, xinnerl, xinnerr, yinnert, yinnerb; int xthird, ythird; XSegment outline[18]; - register XSegment *r; + XSegment *r; if (x == lastx && y == lasty && width == lastWidth && height == lastHeight && lastBW == bw && th == lastTH) @@ -587,7 +587,7 @@ FindFontSet(MyFont *font, const char *fontname) int ascent; int descent; int fnum; - register int i; + int i; if (font->fontset != NULL) { XFreeFontSet(dpy, font->fontset); -- cgit v1.2.3 From 878117d8c70564983afddfb2bb26daa71f25b8c1 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Rename field 'delete' to 'remove' in TitlebarPixmaps 'delete' is a keyword in c++. Its usage confuses some tools that work with c and c++ source code. Signed-off-by: Tim Wiederhake --- src/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index f77b0b6..baff6c8 100644 --- a/src/util.c +++ b/src/util.c @@ -919,11 +919,11 @@ CreateDotPixmap(unsigned *widthp, unsigned *heightp) if (!(h & 1)) h--; *widthp = *heightp = (unsigned int) h; - if (Scr->tbpm.delete == None) { + if (Scr->tbpm.remove == None) { GC gc; Pixmap pix; - pix = Scr->tbpm.delete = + pix = Scr->tbpm.remove = XCreatePixmap(dpy, Scr->Root, (unsigned) h, (unsigned) h, 1); gc = XCreateGC(dpy, pix, 0L, NULL); XSetLineAttributes(dpy, gc, (unsigned) h, LineSolid, CapRound, @@ -934,7 +934,7 @@ CreateDotPixmap(unsigned *widthp, unsigned *heightp) XDrawLine(dpy, pix, gc, h / 2, h / 2, h / 2, h / 2); XFreeGC(dpy, gc); } - return Scr->tbpm.delete; + return Scr->tbpm.remove; } #define questionmark_width 8 -- cgit v1.2.3 From 365a94b62df6144ad016e587f3756d974b6e2018 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Sat, 30 Dec 2023 20:49:48 +0100 Subject: Add explicit cast after memory allocation Still valid c, but now also valid c++. Signed-off-by: Tim Wiederhake --- src/util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index baff6c8..5671fad 100644 --- a/src/util.c +++ b/src/util.c @@ -259,7 +259,7 @@ ExpandFilename(const char *name) if (name[0] != '~') return strdup(name); - newname = malloc((size_t) HomeLen + strlen(name) + 2); + newname = (char *) malloc((size_t) HomeLen + strlen(name) + 2); if (!newname) { twmWarning("unable to allocate %lu bytes to expand filename %s/%s", (unsigned long) HomeLen + (unsigned long) strlen(name) + 2, @@ -358,7 +358,8 @@ FindBitmap(const char *name, unsigned *widthp, unsigned *heightp) /* * Attempt to find icon in old IconDirectory (now obsolete) */ - bigname = malloc(strlen(name) + strlen(Scr->IconDirectory) + 2); + bigname = (char *) + malloc(strlen(name) + strlen(Scr->IconDirectory) + 2); if (!bigname) { twmWarning("unable to allocate memory for \"%s/%s\"", Scr->IconDirectory, name); @@ -399,7 +400,7 @@ InsertRGBColormap(Atom a, XStandardColormap *maps, int nmaps, Bool replace) } if (!sc) { /* no existing, allocate new */ - sc = malloc(sizeof(StdCmap)); + sc = (StdCmap *) malloc(sizeof(StdCmap)); if (!sc) { twmWarning("unable to allocate %lu bytes for StdCmap", (unsigned long) sizeof(StdCmap)); -- cgit v1.2.3 From 4b01408715cd10e3bf02eb1e87531917a09c2645 Mon Sep 17 00:00:00 2001 From: "Thomas E. Dickey" Date: Tue, 5 Mar 2024 03:43:57 -0500 Subject: include "gram.h" only from "parse.h" all of the users of (generated) gram.h rely upon (custom) parse.h, and the order of those headers affects portability. Signed-off-by: Thomas E. Dickey --- src/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 5671fad..9a04ac1 100644 --- a/src/util.c +++ b/src/util.c @@ -59,7 +59,7 @@ in this Software without prior written authorization from The Open Group. #include "twm.h" #include "util.h" -#include "gram.h" +#include "parse.h" #include "screen.h" #include #include -- cgit v1.2.3