X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f3a0bf5c13cba5aeca0947fa8c28803adb1e25d2..42e3337cc7a782ab8705b1dea3841a7b0dcb6224:/src/xrdb.c diff --git a/src/xrdb.c b/src/xrdb.c index 930b4d54d4..a83cb37fe5 100644 --- a/src/xrdb.c +++ b/src/xrdb.c @@ -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,22 +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 +#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 + #include #include +#if 0 #include +#endif #include #include #include -#include +#ifdef VMS +#include "vms-pwd.h" +#else #include +#endif #include -#ifdef emacs -#include "config.h" +#ifndef MAXPATHLEN +#define MAXPATHLEN 256 #endif extern char *getenv (); -extern int 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 (); @@ -79,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 */ } @@ -141,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) { @@ -152,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; @@ -164,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)) @@ -253,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 @@ -365,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);