Skip to content

Commit 221c870

Browse files
committed
Fix as.exe crash on Windows
Code previously used to convert command-line arguments from wide encoding to UTF-8 we used when `as.exe` was built with MinGW, is no longer necessary. It was causing the app to crash on Windows.
1 parent 534baa2 commit 221c870

File tree

4 files changed

+1
-25
lines changed

4 files changed

+1
-25
lines changed

src/gas/gas.hh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ namespace xamarin::android::gas
167167
~Gas ()
168168
{}
169169

170-
void get_command_line (int &argc, char **&argv);
171-
172170
int run (int argc, char **argv);
173171

174172
const std::string& program_name () const noexcept
@@ -217,5 +215,4 @@ namespace xamarin::android::gas
217215
};
218216
}
219217

220-
extern xamarin::android::gas::Gas app;
221218
#endif // __GAS_HH

src/gas/gas.posix.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
using namespace xamarin::android::gas;
88

9-
void Gas::get_command_line ([[maybe_unused]] int &argc, [[maybe_unused]] char **&argv)
10-
{
11-
}
12-
139
void Gas::determine_program_dir ([[maybe_unused]] int argc, char **argv)
1410
{
1511
fs::path program_path { argv[0] };

src/gas/gas.windows.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@
1313

1414
using namespace xamarin::android::gas;
1515

16-
void Gas::get_command_line (int &argc, char **&argv)
17-
{
18-
LPWSTR *argvw = CommandLineToArgvW (GetCommandLineW (), &argc);
19-
argv = new char*[argc + 1];
20-
21-
for (int i = 0; i < argc; i++) {
22-
int size = WideCharToMultiByte (CP_UTF8, 0, argvw [i], -1, NULL, 0, NULL, NULL);
23-
argv [i] = new char [size];
24-
WideCharToMultiByte (CP_UTF8, 0, argvw [i], -1, argv [i], size, NULL, NULL);
25-
}
26-
27-
argv [argc] = NULL;
28-
}
29-
3016
void Gas::determine_program_dir ([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
3117
{
3218
TCHAR buffer[MAX_PATH + 1]{};

src/gas/main.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
// SPDX-License-Identifier: MIT
22
#include "gas.hh"
33

4-
xamarin::android::gas::Gas app;
5-
64
int main (int argc, char **argv)
75
{
8-
// On windows this obtains the utf8 version of args
9-
app.get_command_line (argc, argv);
6+
xamarin::android::gas::Gas app;
107
// TODO: handle exceptions here (use backward for stacktrace perhaps?)
118
return app.run (argc, argv);
129
}

0 commit comments

Comments
 (0)