summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/Makefile.in2
-rw-r--r--utils/font-retry.c13
-rw-r--r--utils/grabclient.c20
-rw-r--r--utils/grabscreen.h4
-rw-r--r--utils/textclient-mobile.c2
-rw-r--r--utils/textclient.c80
-rw-r--r--utils/textclient.h4
-rw-r--r--utils/usleep.h4
-rw-r--r--utils/utf8wc.c6
-rw-r--r--utils/version.h2
-rw-r--r--utils/xshm.c14
-rw-r--r--utils/yarandom.c4
12 files changed, 116 insertions, 39 deletions
diff --git a/utils/Makefile.in b/utils/Makefile.in
index dbb593b..e8fff09 100644
--- a/utils/Makefile.in
+++ b/utils/Makefile.in
@@ -120,7 +120,7 @@ HDRS = alpha.h colors.h fade.h grabscreen.h hsv.h resources.h \
yarandom.h erase.h xshm.h xdbe.h colorbars.h minixpm.h \
xscreensaver-intl.h textclient.h aligned_malloc.h \
thread_util.h async_netdb.h xft.h utf8wc.h pow2.h \
- font-retry.h
+ font-retry.h queue.h
STAR = *
LOGOS = images/$(STAR).xpm \
images/$(STAR).png \
diff --git a/utils/font-retry.c b/utils/font-retry.c
index f8e6507..d726378 100644
--- a/utils/font-retry.c
+++ b/utils/font-retry.c
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 2018 by Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 2018-2020 by Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -110,7 +110,8 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
const char *variable[] = {
"helvetica",
"arial",
- "bitstream vera sans",
+ "bitstream vera sans", /* sometimes foundry is in family */
+ "vera sans", /* sometimes not? */
"gill sans",
"times",
"times new roman",
@@ -118,7 +119,12 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
"utopia",
"palatino",
"lucida",
- "bitstream charter",
+ "clearlyu",
+ "bitstream charter", /* sometimes foundry is in family */
+ "charter", /* sometimes not? */
+ "utopia",
+ "luxi sans",
+ "latin modern roman",
/* Don't use a wildcard family. If none of the above worked, then
then almost none of the X11 fonts are installed, and it's not
@@ -135,6 +141,7 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p)
"courier 10 pitch",
"lucidatypewriter",
"american typewriter",
+ "luxi mono",
"fixed",
"ocr a std",
/* As above, but "can't happen" because we already tried fixed? */
diff --git a/utils/grabclient.c b/utils/grabclient.c
index abe069b..3062fdc 100644
--- a/utils/grabclient.c
+++ b/utils/grabclient.c
@@ -127,11 +127,11 @@ typedef struct {
XtInputId pipe_id;
FILE *pipe;
-# if !defined(USE_IPHONE) && !defined(HAVE_COCOA) /* Real X11 */
+# if !defined(HAVE_IPHONE) && !defined(HAVE_COCOA) /* Real X11 */
pid_t pid;
# endif
-# if !defined(USE_IPHONE) && defined(HAVE_COCOA) /* Desktop OSX */
+# if !defined(HAVE_IPHONE) && defined(HAVE_COCOA) /* Desktop OSX */
char *directory;
# endif
@@ -564,7 +564,7 @@ load_random_image_x11 (Screen *screen, Window window, Drawable drawable,
#elif defined (HAVE_COCOA) /* OSX or iOS */
-# ifndef USE_IPHONE /* HAVE_COCOA && !USE_IPHONE -- desktop OSX */
+# ifndef HAVE_IPHONE /* HAVE_COCOA && !HAVE_IPHONE -- desktop OSX */
# define BACKSLASH(c) \
(! ((c >= 'a' && c <= 'z') || \
@@ -699,7 +699,7 @@ xscreensaver_getimage_file_cb (XtPointer closure, int *source, XtInputId *id)
}
-# else /* HAVE_COCOA && USE_IPHONE -- iOS */
+# else /* HAVE_COCOA && HAVE_IPHONE -- iOS */
/* Callback for ios_load_random_image(), called after we have loaded an
image from the iOS device's Photo Library. See grabclient-ios.m.
@@ -753,7 +753,7 @@ ios_load_random_image_cb (void *uiimage, const char *filename,
free (clo2);
}
-# endif /* HAVE_COCOA && USE_IPHONE */
+# endif /* HAVE_COCOA && HAVE_IPHONE */
static void
@@ -774,7 +774,7 @@ osx_load_image_file_async (Screen *screen, Window xwindow, Drawable drawable,
clo2->callback = callback;
clo2->closure = closure;
-# ifndef USE_IPHONE /* Desktop OSX */
+# ifndef HAVE_IPHONE /* Desktop OSX */
clo2->directory = strdup (dir);
clo2->pipe = open_image_name_pipe (dir);
clo2->pipe_id = XtAppAddInput (XtDisplayToApplicationContext (
@@ -782,14 +782,14 @@ osx_load_image_file_async (Screen *screen, Window xwindow, Drawable drawable,
fileno (clo2->pipe),
(XtPointer) (XtInputReadMask | XtInputExceptMask),
xscreensaver_getimage_file_cb, (XtPointer) clo2);
-# else /* USE_IPHONE */
+# else /* HAVE_IPHONE */
{
XWindowAttributes xgwa;
XGetWindowAttributes (DisplayOfScreen (screen), xwindow, &xgwa);
ios_load_random_image (ios_load_random_image_cb, clo2,
xgwa.width, xgwa.height);
}
-# endif /* USE_IPHONE */
+# endif /* HAVE_IPHONE */
}
@@ -828,13 +828,13 @@ load_random_image_cocoa (Screen *screen, Window window, Drawable drawable,
geom.width = xgwa.width;
geom.height = xgwa.height;
-# ifndef USE_IPHONE
+# ifndef HAVE_IPHONE
if (filep)
dir = get_string_resource (dpy, "imageDirectory", "ImageDirectory");
if (!dir || !*dir)
filep = False;
-# endif /* ! USE_IPHONE */
+# endif /* ! HAVE_IPHONE */
if (deskp && filep) {
deskp = !(random() & 5); /* if both, desktop 1/5th of the time */
diff --git a/utils/grabscreen.h b/utils/grabscreen.h
index 40054c8..a17e671 100644
--- a/utils/grabscreen.h
+++ b/utils/grabscreen.h
@@ -92,14 +92,14 @@ extern Bool osx_load_image_file (Screen *, Window, Drawable,
const char *filename, XRectangle *geom_ret);
#endif /* HAVE_JWXYZ */
-#ifdef USE_IPHONE
+#ifdef HAVE_IPHONE
extern void ios_load_random_image (void (*callback) (void *uiimage,
const char *filename,
int w, int h,
void *closure),
void *closure,
int width, int height);
-#endif /* USE_IPHONE */
+#endif /* HAVE_IPHONE */
#ifdef HAVE_ANDROID
char *jwxyz_draw_random_image (Display *dpy, /* utils/grabclient.c */
diff --git a/utils/textclient-mobile.c b/utils/textclient-mobile.c
index 4d0d891..8745cb0 100644
--- a/utils/textclient-mobile.c
+++ b/utils/textclient-mobile.c
@@ -16,7 +16,7 @@
#include "utils.h"
-#if defined(USE_IPHONE) || defined(HAVE_ANDROID) /* whole file */
+#if defined(HAVE_IPHONE) || defined(HAVE_ANDROID) /* whole file */
#include "textclient.h"
#include "resources.h"
diff --git a/utils/textclient.c b/utils/textclient.c
index fe40928..636b308 100644
--- a/utils/textclient.c
+++ b/utils/textclient.c
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 2012-2016 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 2012-2020 Jamie Zawinski <jwz@jwz.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -22,7 +22,7 @@
#include "utils.h"
-#if !defined(USE_IPHONE) && !defined(HAVE_ANDROID) /* whole file */
+#if !defined(HAVE_IPHONE) && !defined(HAVE_ANDROID) /* whole file */
#include "textclient.h"
#include "resources.h"
@@ -117,6 +117,72 @@ escape_str (char *s, const char *src)
}
#endif
+
+/* Let's see if we're able to fork and exec at all. Thanks, macOS.
+ */
+static Bool
+selftest (void)
+{
+ static Bool done = False;
+ pid_t pid;
+ char buf [255];
+ if (done) return True;
+
+ pid = fork ();
+ switch ((int) pid)
+ {
+ case -1:
+ sprintf (buf, "%s: textclient: selftest: couldn't fork", progname);
+ perror (buf);
+ return False;
+
+ case 0: /* child */
+ {
+ char * const av[] = { "/bin/sh", "-c", "true", 0 };
+ execvp (av[0], av);
+ exit (1); /* exits child fork */
+ break;
+ }
+
+ default: /* parent */
+ {
+ int status = -1;
+ int i;
+ /* Busy-loops are bad mmmmkayyyy */
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 100000L; /* 0.1 sec */
+ for (i = 0; i < 50; i++) { /* 5 sec max */
+ pid_t pid2 = waitpid (pid, &status, 0);
+ if (pid == pid2) break;
+ (void) select (0, 0, 0, 0, &tv);
+ }
+
+ if (status != 0)
+ {
+# ifdef DEBUG
+ fprintf (stderr, "%s: selftest: textclient: status %d\n",
+ progname, status);
+# endif
+ return False;
+ }
+ else
+ {
+# ifdef DEBUG
+ fprintf (stderr, "%s: textclient: selftest ok\n", progname);
+# endif
+ done = True;
+ }
+ break;
+ }
+ }
+
+ return True;
+}
+
+
+static void start_timer (text_data *d);
+
static void
launch_text_generator (text_data *d)
{
@@ -142,6 +208,14 @@ launch_text_generator (text_data *d)
char *cmd = s = malloc ((strlen(oprogram)) * 2 + 100);
# endif
+ if (!selftest())
+ {
+ if (!d->out_buffer || !*d->out_buffer)
+ d->out_buffer = "Can't exec; Gatekeeper problem?\r\n\r\n";
+ start_timer (d);
+ return;
+ }
+
strcpy (s, "( ");
strcat (s, oprogram);
s += strlen (s);
@@ -670,4 +744,4 @@ textclient_putc (text_data *d, XKeyEvent *k)
return False;
}
-#endif /* !USE_IPHONE -- whole file */
+#endif /* !HAVE_IPHONE -- whole file */
diff --git a/utils/textclient.h b/utils/textclient.h
index 0fe582d..5be8079 100644
--- a/utils/textclient.h
+++ b/utils/textclient.h
@@ -14,7 +14,7 @@
#ifndef __TEXTCLIENT_H__
#define __TEXTCLIENT_H__
-# ifdef USE_IPHONE
+# ifdef HAVE_IPHONE
# undef HAVE_FORKPTY
# endif
@@ -29,7 +29,7 @@ extern void textclient_reshape (text_data *,
extern int textclient_getc (text_data *);
extern Bool textclient_putc (text_data *, XKeyEvent *);
-# if defined(USE_IPHONE) || defined(HAVE_ANDROID)
+# if defined(HAVE_IPHONE) || defined(HAVE_ANDROID)
extern char *textclient_mobile_date_string (void);
extern char *textclient_mobile_url_string (Display *, const char *url);
# endif
diff --git a/utils/usleep.h b/utils/usleep.h
index 3225d66..f32a9c9 100644
--- a/utils/usleep.h
+++ b/utils/usleep.h
@@ -12,10 +12,6 @@
#ifndef __SCREENHACK_USLEEP_H__
#define __SCREENHACK_USLEEP_H__
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
diff --git a/utils/utf8wc.c b/utils/utf8wc.c
index c948f22..b445f30 100644
--- a/utils/utf8wc.c
+++ b/utils/utf8wc.c
@@ -266,7 +266,7 @@ utf8_split (const char *string, int *length_ret)
unsigned long uc;
long len2 = utf8_decode (in, len, &uc);
char tmp[10];
- strncpy (tmp, (char *) in, len2);
+ memcpy (tmp, (char *) in, len2);
tmp[len2] = 0;
ret[i++] = strdup (tmp);
in += len2;
@@ -299,8 +299,8 @@ utf8_split (const char *string, int *length_ret)
long L1 = strlen(ret[i-2]);
long L2 = strlen(ret[i-1]);
char *s2 = (char *) malloc (L1 + L2 + 1);
- strncpy (s2, ret[i-2], L1);
- strncpy (s2 + L1, ret[i-1], L2);
+ memcpy (s2, ret[i-2], L1);
+ memcpy (s2 + L1, ret[i-1], L2);
s2[L1 + L2] = 0;
free (ret[i-2]);
ret[i-2] = s2;
diff --git a/utils/version.h b/utils/version.h
index 7a20c66..054dd99 100644
--- a/utils/version.h
+++ b/utils/version.h
@@ -1,2 +1,2 @@
static const char screensaver_id[] =
- "@(#)xscreensaver 5.44 (20-Mar-2020), by Jamie Zawinski (jwz@jwz.org)";
+ "@(#)xscreensaver 5.45 (08-Dec-2020), by Jamie Zawinski (jwz@jwz.org)";
diff --git a/utils/xshm.c b/utils/xshm.c
index 8992140..3c99623 100644
--- a/utils/xshm.c
+++ b/utils/xshm.c
@@ -89,7 +89,7 @@ shm_ehandler (Display *dpy, XErrorEvent *error)
XSync((DPY), False); \
if (old_handler) \
XSetErrorHandler (old_handler); \
- old_handler = 0; \
+ old_handler = 0; \
} while(0)
#endif /* HAVE_XSHM_EXTENSION */
@@ -291,6 +291,8 @@ void
destroy_xshm_image (Display *dpy, XImage *image, XShmSegmentInfo *shm_info)
{
#ifdef HAVE_XSHM_EXTENSION
+ Status status;
+
if (shm_info->shmid == -1) {
#endif /* HAVE_XSHM_EXTENSION */
@@ -303,8 +305,6 @@ destroy_xshm_image (Display *dpy, XImage *image, XShmSegmentInfo *shm_info)
#ifdef HAVE_XSHM_EXTENSION
}
- Status status;
-
CATCH_X_ERROR(dpy);
status = XShmDetach (dpy, shm_info);
UNCATCH_X_ERROR(dpy);
@@ -312,10 +312,10 @@ destroy_xshm_image (Display *dpy, XImage *image, XShmSegmentInfo *shm_info)
status = False;
if (!status)
fprintf (stderr, "%s: XShmDetach failed!\n", progname);
-#ifdef DEBUG
+# ifdef DEBUG
else
fprintf (stderr, "%s: XShmDetach(dpy, shm_info) ==> True\n", progname);
-#endif
+# endif
XDestroyImage (image);
XSync(dpy, False);
@@ -329,10 +329,10 @@ destroy_xshm_image (Display *dpy, XImage *image, XShmSegmentInfo *shm_info)
(unsigned long) shm_info->shmaddr);
perror(buf);
}
-#ifdef DEBUG
+# ifdef DEBUG
else
fprintf (stderr, "%s: shmdt(shm_info->shmaddr) ==> 0\n", progname);
-#endif
+# endif
XSync(dpy, False);
diff --git a/utils/yarandom.c b/utils/yarandom.c
index f450735..0f51cb6 100644
--- a/utils/yarandom.c
+++ b/utils/yarandom.c
@@ -118,9 +118,9 @@ ya_rand_init(unsigned int seed)
#define ROT(X,N) (((X)<<(N)) | ((X)>>((sizeof(unsigned int)*8)-(N))))
seed = (999U * (unsigned int) tp.tv_sec);
seed = ROT (seed, 11);
- seed += (1001 * tp.tv_usec);
+ seed += (1001 * (unsigned int) tp.tv_usec);
seed = ROT (seed, 7);
- seed += (1003 * getpid());
+ seed += (1003 * (unsigned int) getpid());
seed = ROT (seed, 13);
}