cosmetic fixes from Rudi
[sxemacs] / src / dumper.c
index 2f6742b..1b0d3f8 100644 (file)
@@ -34,6 +34,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 #include <sys/mman.h>
 #endif
 
+/* For PATH_EXEC */
+#include <sxe-paths.h>
+
 #ifndef SEPCHAR
 #define SEPCHAR ':'
 #endif
@@ -587,19 +590,20 @@ pdump_register_struct(const void *data,
                if (me >= 65536) {
                        stderr_out("Backtrace overflow, loop ?\n");
                        abort();
+               } else {
+                       backtrace[me].obj = 0;
+                       backtrace[me].position = 0;
+                       backtrace[me].offset = 0;
+                       
+                       pdump_add_entry(pdump_get_entry_list(sdesc),
+                                       data, sdesc->size, count);
+                       for (i = 0; i < count; i++) {
+                               pdump_register_sub(
+                                       ((const char*)data) + sdesc->size * i,
+                                       sdesc->description, me);
+                       }
+                       --depth;
                }
-               backtrace[me].obj = 0;
-               backtrace[me].position = 0;
-               backtrace[me].offset = 0;
-
-               pdump_add_entry(pdump_get_entry_list(sdesc),
-                               data, sdesc->size, count);
-               for (i = 0; i < count; i++) {
-                       pdump_register_sub(
-                               ((const char*)data) + sdesc->size * i,
-                               sdesc->description, me);
-               }
-               --depth;
        }
 }
 
@@ -1355,6 +1359,7 @@ wipe_out_libtool_stuff(char *path)
 int pdump_load(const char *argv0)
 {
        char exe_path[PATH_MAX], real_exe_path[PATH_MAX];
+       char libarchdir_path[PATH_MAX] = PATH_EXEC "/sxemacs";
        char *w;
        const char *dir, *p;
 
@@ -1374,7 +1379,7 @@ int pdump_load(const char *argv0)
                /* invocation-name includes a directory component -- presumably it
                   is relative to cwd, not $PATH */
                assert(strlen(dir) < sizeof(exe_path));
-               strncpy(exe_path, dir, sizeof(exe_path)-1);
+               xstrncpy(exe_path, dir, sizeof(exe_path));
                exe_path[sizeof(exe_path)-1]='\0';
        } else {
                const char *path = getenv("PATH");
@@ -1406,7 +1411,7 @@ int pdump_load(const char *argv0)
                                remain--;
                        }
                        if (remain > 0) {
-                               strncpy(w, name, remain);
+                               xstrncpy(w, name, remain);
                                w[remain]='\0';
                        }
 
@@ -1441,10 +1446,11 @@ int pdump_load(const char *argv0)
 
        /* Save exe_path because pdump_file_try() modifies it */
        assert(strlen(exe_path) < sizeof(real_exe_path));
-       strcpy(real_exe_path, exe_path);
+       xstrncpy(real_exe_path, exe_path, sizeof(real_exe_path));
        if (pdump_file_try(exe_path,sizeof(exe_path))
            || (xrealpath(real_exe_path, real_exe_path)
-               && pdump_file_try(real_exe_path,sizeof(real_exe_path)))) {
+               && pdump_file_try(real_exe_path,sizeof(real_exe_path)))
+           || pdump_file_try(libarchdir_path,sizeof(libarchdir_path)) ) {
                pdump_load_finish();
                return 1;
        }