summaryrefslogtreecommitdiff
path: root/nt/cmdproxy.c
diff options
context:
space:
mode:
authorJuanma Barranquero <lekktu@gmail.com>2010-09-28 02:55:08 +0200
committerJuanma Barranquero <lekktu@gmail.com>2010-09-28 02:55:08 +0200
commit0597ab06f6681758096685a0cd3ed3f24ab6e971 (patch)
tree462befdef914fd872fd42949d804a9b0b90cfbef /nt/cmdproxy.c
parent95b6d681b1121e1be8955aa3f79dd39098edf4cf (diff)
downloademacs-0597ab06f6681758096685a0cd3ed3f24ab6e971.tar.gz
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.
Diffstat (limited to 'nt/cmdproxy.c')
-rw-r--r--nt/cmdproxy.c51
1 files changed, 23 insertions, 28 deletions
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, ...);
/* 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 @@ vfprintf(HANDLE hnd, char * msg, va_list args)
}
int
-fprintf(HANDLE hnd, char * msg, ...)
+fprintf (HANDLE hnd, const char * msg, ...)
{
va_list args;
int rc;
@@ -71,7 +70,7 @@ fprintf(HANDLE hnd, char * msg, ...)
}
int
-printf(char * msg, ...)
+printf (const char * msg, ...)
{
va_list args;
int rc;
@@ -84,7 +83,7 @@ printf(char * msg, ...)
}
void
-fail (char * msg, ...)
+fail (const char * msg, ...)
{
va_list args;
@@ -96,7 +95,7 @@ fail (char * msg, ...)
}
void
-warn (char * msg, ...)
+warn (const char * msg, ...)
{
va_list args;
@@ -122,15 +121,15 @@ canon_filename (char *fname)
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 @@ int escape_char = '\\';
/* 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 @@ get_next_token (char * buf, char ** pSrc)
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 @@ get_next_token (char * buf, char ** pSrc)
/* 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 @@ search_dir (char *dir, char *exec, int bufsize, char *buffer)
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 @@ console_event_handler (DWORD event)
/* 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 @@ main (int argc, char ** argv)
/* 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 @@ main (int argc, char ** argv)
/* 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 @@ main (int argc, char ** argv)
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 @@ main (int argc, char ** argv)
_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 @@ main (int argc, char ** argv)
}
if (run_command_dot_com)
- {
- _snprintf (p, remlen, " /e:%d", envsize);
- remlen = maxlen - (p - cmdline);
- }
+ _snprintf (p, remlen, " /e:%d", envsize);
}
}