]> code.delx.au - gnu-emacs/blobdiff - src/xrdb.c
(regi-interpret): Use `mapc' rather than `mapcar'.
[gnu-emacs] / src / xrdb.c
index bab1b47d481ade4fd958b591e54b2f4d8242cb23..79f1da81a413729e30ac1ec0da79e969b3b183d3 100644 (file)
@@ -1,11 +1,12 @@
 /* Deal with the X Resource Manager.
 /* Deal with the X Resource Manager.
-   Copyright (C) 1990, 1993, 1994 Free Software Foundation.
+   Copyright (C) 1990, 1993, 1994, 2000, 2001, 2002, 2003, 2004,
+                 2005, 2006, 2007 Free Software Foundation, Inc.
 
 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
 
 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)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -15,8 +16,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
 
 You should have received a copy of the GNU General Public License
 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.  */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 /* Written by jla, 4/90 */
 
 
 /* Written by jla, 4/90 */
 
@@ -33,12 +34,15 @@ Boston, MA 02111-1307, USA.  */
 #include <stdio.h>
 
 #if 1 /* I'd really appreciate it if this code could go away...  -JimB */
 #include <stdio.h>
 
 #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
+/* This avoids lossage in the `dual-universe' headers on AT&T SysV
+   X11.  Don't do it on Solaris, because it breaks compilation with
+   XFree86 4.0.3 (and probably many other X11R6 releases) on Solaris
+   2 */
+#if defined(USG5) && !defined(SOLARIS2)
 #ifndef SYSV
 #define SYSV
 #endif
 #ifndef SYSV
 #define SYSV
 #endif
-#endif /* USG5 */
+#endif /* USG5 && !SOLARIS2 */
 
 #endif /* 1 */
 
 
 #endif /* 1 */
 
@@ -50,9 +54,7 @@ Boston, MA 02111-1307, USA.  */
 #include <X11/X.h>
 #include <X11/Xutil.h>
 #include <X11/Xresource.h>
 #include <X11/X.h>
 #include <X11/Xutil.h>
 #include <X11/Xresource.h>
-#ifdef VMS
-#include "vms-pwd.h"
-#else
+#ifdef HAVE_PWD_H
 #include <pwd.h>
 #endif
 #include <sys/stat.h>
 #include <pwd.h>
 #endif
 #include <sys/stat.h>
@@ -86,10 +88,13 @@ extern char *get_system_name ();
 /* Make sure not to #include anything after these definitions.  Let's
    not step on anyone's prototypes.  */
 #ifdef emacs
 /* Make sure not to #include anything after these definitions.  Let's
    not step on anyone's prototypes.  */
 #ifdef emacs
+/* darwin.h may have already defined these.  */
+#undef malloc
+#undef realloc
+#undef free
 #define malloc xmalloc
 #define realloc xrealloc
 #define free xfree
 #define malloc xmalloc
 #define realloc xrealloc
 #define free xfree
-extern long *xmalloc (), *xrealloc ();
 #endif
 
 char *x_get_string_resource ();
 #endif
 
 char *x_get_string_resource ();
@@ -181,7 +186,7 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix)
   while (p < string + string_len)
     {
       /* The chunk we're about to stick on the end of result.  */
   while (p < string + string_len)
     {
       /* The chunk we're about to stick on the end of result.  */
-      char *next;
+      char *next = NULL;
       int next_len;
 
       if (*p == '%')
       int next_len;
 
       if (*p == '%')
@@ -227,11 +232,11 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix)
                    free (path);
                    return NULL;
                  }
                    free (path);
                    return NULL;
                  }
-               
+
                next = lang;
                next_len = strlen (next);
                break;
                next = lang;
                next_len = strlen (next);
                break;
-             
+
              case 't':
              case 'c':
                free (path);
              case 't':
              case 'c':
                free (path);
@@ -247,7 +252,7 @@ magic_file_p (string, string_len, class, escaped_suffix, suffix)
          path_size = (path_len + next_len + 1) * 2;
          path = (char *) realloc (path, path_size);
        }
          path_size = (path_len + next_len + 1) * 2;
          path = (char *) realloc (path, path_size);
        }
-      
+
       bcopy (next, path + path_len, next_len);
       path_len += next_len;
 
       bcopy (next, path + path_len, next_len);
       path_len += next_len;
 
@@ -309,8 +314,8 @@ gethomedir ()
        ptr = pw->pw_dir;
     }
 
        ptr = pw->pw_dir;
     }
 
-  if (ptr == NULL) 
-    return "/";
+  if (ptr == NULL)
+    return xstrdup ("/");
 
   copy = (char *) malloc (strlen (ptr) + 2);
   strcpy (copy, ptr);
 
   copy = (char *) malloc (strlen (ptr) + 2);
   strcpy (copy, ptr);
@@ -321,19 +326,19 @@ gethomedir ()
 
 
 static int
 
 
 static int
-file_p (path)
-     char *path;
+file_p (filename)
+     char *filename;
 {
   struct stat status;
 
 {
   struct stat status;
 
-  return (access (path, 4) == 0                        /* exists and is readable */
-         && stat (path, &status) == 0          /* get the status */
+  return (access (filename, 4) == 0             /* exists and is readable */
+         && stat (filename, &status) == 0      /* get the status */
          && (S_ISDIR (status.st_mode)) == 0);  /* not a directory */
 }
 
 
 /* Find the first element of SEARCH_PATH which exists and is readable,
          && (S_ISDIR (status.st_mode)) == 0);  /* not a directory */
 }
 
 
 /* Find the first element of SEARCH_PATH which exists and is readable,
-   after expanding the %-escapes.  Return 0 if we didn't find any, and 
+   after expanding the %-escapes.  Return 0 if we didn't find any, and
    the path name of the one we found otherwise.  */
 
 static char *
    the path name of the one we found otherwise.  */
 
 static char *
@@ -346,7 +351,7 @@ search_magic_path (search_path, class, escaped_suffix, suffix)
     {
       for (p = s; *p && *p != ':'; p++)
        ;
     {
       for (p = s; *p && *p != ':'; p++)
        ;
-      
+
       if (p > s)
        {
          char *path = magic_file_p (s, p - s, class, escaped_suffix, suffix);
       if (p > s)
        {
          char *path = magic_file_p (s, p - s, class, escaped_suffix, suffix);
@@ -419,7 +424,7 @@ get_user_app (class)
       || ((path = getenv ("XAPPLRESDIR"))
          && ((file = search_magic_path (path, class, "/%L/%N", 0))
              || (file = search_magic_path (path, class, "/%N", 0))))
       || ((path = getenv ("XAPPLRESDIR"))
          && ((file = search_magic_path (path, class, "/%L/%N", 0))
              || (file = search_magic_path (path, class, "/%N", 0))))
-      
+
       /* Check in the home directory.  This is a bit of a hack; let's
         hope one's home directory doesn't contain any %-escapes.  */
       || (free_it = gethomedir (),
       /* Check in the home directory.  This is a bit of a hack; let's
         hope one's home directory doesn't contain any %-escapes.  */
       || (free_it = gethomedir (),
@@ -525,7 +530,9 @@ x_load_resources (display, xrm_string, myname, myclass)
   XrmDatabase rdb;
   XrmDatabase db;
   char line[256];
   XrmDatabase rdb;
   XrmDatabase db;
   char line[256];
+
   char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
   char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
+
 #ifdef USE_MOTIF
   char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1";
   extern Lisp_Object Vdouble_click_time;
 #ifdef USE_MOTIF
   char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1";
   extern Lisp_Object Vdouble_click_time;
@@ -542,34 +549,38 @@ x_load_resources (display, xrm_string, myname, myclass)
   /* Add some font defaults.  If the font `helv' doesn't exist, widgets
      will use some other default font.  */
 #ifdef USE_MOTIF
   /* Add some font defaults.  If the font `helv' doesn't exist, widgets
      will use some other default font.  */
 #ifdef USE_MOTIF
-  
-  sprintf (line, "%s*fontList: %s", myname, helv);
+
+  sprintf (line, "%s.pane.background: grey75", myclass);
+  XrmPutLineResource (&rdb, line);
+  sprintf (line, "%s*fontList: %s", myclass, helv);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*menu*background: grey75", myname);
+  sprintf (line, "%s*menu*background: grey75", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*menubar*background: grey75", myname, helv);
+  sprintf (line, "%s*menubar*background: grey75", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*verticalScrollBar.background: grey75", myname);
+  sprintf (line, "%s*verticalScrollBar.background: grey75", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s.dialog*.background: grey75", myname);
+  sprintf (line, "%s*verticalScrollBar.troughColor: grey75", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*fsb.Text.background: white", myname);
+  sprintf (line, "%s.dialog*.background: grey75", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*fsb.FilterText.background: white", myname);
+  sprintf (line, "%s*fsb.Text.background: white", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*fsb*DirList.background: white", myname);
+  sprintf (line, "%s*fsb.FilterText.background: white", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*fsb*ItemsList.background: white", myname);
+  sprintf (line, "%s*fsb*DirList.background: white", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*fsb*background: grey75", myname);
+  sprintf (line, "%s*fsb*ItemsList.background: white", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*fsb.Text.fontList: %s", myname, courier);
+  sprintf (line, "%s*fsb*background: grey75", myclass);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*fsb.FilterText.fontList: %s", myname, courier);
+  sprintf (line, "%s*fsb.Text.fontList: %s", myclass, courier);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*fsb*ItemsList.fontList: %s", myname, courier);
+  sprintf (line, "%s*fsb.FilterText.fontList: %s", myclass, courier);
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
-  sprintf (line, "%s*fsb*DirList.fontList: %s", myname, courier);
+  sprintf (line, "%s*fsb*ItemsList.fontList: %s", myclass, courier);
+  XrmPutLineResource (&rdb, line);
+  sprintf (line, "%s*fsb*DirList.fontList: %s", myclass, courier);
   XrmPutLineResource (&rdb, line);
 
   /* Set double click time of list boxes in the file selection
   XrmPutLineResource (&rdb, line);
 
   /* Set double click time of list boxes in the file selection
@@ -577,15 +588,15 @@ x_load_resources (display, xrm_string, myname, myclass)
   if (INTEGERP (Vdouble_click_time) && XINT (Vdouble_click_time) > 0)
     {
       sprintf (line, "%s*fsb*DirList.doubleClickInterval: %d",
   if (INTEGERP (Vdouble_click_time) && XINT (Vdouble_click_time) > 0)
     {
       sprintf (line, "%s*fsb*DirList.doubleClickInterval: %d",
-              myname, XFASTINT (Vdouble_click_time));
+              myclass, XFASTINT (Vdouble_click_time));
       XrmPutLineResource (&rdb, line);
       sprintf (line, "%s*fsb*ItemsList.doubleClickInterval: %d",
       XrmPutLineResource (&rdb, line);
       sprintf (line, "%s*fsb*ItemsList.doubleClickInterval: %d",
-              myname, XFASTINT (Vdouble_click_time));
+              myclass, XFASTINT (Vdouble_click_time));
       XrmPutLineResource (&rdb, line);
     }
 
 #else /* not USE_MOTIF */
       XrmPutLineResource (&rdb, line);
     }
 
 #else /* not USE_MOTIF */
-  
+
   sprintf (line, "Emacs.dialog*.font: %s", helv);
   XrmPutLineResource (&rdb, line);
   sprintf (line, "Emacs.dialog*.background: grey75");
   sprintf (line, "Emacs.dialog*.font: %s", helv);
   XrmPutLineResource (&rdb, line);
   sprintf (line, "Emacs.dialog*.background: grey75");
@@ -596,7 +607,7 @@ x_load_resources (display, xrm_string, myname, myclass)
   XrmPutLineResource (&rdb, line);
   sprintf (line, "Emacs*verticalScrollBar.background: grey75");
   XrmPutLineResource (&rdb, line);
   XrmPutLineResource (&rdb, line);
   sprintf (line, "Emacs*verticalScrollBar.background: grey75");
   XrmPutLineResource (&rdb, line);
-  
+
 #endif /* not USE_MOTIF */
 
   user_database = get_user_db (display);
 #endif /* not USE_MOTIF */
 
   user_database = get_user_db (display);
@@ -631,7 +642,7 @@ x_load_resources (display, xrm_string, myname, myclass)
   db = get_environ_db ();
   if (db != NULL)
     XrmMergeDatabases (db, &rdb);
   db = get_environ_db ();
   if (db != NULL)
     XrmMergeDatabases (db, &rdb);
-  
+
   /* Last, merge in any specification from the command line. */
   if (xrm_string != NULL)
     {
   /* Last, merge in any specification from the command line. */
   if (xrm_string != NULL)
     {
@@ -806,3 +817,6 @@ main (argc, argv)
   XCloseDisplay (display);
 }
 #endif /* TESTRM */
   XCloseDisplay (display);
 }
 #endif /* TESTRM */
+
+/* arch-tag: 37e6fbab-ed05-4363-9e76-6c4109ed511f
+   (do not change this comment) */