@@ -20,17 +20,17 @@ PrintError(LPCWSTR wszPrefix, DWORD dwError)
20
20
DWORD cch = 0 ;
21
21
22
22
cch = FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER
23
- | FORMAT_MESSAGE_FROM_SYSTEM
24
- | FORMAT_MESSAGE_IGNORE_INSERTS ,
25
- NULL , dwError , LANG_NEUTRAL ,
26
- (LPTSTR )& lpsz , 0 , NULL );
23
+ | FORMAT_MESSAGE_FROM_SYSTEM
24
+ | FORMAT_MESSAGE_IGNORE_INSERTS ,
25
+ NULL , dwError , LANG_NEUTRAL ,
26
+ (LPTSTR )& lpsz , 0 , NULL );
27
27
if (cch < 1 ) {
28
- cch = FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER
29
- | FORMAT_MESSAGE_FROM_STRING
30
- | FORMAT_MESSAGE_ARGUMENT_ARRAY ,
31
- L"Code 0x%1!08x!" ,
32
- 0 , LANG_NEUTRAL , (LPTSTR )& lpsz , 0 ,
33
- (va_list * )& dwError );
28
+ cch = FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER
29
+ | FORMAT_MESSAGE_FROM_STRING
30
+ | FORMAT_MESSAGE_ARGUMENT_ARRAY ,
31
+ L"Code 0x%1!08x!" ,
32
+ 0 , LANG_NEUTRAL , (LPTSTR )& lpsz , 0 ,
33
+ (va_list * )& dwError );
34
34
}
35
35
fwprintf (stderr , L"%s: %s" , wszPrefix , lpsz );
36
36
LocalFree ((HLOCAL )lpsz );
@@ -56,38 +56,38 @@ main(void)
56
56
57
57
/* if not set, set TERM to msys */
58
58
if (GetEnvironmentVariable (L"TERM" , NULL , 0 ) == 0 ) {
59
- SetEnvironmentVariable (L"TERM" , L"msys" );
59
+ SetEnvironmentVariable (L"TERM" , L"msys" );
60
60
}
61
61
62
62
/* if not set, set PLINK_PROTOCOL to ssh */
63
63
if (GetEnvironmentVariable (L"PLINK_PROTOCOL" , NULL , 0 ) == 0 ) {
64
- SetEnvironmentVariable (L"PLINK_PROTOCOL" , L"ssh" );
64
+ SetEnvironmentVariable (L"PLINK_PROTOCOL" , L"ssh" );
65
65
}
66
66
67
67
/* set HOME to %HOMEDRIVE%%HOMEPATH% or %USERPROFILE%
68
68
* With roaming profiles: HOMEPATH is the roaming location and
69
69
* USERPROFILE is the local location
70
70
*/
71
71
if (GetEnvironmentVariable (L"HOME" , NULL , 0 ) == 0 ) {
72
- LPWSTR e = NULL ;
73
- len = GetEnvironmentVariable (L"HOMEPATH" , NULL , 0 );
74
- if (len == 0 ) {
75
- len = GetEnvironmentVariable (L"USERPROFILE" , NULL , 0 );
76
- if (len != 0 ) {
77
- e = (LPWSTR )malloc (len * sizeof (WCHAR ));
78
- GetEnvironmentVariable (L"USERPROFILE" , e , len );
79
- SetEnvironmentVariable (L"HOME" , e );
80
- free (e );
81
- }
82
- } else {
83
- int n ;
84
- len += GetEnvironmentVariable (L"HOMEDRIVE" , NULL , 0 );
85
- e = (LPWSTR )malloc (sizeof (WCHAR ) * (len + 2 ));
86
- n = GetEnvironmentVariable (L"HOMEDRIVE" , e , len );
87
- GetEnvironmentVariable (L"HOMEPATH" , & e [n ], len - n );
88
- SetEnvironmentVariable (L"HOME" , e );
89
- free (e );
90
- }
72
+ LPWSTR e = NULL ;
73
+ len = GetEnvironmentVariable (L"HOMEPATH" , NULL , 0 );
74
+ if (len == 0 ) {
75
+ len = GetEnvironmentVariable (L"USERPROFILE" , NULL , 0 );
76
+ if (len != 0 ) {
77
+ e = (LPWSTR )malloc (len * sizeof (WCHAR ));
78
+ GetEnvironmentVariable (L"USERPROFILE" , e , len );
79
+ SetEnvironmentVariable (L"HOME" , e );
80
+ free (e );
81
+ }
82
+ } else {
83
+ int n ;
84
+ len += GetEnvironmentVariable (L"HOMEDRIVE" , NULL , 0 );
85
+ e = (LPWSTR )malloc (sizeof (WCHAR ) * (len + 2 ));
86
+ n = GetEnvironmentVariable (L"HOMEDRIVE" , e , len );
87
+ GetEnvironmentVariable (L"HOMEPATH" , & e [n ], len - n );
88
+ SetEnvironmentVariable (L"HOME" , e );
89
+ free (e );
90
+ }
91
91
}
92
92
93
93
/* extend the PATH */
@@ -100,7 +100,7 @@ main(void)
100
100
wcscat (path2 , exepath );
101
101
PathAppend (path2 , L"mingw\\bin;" );
102
102
GetEnvironmentVariable (L"PATH" , & path2 [wcslen (path2 )],
103
- (len /sizeof (WCHAR ))- wcslen (path2 ));
103
+ (len /sizeof (WCHAR ))- wcslen (path2 ));
104
104
SetEnvironmentVariable (L"PATH" , path2 );
105
105
free (path2 );
106
106
@@ -111,75 +111,75 @@ main(void)
111
111
* untouched.
112
112
*/
113
113
{
114
- int wargc = 0 , gui = 0 ;
115
- LPWSTR cmdline = NULL ;
116
- LPWSTR * wargv = NULL , p = NULL ;
117
- cmdline = GetCommandLine ();
118
- wargv = CommandLineToArgvW (cmdline , & wargc );
119
- cmd = (LPWSTR )malloc (sizeof (WCHAR ) * (wcslen (cmdline ) + MAX_PATH ));
120
- if (wargc > 1 && wcsicmp (L"gui" , wargv [1 ]) == 0 ) {
121
- wait = 0 ;
122
- if (wargc > 2 && wcsicmp (L"citool" , wargv [2 ]) == 0 ) {
123
- wait = 1 ;
124
- wcscpy (cmd , L"git.exe" );
125
- } else {
126
- WCHAR script [MAX_PATH ];
127
- gui = 1 ;
128
- wcscpy (script , exepath );
129
- PathAppend (script , L"libexec\\git-core\\git-gui" );
130
- PathQuoteSpaces (script );
131
- wcscpy (cmd , L"wish.exe " );
132
- wcscat (cmd , script );
133
- wcscat (cmd , L" --" );
134
- exep = NULL ; /* find the module from the commandline */
135
- }
136
- } else {
137
- wcscpy (cmd , L"git.exe" );
138
- }
139
- /* find the first space after the initial parameter then append all */
140
- p = wcschr (& cmdline [wcslen (wargv [0 ])], L' ' );
141
- if (p && * p ) {
142
- /* for git gui subcommands, remove the 'gui' word */
143
- if (gui ) {
144
- while (* p == L' ' ) ++ p ;
145
- p = wcschr (p , L' ' );
146
- }
147
- if (p && * p )
148
- wcscat (cmd , p );
149
- }
150
- LocalFree (wargv );
114
+ int wargc = 0 , gui = 0 ;
115
+ LPWSTR cmdline = NULL ;
116
+ LPWSTR * wargv = NULL , p = NULL ;
117
+ cmdline = GetCommandLine ();
118
+ wargv = CommandLineToArgvW (cmdline , & wargc );
119
+ cmd = (LPWSTR )malloc (sizeof (WCHAR ) * (wcslen (cmdline ) + MAX_PATH ));
120
+ if (wargc > 1 && wcsicmp (L"gui" , wargv [1 ]) == 0 ) {
121
+ wait = 0 ;
122
+ if (wargc > 2 && wcsicmp (L"citool" , wargv [2 ]) == 0 ) {
123
+ wait = 1 ;
124
+ wcscpy (cmd , L"git.exe" );
125
+ } else {
126
+ WCHAR script [MAX_PATH ];
127
+ gui = 1 ;
128
+ wcscpy (script , exepath );
129
+ PathAppend (script , L"libexec\\git-core\\git-gui" );
130
+ PathQuoteSpaces (script );
131
+ wcscpy (cmd , L"wish.exe " );
132
+ wcscat (cmd , script );
133
+ wcscat (cmd , L" --" );
134
+ exep = NULL ; /* find the module from the commandline */
135
+ }
136
+ } else {
137
+ wcscpy (cmd , L"git.exe" );
138
+ }
139
+ /* find the first space after the initial parameter then append all */
140
+ p = wcschr (& cmdline [wcslen (wargv [0 ])], L' ' );
141
+ if (p && * p ) {
142
+ /* for git gui subcommands, remove the 'gui' word */
143
+ if (gui ) {
144
+ while (* p == L' ' ) ++ p ;
145
+ p = wcschr (p , L' ' );
146
+ }
147
+ if (p && * p )
148
+ wcscat (cmd , p );
149
+ }
150
+ LocalFree (wargv );
151
151
}
152
152
153
153
/* set the console to ANSI/GUI codepage */
154
154
codepage = GetConsoleCP ();
155
155
SetConsoleCP (GetACP ());
156
156
157
157
{
158
- STARTUPINFO si ;
159
- PROCESS_INFORMATION pi ;
160
- BOOL br = FALSE;
161
- ZeroMemory (& pi , sizeof (PROCESS_INFORMATION ));
162
- ZeroMemory (& si , sizeof (STARTUPINFO ));
163
- si .cb = sizeof (STARTUPINFO );
164
- br = CreateProcess (exep ,/* module: null means use command line */
165
- cmd , /* modified command line */
166
- NULL , /* process handle inheritance */
167
- NULL , /* thread handle inheritance */
168
- TRUE, /* handles inheritable? */
169
- CREATE_UNICODE_ENVIRONMENT ,
170
- NULL , /* environment: use parent */
171
- NULL , /* starting directory: use parent */
172
- & si , & pi );
173
- if (br ) {
174
- if (wait )
175
- WaitForSingleObject (pi .hProcess , INFINITE );
176
- if (!GetExitCodeProcess (pi .hProcess , (DWORD * )& r ))
177
- PrintError (L"error reading exit code" , GetLastError ());
178
- CloseHandle (pi .hProcess );
179
- } else {
180
- PrintError (L"error launching git" , GetLastError ());
181
- r = 1 ;
182
- }
158
+ STARTUPINFO si ;
159
+ PROCESS_INFORMATION pi ;
160
+ BOOL br = FALSE;
161
+ ZeroMemory (& pi , sizeof (PROCESS_INFORMATION ));
162
+ ZeroMemory (& si , sizeof (STARTUPINFO ));
163
+ si .cb = sizeof (STARTUPINFO );
164
+ br = CreateProcess (exep ,/* module: null means use command line */
165
+ cmd , /* modified command line */
166
+ NULL , /* process handle inheritance */
167
+ NULL , /* thread handle inheritance */
168
+ TRUE, /* handles inheritable? */
169
+ CREATE_UNICODE_ENVIRONMENT ,
170
+ NULL , /* environment: use parent */
171
+ NULL , /* starting directory: use parent */
172
+ & si , & pi );
173
+ if (br ) {
174
+ if (wait )
175
+ WaitForSingleObject (pi .hProcess , INFINITE );
176
+ if (!GetExitCodeProcess (pi .hProcess , (DWORD * )& r ))
177
+ PrintError (L"error reading exit code" , GetLastError ());
178
+ CloseHandle (pi .hProcess );
179
+ } else {
180
+ PrintError (L"error launching git" , GetLastError ());
181
+ r = 1 ;
182
+ }
183
183
}
184
184
185
185
free (cmd );
0 commit comments