Jason Edmeades : cmd.exe: Fix dir /w.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Jun 4 08:14:43 CDT 2007
Module: wine
Branch: master
Commit: a1639ebfc6bee6b357104d9f46a96ef50dd303ad
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a1639ebfc6bee6b357104d9f46a96ef50dd303ad
Author: Jason Edmeades <jason.edmeades at googlemail.com>
Date: Sun Jun 3 22:07:47 2007 +0100
cmd.exe: Fix dir /w.
Use of %* fails when using wvsprintf, so just pad manually,
but maintain only a single output call.
---
programs/cmd/directory.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c
index e9c413a..4940140 100644
--- a/programs/cmd/directory.c
+++ b/programs/cmd/directory.c
@@ -72,6 +72,7 @@ static const WCHAR dotdotW[] = {'.','.','\0'};
static const WCHAR starW[] = {'*','\0'};
static const WCHAR slashW[] = {'\\','\0'};
static const WCHAR emptyW[] = {'\0'};
+static const WCHAR spaceW[] = {' ','\0'};
/*****************************************************************************
* WCMD_directory
@@ -618,8 +619,24 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if ((cur_width + widest) > max_width) {
cur_width = 0;
} else {
- static const WCHAR fmt[] = {'%','*','.','s','\0'};
- WCMD_output (fmt, (tmp_width - cur_width), emptyW);
+ int padding = cur_width - tmp_width;
+ int toWrite = 0;
+ WCHAR temp[101];
+
+ /* Note: WCMD_output uses wvsprintf which does not allow %*
+ so manually pad with spaces to appropriate width */
+ strcpyW(temp, emptyW);
+ while (padding > 0) {
+ strcatW(&temp[toWrite], spaceW);
+ toWrite++;
+ if (toWrite > 99) {
+ WCMD_output(temp);
+ toWrite = 0;
+ strcpyW(temp, emptyW);
+ }
+ padding--;
+ }
+ WCMD_output(temp);
}
} else if ((fd+i)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
More information about the wine-cvs
mailing list