]> code.delx.au - gnu-emacs/blobdiff - src/xrdb.c
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
[gnu-emacs] / src / xrdb.c
index 23f6b9424698f93988a45fc874fd66dcf2f764ef..a83cb37fe53e9c9ef9cd530b74237a08a117bfd8 100644 (file)
@@ -1,9 +1,9 @@
 /* Deal with the X Resource Manager.
-   Copyright (C) 1990 Free Software Foundation.
+   Copyright (C) 1990, 1992 Free Software Foundation.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 This program is distributed in the hope that it will be useful,
@@ -17,23 +17,52 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /* Written by jla, 4/90 */
 
+#ifdef emacs
+#include "config.h"
+#endif
+
+#if 1 /* I'd really appreciate it if this code could go away...  -JimB */
+/* this avoids lossage in the `dual-universe' headers on AT&T SysV X11 */
+#ifdef USG5
+#define SYSV
+#include <unistd.h>
+#endif /* USG5 */
+
+#endif /* 1 */
+
+/* This should be included before the X include files; otherwise, we get
+   warnings about redefining NULL under BSD 4.3.  */
+#include <sys/param.h>
+
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
+#if 0
 #include <X11/Xos.h>
+#endif
 #include <X11/X.h>
 #include <X11/Xutil.h>
 #include <X11/Xresource.h>
-#include <sys/param.h>
+#ifdef VMS
+#include "vms-pwd.h"
+#else
 #include <pwd.h>
+#endif
 #include <sys/stat.h>
-#include <sys/types.h>
 
-#ifdef emacs
-#include "config.h"
+#ifndef MAXPATHLEN
+#define MAXPATHLEN     256
 #endif
 
 extern char *getenv ();
-extern uid_t getuid ();
+
+/* This does cause trouble on AIX.  I'm going to take the comment at
+   face value.  */
+#if 0
+extern short getuid ();                /* If this causes portability problems,
+                                  I think we should just delete it; it'll
+                                  default to `int' anyway.  */
+#endif
+
 extern struct passwd *getpwuid ();
 extern struct passwd *getpwnam ();
 
@@ -80,7 +109,7 @@ file_p (path)
 {
   struct stat status;
 
-  return (access (path, R_OK) == 0             /* exists and is readable */
+  return (access (path, 4) == 0                        /* exists and is readable */
          && stat (path, &status) == 0          /* get the status */
          && (status.st_mode & S_IFDIR) == 0);  /* not a directory */
 }
@@ -142,7 +171,10 @@ magic_searchpath_decoder (incantation_string, file, return_path)
 {
   register char *s = incantation_string;
   register char *p;
-  register char string[MAXPATHLEN];
+
+  /* Must be big enough for "%N%S".  */
+  register int string_size = MAXPATHLEN;
+  register char *string = (char *) alloca (string_size * sizeof (*string));
 
   while (*s)
     {
@@ -153,6 +185,7 @@ magic_searchpath_decoder (incantation_string, file, return_path)
 
       if (*p == ':' && *(p + 1) == ':')
        {
+         /* We know string is big enough for this.  */
          bcopy ("%N%S", string, 5);
          if (decode_magic (string, file, return_path))
            return 1;
@@ -165,6 +198,11 @@ magic_searchpath_decoder (incantation_string, file, return_path)
        {
          int len = p - s;
 
+         if (string_size < len+1)
+           {
+             string_size = 2 * len;
+             string = (char *) alloca (string_size * sizeof (*string));
+           }
          bcopy (s, string, len);
          string[len + 1] = '\0';
          if (decode_magic (string, file, return_path))
@@ -254,7 +292,12 @@ get_user_db (display)
   XrmDatabase db;
   char *xdefs;
 
+#ifdef PBaseSize               /* Cheap way to test for X11R4 or later.  */
   xdefs = XResourceManagerString (display);
+#else
+  xdefs = display->xdefaults;
+#endif
+
   if (xdefs != NULL)
     db = XrmGetStringDatabase (xdefs);
   else
@@ -366,7 +409,7 @@ x_get_resource (rdb, name, class, expected_type, ret_value)
       && (type == expected_type))
     {
       if (type == x_rm_string)
-       (char *) ret_value->addr = value.addr;
+       ret_value->addr = (char *) value.addr;
       else
        bcopy (value.addr, ret_value->addr, ret_value->size);