attrib: Use FormatMessageW() for better internationalization support.
Francois Gouget
fgouget at free.fr
Thu Oct 20 07:47:54 CDT 2011
This makes it possible to reorder the format string placeholders in message translations... should the need arise.
---
programs/attrib/attrib.c | 10 ++++++----
programs/attrib/attrib.rc | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/programs/attrib/attrib.c b/programs/attrib/attrib.c
index 0ca64c3..f7a8763 100644
--- a/programs/attrib/attrib.c
+++ b/programs/attrib/attrib.c
@@ -72,10 +72,12 @@ static int ATTRIB_wprintf(const WCHAR *format, ...) {
}
va_start(parms, format);
- len = vsnprintfW(output_bufW, MAX_WRITECONSOLE_SIZE/sizeof(WCHAR), format, parms);
+ SetLastError(NO_ERROR);
+ len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, format, 0, 0, output_bufW,
+ MAX_WRITECONSOLE_SIZE/sizeof(*output_bufW), &parms);
va_end(parms);
- if (len < 0) {
- WINE_FIXME("String too long.\n");
+ 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