Hugh McMaster : regsvr32: Move / i command line code to a separate function.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jun 16 10:13:14 CDT 2015
Module: wine
Branch: master
Commit: 00c13a20a6a078aa9582c7c2523d9d9591ef0011
URL: http://source.winehq.org/git/wine.git/?a=commit;h=00c13a20a6a078aa9582c7c2523d9d9591ef0011
Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date: Mon Jun 15 21:46:06 2015 +1000
regsvr32: Move /i command line code to a separate function.
---
programs/regsvr32/regsvr32.c | 70 +++++++++++++++++++++-----------------------
1 file changed, 33 insertions(+), 37 deletions(-)
diff --git a/programs/regsvr32/regsvr32.c b/programs/regsvr32/regsvr32.c
index 624acd6..e048b30 100644
--- a/programs/regsvr32/regsvr32.c
+++ b/programs/regsvr32/regsvr32.c
@@ -202,6 +202,37 @@ static int InstallDll(BOOL install, char *strDll, WCHAR *command_line)
return 0;
}
+static WCHAR *parse_command_line(char *command_line)
+{
+ WCHAR *ret = NULL;
+
+ if (command_line[0] == ':' && command_line[1])
+ {
+ int len = strlen(command_line);
+
+ command_line++;
+ len--;
+ /* remove double quotes */
+ if (command_line[0] == '"')
+ {
+ command_line++;
+ len--;
+ if (command_line[0])
+ {
+ len--;
+ command_line[len] = 0;
+ }
+ }
+ if (command_line[0])
+ {
+ len = MultiByteToWideChar(CP_ACP, 0, command_line, -1, NULL, 0);
+ ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ if (ret) MultiByteToWideChar(CP_ACP, 0, command_line, -1, ret, len);
+ }
+ }
+ return ret;
+}
+
int main(int argc, char* argv[])
{
int i;
@@ -227,45 +258,10 @@ int main(int argc, char* argv[])
Silent = TRUE;
else if ((!strncasecmp(argv[i], "/i", strlen("/i")))||(!strncasecmp(argv[i], "-i", strlen("-i"))))
{
- CHAR* command_line = argv[i] + strlen("/i");
-
CallInstall = TRUE;
- if (command_line[0] == ':' && command_line[1])
- {
- int len = strlen(command_line);
-
- command_line++;
- len--;
- /* remove double quotes */
- if (command_line[0] == '"')
- {
- command_line++;
- len--;
- if (command_line[0])
- {
- len--;
- command_line[len] = 0;
- }
- }
- if (command_line[0])
- {
- len = MultiByteToWideChar(CP_ACP, 0, command_line, -1,
- NULL, 0);
- wsCommandLine = HeapAlloc(GetProcessHeap(), 0,
- len * sizeof(WCHAR));
- if (wsCommandLine)
- MultiByteToWideChar(CP_ACP, 0, command_line, -1,
- wsCommandLine, len);
- }
- else
- {
- wsCommandLine = EmptyLine;
- }
- }
- else
- {
+ wsCommandLine = parse_command_line(argv[i] + strlen("/i"));
+ if (!wsCommandLine)
wsCommandLine = EmptyLine;
- }
}
else if((!strcasecmp(argv[i], "/n"))||(!strcasecmp(argv[i], "-n")))
CallRegister = FALSE;
More information about the wine-cvs
mailing list