X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/7a22490f14441898e1c4f6679f5924f097f3bb34..6ffb560b2a940d19419ac5afe11418588ef8c61f:/src/xrdb.c?ds=sidebyside diff --git a/src/xrdb.c b/src/xrdb.c index 60dcdae080..9e85e5a627 100644 --- a/src/xrdb.c +++ b/src/xrdb.c @@ -1,5 +1,5 @@ /* Deal with the X Resource Manager. - Copyright (C) 1990, 1993-1994, 2000-2013 Free Software Foundation, + Copyright (C) 1990, 1993-1994, 2000-2015 Free Software Foundation, Inc. Author: Joseph Arceneaux @@ -48,10 +48,6 @@ along with GNU Emacs. If not, see . */ #include "keyboard.h" #endif -char *x_get_string_resource (XrmDatabase rdb, const char *name, - const char *class); - - /* X file search path processing. */ @@ -183,7 +179,7 @@ magic_db (const char *string, ptrdiff_t string_len, const char *class, else next = p, next_len = 1; - /* Do we have room for this component followed by a '\0' ? */ + /* Do we have room for this component followed by a '\0'? */ if (path_size - path_len <= next_len) { if (min (PTRDIFF_MAX, SIZE_MAX) / 2 - 1 - path_len < next_len) @@ -236,11 +232,10 @@ gethomedir (void) if (ptr == NULL) return xstrdup ("/"); - copy = xmalloc (strlen (ptr) + 2); - strcpy (copy, ptr); - strcat (copy, "/"); - - return copy; + ptrdiff_t len = strlen (ptr); + copy = xmalloc (len + 2); + strcpy (copy + len, "/"); + return memcpy (copy, ptr, len); } @@ -340,6 +335,7 @@ get_user_app (const char *class) return db; } +static char const xdefaults[] = ".Xdefaults"; static XrmDatabase get_user_db (Display *display) @@ -357,16 +353,12 @@ get_user_db (Display *display) db = XrmGetStringDatabase (xdefs); else { - char *home; - char *xdefault; - - home = gethomedir (); - xdefault = xmalloc (strlen (home) + sizeof ".Xdefaults"); - strcpy (xdefault, home); - strcat (xdefault, ".Xdefaults"); - db = XrmGetFileDatabase (xdefault); - xfree (home); - xfree (xdefault); + char *home = gethomedir (); + ptrdiff_t homelen = strlen (home); + char *filename = xrealloc (home, homelen + sizeof xdefaults); + strcpy (filename + homelen, xdefaults); + db = XrmGetFileDatabase (filename); + xfree (filename); } #ifdef HAVE_XSCREENRESOURCESTRING @@ -386,24 +378,23 @@ static XrmDatabase get_environ_db (void) { XrmDatabase db; - char *p; - char *path = 0; + char *p = getenv ("XENVIRONMENT"); + char *filename = 0; - if ((p = getenv ("XENVIRONMENT")) == NULL) + if (!p) { - static char const xdefaults[] = ".Xdefaults-"; char *home = gethomedir (); - char const *host = SSDATA (Vsystem_name); - ptrdiff_t pathsize = (strlen (home) + sizeof xdefaults - + SBYTES (Vsystem_name)); - path = xrealloc (home, pathsize); - strcat (strcat (path, xdefaults), host); - p = path; + ptrdiff_t homelen = strlen (home); + Lisp_Object system_name = Fsystem_name (); + ptrdiff_t filenamesize = (homelen + sizeof xdefaults + + SBYTES (system_name)); + p = filename = xrealloc (home, filenamesize); + lispstpcpy (stpcpy (filename + homelen, xdefaults), system_name); } db = XrmGetFileDatabase (p); - xfree (path); + xfree (filename); return db; } @@ -458,6 +449,10 @@ x_load_resources (Display *display, const char *xrm_string, XrmPutLineResource (&rdb, line); sprintf (line, "%s*verticalScrollBar.troughColor: grey75", myclass); XrmPutLineResource (&rdb, line); + sprintf (line, "%s*horizontalScrollBar.background: grey75", myclass); + XrmPutLineResource (&rdb, line); + sprintf (line, "%s*horizontalScrollBar.troughColor: grey75", myclass); + XrmPutLineResource (&rdb, line); sprintf (line, "%s.dialog*.background: grey75", myclass); XrmPutLineResource (&rdb, line); sprintf (line, "%s*fsb.Text.background: white", myclass); @@ -505,6 +500,8 @@ x_load_resources (Display *display, const char *xrm_string, XrmPutLineResource (&rdb, line); sprintf (line, "Emacs*verticalScrollBar.background: grey75"); XrmPutLineResource (&rdb, line); + sprintf (line, "Emacs*horizontalScrollBar.background: grey75"); + XrmPutLineResource (&rdb, line); #endif /* not USE_MOTIF */ @@ -670,7 +667,7 @@ main (int argc, char **argv) /* In a real program, you'd want to also do this: */ display->db = xdb; - while (1) + while (true) { char query_name[90]; char query_class[90];