Mercurial > hg > xemacs-beta
comparison src/dumper.c @ 4388:1a14c304cb8e
Don't use PATH_MAX_EXTERNAL, non-Win32.
2008-01-08 Aidan Kehoe <kehoea@parhasard.net>
* text.h (MAX_XETCHAR_SIZE): Remove, eliminating a redefinition
warning on Win32.
* dumper.c (pdump_load):
Don't use PATH_MAX_EXTERNAL, instead allocate enough for the path
+ DUMP_SLACK (space for .dmp and version information), already
used on Win32 and #defined to be 100.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 09 Jan 2008 00:28:17 +0100 |
parents | 1ce0622a56a3 |
children | 19a72041c5ed |
comparison
equal
deleted
inserted
replaced
4387:9aa16aa434b6 | 4388:1a14c304cb8e |
---|---|
2628 } | 2628 } |
2629 while (w > exe_path && !IS_DIRECTORY_SEP (*w)); | 2629 while (w > exe_path && !IS_DIRECTORY_SEP (*w)); |
2630 return 0; | 2630 return 0; |
2631 } | 2631 } |
2632 | 2632 |
2633 #define DUMP_SLACK 100 /* Enough to include dump ID, version name, .DMP */ | |
2634 | |
2633 int | 2635 int |
2634 pdump_load (const Wexttext *argv0) | 2636 pdump_load (const Wexttext *argv0) |
2635 { | 2637 { |
2636 #ifdef WIN32_NATIVE | 2638 #ifdef WIN32_NATIVE |
2637 Wexttext *exe_path = NULL; | 2639 Wexttext *exe_path = NULL; |
2638 int bufsize = 4096; | 2640 int bufsize = 4096; |
2639 int cchpathsize; | 2641 int cchpathsize; |
2640 #define DUMP_SLACK 100 /* Enough to include dump ID, version name, .DMP */ | |
2641 | 2642 |
2642 /* Copied from mswindows_get_module_file_name (). Not clear if it's | 2643 /* Copied from mswindows_get_module_file_name (). Not clear if it's |
2643 kosher to malloc() yet. */ | 2644 kosher to malloc() yet. */ |
2644 while (1) | 2645 while (1) |
2645 { | 2646 { |
2657 { | 2658 { |
2658 Wexttext *wexe = MULTIBYTE_TO_WEXTTEXT ((Extbyte *) exe_path); | 2659 Wexttext *wexe = MULTIBYTE_TO_WEXTTEXT ((Extbyte *) exe_path); |
2659 wext_strcpy (exe_path, wexe); | 2660 wext_strcpy (exe_path, wexe); |
2660 } | 2661 } |
2661 #else /* !WIN32_NATIVE */ | 2662 #else /* !WIN32_NATIVE */ |
2662 Wexttext exe_path[PATH_MAX_EXTERNAL]; | 2663 Wexttext *exe_path; |
2663 Wexttext *w; | 2664 Wexttext *w; |
2664 const Wexttext *dir, *p; | 2665 const Wexttext *dir, *p; |
2665 | 2666 |
2666 #ifdef DUMP_IN_EXEC | 2667 #ifdef DUMP_IN_EXEC |
2667 if (pdump_ram_try ()) | 2668 if (pdump_ram_try ()) |
2692 | 2693 |
2693 if (p != dir) | 2694 if (p != dir) |
2694 { | 2695 { |
2695 /* invocation-name includes a directory component -- presumably it | 2696 /* invocation-name includes a directory component -- presumably it |
2696 is relative to cwd, not $PATH. */ | 2697 is relative to cwd, not $PATH. */ |
2698 exe_path = alloca_array (Wexttext, 1 + wext_strlen (dir) + DUMP_SLACK); | |
2697 wext_strcpy (exe_path, dir); | 2699 wext_strcpy (exe_path, dir); |
2698 } | 2700 } |
2699 else | 2701 else |
2700 { | 2702 { |
2701 const Wexttext *path = wext_getenv ("PATH"); /* not egetenv -- | 2703 const Wexttext *path = wext_getenv ("PATH"); /* not egetenv -- |
2702 not yet init. */ | 2704 not yet init. */ |
2703 const Wexttext *name = p; | 2705 const Wexttext *name = p; |
2706 exe_path = alloca_array (Wexttext, | |
2707 1 + DUMP_SLACK + max (wext_strlen (name), | |
2708 wext_strlen (path))); | |
2704 for (;;) | 2709 for (;;) |
2705 { | 2710 { |
2706 p = path; | 2711 p = path; |
2707 while (*p && *p != SEPCHAR) | 2712 while (*p && *p != SEPCHAR) |
2708 p++; | 2713 p++; |