]> code.delx.au - gnu-emacs/blobdiff - src/xrdb.c
(LD_SWITCH_MACHINE):
[gnu-emacs] / src / xrdb.c
index 9ab9f87e9151a5e012e3d896c61715a73af70863..9105f6ea763c26b215f9629681abe166c78c021e 100644 (file)
@@ -1,19 +1,22 @@
 /* Deal with the X Resource Manager.
-   Copyright (C) 1990, 1993 Free Software Foundation.
+   Copyright (C) 1990, 1993, 1994 Free Software Foundation.
 
-This program is free software; you can redistribute it and/or modify
+This file is part of GNU Emacs.
+
+GNU Emacs 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 2, or (at your option)
 any later version.
 
-This program is distributed in the hope that it will be useful,
+GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+along with GNU Emacs; see the file COPYING.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 /* Written by jla, 4/90 */
 
@@ -26,16 +29,14 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #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
+#ifndef SYSV
 #define SYSV
+#endif
 #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
@@ -51,10 +52,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #endif
 #include <sys/stat.h>
 
-#ifndef MAXPATHLEN
-#define MAXPATHLEN     256
-#endif
-
 #if !defined(S_ISDIR) && defined(S_IFDIR)
 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
 #endif
@@ -69,7 +66,7 @@ extern short getuid ();               /* If this causes portability problems,
                                   default to `int' anyway.  */
 #endif
 
-#if defined (__bsdi__) || defined (DECLARE_GETPWUID_WITH_UID_T)
+#ifdef DECLARE_GETPWUID_WITH_UID_T
 extern struct passwd *getpwuid (uid_t);
 extern struct passwd *getpwnam (const char *);
 #else
@@ -406,6 +403,7 @@ get_user_app (class)
 {
   char *path;
   char *file = 0;
+  char *free_it = 0;
 
   /* Check for XUSERFILESEARCHPATH.  It is a path of complete file
      names, not directories.  */
@@ -420,16 +418,20 @@ get_user_app (class)
       
       /* Check in the home directory.  This is a bit of a hack; let's
         hope one's home directory doesn't contain any %-escapes.  */
-      || (path = gethomedir (),
-         ((file = search_magic_path (path, class, "%L/%N", 0))
-          || (file = search_magic_path (path, class, "%N", 0)))))
+      || (free_it = gethomedir (),
+         ((file = search_magic_path (free_it, class, "%L/%N", 0))
+          || (file = search_magic_path (free_it, class, "%N", 0)))))
     {
       XrmDatabase db = XrmGetFileDatabase (file);
       free (file);
+      if (free_it)
+       free (free_it);
       return db;
     }
-  else
-    return NULL;
+
+  if (free_it)
+    free (free_it);
+  return NULL;
 }
 
 
@@ -521,7 +523,11 @@ x_load_resources (display, xrm_string, myname, myclass)
   XrmDatabase db;
 
   x_rm_string = XrmStringToQuark (XrmStringType);
+#ifndef USE_X_TOOLKIT
+  /* pmr@osf.org says this shouldn't be done if USE_X_TOOLKIT.
+     I suspect it's because the toolkit version does this elsewhere.  */
   XrmInitialize ();
+#endif
   rdb = XrmGetStringDatabase ("");
 
   user_database = get_user_db (display);