X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fdumper.c;h=c1a9912e1f3516bc98563a0c9c53a90c5e1aab70;hb=ee38d21b330f5001b47a577cefb5ba7b82a3b7d3;hp=3c5b04dd24c47902f3c37b9df2fa842eecd604d5;hpb=dbf2768f7b146e97e37a27316f70bb313f1acf15;p=chise%2Fxemacs-chise.git.1 diff --git a/src/dumper.c b/src/dumper.c index 3c5b04d..c1a9912 100644 --- a/src/dumper.c +++ b/src/dumper.c @@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */ #include "sysfile.h" #include "console-stream.h" #include "dumper.h" +#include "sysdep.h" #ifdef WIN32_NATIVE #include "nt.h" @@ -439,7 +440,7 @@ pdump_get_indirect_count (EMACS_INT code, stderr_out ("Unsupported count type : %d (line = %d, code=%ld)\n", idesc[line].type, line, (long)code); pdump_backtrace (); - abort (); + ABORT (); } count += delta; return count; @@ -539,7 +540,7 @@ pdump_register_sub (const void *data, const struct lrecord_description *desc, in default: stderr_out ("Unsupported dump type : %d\n", desc[pos].type); pdump_backtrace (); - abort (); + ABORT (); }; } } @@ -568,7 +569,7 @@ pdump_register_object (Lisp_Object obj) if (me>65536) { stderr_out ("Backtrace overflow, loop ?\n"); - abort (); + ABORT (); } backtrace[me].obj = objh; backtrace[me].position = 0; @@ -603,7 +604,7 @@ pdump_register_struct (const void *data, if (me>65536) { stderr_out ("Backtrace overflow, loop ?\n"); - abort (); + ABORT (); } backtrace[me].obj = 0; backtrace[me].position = 0; @@ -716,7 +717,7 @@ pdump_dump_data (pdump_entry_list_elt *elt, } default: stderr_out ("Unsupported dump type : %d\n", desc[pos].type); - abort (); + ABORT (); } } } @@ -794,7 +795,7 @@ pdump_reloc_one (void *data, EMACS_INT delta, } default: stderr_out ("Unsupported dump type : %d\n", desc[pos].type); - abort (); + ABORT (); }; } } @@ -990,7 +991,7 @@ pdump (void) t_frame = Vterminal_frame; Vterminal_frame = Qnil; t_device = Vterminal_device; Vterminal_device = Qnil; - dump_add_opaque (&lrecord_implementations_table, + dump_add_opaque ((void *) &lrecord_implementations_table, lrecord_type_count * sizeof (lrecord_implementations_table[0])); dump_add_opaque (&lrecord_markers, lrecord_type_count * sizeof (lrecord_markers[0])); @@ -1364,9 +1365,11 @@ pdump_file_try (char *exe_path) int pdump_load (const char *argv0) { - char exe_path[PATH_MAX]; + char exe_path[PATH_MAX], real_exe_path[PATH_MAX]; #ifdef WIN32_NATIVE GetModuleFileName (NULL, exe_path, PATH_MAX); + /* #### urk, needed for xrealpath() below */ + Vdirectory_sep_char = make_char ('\\'); #else /* !WIN32_NATIVE */ char *w; const char *dir, *p; @@ -1412,13 +1415,17 @@ pdump_load (const char *argv0) } strcpy (w, name); - /* ### #$%$#^$^@%$^#%@$ ! */ -#ifdef access -#undef access -#endif + /* Check that exe_path is executable and not a directory */ +#undef access /* avoid !@#$%^& encapsulated access */ +#undef stat /* avoid !@#$%^& encapsulated stat */ + { + struct stat statbuf; + if (access (exe_path, X_OK) == 0 + && stat (exe_path, &statbuf) == 0 + && ! S_ISDIR (statbuf.st_mode)) + break; + } - if (!access (exe_path, X_OK)) - break; if (!*p) { /* Oh well, let's have some kind of default */ @@ -1430,7 +1437,11 @@ pdump_load (const char *argv0) } #endif /* WIN32_NATIVE */ - if (pdump_file_try (exe_path)) + /* Save exe_path because pdump_file_try() modifies it */ + strcpy(real_exe_path, exe_path); + if (pdump_file_try (exe_path) + || (xrealpath(real_exe_path, real_exe_path) + && pdump_file_try (real_exe_path))) { pdump_load_finish (); return 1;