aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2010-09-28 02:55:08 +0200
committerJuanma Barranquero2010-09-28 02:55:08 +0200
commit0597ab06f6681758096685a0cd3ed3f24ab6e971 (patch)
tree462befdef914fd872fd42949d804a9b0b90cfbef
parent95b6d681b1121e1be8955aa3f79dd39098edf4cf (diff)
downloademacs-0597ab06f6681758096685a0cd3ed3f24ab6e971.tar.gz
emacs-0597ab06f6681758096685a0cd3ed3f24ab6e971.zip
nt/*.c: Use const char*; remove unused code.
* addpm.c (entry, add_registry, main): * addsection.c (file_data, open_input_file, open_output_file) (find_section, PTR_TO_OFFSET, copy_executable_and_add_section) (COPY_CHUNK): * cmdproxy.c (vfprintf, fprintf, printf, fail, warn, skip_space) (skip_nonspace, get_next_token, search_dir, make_absolute) (spawn, main): * preprep.c (file_data, open_input_file, open_output_file) (open_inout_file, find_section, PTR_TO_OFFSET, COPY_CHUNK, main): Use const char*. * cmdproxy.c (stdin): Don't define, not used. (main): Don't assign remlen after last use.
-rw-r--r--nt/ChangeLog16
-rw-r--r--nt/addpm.c12
-rw-r--r--nt/addsection.c28
-rw-r--r--nt/cmdproxy.c51
-rw-r--r--nt/preprep.c32
5 files changed, 75 insertions, 64 deletions
diff --git a/nt/ChangeLog b/nt/ChangeLog
index 275b9bd6279..bacb207c836 100644
--- a/nt/ChangeLog
+++ b/nt/ChangeLog
@@ -1,3 +1,19 @@
12010-09-28 Juanma Barranquero <lekktu@gmail.com>
2
3 * addpm.c (entry, add_registry, main):
4 * addsection.c (file_data, open_input_file, open_output_file)
5 (find_section, PTR_TO_OFFSET, copy_executable_and_add_section)
6 (COPY_CHUNK):
7 * cmdproxy.c (vfprintf, fprintf, printf, fail, warn, skip_space)
8 (skip_nonspace, get_next_token, search_dir, make_absolute)
9 (spawn, main):
10 * preprep.c (file_data, open_input_file, open_output_file)
11 (open_inout_file, find_section, PTR_TO_OFFSET, COPY_CHUNK, main):
12 Use const char*.
13
14 * cmdproxy.c (stdin): Don't define, not used.
15 (main): Don't assign remlen after last use.
16
12010-09-22 Juanma Barranquero <lekktu@gmail.com> 172010-09-22 Juanma Barranquero <lekktu@gmail.com>
2 18
3 * configure.bat: Err out when the argument of --cflags contains 19 * configure.bat: Err out when the argument of --cflags contains
diff --git a/nt/addpm.c b/nt/addpm.c
index de09fd5382c..719573de373 100644
--- a/nt/addpm.c
+++ b/nt/addpm.c
@@ -67,8 +67,8 @@ DdeCallback (UINT uType, UINT uFmt, HCONV hconv,
67 67
68static struct entry 68static struct entry
69{ 69{
70 char *name; 70 const char *name;
71 char *value; 71 const char *value;
72} 72}
73env_vars[] = 73env_vars[] =
74{ 74{
@@ -85,7 +85,7 @@ env_vars[] =
85}; 85};
86 86
87BOOL 87BOOL
88add_registry (char *path) 88add_registry (const char *path)
89{ 89{
90 HKEY hrootkey = NULL; 90 HKEY hrootkey = NULL;
91 int i; 91 int i;
@@ -178,7 +178,7 @@ add_registry (char *path)
178 178
179 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++) 179 for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++)
180 { 180 {
181 char * value = env_vars[i].value ? env_vars[i].value : path; 181 const char * value = env_vars[i].value ? env_vars[i].value : path;
182 182
183 if (RegSetValueEx (hrootkey, env_vars[i].name, 183 if (RegSetValueEx (hrootkey, env_vars[i].name,
184 0, REG_EXPAND_SZ, 184 0, REG_EXPAND_SZ,
@@ -198,8 +198,8 @@ main (int argc, char *argv[])
198 int shortcuts_created = 0; 198 int shortcuts_created = 0;
199 int com_available = 1; 199 int com_available = 1;
200 char modname[MAX_PATH]; 200 char modname[MAX_PATH];
201 char *prog_name; 201 const char *prog_name;
202 char *emacs_path; 202 const char *emacs_path;
203 char *p; 203 char *p;
204 int quiet = 0; 204 int quiet = 0;
205 HRESULT result; 205 HRESULT result;
diff --git a/nt/addsection.c b/nt/addsection.c
index 78457ec0ee8..94087044bc2 100644
--- a/nt/addsection.c
+++ b/nt/addsection.c
@@ -37,9 +37,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
37 37
38PIMAGE_NT_HEADERS 38PIMAGE_NT_HEADERS
39(__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress, 39(__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
40 DWORD FileLength, 40 DWORD FileLength,
41 LPDWORD HeaderSum, 41 LPDWORD HeaderSum,
42 LPDWORD CheckSum); 42 LPDWORD CheckSum);
43 43
44#undef min 44#undef min
45#undef max 45#undef max
@@ -50,15 +50,15 @@ PIMAGE_NT_HEADERS
50/* File handling. */ 50/* File handling. */
51 51
52typedef struct file_data { 52typedef struct file_data {
53 char *name; 53 const char *name;
54 unsigned long size; 54 unsigned long size;
55 HANDLE file; 55 HANDLE file;
56 HANDLE file_mapping; 56 HANDLE file_mapping;
57 unsigned char *file_base; 57 unsigned char *file_base;
58} file_data; 58} file_data;
59 59
60int 60int
61open_input_file (file_data *p_file, char *filename) 61open_input_file (file_data *p_file, const char *filename)
62{ 62{
63 HANDLE file; 63 HANDLE file;
64 HANDLE file_mapping; 64 HANDLE file_mapping;
@@ -90,7 +90,7 @@ open_input_file (file_data *p_file, char *filename)
90} 90}
91 91
92int 92int
93open_output_file (file_data *p_file, char *filename, unsigned long size) 93open_output_file (file_data *p_file, const char *filename, unsigned long size)
94{ 94{
95 HANDLE file; 95 HANDLE file;
96 HANDLE file_mapping; 96 HANDLE file_mapping;
@@ -146,7 +146,7 @@ get_unrounded_section_size (PIMAGE_SECTION_HEADER p_section)
146 146
147/* Return pointer to section header for named section. */ 147/* Return pointer to section header for named section. */
148IMAGE_SECTION_HEADER * 148IMAGE_SECTION_HEADER *
149find_section (char * name, IMAGE_NT_HEADERS * nt_header) 149find_section (const char *name, IMAGE_NT_HEADERS *nt_header)
150{ 150{
151 PIMAGE_SECTION_HEADER section; 151 PIMAGE_SECTION_HEADER section;
152 int i; 152 int i;
@@ -260,7 +260,7 @@ relocate_offset (DWORD offset,
260#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) 260#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL))
261 261
262#define PTR_TO_OFFSET(ptr, pfile_data) \ 262#define PTR_TO_OFFSET(ptr, pfile_data) \
263 ((unsigned char *)(ptr) - (pfile_data)->file_base) 263 ((unsigned const char *)(ptr) - (pfile_data)->file_base)
264 264
265#define OFFSET_TO_PTR(offset, pfile_data) \ 265#define OFFSET_TO_PTR(offset, pfile_data) \
266 ((pfile_data)->file_base + (DWORD)(offset)) 266 ((pfile_data)->file_base + (DWORD)(offset))
@@ -272,7 +272,7 @@ relocate_offset (DWORD offset,
272static void 272static void
273copy_executable_and_add_section (file_data *p_infile, 273copy_executable_and_add_section (file_data *p_infile,
274 file_data *p_outfile, 274 file_data *p_outfile,
275 char *new_section_name, 275 const char *new_section_name,
276 DWORD new_section_size) 276 DWORD new_section_size)
277{ 277{
278 unsigned char *dst; 278 unsigned char *dst;
@@ -287,7 +287,7 @@ copy_executable_and_add_section (file_data *p_infile,
287 287
288#define COPY_CHUNK(message, src, size, verbose) \ 288#define COPY_CHUNK(message, src, size, verbose) \
289 do { \ 289 do { \
290 unsigned char *s = (void *)(src); \ 290 unsigned const char *s = (void *)(src); \
291 unsigned long count = (size); \ 291 unsigned long count = (size); \
292 if (verbose) \ 292 if (verbose) \
293 { \ 293 { \
diff --git a/nt/cmdproxy.c b/nt/cmdproxy.c
index 0f9bd65112d..7c68f868658 100644
--- a/nt/cmdproxy.c
+++ b/nt/cmdproxy.c
@@ -43,12 +43,11 @@ extern int _snprintf (char *buffer, size_t count, const char *format, ...);
43 43
44/* These routines are used primarily to minimize the executable size. */ 44/* These routines are used primarily to minimize the executable size. */
45 45
46#define stdin GetStdHandle (STD_INPUT_HANDLE)
47#define stdout GetStdHandle (STD_OUTPUT_HANDLE) 46#define stdout GetStdHandle (STD_OUTPUT_HANDLE)
48#define stderr GetStdHandle (STD_ERROR_HANDLE) 47#define stderr GetStdHandle (STD_ERROR_HANDLE)
49 48
50int 49int
51vfprintf(HANDLE hnd, char * msg, va_list args) 50vfprintf (HANDLE hnd, const char * msg, va_list args)
52{ 51{
53 DWORD bytes_written; 52 DWORD bytes_written;
54 char buf[1024]; 53 char buf[1024];
@@ -58,7 +57,7 @@ vfprintf(HANDLE hnd, char * msg, va_list args)
58} 57}
59 58
60int 59int
61fprintf(HANDLE hnd, char * msg, ...) 60fprintf (HANDLE hnd, const char * msg, ...)
62{ 61{
63 va_list args; 62 va_list args;
64 int rc; 63 int rc;
@@ -71,7 +70,7 @@ fprintf(HANDLE hnd, char * msg, ...)
71} 70}
72 71
73int 72int
74printf(char * msg, ...) 73printf (const char * msg, ...)
75{ 74{
76 va_list args; 75 va_list args;
77 int rc; 76 int rc;
@@ -84,7 +83,7 @@ printf(char * msg, ...)
84} 83}
85 84
86void 85void
87fail (char * msg, ...) 86fail (const char * msg, ...)
88{ 87{
89 va_list args; 88 va_list args;
90 89
@@ -96,7 +95,7 @@ fail (char * msg, ...)
96} 95}
97 96
98void 97void
99warn (char * msg, ...) 98warn (const char * msg, ...)
100{ 99{
101 va_list args; 100 va_list args;
102 101
@@ -122,15 +121,15 @@ canon_filename (char *fname)
122 return fname; 121 return fname;
123} 122}
124 123
125char * 124const char *
126skip_space (char *str) 125skip_space (const char *str)
127{ 126{
128 while (isspace (*str)) str++; 127 while (isspace (*str)) str++;
129 return str; 128 return str;
130} 129}
131 130
132char * 131const char *
133skip_nonspace (char *str) 132skip_nonspace (const char *str)
134{ 133{
135 while (*str && !isspace (*str)) str++; 134 while (*str && !isspace (*str)) str++;
136 return str; 135 return str;
@@ -140,9 +139,9 @@ int escape_char = '\\';
140 139
141/* Get next token from input, advancing pointer. */ 140/* Get next token from input, advancing pointer. */
142int 141int
143get_next_token (char * buf, char ** pSrc) 142get_next_token (char * buf, const char ** pSrc)
144{ 143{
145 char * p = *pSrc; 144 const char * p = *pSrc;
146 char * o = buf; 145 char * o = buf;
147 146
148 p = skip_space (p); 147 p = skip_space (p);
@@ -209,7 +208,7 @@ get_next_token (char * buf, char ** pSrc)
209 else 208 else
210 { 209 {
211 /* Next token is delimited by whitespace. */ 210 /* Next token is delimited by whitespace. */
212 char * p1 = skip_nonspace (p); 211 const char * p1 = skip_nonspace (p);
213 memcpy (o, p, p1 - p); 212 memcpy (o, p, p1 - p);
214 o += (p1 - p); 213 o += (p1 - p);
215 *o = '\0'; 214 *o = '\0';
@@ -224,9 +223,9 @@ get_next_token (char * buf, char ** pSrc)
224/* Search for EXEC file in DIR. If EXEC does not have an extension, 223/* Search for EXEC file in DIR. If EXEC does not have an extension,
225 DIR is searched for EXEC with the standard extensions appended. */ 224 DIR is searched for EXEC with the standard extensions appended. */
226int 225int
227search_dir (char *dir, char *exec, int bufsize, char *buffer) 226search_dir (const char *dir, const char *exec, int bufsize, char *buffer)
228{ 227{
229 char *exts[] = {".bat", ".cmd", ".exe", ".com"}; 228 const char *exts[] = {".bat", ".cmd", ".exe", ".com"};
230 int n_exts = sizeof (exts) / sizeof (char *); 229 int n_exts = sizeof (exts) / sizeof (char *);
231 char *dummy; 230 char *dummy;
232 int i, rc; 231 int i, rc;
@@ -246,13 +245,13 @@ search_dir (char *dir, char *exec, int bufsize, char *buffer)
246 any file extensions. If an absolute name for PROG cannot be found, 245 any file extensions. If an absolute name for PROG cannot be found,
247 return NULL. */ 246 return NULL. */
248char * 247char *
249make_absolute (char *prog) 248make_absolute (const char *prog)
250{ 249{
251 char absname[MAX_PATH]; 250 char absname[MAX_PATH];
252 char dir[MAX_PATH]; 251 char dir[MAX_PATH];
253 char curdir[MAX_PATH]; 252 char curdir[MAX_PATH];
254 char *p, *fname; 253 char *p, *path;
255 char *path; 254 const char *fname;
256 int i; 255 int i;
257 256
258 /* At least partial absolute path specified; search there. */ 257 /* At least partial absolute path specified; search there. */
@@ -372,7 +371,7 @@ console_event_handler (DWORD event)
372/* Change from normal usage; return value indicates whether spawn 371/* Change from normal usage; return value indicates whether spawn
373 succeeded or failed - program return code is returned separately. */ 372 succeeded or failed - program return code is returned separately. */
374int 373int
375spawn (char * progname, char * cmdline, char * dir, int * retcode) 374spawn (const char *progname, char *cmdline, const char *dir, int *retcode)
376{ 375{
377 BOOL success = FALSE; 376 BOOL success = FALSE;
378 SECURITY_ATTRIBUTES sec_attrs; 377 SECURITY_ATTRIBUTES sec_attrs;
@@ -470,8 +469,8 @@ main (int argc, char ** argv)
470 /* Due to problems with interaction between API functions that use "OEM" 469 /* Due to problems with interaction between API functions that use "OEM"
471 codepage vs API functions that use the "ANSI" codepage, we need to 470 codepage vs API functions that use the "ANSI" codepage, we need to
472 make things consistent by choosing one and sticking with it. */ 471 make things consistent by choosing one and sticking with it. */
473 SetConsoleCP (GetACP()); 472 SetConsoleCP (GetACP ());
474 SetConsoleOutputCP (GetACP()); 473 SetConsoleOutputCP (GetACP ());
475 474
476 /* Although Emacs always sets argv[0] to an absolute pathname, we 475 /* Although Emacs always sets argv[0] to an absolute pathname, we
477 might get run in other ways as well, so convert argv[0] to an 476 might get run in other ways as well, so convert argv[0] to an
@@ -509,7 +508,7 @@ main (int argc, char ** argv)
509 /* Ask command.com to create an environment block with a reasonable 508 /* Ask command.com to create an environment block with a reasonable
510 amount of free space. */ 509 amount of free space. */
511 envsize = get_env_size () + 300; 510 envsize = get_env_size () + 300;
512 pass_through_args = (char **) alloca (argc * sizeof(char *)); 511 pass_through_args = (char **) alloca (argc * sizeof (char *));
513 num_pass_through_args = 0; 512 num_pass_through_args = 0;
514 513
515 while (--argc > 0) 514 while (--argc > 0)
@@ -583,7 +582,7 @@ main (int argc, char ** argv)
583 582
584 if (strpbrk (cmdline, copout_chars) == NULL) 583 if (strpbrk (cmdline, copout_chars) == NULL)
585 { 584 {
586 char *args; 585 const char *args;
587 586
588 /* The program name is the first token of cmdline. Since 587 /* The program name is the first token of cmdline. Since
589 filenames cannot legally contain embedded quotes, the value 588 filenames cannot legally contain embedded quotes, the value
@@ -659,7 +658,6 @@ main (int argc, char ** argv)
659 _snprintf (p, remlen, " /e:%d /c %s", envsize, cmdline); 658 _snprintf (p, remlen, " /e:%d /c %s", envsize, cmdline);
660 else 659 else
661 _snprintf (p, remlen, " /c %s", cmdline); 660 _snprintf (p, remlen, " /c %s", cmdline);
662 remlen = maxlen - (p - buf);
663 cmdline = buf; 661 cmdline = buf;
664 } 662 }
665 else 663 else
@@ -696,10 +694,7 @@ main (int argc, char ** argv)
696 } 694 }
697 695
698 if (run_command_dot_com) 696 if (run_command_dot_com)
699 { 697 _snprintf (p, remlen, " /e:%d", envsize);
700 _snprintf (p, remlen, " /e:%d", envsize);
701 remlen = maxlen - (p - cmdline);
702 }
703 } 698 }
704 } 699 }
705 700
diff --git a/nt/preprep.c b/nt/preprep.c
index dbcc8a85682..220b0e40ce6 100644
--- a/nt/preprep.c
+++ b/nt/preprep.c
@@ -1,4 +1,4 @@
1/* Pro-process emacs.exe for profiling by MSVC. 1/* Pre-process emacs.exe for profiling by MSVC.
2 Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2 Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3 2008, 2009, 2010 Free Software Foundation, Inc. 3 2008, 2009, 2010 Free Software Foundation, Inc.
4 4
@@ -37,9 +37,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
37 37
38PIMAGE_NT_HEADERS 38PIMAGE_NT_HEADERS
39(__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress, 39(__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
40 DWORD FileLength, 40 DWORD FileLength,
41 LPDWORD HeaderSum, 41 LPDWORD HeaderSum,
42 LPDWORD CheckSum); 42 LPDWORD CheckSum);
43 43
44#undef min 44#undef min
45#undef max 45#undef max
@@ -50,15 +50,15 @@ PIMAGE_NT_HEADERS
50/* File handling. */ 50/* File handling. */
51 51
52typedef struct file_data { 52typedef struct file_data {
53 char *name; 53 const char *name;
54 unsigned long size; 54 unsigned long size;
55 HANDLE file; 55 HANDLE file;
56 HANDLE file_mapping; 56 HANDLE file_mapping;
57 unsigned char *file_base; 57 unsigned char *file_base;
58} file_data; 58} file_data;
59 59
60int 60int
61open_input_file (file_data *p_file, char *filename) 61open_input_file (file_data *p_file, const char *filename)
62{ 62{
63 HANDLE file; 63 HANDLE file;
64 HANDLE file_mapping; 64 HANDLE file_mapping;
@@ -90,7 +90,7 @@ open_input_file (file_data *p_file, char *filename)
90} 90}
91 91
92int 92int
93open_output_file (file_data *p_file, char *filename, unsigned long size) 93open_output_file (file_data *p_file, const char *filename, unsigned long size)
94{ 94{
95 HANDLE file; 95 HANDLE file;
96 HANDLE file_mapping; 96 HANDLE file_mapping;
@@ -120,7 +120,7 @@ open_output_file (file_data *p_file, char *filename, unsigned long size)
120} 120}
121 121
122int 122int
123open_inout_file (file_data *p_file, char *filename) 123open_inout_file (file_data *p_file, const char *filename)
124{ 124{
125 HANDLE file; 125 HANDLE file;
126 HANDLE file_mapping; 126 HANDLE file_mapping;
@@ -178,7 +178,7 @@ get_unrounded_section_size (PIMAGE_SECTION_HEADER p_section)
178 178
179/* Return pointer to section header for named section. */ 179/* Return pointer to section header for named section. */
180IMAGE_SECTION_HEADER * 180IMAGE_SECTION_HEADER *
181find_section (char * name, IMAGE_NT_HEADERS * nt_header) 181find_section (const char *name, IMAGE_NT_HEADERS *nt_header)
182{ 182{
183 PIMAGE_SECTION_HEADER section; 183 PIMAGE_SECTION_HEADER section;
184 int i; 184 int i;
@@ -295,7 +295,7 @@ relocate_offset (DWORD offset,
295#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) 295#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL))
296 296
297#define PTR_TO_OFFSET(ptr, pfile_data) \ 297#define PTR_TO_OFFSET(ptr, pfile_data) \
298 ((unsigned char *)(ptr) - (pfile_data)->file_base) 298 ((unsigned const char *)(ptr) - (pfile_data)->file_base)
299 299
300#define OFFSET_TO_PTR(offset, pfile_data) \ 300#define OFFSET_TO_PTR(offset, pfile_data) \
301 ((pfile_data)->file_base + (DWORD)(offset)) 301 ((pfile_data)->file_base + (DWORD)(offset))
@@ -361,7 +361,7 @@ copy_executable_and_move_sections (file_data *p_infile,
361 361
362#define COPY_CHUNK(message, src, size) \ 362#define COPY_CHUNK(message, src, size) \
363 do { \ 363 do { \
364 unsigned char *s = (void *)(src); \ 364 unsigned const char *s = (void *)(src); \
365 unsigned long count = (size); \ 365 unsigned long count = (size); \
366 printf ("%s\n", (message)); \ 366 printf ("%s\n", (message)); \
367 printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base); \ 367 printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base); \
@@ -766,7 +766,7 @@ main (int argc, char **argv)
766 PIMAGE_NT_HEADERS nt_header; 766 PIMAGE_NT_HEADERS nt_header;
767 file_data in_file, out_file; 767 file_data in_file, out_file;
768 char out_filename[MAX_PATH], in_filename[MAX_PATH]; 768 char out_filename[MAX_PATH], in_filename[MAX_PATH];
769 char *ptr; 769 const char *ptr;
770 770
771 strcpy (in_filename, argv[1]); 771 strcpy (in_filename, argv[1]);
772 strcpy (out_filename, argv[2]); 772 strcpy (out_filename, argv[2]);