mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Now that we are building with C++11 features enabled, replace use of NULL with nullptr. The benefit of using nullptr is that it can never be confused for an integral type because it does not support implicit conversions to integral types except boolean - unlike NULL, which is defined as a literal `0`.
68 lines
2.5 KiB
C++
68 lines
2.5 KiB
C++
// Copyright Joyent, Inc. and other Node contributors.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
// following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included
|
|
// in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
#include "node.h"
|
|
|
|
#ifdef _WIN32
|
|
int wmain(int argc, wchar_t *wargv[]) {
|
|
// Convert argv to to UTF8
|
|
char** argv = new char*[argc];
|
|
for (int i = 0; i < argc; i++) {
|
|
// Compute the size of the required buffer
|
|
DWORD size = WideCharToMultiByte(CP_UTF8,
|
|
0,
|
|
wargv[i],
|
|
-1,
|
|
nullptr,
|
|
0,
|
|
nullptr,
|
|
nullptr);
|
|
if (size == 0) {
|
|
// This should never happen.
|
|
fprintf(stderr, "Could not convert arguments to utf8.");
|
|
exit(1);
|
|
}
|
|
// Do the actual conversion
|
|
argv[i] = new char[size];
|
|
DWORD result = WideCharToMultiByte(CP_UTF8,
|
|
0,
|
|
wargv[i],
|
|
-1,
|
|
argv[i],
|
|
size,
|
|
nullptr,
|
|
nullptr);
|
|
if (result == 0) {
|
|
// This should never happen.
|
|
fprintf(stderr, "Could not convert arguments to utf8.");
|
|
exit(1);
|
|
}
|
|
}
|
|
// Now that conversion is done, we can finally start.
|
|
return node::Start(argc, argv);
|
|
}
|
|
#else
|
|
// UNIX
|
|
int main(int argc, char *argv[]) {
|
|
return node::Start(argc, argv);
|
|
}
|
|
#endif
|