From 8049ae1af8e431a8b54c34107c31cf85547972a5 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Sun, 4 Mar 2007 22:34:20 +0000 Subject: [PATCH] cmd.exe: PROMPT option to show pushd levels. --- programs/cmd/builtins.c | 11 +++++------ programs/cmd/wcmd.h | 9 +++++++++ programs/cmd/wcmdmain.c | 9 ++++++++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 3aeac711c7a..8418ab47e2c 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -42,12 +42,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(cmd); void WCMD_execute (char *orig_command, char *parameter, char *substitution); -struct env_stack -{ - struct env_stack *next; - WCHAR *strings; -}; - struct env_stack *saved_environment; struct env_stack *pushd_directories; @@ -612,6 +606,11 @@ void WCMD_pushd (void) { } else { curdir -> next = pushd_directories; curdir -> strings = thisdir; + if (pushd_directories == NULL) { + curdir -> stackdepth = 1; + } else { + curdir -> stackdepth = pushd_directories -> stackdepth + 1; + } pushd_directories = curdir; } } diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 61e304401f3..49307c79947 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -94,6 +94,15 @@ typedef struct { BOOL skip_rest; /* Skip the rest of the batch program and exit */ } BATCH_CONTEXT; +/* Data structure to save setlocal and pushd information */ + +struct env_stack +{ + struct env_stack *next; + int stackdepth; /* Only used for pushd and popd */ + WCHAR *strings; +}; + #endif /* !RC_INVOKED */ /* diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 4253f317cce..a1f426c1877 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -45,6 +45,7 @@ const char anykey[] = "Press Return key to continue: "; char quals[MAX_PATH], param1[MAX_PATH], param2[MAX_PATH]; BATCH_CONTEXT *context = NULL; static HANDLE old_stdin = INVALID_HANDLE_VALUE, old_stdout = INVALID_HANDLE_VALUE; +extern struct env_stack *pushd_directories; static char *WCMD_expand_envvar(char *start); @@ -932,10 +933,16 @@ void WCMD_show_prompt (void) { case 'V': lstrcat (q, version_string); while (*q) q++; - break; + break; case '_': *q++ = '\n'; break; + case '+': + if (pushd_directories) { + memset(q, '+', pushd_directories->stackdepth); + q = q + pushd_directories->stackdepth; + } + break; } p++; *q = '\0';