cmd.exe: Support SHIFT /n option.
This commit is contained in:
parent
ffbaedef51
commit
612dc9d35d
|
@ -89,7 +89,7 @@ void WCMD_batch (char *file, char *command, int called, char *startLabel, HANDLE
|
|||
context = (BATCH_CONTEXT *)LocalAlloc (LMEM_FIXED, sizeof (BATCH_CONTEXT));
|
||||
context -> h = h;
|
||||
context -> command = command;
|
||||
context -> shift_count = 0;
|
||||
memset(context -> shift_count, 0x00, sizeof(context -> shift_count));
|
||||
context -> prev_context = prev_context;
|
||||
context -> skip_rest = FALSE;
|
||||
|
||||
|
@ -386,7 +386,7 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
|
|||
/* Extract the parameter to play with */
|
||||
if ((*lastModifier >= '0' && *lastModifier <= '9')) {
|
||||
strcpy(outputparam, WCMD_parameter (context -> command,
|
||||
*lastModifier-'0' + context -> shift_count, NULL));
|
||||
*lastModifier-'0' + context -> shift_count[*lastModifier-'0'], NULL));
|
||||
} else {
|
||||
/* FIXME: Retrieve 'for' variable %c\n", *lastModifier); */
|
||||
/* Need to get 'for' loop variable into outputparam */
|
||||
|
|
|
@ -1388,11 +1388,32 @@ void WCMD_setshow_time (void) {
|
|||
* WCMD_shift
|
||||
*
|
||||
* Shift batch parameters.
|
||||
* Optional /n says where to start shifting (n=0-8)
|
||||
*/
|
||||
|
||||
void WCMD_shift (void) {
|
||||
void WCMD_shift (char *command) {
|
||||
int start;
|
||||
|
||||
if (context != NULL) context -> shift_count++;
|
||||
if (context != NULL) {
|
||||
char *pos = strchr(command, '/');
|
||||
int i;
|
||||
|
||||
if (pos == NULL) {
|
||||
start = 0;
|
||||
} else if (*(pos+1)>='0' && *(pos+1)<='8') {
|
||||
start = (*(pos+1) - '0');
|
||||
} else {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
WCMD_print_error();
|
||||
return;
|
||||
}
|
||||
|
||||
WINE_TRACE("Shifting variables, starting at %d\n", start);
|
||||
for (i=start;i<=8;i++) {
|
||||
context -> shift_count[i] = context -> shift_count[i+1] + 1;
|
||||
}
|
||||
context -> shift_count[9] = context -> shift_count[9] + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ void WCMD_setshow_env (char *command);
|
|||
void WCMD_setshow_path (char *command);
|
||||
void WCMD_setshow_prompt (void);
|
||||
void WCMD_setshow_time (void);
|
||||
void WCMD_shift (void);
|
||||
void WCMD_shift (char *command);
|
||||
void WCMD_show_prompt (void);
|
||||
void WCMD_title (char *);
|
||||
void WCMD_type (void);
|
||||
|
@ -91,7 +91,7 @@ void WCMD_splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ex
|
|||
typedef struct {
|
||||
char *command; /* The command which invoked the batch file */
|
||||
HANDLE h; /* Handle to the open batch file */
|
||||
int shift_count; /* Number of SHIFT commands executed */
|
||||
int shift_count[10]; /* Offset in terms of shifts for %0 - %9 */
|
||||
void *prev_context; /* Pointer to the previous context block */
|
||||
BOOL skip_rest; /* Skip the rest of the batch program and exit */
|
||||
} BATCH_CONTEXT;
|
||||
|
|
|
@ -411,7 +411,7 @@ void WCMD_process_command (char *command)
|
|||
/* Replace use of %0...%9 if in batch program*/
|
||||
} else if (context && (i >= 0) && (i <= 9)) {
|
||||
s = strdup (p+2);
|
||||
t = WCMD_parameter (context -> command, i + context -> shift_count, NULL);
|
||||
t = WCMD_parameter (context -> command, i + context -> shift_count[i], NULL);
|
||||
strcpy (p, t);
|
||||
strcat (p, s);
|
||||
free (s);
|
||||
|
@ -629,7 +629,7 @@ void WCMD_process_command (char *command)
|
|||
WCMD_setshow_env (p);
|
||||
break;
|
||||
case WCMD_SHIFT:
|
||||
WCMD_shift ();
|
||||
WCMD_shift (p);
|
||||
break;
|
||||
case WCMD_TIME:
|
||||
WCMD_setshow_time ();
|
||||
|
|
Loading…
Reference in New Issue