@@ -6,7 +6,8 @@ Taken from:
66
77This license applies only to this file:
88
9- Copyright (C) 2001-2017 Julian Raschke, Jan Lücker and all contributors.
9+ Copyright (C) 2001-2023 Julian Raschke, Jan Lücker, cyberarm, and all
10+ other contributors: https://github.com/gosu/gosu/graphs/contributors
1011
1112Permission is hereby granted, free of charge, to any person obtaining a
1213copy of this software and associated documentation files (the "Software"),
@@ -27,58 +28,51 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2728DEALINGS IN THE SOFTWARE.
2829
2930 Julian Raschke <[email protected] > & contributors 30- http ://www.libgosu.org/
31+ https ://www.libgosu.org/
3132
3233*/
3334
3435// #ifdef _MSC_VER
3536#ifdef _WIN32
3637
37- #include < windows.h>
3838#include < exception>
3939#include < string>
4040#include < vector>
41+ #include < windows.h>
4142using namespace std ;
4243
43- vector<string> splitCmdLine ()
44+ vector<string> split_cmd_line ()
4445{
4546 vector<string> result;
4647
47- const char * cmdLine = ::GetCommandLineA ();
48+ const char * cmd_line = ::GetCommandLineA ();
4849
49- const char * argBegin = 0 ;
50- bool isQuotedArg = false ;
50+ const char * arg_begin = nullptr ;
51+ bool is_quoted_arg = false ;
5152
52- while (*cmdLine)
53- {
54- if (*cmdLine == ' "' )
55- {
56- if (argBegin == 0 )
57- {
58- argBegin = cmdLine + 1 ;
59- isQuotedArg = true ;
53+ while (*cmd_line) {
54+ if (*cmd_line == ' "' ) {
55+ if (arg_begin == nullptr ) {
56+ arg_begin = cmd_line + 1 ;
57+ is_quoted_arg = true ;
6058 }
61- else if (isQuotedArg)
62- {
63- result.push_back (std::string (argBegin, cmdLine));
64- argBegin = 0 ;
59+ else if (is_quoted_arg) {
60+ result.push_back (string (arg_begin, cmd_line));
61+ arg_begin = nullptr ;
6562 }
6663 }
67- else if (!isspace ((unsigned char )*cmdLine) && argBegin == 0 )
68- {
69- argBegin = cmdLine;
70- isQuotedArg = false ;
64+ else if (!isspace ((unsigned char )*cmd_line) && arg_begin == nullptr ) {
65+ arg_begin = cmd_line;
66+ is_quoted_arg = false ;
7167 }
72- else if (isspace ((unsigned char )*cmdLine) && argBegin != 0 && !isQuotedArg)
73- {
74- result.push_back (std::string (argBegin, cmdLine + 1 ));
75- argBegin = 0 ;
68+ else if (isspace ((unsigned char )*cmd_line) && arg_begin != nullptr && !is_quoted_arg) {
69+ result.push_back (string (arg_begin, cmd_line + 1 ));
70+ arg_begin = nullptr ;
7671 }
77- ++cmdLine ;
72+ ++cmd_line ;
7873 }
7974
80- if (argBegin != 0 )
81- result.push_back (argBegin);
75+ if (arg_begin != 0 ) result.push_back (arg_begin);
8276
8377 return result;
8478}
@@ -87,20 +81,18 @@ int main(int argc, char* argv[]);
8781
8882int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int )
8983{
90- try
91- {
92- vector<string> arguments = splitCmdLine ();
84+ try {
85+ vector<string> arguments = split_cmd_line ();
9386 vector<char *> argv (arguments.size ());
94- for (unsigned i = 0 ; i < argv.size (); ++i)
87+ for (unsigned i = 0 ; i < argv.size (); ++i) {
9588 argv[i] = const_cast <char *>(arguments[i].c_str ());
89+ }
9690 return main (argv.size (), &argv[0 ]);
9791 }
98- catch (const std::exception& e)
99- {
92+ catch (const exception& e) {
10093 ::MessageBoxA (0 , e.what(), "Uncaught Exception", MB_OK | MB_ICONERROR);
10194 return EXIT_FAILURE;
10295 }
10396}
10497
10598#endif
106-
0 commit comments