attrib: Use FormatMessageW() for better internationalization support. (try2)
Francois Gouget
fgouget at free.fr
Fri Oct 21 02:42:18 CDT 2011
This makes it possible to reorder the format string placeholders in message translations... should the need arise.
---
Using __ms_va_list this time.
programs/attrib/attrib.c | 16 +++++++++-------
programs/attrib/attrib.rc | 2 +-
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/programs/attrib/attrib.c b/programs/attrib/attrib.c
index 0ca64c3..2dd45e2 100644
--- a/programs/attrib/attrib.c
+++ b/programs/attrib/attrib.c
@@ -53,7 +53,7 @@ static int ATTRIB_wprintf(const WCHAR *format, ...) {
static BOOL traceOutput = FALSE;
#define MAX_WRITECONSOLE_SIZE 65535
- va_list parms;
+ __ms_va_list parms;
DWORD nOut;
int len;
DWORD res = 0;
@@ -71,11 +71,13 @@ static int ATTRIB_wprintf(const WCHAR *format, ...) {
return 0;
}
- va_start(parms, format);
- len = vsnprintfW(output_bufW, MAX_WRITECONSOLE_SIZE/sizeof(WCHAR), format, parms);
- va_end(parms);
- if (len < 0) {
- WINE_FIXME("String too long.\n");
+ __ms_va_start(parms, format);
+ SetLastError(NO_ERROR);
+ len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, format, 0, 0, output_bufW,
+ MAX_WRITECONSOLE_SIZE/sizeof(*output_bufW), &parms);
+ __ms_va_end(parms);
+ if (len == 0 && GetLastError() != NO_ERROR) {
+ WINE_FIXME("Could not format string: le=%u, fmt=%s\n", GetLastError(), wine_dbgstr_w(format));
return 0;
}
@@ -178,7 +180,7 @@ int wmain(int argc, WCHAR *argv[])
fd.dwFileAttributes |= FILE_ATTRIBUTE_NORMAL;
SetFileAttributesW(name, fd.dwFileAttributes);
} else {
- static const WCHAR fmt[] = {'%','s',' ',' ',' ','%','s','\n','\0'};
+ static const WCHAR fmt[] = {'%','1',' ',' ',' ','%','2','\n','\0'};
if (fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) {
flags[0] = 'H';
}
diff --git a/programs/attrib/attrib.rc b/programs/attrib/attrib.rc
index 858b300..9e2390e 100644
--- a/programs/attrib/attrib.rc
+++ b/programs/attrib/attrib.rc
@@ -25,7 +25,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE
{
STRING_NYI, "Not Yet Implemented\n\n"
- STRING_FILENOTFOUND, "%s: File Not Found\n"
+ STRING_FILENOTFOUND, "%1: File Not Found\n"
STRING_HELP,
"ATTRIB - Displays or changes file attributes.\n\
\n\
--
1.7.6.3
More information about the wine-patches
mailing list