summaryrefslogtreecommitdiff
path: root/src/xrdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xrdb.c')
-rw-r--r--src/xrdb.c108
1 files changed, 42 insertions, 66 deletions
diff --git a/src/xrdb.c b/src/xrdb.c
index 513768e3cde..e0d948fd3a6 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -20,9 +20,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
-#ifdef emacs
#include <config.h>
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -52,38 +50,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
extern char *getenv (const char *);
-/* 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
-
-#ifdef DECLARE_GETPWUID_WITH_UID_T
-extern struct passwd *getpwuid (uid_t);
-extern struct passwd *getpwnam (const char *);
-#else
extern struct passwd *getpwuid (uid_t);
extern struct passwd *getpwnam (const char *);
-#endif
-extern char *get_system_name (void);
-
-/* 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
-#endif
+extern const char *get_system_name (void);
-char *x_get_string_resource (XrmDatabase rdb, char *name, char *class);
-static int file_p (char *filename);
+char *x_get_string_resource (XrmDatabase rdb, const char *name,
+ const char *class);
+static int file_p (const char *filename);
/* X file search path processing. */
@@ -98,7 +72,7 @@ char *x_customization_string;
resource, for later use in search path decoding. If we find no
such resource, return zero. */
char *
-x_get_customization_string (XrmDatabase db, char *name, char *class)
+x_get_customization_string (XrmDatabase db, const char *name, const char *class)
{
char *full_name
= (char *) alloca (strlen (name) + sizeof ("customization") + 3);
@@ -113,7 +87,7 @@ x_get_customization_string (XrmDatabase db, char *name, char *class)
if (result)
{
- char *copy = (char *) malloc (strlen (result) + 1);
+ char *copy = (char *) xmalloc (strlen (result) + 1);
strcpy (copy, result);
return copy;
}
@@ -153,20 +127,20 @@ x_get_customization_string (XrmDatabase db, char *name, char *class)
Return NULL otherwise. */
static char *
-magic_file_p (char *string, int string_len, char *class, char *escaped_suffix, char *suffix)
+magic_file_p (const char *string, int string_len, const char *class, const char *escaped_suffix, const char *suffix)
{
char *lang = getenv ("LANG");
int path_size = 100;
- char *path = (char *) malloc (path_size);
+ char *path = (char *) xmalloc (path_size);
int path_len = 0;
- char *p = string;
+ const char *p = string;
while (p < string + string_len)
{
/* The chunk we're about to stick on the end of result. */
- char *next = NULL;
+ const char *next = NULL;
int next_len;
if (*p == '%')
@@ -209,7 +183,7 @@ magic_file_p (char *string, int string_len, char *class, char *escaped_suffix, c
case 'l':
if (! lang)
{
- free (path);
+ xfree (path);
return NULL;
}
@@ -219,7 +193,7 @@ magic_file_p (char *string, int string_len, char *class, char *escaped_suffix, c
case 't':
case 'c':
- free (path);
+ xfree (path);
return NULL;
}
}
@@ -230,7 +204,7 @@ magic_file_p (char *string, int string_len, char *class, char *escaped_suffix, c
if (path_len + next_len + 1 > path_size)
{
path_size = (path_len + next_len + 1) * 2;
- path = (char *) realloc (path, path_size);
+ path = (char *) xrealloc (path, path_size);
}
memcpy (path + path_len, next, next_len);
@@ -256,7 +230,7 @@ magic_file_p (char *string, int string_len, char *class, char *escaped_suffix, c
if (path_len + suffix_len + 1 > path_size)
{
path_size = (path_len + suffix_len + 1);
- path = (char *) realloc (path, path_size);
+ path = (char *) xrealloc (path, path_size);
}
memcpy (path + path_len, suffix, suffix_len);
@@ -267,7 +241,7 @@ magic_file_p (char *string, int string_len, char *class, char *escaped_suffix, c
if (! file_p (path))
{
- free (path);
+ xfree (path);
return NULL;
}
@@ -297,7 +271,7 @@ gethomedir (void)
if (ptr == NULL)
return xstrdup ("/");
- copy = (char *) malloc (strlen (ptr) + 2);
+ copy = (char *) xmalloc (strlen (ptr) + 2);
strcpy (copy, ptr);
strcat (copy, "/");
@@ -306,7 +280,7 @@ gethomedir (void)
static int
-file_p (char *filename)
+file_p (const char *filename)
{
struct stat status;
@@ -321,9 +295,9 @@ file_p (char *filename)
the path name of the one we found otherwise. */
static char *
-search_magic_path (char *search_path, char *class, char *escaped_suffix, char *suffix)
+search_magic_path (const char *search_path, const char *class, const char *escaped_suffix, const char *suffix)
{
- register char *s, *p;
+ const char *s, *p;
for (s = search_path; *s; s = p)
{
@@ -332,7 +306,8 @@ search_magic_path (char *search_path, char *class, char *escaped_suffix, char *s
if (p > s)
{
- char *path = magic_file_p (s, p - s, class, escaped_suffix, suffix);
+ char *path = magic_file_p (s, p - s, class, escaped_suffix,
+ suffix);
if (path)
return path;
}
@@ -356,7 +331,7 @@ search_magic_path (char *search_path, char *class, char *escaped_suffix, char *s
/* Producing databases for individual sources. */
static XrmDatabase
-get_system_app (char *class)
+get_system_app (const char *class)
{
XrmDatabase db = NULL;
char *path;
@@ -368,7 +343,7 @@ get_system_app (char *class)
if (path)
{
db = XrmGetFileDatabase (path);
- free (path);
+ xfree (path);
}
return db;
@@ -383,7 +358,7 @@ get_fallback (Display *display)
static XrmDatabase
-get_user_app (char *class)
+get_user_app (const char *class)
{
char *path;
char *file = 0;
@@ -407,12 +382,12 @@ get_user_app (char *class)
|| (file = search_magic_path (free_it, class, "%N", 0)))))
{
XrmDatabase db = XrmGetFileDatabase (file);
- free (file);
- free (free_it);
+ xfree (file);
+ xfree (free_it);
return db;
}
- free (free_it);
+ xfree (free_it);
return NULL;
}
@@ -437,12 +412,12 @@ get_user_db (Display *display)
char *xdefault;
home = gethomedir ();
- xdefault = (char *) malloc (strlen (home) + sizeof (".Xdefaults"));
+ xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults"));
strcpy (xdefault, home);
strcat (xdefault, ".Xdefaults");
db = XrmGetFileDatabase (xdefault);
- free (home);
- free (xdefault);
+ xfree (home);
+ xfree (xdefault);
}
#ifdef HAVE_XSCREENRESOURCESTRING
@@ -463,13 +438,14 @@ get_environ_db (void)
{
XrmDatabase db;
char *p;
- char *path = 0, *home = 0, *host;
+ char *path = 0, *home = 0;
+ const char *host;
if ((p = getenv ("XENVIRONMENT")) == NULL)
{
home = gethomedir ();
host = get_system_name ();
- path = (char *) malloc (strlen (home)
+ path = (char *) xmalloc (strlen (home)
+ sizeof (".Xdefaults-")
+ strlen (host));
sprintf (path, "%s%s%s", home, ".Xdefaults-", host);
@@ -478,8 +454,8 @@ get_environ_db (void)
db = XrmGetFileDatabase (p);
- free (path);
- free (home);
+ xfree (path);
+ xfree (home);
return db;
}
@@ -494,18 +470,18 @@ XrmRepresentation x_rm_string; /* Quark representation */
/* Load X resources based on the display and a possible -xrm option. */
XrmDatabase
-x_load_resources (Display *display, char *xrm_string, char *myname, char *myclass)
+x_load_resources (Display *display, const char *xrm_string,
+ const char *myname, const char *myclass)
{
XrmDatabase user_database;
XrmDatabase rdb;
XrmDatabase db;
char line[256];
- char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
+ const 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;
+ const char *courier = "-*-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1";
#endif
x_rm_string = XrmStringToQuark (XrmStringType);
@@ -584,7 +560,7 @@ x_load_resources (Display *display, char *xrm_string, char *myname, char *myclas
/* Figure out what the "customization string" is, so we can use it
to decode paths. */
- free (x_customization_string);
+ xfree (x_customization_string);
x_customization_string
= x_get_customization_string (user_database, myname, myclass);
@@ -628,7 +604,7 @@ x_load_resources (Display *display, char *xrm_string, char *myname, char *myclas
and of type TYPE from database RDB. The value is returned in RET_VALUE. */
int
-x_get_resource (XrmDatabase rdb, char *name, char *class, XrmRepresentation expected_type, XrmValue *ret_value)
+x_get_resource (XrmDatabase rdb, const char *name, const char *class, XrmRepresentation expected_type, XrmValue *ret_value)
{
XrmValue value;
XrmName namelist[100];
@@ -656,7 +632,7 @@ x_get_resource (XrmDatabase rdb, char *name, char *class, XrmRepresentation expe
database RDB. */
char *
-x_get_string_resource (XrmDatabase rdb, char *name, char *class)
+x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
{
XrmValue value;