net: Use FormatMessageW() for better internationalization support.
Francois Gouget
fgouget at free.fr
Thu Oct 20 07:48:04 CDT 2011
This makes it possible to reorder the format string placeholders in message translations.
Also the last argument to STRING_USE_ENTRY is a DWORD, that is a regular unsigned int, not a long.
---
programs/net/net.c | 10 ++++++----
programs/net/net.rc | 18 +++++++++---------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/programs/net/net.c b/programs/net/net.c
index de83ccd..2ec5ad8 100644
--- a/programs/net/net.c
+++ b/programs/net/net.c
@@ -60,9 +60,11 @@ static int output_vprintf(const WCHAR* fmt, va_list va_args)
WCHAR str[8192];
int len;
- len = vsnprintfW(str, sizeof(str)/sizeof(*str), fmt, va_args);
- if (len < 0)
- WINE_FIXME("String too long.\n");
+ SetLastError(NO_ERROR);
+ len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, fmt, 0, 0, str,
+ sizeof(str)/sizeof(*str), &va_args);
+ if (len == 0 && GetLastError() != NO_ERROR)
+ WINE_FIXME("Could not format string: le=%u, fmt=%s\n", GetLastError(), wine_dbgstr_w(fmt));
else
output_write(str, len);
return 0;
@@ -156,7 +158,7 @@ static BOOL net_use(int argc, const WCHAR* argv[])
static BOOL net_enum_services(void)
{
- static const WCHAR runningW[]={' ',' ',' ',' ','%','s','\n',0};
+ static const WCHAR runningW[]={' ',' ',' ',' ','%','1','\n',0};
SC_HANDLE SCManager;
LPENUM_SERVICE_STATUS_PROCESSW services;
DWORD size, i, count, resume;
diff --git a/programs/net/net.rc b/programs/net/net.rc
index eb0adc9..1ed0498 100644
--- a/programs/net/net.rc
+++ b/programs/net/net.rc
@@ -27,20 +27,20 @@ STRINGTABLE
STRING_USAGE, "The syntax of this command is:\n\nNET command [arguments]\n -or-\nNET command /HELP\n\nWhere 'command' is one of HELP, START, STOP or USE.\n"
STRING_START_USAGE, "The syntax of this command is:\n\nNET START [service]\n\nDisplays the list of running services if 'service' is omitted. Otherwise 'service' is the name of the service to start.\n"
STRING_STOP_USAGE, "The syntax of this command is:\n\nNET STOP service\n\nWhere 'service' is the name of the service to stop.\n"
- STRING_STOP_DEP, "Stopping dependent service: %s\n"
- STRING_CANT_STOP, "Could not stop service %s\n"
+ STRING_STOP_DEP, "Stopping dependent service: %1\n"
+ STRING_CANT_STOP, "Could not stop service %1\n"
STRING_NO_SCM, "Could not get handle to service control manager.\n"
STRING_NO_SVCHANDLE, "Could not get handle to service.\n"
- STRING_START_SVC, "The %s service is starting.\n"
- STRING_START_SVC_SUCCESS, "The %s service was started successfully.\n"
- STRING_START_SVC_FAIL, "The %s service failed to start.\n"
- STRING_STOP_SVC, "The %s service is stopping.\n"
- STRING_STOP_SVC_SUCCESS, "The %s service was stopped successfully.\n"
- STRING_STOP_SVC_FAIL, "The %s service failed to stop.\n"
+ STRING_START_SVC, "The %1 service is starting.\n"
+ STRING_START_SVC_SUCCESS, "The %1 service was started successfully.\n"
+ STRING_START_SVC_FAIL, "The %1 service failed to start.\n"
+ STRING_STOP_SVC, "The %1 service is stopping.\n"
+ STRING_STOP_SVC_SUCCESS, "The %1 service was stopped successfully.\n"
+ STRING_STOP_SVC_FAIL, "The %1 service failed to stop.\n"
STRING_RUNNING_HEADER, "The following services are running:\n"
STRING_NO_ENTRIES, "There are no entries in the list.\n"
STRING_USE_HEADER, "\nStatus Local Remote\n---------------------------------------------------------------\n"
- STRING_USE_ENTRY, "%s %s %s Open resources: %lu\n"
+ STRING_USE_ENTRY, "%1 %2 %3 Open resources: %4!u!\n"
STRING_OK, "OK"
STRING_PAUSED, "Paused"
STRING_SESSLOST, "Disconnected"
--
1.7.6.3
More information about the wine-patches
mailing list