diff options
author | Chris Piazza <cpiazza@FreeBSD.org> | 2000-05-19 07:50:53 +0000 |
---|---|---|
committer | Chris Piazza <cpiazza@FreeBSD.org> | 2000-05-19 07:50:53 +0000 |
commit | d6e2160013bda7fe129d03ef9e4983fbb112c03b (patch) | |
tree | f3748d50f78098f9c141805dc686b0373ccc15c9 /x11-clocks | |
parent | Correct the COMMENT (diff) |
Avoid segfaults in some special cases
PR: 18643
Submitted by: maintainer
Diffstat (limited to 'x11-clocks')
-rw-r--r-- | x11-clocks/tclock/files/patch-aa | 226 |
1 files changed, 94 insertions, 132 deletions
diff --git a/x11-clocks/tclock/files/patch-aa b/x11-clocks/tclock/files/patch-aa index c5b69a5e1118..c46bede26e3c 100644 --- a/x11-clocks/tclock/files/patch-aa +++ b/x11-clocks/tclock/files/patch-aa @@ -1,132 +1,94 @@ -*** tclock.c Sun Feb 7 20:24:51 1999 ---- work/tclock.c Sun Feb 7 20:34:52 1999 -*************** -*** 22,28 **** ---- 22,31 ---- - */ - - #include <stdio.h> -+ #include <stdlib.h> -+ #include <unistd.h> - #include <math.h> -+ #include <time.h> - #include <X11/Xlib.h> - #include <X11/Xutil.h> - #include <X11/Xos.h> -*************** -*** 51,57 **** - int screen_number; - Window rootWindow, mainWindow; - int ShapeEventNumber, ShapeErrorNumber; -! long clock; - struct tm lastTimes, times; - Pixmap border, clip; - GC clearGC, drawGC; ---- 54,60 ---- - int screen_number; - Window rootWindow, mainWindow; - int ShapeEventNumber, ShapeErrorNumber; -! time_t lclock; - struct tm lastTimes, times; - Pixmap border, clip; - GC clearGC, drawGC; -*************** -*** 212,218 **** - XShapeCombineMask(display, mainWindow, ShapeBounding, 0, 0, border, ShapeSet); - XShapeCombineMask(display, mainWindow, ShapeClip, 0, 0, clip, ShapeSet); - -! XFlush(display, 1); - - /* This call to XPending ensures that if the window gets closed, we die */ - XPending(display); ---- 215,221 ---- - XShapeCombineMask(display, mainWindow, ShapeBounding, 0, 0, border, ShapeSet); - XShapeCombineMask(display, mainWindow, ShapeClip, 0, 0, clip, ShapeSet); - -! XFlush(display); - - /* This call to XPending ensures that if the window gets closed, we die */ - XPending(display); -*************** -*** 233,243 **** - int - sigalrm() - { -! clock = time(0); -! times = *localtime(&clock); - times.tm_hour = times.tm_hour * 5 + times.tm_min / 12; - reshape(); -! signal(SIGALRM, sigalrm); /* For SysV lusers */ - } - - unsigned long ---- 236,246 ---- - int - sigalrm() - { -! lclock = time(0); -! times = *localtime(&lclock); - times.tm_hour = times.tm_hour * 5 + times.tm_min / 12; - reshape(); -! signal(SIGALRM, (void *)sigalrm); /* For SysV lusers */ - } - - unsigned long -*************** -*** 330,336 **** - display = XOpenDisplay(displayName); - if(display == 0) - { -! fprintf("Couldn't open display %s\n", displayName); - exit(-1); - } - ---- 333,339 ---- - display = XOpenDisplay(displayName); - if(display == 0) - { -! fprintf(stderr, "Couldn't open display %s\n", displayName); - exit(-1); - } - -*************** -*** 347,353 **** - if(access(fn, R_OK) == 0) - XrmMergeDatabases(XrmGetFileDatabase(fn), &db); - -! if(getenv("XENVIRONMENT") && access(getenv("XENVIRONMENT")) == 0) - XrmMergeDatabases(XrmGetFileDatabase(getenv("XENVIRONMENT")), &db); - - XrmMergeDatabases(cmdDB, &db); ---- 350,356 ---- - if(access(fn, R_OK) == 0) - XrmMergeDatabases(XrmGetFileDatabase(fn), &db); - -! if(getenv("XENVIRONMENT") && access(getenv("XENVIRONMENT"), R_OK) == 0) - XrmMergeDatabases(XrmGetFileDatabase(getenv("XENVIRONMENT")), &db); - - XrmMergeDatabases(cmdDB, &db); -*************** -*** 410,416 **** - XMapRaised(display, mainWindow); - XFlush(display); - -! signal(SIGALRM, sigalrm); - new.it_interval.tv_sec = 1; - new.it_value.tv_sec = 1; - new.it_interval.tv_usec = 0; ---- 413,419 ---- - XMapRaised(display, mainWindow); - XFlush(display); - -! signal(SIGALRM, (void *)sigalrm); - new.it_interval.tv_sec = 1; - new.it_value.tv_sec = 1; - new.it_interval.tv_usec = 0; -*************** -*** 420,423 **** - for(;;) - sigpause(0); - } -- ---- 423,425 ---- +--- tclock.c.orig Mon Dec 21 11:56:29 1992 ++++ tclock.c Fri May 19 00:49:55 2000 +@@ -22,7 +22,10 @@ + */ + + #include <stdio.h> ++#include <stdlib.h> ++#include <unistd.h> + #include <math.h> ++#include <time.h> + #include <X11/Xlib.h> + #include <X11/Xutil.h> + #include <X11/Xos.h> +@@ -51,7 +54,7 @@ + int screen_number; + Window rootWindow, mainWindow; + int ShapeEventNumber, ShapeErrorNumber; +-long clock; ++time_t lclock; + struct tm lastTimes, times; + Pixmap border, clip; + GC clearGC, drawGC; +@@ -212,7 +215,7 @@ + XShapeCombineMask(display, mainWindow, ShapeBounding, 0, 0, border, ShapeSet); + XShapeCombineMask(display, mainWindow, ShapeClip, 0, 0, clip, ShapeSet); + +- XFlush(display, 1); ++ XFlush(display); + + /* This call to XPending ensures that if the window gets closed, we die */ + XPending(display); +@@ -233,11 +236,11 @@ + int + sigalrm() + { +- clock = time(0); +- times = *localtime(&clock); ++ lclock = time(0); ++ times = *localtime(&lclock); + times.tm_hour = times.tm_hour * 5 + times.tm_min / 12; + reshape(); +- signal(SIGALRM, sigalrm); /* For SysV lusers */ ++ signal(SIGALRM, (void *)sigalrm); /* For SysV lusers */ + } + + unsigned long +@@ -309,6 +312,7 @@ + extern + char *getenv(); + char *displayName, fn[1000]; ++ char *sdb; + int parseReturn, rc; + + XrmParseCommand(&db, option, numOptions, "tclock", &ac, av); +@@ -330,7 +334,7 @@ + display = XOpenDisplay(displayName); + if(display == 0) + { +- fprintf("Couldn't open display %s\n", displayName); ++ fprintf(stderr, "Couldn't open display %s\n", displayName); + exit(-1); + } + +@@ -341,13 +345,14 @@ + exit(1); + + db = XrmGetStringDatabase(tclockDefaults); +- XrmMergeDatabases(XrmGetStringDatabase(XResourceManagerString(display)), &db); ++ if(sdb = XResourceManagerString(display)) ++ XrmMergeDatabases(XrmGetStringDatabase(sdb), &db); + + sprintf(fn, "%s/.Xdefaults", getenv("HOME")); + if(access(fn, R_OK) == 0) + XrmMergeDatabases(XrmGetFileDatabase(fn), &db); + +- if(getenv("XENVIRONMENT") && access(getenv("XENVIRONMENT")) == 0) ++ if(getenv("XENVIRONMENT") && access(getenv("XENVIRONMENT"), R_OK) == 0) + XrmMergeDatabases(XrmGetFileDatabase(getenv("XENVIRONMENT")), &db); + + XrmMergeDatabases(cmdDB, &db); +@@ -410,7 +415,7 @@ + XMapRaised(display, mainWindow); + XFlush(display); + +- signal(SIGALRM, sigalrm); ++ signal(SIGALRM, (void *)sigalrm); + new.it_interval.tv_sec = 1; + new.it_value.tv_sec = 1; + new.it_interval.tv_usec = 0; +@@ -420,4 +425,3 @@ + for(;;) + sigpause(0); + } +- |