Kaydet (Commit) 9281d3d8 authored tarafından Vladimir Glazounov's avatar Vladimir Glazounov

INTEGRATION: CWS dmake46 (1.2.8); FILE MERGED

2006/07/27 01:10:48 vq 1.2.8.2: #i67808# Fix the internal echo command of the native Windows dmake version.
The patch also moves the usage of the global variable Packed_shell to
msdos/runargv.c and msdos/spawn.c.
2006/07/20 02:41:14 vq 1.2.8.1: #i10000# No code changes. Only comments were added/improved.
üst f2ed60fe
/* RCS $Id: runargv.c,v 1.2 2006-04-20 12:06:24 hr Exp $ /* RCS $Id: runargv.c,v 1.3 2006-09-25 09:41:53 vg Exp $
-- --
-- SYNOPSIS -- SYNOPSIS
-- Run a sub process. -- Run a sub process.
...@@ -55,31 +55,37 @@ char *cmd; ...@@ -55,31 +55,37 @@ char *cmd;
Do_profile_output( "s", M_RECIPE, target ); Do_profile_output( "s", M_RECIPE, target );
_add_child(target, ignore); _add_child(target, ignore);
/* return immediately for noop command */
if (strncmp(cmd, "noop", 4) == 0 && (cmd[4] == ' ' || cmd[4] == '\0')) { /* remove leading whitespace */
while( iswhite(*cmd) ) ++cmd;
/* Return immediately for empty line or noop command. */
if ( !*cmd || /* empty line */
( strncmp(cmd, "noop", 4) == 0 && /* noop command */
(iswhite(cmd[4]) || cmd[4] == '\0')) ) {
status = 0;
}
else if( !shell && /* internal echo only if not in shell */
strncmp(cmd, "echo", 4) == 0 &&
(iswhite(cmd[4]) || cmd[4] == '\0') ) {
char *tstr = cmd+4;
int nl = 1;
while( iswhite(*tstr) ) ++tstr;
if ( strncmp(tstr,"-n",2 ) == 0) {
nl = 0;
tstr = tstr+2;
while( iswhite(*tstr) ) ++tstr;
}
printf("%s%s", tstr, nl ? "\n" : "");
fflush(stdout);
status = 0; status = 0;
} }
else { else {
argv = Pack_argv( group, shell, cmd ); argv = Pack_argv( group, shell, cmd );
Packed_shell = shell||group;
if ( strcmp(argv[0],"echo") == 0 ) { status = spawnvpe(P_WAIT, *argv, argv, environ);
int i;
int first = 1;
int nl = 1;
if (strcmp(argv[1],"-n") == 0) nl--;
for (i=2-nl;argv[i]; i++) {
if (!first) putchar(' ');
printf("%s", argv[i]);
}
if (nl) printf("\n");
fflush(stdout);
status = 0;
}
else {
status = spawnvpe(P_WAIT, *argv, argv, environ);
}
} }
if( status == -1 ) Error("%s: %s", argv[0], strerror(errno)); if( status == -1 ) Error("%s: %s", argv[0], strerror(errno));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment