(U-00020061): Move `ideographic-{radical|strokes}@{ucs|cns}' and
[chise/xemacs-chise.git.1] / src / dumper.c
index 3c5b04d..a884710 100644 (file)
@@ -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"
@@ -281,7 +282,11 @@ static int pdump_fd;
 static void *pdump_buf;
 static FILE *pdump_out;
 
+#ifdef UTF2000
+#define PDUMP_HASHSIZE 20000001
+#else
 #define PDUMP_HASHSIZE 200001
+#endif
 
 static pdump_entry_list_elt **pdump_hash;
 
@@ -990,7 +995,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 +1369,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 +1419,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 +1441,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;