comparison src/dumper.c @ 2563:6bee993389f3

[xemacs-hg @ 2005-02-04 03:01:19 by ben] misc source fixes dumper.c: Include extra DUMP_SLACK when allocating space for exe path. glyphs-eimage.c: Reformat comment. sysproc.h: Delete out-of-date comment about abort.
author ben
date Fri, 04 Feb 2005 03:01:21 +0000
parents b880fa9b5d8a
children d8df26f08486
comparison
equal deleted inserted replaced
2562:ecc681180115 2563:6bee993389f3
1 /* Portable data dumper for XEmacs. 1 /* Portable data dumper for XEmacs.
2 Copyright (C) 1999-2000,2004 Olivier Galibert 2 Copyright (C) 1999-2000,2004 Olivier Galibert
3 Copyright (C) 2001 Martin Buchholz 3 Copyright (C) 2001 Martin Buchholz
4 Copyright (C) 2001, 2002, 2003, 2004 Ben Wing. 4 Copyright (C) 2001, 2002, 2003, 2004, 2005 Ben Wing.
5 5
6 This file is part of XEmacs. 6 This file is part of XEmacs.
7 7
8 XEmacs is free software; you can redistribute it and/or modify it 8 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the 9 under the terms of the GNU General Public License as published by the
2082 static int 2082 static int
2083 pdump_file_try (Wexttext *exe_path) 2083 pdump_file_try (Wexttext *exe_path)
2084 { 2084 {
2085 Wexttext *w = exe_path + wext_strlen (exe_path); 2085 Wexttext *w = exe_path + wext_strlen (exe_path);
2086 2086
2087 /* We look for various names, including those with the version and dump ID,
2088 those with just the dump ID, and those without either. We first try
2089 adding directly to the executable name, then lopping off any extension
2090 (e.g. .exe) or version name in the executable (xemacs-21.5.18). */
2087 do 2091 do
2088 { 2092 {
2089 wext_sprintf (w, WEXTSTRING ("-%s-%08x.dmp"), WEXTSTRING (EMACS_VERSION), 2093 wext_sprintf (w, WEXTSTRING ("-%s-%08x.dmp"), WEXTSTRING (EMACS_VERSION),
2090 dump_id); 2094 dump_id);
2091 if (pdump_file_get (exe_path)) 2095 if (pdump_file_get (exe_path))
2126 { 2130 {
2127 #ifdef WIN32_NATIVE 2131 #ifdef WIN32_NATIVE
2128 Wexttext *exe_path = NULL; 2132 Wexttext *exe_path = NULL;
2129 int bufsize = 4096; 2133 int bufsize = 4096;
2130 int cchpathsize; 2134 int cchpathsize;
2135 #define DUMP_SLACK 100 /* Enough to include dump ID, version name, .DMP */
2131 2136
2132 /* Copied from mswindows_get_module_file_name (). Not clear if it's 2137 /* Copied from mswindows_get_module_file_name (). Not clear if it's
2133 kosher to malloc() yet. */ 2138 kosher to malloc() yet. */
2134 while (1) 2139 while (1)
2135 { 2140 {
2136 exe_path = alloca_array (Wexttext, bufsize); 2141 exe_path = alloca_array (Wexttext, bufsize);
2137 cchpathsize = qxeGetModuleFileName (NULL, (Extbyte *) exe_path, 2142 cchpathsize = qxeGetModuleFileName (NULL, (Extbyte *) exe_path,
2138 bufsize); 2143 bufsize);
2139 if (!cchpathsize) 2144 if (!cchpathsize)
2140 goto fail; 2145 goto fail;
2141 if (cchpathsize + 1 <= bufsize) 2146 if (cchpathsize + DUMP_SLACK <= bufsize)
2142 break; 2147 break;
2143 bufsize *= 2; 2148 bufsize *= 2;
2144 } 2149 }
2145 2150
2146 if (!XEUNICODE_P) 2151 if (!XEUNICODE_P)