changeset 110628:19b118dd1498

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.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 28 Sep 2010 02:55:08 +0200
parents 6a7fb61524be
children 531fc2a3b1cc
files nt/ChangeLog nt/addpm.c nt/addsection.c nt/cmdproxy.c nt/preprep.c
diffstat 5 files changed, 75 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/nt/ChangeLog	Tue Sep 28 01:25:27 2010 +0200
+++ b/nt/ChangeLog	Tue Sep 28 02:55:08 2010 +0200
@@ -1,3 +1,19 @@
+2010-09-28  Juanma Barranquero  <lekktu@gmail.com>
+
+	* 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.
+
 2010-09-22  Juanma Barranquero  <lekktu@gmail.com>
 
 	* configure.bat: Err out when the argument of --cflags contains
--- a/nt/addpm.c	Tue Sep 28 01:25:27 2010 +0200
+++ b/nt/addpm.c	Tue Sep 28 02:55:08 2010 +0200
@@ -67,8 +67,8 @@
 
 static struct entry
 {
-  char *name;
-  char *value;
+  const char *name;
+  const char *value;
 }
 env_vars[] =
 {
@@ -85,7 +85,7 @@
 };
 
 BOOL
-add_registry (char *path)
+add_registry (const char *path)
 {
   HKEY hrootkey = NULL;
   int i;
@@ -178,7 +178,7 @@
 
   for (i = 0; i < (sizeof (env_vars) / sizeof (env_vars[0])); i++)
     {
-      char * value = env_vars[i].value ? env_vars[i].value : path;
+      const char * value = env_vars[i].value ? env_vars[i].value : path;
 
       if (RegSetValueEx (hrootkey, env_vars[i].name,
 			 0, REG_EXPAND_SZ,
@@ -198,8 +198,8 @@
   int shortcuts_created = 0;
   int com_available = 1;
   char modname[MAX_PATH];
-  char *prog_name;
-  char *emacs_path;
+  const char *prog_name;
+  const char *emacs_path;
   char *p;
   int quiet = 0;
   HRESULT result;
--- a/nt/addsection.c	Tue Sep 28 01:25:27 2010 +0200
+++ b/nt/addsection.c	Tue Sep 28 02:55:08 2010 +0200
@@ -37,9 +37,9 @@
 
 PIMAGE_NT_HEADERS
 (__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
-				    DWORD FileLength,
-				    LPDWORD HeaderSum,
-				    LPDWORD CheckSum);
+				     DWORD FileLength,
+				     LPDWORD HeaderSum,
+				     LPDWORD CheckSum);
 
 #undef min
 #undef max
@@ -50,15 +50,15 @@
 /* File handling.  */
 
 typedef struct file_data {
-    char          *name;
-    unsigned long  size;
-    HANDLE         file;
-    HANDLE         file_mapping;
-    unsigned char *file_base;
+  const char    *name;
+  unsigned long  size;
+  HANDLE         file;
+  HANDLE         file_mapping;
+  unsigned char *file_base;
 } file_data;
 
 int
-open_input_file (file_data *p_file, char *filename)
+open_input_file (file_data *p_file, const char *filename)
 {
   HANDLE file;
   HANDLE file_mapping;
@@ -90,7 +90,7 @@
 }
 
 int
-open_output_file (file_data *p_file, char *filename, unsigned long size)
+open_output_file (file_data *p_file, const char *filename, unsigned long size)
 {
   HANDLE file;
   HANDLE file_mapping;
@@ -146,7 +146,7 @@
 
 /* Return pointer to section header for named section. */
 IMAGE_SECTION_HEADER *
-find_section (char * name, IMAGE_NT_HEADERS * nt_header)
+find_section (const char *name, IMAGE_NT_HEADERS *nt_header)
 {
   PIMAGE_SECTION_HEADER section;
   int i;
@@ -260,7 +260,7 @@
 #define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL))
 
 #define PTR_TO_OFFSET(ptr, pfile_data) \
-          ((unsigned char *)(ptr) - (pfile_data)->file_base)
+          ((unsigned const char *)(ptr) - (pfile_data)->file_base)
 
 #define OFFSET_TO_PTR(offset, pfile_data) \
           ((pfile_data)->file_base + (DWORD)(offset))
@@ -272,7 +272,7 @@
 static void
 copy_executable_and_add_section (file_data *p_infile,
 				 file_data *p_outfile,
-				 char *new_section_name,
+				 const char *new_section_name,
 				 DWORD new_section_size)
 {
   unsigned char *dst;
@@ -287,7 +287,7 @@
 
 #define COPY_CHUNK(message, src, size, verbose)					\
   do {										\
-    unsigned char *s = (void *)(src);						\
+    unsigned const char *s = (void *)(src);						\
     unsigned long count = (size);						\
     if (verbose)								\
       {										\
--- a/nt/cmdproxy.c	Tue Sep 28 01:25:27 2010 +0200
+++ b/nt/cmdproxy.c	Tue Sep 28 02:55:08 2010 +0200
@@ -43,12 +43,11 @@
 
 /* These routines are used primarily to minimize the executable size.  */
 
-#define stdin  GetStdHandle (STD_INPUT_HANDLE)
 #define stdout GetStdHandle (STD_OUTPUT_HANDLE)
 #define stderr GetStdHandle (STD_ERROR_HANDLE)
 
 int
-vfprintf(HANDLE hnd, char * msg, va_list args)
+vfprintf (HANDLE hnd, const char * msg, va_list args)
 {
   DWORD bytes_written;
   char buf[1024];
@@ -58,7 +57,7 @@
 }
 
 int
-fprintf(HANDLE hnd, char * msg, ...)
+fprintf (HANDLE hnd, const char * msg, ...)
 {
   va_list args;
   int rc;
@@ -71,7 +70,7 @@
 }
 
 int
-printf(char * msg, ...)
+printf (const char * msg, ...)
 {
   va_list args;
   int rc;
@@ -84,7 +83,7 @@
 }
 
 void
-fail (char * msg, ...)
+fail (const char * msg, ...)
 {
   va_list args;
 
@@ -96,7 +95,7 @@
 }
 
 void
-warn (char * msg, ...)
+warn (const char * msg, ...)
 {
   va_list args;
 
@@ -122,15 +121,15 @@
   return fname;
 }
 
-char *
-skip_space (char *str)
+const char *
+skip_space (const char *str)
 {
   while (isspace (*str)) str++;
   return str;
 }
 
-char *
-skip_nonspace (char *str)
+const char *
+skip_nonspace (const char *str)
 {
   while (*str && !isspace (*str)) str++;
   return str;
@@ -140,9 +139,9 @@
 
 /* Get next token from input, advancing pointer.  */
 int
-get_next_token (char * buf, char ** pSrc)
+get_next_token (char * buf, const char ** pSrc)
 {
-  char * p = *pSrc;
+  const char * p = *pSrc;
   char * o = buf;
 
   p = skip_space (p);
@@ -209,7 +208,7 @@
   else
     {
       /* Next token is delimited by whitespace.  */
-      char * p1 = skip_nonspace (p);
+      const char * p1 = skip_nonspace (p);
       memcpy (o, p, p1 - p);
       o += (p1 - p);
       *o = '\0';
@@ -224,9 +223,9 @@
 /* Search for EXEC file in DIR.  If EXEC does not have an extension,
    DIR is searched for EXEC with the standard extensions appended.  */
 int
-search_dir (char *dir, char *exec, int bufsize, char *buffer)
+search_dir (const char *dir, const char *exec, int bufsize, char *buffer)
 {
-  char *exts[] = {".bat", ".cmd", ".exe", ".com"};
+  const char *exts[] = {".bat", ".cmd", ".exe", ".com"};
   int n_exts = sizeof (exts) / sizeof (char *);
   char *dummy;
   int i, rc;
@@ -246,13 +245,13 @@
    any file extensions.  If an absolute name for PROG cannot be found,
    return NULL.  */
 char *
-make_absolute (char *prog)
+make_absolute (const char *prog)
 {
   char absname[MAX_PATH];
   char dir[MAX_PATH];
   char curdir[MAX_PATH];
-  char *p, *fname;
-  char *path;
+  char *p, *path;
+  const char *fname;
   int i;
 
   /* At least partial absolute path specified; search there.  */
@@ -372,7 +371,7 @@
 /* Change from normal usage; return value indicates whether spawn
    succeeded or failed - program return code is returned separately.  */
 int
-spawn (char * progname, char * cmdline, char * dir, int * retcode)
+spawn (const char *progname, char *cmdline, const char *dir, int *retcode)
 {
   BOOL success = FALSE;
   SECURITY_ATTRIBUTES sec_attrs;
@@ -470,8 +469,8 @@
   /* Due to problems with interaction between API functions that use "OEM"
      codepage vs API functions that use the "ANSI" codepage, we need to
      make things consistent by choosing one and sticking with it.  */
-  SetConsoleCP (GetACP());
-  SetConsoleOutputCP (GetACP());
+  SetConsoleCP (GetACP ());
+  SetConsoleOutputCP (GetACP ());
 
   /* Although Emacs always sets argv[0] to an absolute pathname, we
      might get run in other ways as well, so convert argv[0] to an
@@ -509,7 +508,7 @@
   /* Ask command.com to create an environment block with a reasonable
      amount of free space.  */
   envsize = get_env_size () + 300;
-  pass_through_args = (char **) alloca (argc * sizeof(char *));
+  pass_through_args = (char **) alloca (argc * sizeof (char *));
   num_pass_through_args = 0;
 
   while (--argc > 0)
@@ -583,7 +582,7 @@
 
       if (strpbrk (cmdline, copout_chars) == NULL)
 	{
- 	  char *args;
+ 	  const char *args;
 
 	  /* The program name is the first token of cmdline.  Since
 	     filenames cannot legally contain embedded quotes, the value
@@ -659,7 +658,6 @@
 	    _snprintf (p, remlen, " /e:%d /c %s", envsize, cmdline);
 	  else
 	    _snprintf (p, remlen, " /c %s", cmdline);
-	  remlen = maxlen - (p - buf);
 	  cmdline = buf;
 	}
       else
@@ -696,10 +694,7 @@
 	    }
 
 	  if (run_command_dot_com)
-	    {
-	      _snprintf (p, remlen, " /e:%d", envsize);
-	      remlen = maxlen - (p - cmdline);
-	    }
+	    _snprintf (p, remlen, " /e:%d", envsize);
 	}
     }
 
--- a/nt/preprep.c	Tue Sep 28 01:25:27 2010 +0200
+++ b/nt/preprep.c	Tue Sep 28 02:55:08 2010 +0200
@@ -1,4 +1,4 @@
-/* Pro-process emacs.exe for profiling by MSVC.
+/* Pre-process emacs.exe for profiling by MSVC.
    Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
      2008, 2009, 2010  Free Software Foundation, Inc.
 
@@ -37,9 +37,9 @@
 
 PIMAGE_NT_HEADERS
 (__stdcall * pfnCheckSumMappedFile) (LPVOID BaseAddress,
-				    DWORD FileLength,
-				    LPDWORD HeaderSum,
-				    LPDWORD CheckSum);
+				     DWORD FileLength,
+				     LPDWORD HeaderSum,
+				     LPDWORD CheckSum);
 
 #undef min
 #undef max
@@ -50,15 +50,15 @@
 /* File handling.  */
 
 typedef struct file_data {
-    char          *name;
-    unsigned long  size;
-    HANDLE         file;
-    HANDLE         file_mapping;
-    unsigned char *file_base;
+  const char    *name;
+  unsigned long  size;
+  HANDLE         file;
+  HANDLE         file_mapping;
+  unsigned char *file_base;
 } file_data;
 
 int
-open_input_file (file_data *p_file, char *filename)
+open_input_file (file_data *p_file, const char *filename)
 {
   HANDLE file;
   HANDLE file_mapping;
@@ -90,7 +90,7 @@
 }
 
 int
-open_output_file (file_data *p_file, char *filename, unsigned long size)
+open_output_file (file_data *p_file, const char *filename, unsigned long size)
 {
   HANDLE file;
   HANDLE file_mapping;
@@ -120,7 +120,7 @@
 }
 
 int
-open_inout_file (file_data *p_file, char *filename)
+open_inout_file (file_data *p_file, const char *filename)
 {
   HANDLE file;
   HANDLE file_mapping;
@@ -178,7 +178,7 @@
 
 /* Return pointer to section header for named section. */
 IMAGE_SECTION_HEADER *
-find_section (char * name, IMAGE_NT_HEADERS * nt_header)
+find_section (const char *name, IMAGE_NT_HEADERS *nt_header)
 {
   PIMAGE_SECTION_HEADER section;
   int i;
@@ -295,7 +295,7 @@
 #define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL))
 
 #define PTR_TO_OFFSET(ptr, pfile_data) \
-          ((unsigned char *)(ptr) - (pfile_data)->file_base)
+          ((unsigned const char *)(ptr) - (pfile_data)->file_base)
 
 #define OFFSET_TO_PTR(offset, pfile_data) \
           ((pfile_data)->file_base + (DWORD)(offset))
@@ -361,7 +361,7 @@
 
 #define COPY_CHUNK(message, src, size)						\
   do {										\
-    unsigned char *s = (void *)(src);						\
+    unsigned const char *s = (void *)(src);					\
     unsigned long count = (size);						\
     printf ("%s\n", (message));							\
     printf ("\t0x%08x Offset in input file.\n", s - p_infile->file_base);	\
@@ -766,7 +766,7 @@
   PIMAGE_NT_HEADERS nt_header;
   file_data in_file, out_file;
   char out_filename[MAX_PATH], in_filename[MAX_PATH];
-  char *ptr;
+  const char *ptr;
 
   strcpy (in_filename, argv[1]);
   strcpy (out_filename, argv[2]);