diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/xrdb.c | 65 |
2 files changed, 26 insertions, 46 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 551ab9d215a..bf094a12d96 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2010-08-08 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * xrdb.c: Remove include guard. Remove | ||
| 4 | DECLARE_GETPWUID_WITH_UID_T conditional it had no effect. | ||
| 5 | Remove #if 0 code. Replace malloc->xmalloc, free->xfree, | ||
| 6 | realloc->xrealloc instead of using #defines. | ||
| 7 | |||
| 1 | 2010-08-08 Eli Zaretskii <eliz@gnu.org> | 8 | 2010-08-08 Eli Zaretskii <eliz@gnu.org> |
| 2 | 9 | ||
| 3 | * cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line): | 10 | * cmds.c (Fforward_line, Fbeginning_of_line, Fend_of_line): |
diff --git a/src/xrdb.c b/src/xrdb.c index 39637b04081..72b9e07738e 100644 --- a/src/xrdb.c +++ b/src/xrdb.c | |||
| @@ -20,9 +20,7 @@ GNU General Public License for more details. | |||
| 20 | You should have received a copy of the GNU General Public License | 20 | You should have received a copy of the GNU General Public License |
| 21 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | 21 | along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 22 | 22 | ||
| 23 | #ifdef emacs | ||
| 24 | #include <config.h> | 23 | #include <config.h> |
| 25 | #endif | ||
| 26 | 24 | ||
| 27 | #ifdef HAVE_UNISTD_H | 25 | #ifdef HAVE_UNISTD_H |
| 28 | #include <unistd.h> | 26 | #include <unistd.h> |
| @@ -52,36 +50,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 52 | 50 | ||
| 53 | extern char *getenv (const char *); | 51 | extern char *getenv (const char *); |
| 54 | 52 | ||
| 55 | /* This does cause trouble on AIX. I'm going to take the comment at | ||
| 56 | face value. */ | ||
| 57 | #if 0 | ||
| 58 | extern short getuid (); /* If this causes portability problems, | ||
| 59 | I think we should just delete it; it'll | ||
| 60 | default to `int' anyway. */ | ||
| 61 | #endif | ||
| 62 | |||
| 63 | #ifdef DECLARE_GETPWUID_WITH_UID_T | ||
| 64 | extern struct passwd *getpwuid (uid_t); | 53 | extern struct passwd *getpwuid (uid_t); |
| 65 | extern struct passwd *getpwnam (const char *); | 54 | extern struct passwd *getpwnam (const char *); |
| 66 | #else | ||
| 67 | extern struct passwd *getpwuid (uid_t); | ||
| 68 | extern struct passwd *getpwnam (const char *); | ||
| 69 | #endif | ||
| 70 | 55 | ||
| 71 | extern char *get_system_name (void); | 56 | extern char *get_system_name (void); |
| 72 | 57 | ||
| 73 | /* Make sure not to #include anything after these definitions. Let's | ||
| 74 | not step on anyone's prototypes. */ | ||
| 75 | #ifdef emacs | ||
| 76 | /* darwin.h may have already defined these. */ | ||
| 77 | #undef malloc | ||
| 78 | #undef realloc | ||
| 79 | #undef free | ||
| 80 | #define malloc xmalloc | ||
| 81 | #define realloc xrealloc | ||
| 82 | #define free xfree | ||
| 83 | #endif | ||
| 84 | |||
| 85 | char *x_get_string_resource (XrmDatabase rdb, const char *name, | 58 | char *x_get_string_resource (XrmDatabase rdb, const char *name, |
| 86 | const char *class); | 59 | const char *class); |
| 87 | static int file_p (const char *filename); | 60 | static int file_p (const char *filename); |
| @@ -114,7 +87,7 @@ x_get_customization_string (XrmDatabase db, const char *name, const char *class) | |||
| 114 | 87 | ||
| 115 | if (result) | 88 | if (result) |
| 116 | { | 89 | { |
| 117 | char *copy = (char *) malloc (strlen (result) + 1); | 90 | char *copy = (char *) xmalloc (strlen (result) + 1); |
| 118 | strcpy (copy, result); | 91 | strcpy (copy, result); |
| 119 | return copy; | 92 | return copy; |
| 120 | } | 93 | } |
| @@ -159,7 +132,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char | |||
| 159 | char *lang = getenv ("LANG"); | 132 | char *lang = getenv ("LANG"); |
| 160 | 133 | ||
| 161 | int path_size = 100; | 134 | int path_size = 100; |
| 162 | char *path = (char *) malloc (path_size); | 135 | char *path = (char *) xmalloc (path_size); |
| 163 | int path_len = 0; | 136 | int path_len = 0; |
| 164 | 137 | ||
| 165 | const char *p = string; | 138 | const char *p = string; |
| @@ -210,7 +183,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char | |||
| 210 | case 'l': | 183 | case 'l': |
| 211 | if (! lang) | 184 | if (! lang) |
| 212 | { | 185 | { |
| 213 | free (path); | 186 | xfree (path); |
| 214 | return NULL; | 187 | return NULL; |
| 215 | } | 188 | } |
| 216 | 189 | ||
| @@ -220,7 +193,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char | |||
| 220 | 193 | ||
| 221 | case 't': | 194 | case 't': |
| 222 | case 'c': | 195 | case 'c': |
| 223 | free (path); | 196 | xfree (path); |
| 224 | return NULL; | 197 | return NULL; |
| 225 | } | 198 | } |
| 226 | } | 199 | } |
| @@ -231,7 +204,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char | |||
| 231 | if (path_len + next_len + 1 > path_size) | 204 | if (path_len + next_len + 1 > path_size) |
| 232 | { | 205 | { |
| 233 | path_size = (path_len + next_len + 1) * 2; | 206 | path_size = (path_len + next_len + 1) * 2; |
| 234 | path = (char *) realloc (path, path_size); | 207 | path = (char *) xrealloc (path, path_size); |
| 235 | } | 208 | } |
| 236 | 209 | ||
| 237 | memcpy (path + path_len, next, next_len); | 210 | memcpy (path + path_len, next, next_len); |
| @@ -257,7 +230,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char | |||
| 257 | if (path_len + suffix_len + 1 > path_size) | 230 | if (path_len + suffix_len + 1 > path_size) |
| 258 | { | 231 | { |
| 259 | path_size = (path_len + suffix_len + 1); | 232 | path_size = (path_len + suffix_len + 1); |
| 260 | path = (char *) realloc (path, path_size); | 233 | path = (char *) xrealloc (path, path_size); |
| 261 | } | 234 | } |
| 262 | 235 | ||
| 263 | memcpy (path + path_len, suffix, suffix_len); | 236 | memcpy (path + path_len, suffix, suffix_len); |
| @@ -268,7 +241,7 @@ magic_file_p (const char *string, int string_len, const char *class, const char | |||
| 268 | 241 | ||
| 269 | if (! file_p (path)) | 242 | if (! file_p (path)) |
| 270 | { | 243 | { |
| 271 | free (path); | 244 | xfree (path); |
| 272 | return NULL; | 245 | return NULL; |
| 273 | } | 246 | } |
| 274 | 247 | ||
| @@ -298,7 +271,7 @@ gethomedir (void) | |||
| 298 | if (ptr == NULL) | 271 | if (ptr == NULL) |
| 299 | return xstrdup ("/"); | 272 | return xstrdup ("/"); |
| 300 | 273 | ||
| 301 | copy = (char *) malloc (strlen (ptr) + 2); | 274 | copy = (char *) xmalloc (strlen (ptr) + 2); |
| 302 | strcpy (copy, ptr); | 275 | strcpy (copy, ptr); |
| 303 | strcat (copy, "/"); | 276 | strcat (copy, "/"); |
| 304 | 277 | ||
| @@ -370,7 +343,7 @@ get_system_app (const char *class) | |||
| 370 | if (path) | 343 | if (path) |
| 371 | { | 344 | { |
| 372 | db = XrmGetFileDatabase (path); | 345 | db = XrmGetFileDatabase (path); |
| 373 | free (path); | 346 | xfree (path); |
| 374 | } | 347 | } |
| 375 | 348 | ||
| 376 | return db; | 349 | return db; |
| @@ -409,12 +382,12 @@ get_user_app (const char *class) | |||
| 409 | || (file = search_magic_path (free_it, class, "%N", 0))))) | 382 | || (file = search_magic_path (free_it, class, "%N", 0))))) |
| 410 | { | 383 | { |
| 411 | XrmDatabase db = XrmGetFileDatabase (file); | 384 | XrmDatabase db = XrmGetFileDatabase (file); |
| 412 | free (file); | 385 | xfree (file); |
| 413 | free (free_it); | 386 | xfree (free_it); |
| 414 | return db; | 387 | return db; |
| 415 | } | 388 | } |
| 416 | 389 | ||
| 417 | free (free_it); | 390 | xfree (free_it); |
| 418 | return NULL; | 391 | return NULL; |
| 419 | } | 392 | } |
| 420 | 393 | ||
| @@ -439,12 +412,12 @@ get_user_db (Display *display) | |||
| 439 | char *xdefault; | 412 | char *xdefault; |
| 440 | 413 | ||
| 441 | home = gethomedir (); | 414 | home = gethomedir (); |
| 442 | xdefault = (char *) malloc (strlen (home) + sizeof (".Xdefaults")); | 415 | xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults")); |
| 443 | strcpy (xdefault, home); | 416 | strcpy (xdefault, home); |
| 444 | strcat (xdefault, ".Xdefaults"); | 417 | strcat (xdefault, ".Xdefaults"); |
| 445 | db = XrmGetFileDatabase (xdefault); | 418 | db = XrmGetFileDatabase (xdefault); |
| 446 | free (home); | 419 | xfree (home); |
| 447 | free (xdefault); | 420 | xfree (xdefault); |
| 448 | } | 421 | } |
| 449 | 422 | ||
| 450 | #ifdef HAVE_XSCREENRESOURCESTRING | 423 | #ifdef HAVE_XSCREENRESOURCESTRING |
| @@ -471,7 +444,7 @@ get_environ_db (void) | |||
| 471 | { | 444 | { |
| 472 | home = gethomedir (); | 445 | home = gethomedir (); |
| 473 | host = get_system_name (); | 446 | host = get_system_name (); |
| 474 | path = (char *) malloc (strlen (home) | 447 | path = (char *) xmalloc (strlen (home) |
| 475 | + sizeof (".Xdefaults-") | 448 | + sizeof (".Xdefaults-") |
| 476 | + strlen (host)); | 449 | + strlen (host)); |
| 477 | sprintf (path, "%s%s%s", home, ".Xdefaults-", host); | 450 | sprintf (path, "%s%s%s", home, ".Xdefaults-", host); |
| @@ -480,8 +453,8 @@ get_environ_db (void) | |||
| 480 | 453 | ||
| 481 | db = XrmGetFileDatabase (p); | 454 | db = XrmGetFileDatabase (p); |
| 482 | 455 | ||
| 483 | free (path); | 456 | xfree (path); |
| 484 | free (home); | 457 | xfree (home); |
| 485 | 458 | ||
| 486 | return db; | 459 | return db; |
| 487 | } | 460 | } |
| @@ -586,7 +559,7 @@ x_load_resources (Display *display, const char *xrm_string, | |||
| 586 | 559 | ||
| 587 | /* Figure out what the "customization string" is, so we can use it | 560 | /* Figure out what the "customization string" is, so we can use it |
| 588 | to decode paths. */ | 561 | to decode paths. */ |
| 589 | free (x_customization_string); | 562 | xfree (x_customization_string); |
| 590 | x_customization_string | 563 | x_customization_string |
| 591 | = x_get_customization_string (user_database, myname, myclass); | 564 | = x_get_customization_string (user_database, myname, myclass); |
| 592 | 565 | ||