GCC Code Coverage Report
Directory: ../src/ Exec Total Coverage
File: /home/node-core-coverage/node-core-coverage/workdir/node/out/../src/node_main.cc Lines: 4 4 100.0 %
Date: 2016-12-16 Branches: 0 0 0.0 %

Line Branch Exec Source
1
#include "node.h"
2
3
#ifdef _WIN32
4
#include <VersionHelpers.h>
5
#include <WinError.h>
6
7
int wmain(int argc, wchar_t *wargv[]) {
8
  if (!IsWindows7OrGreater()) {
9
    fprintf(stderr, "This application is only supported on Windows 7, "
10
                    "Windows Server 2008 R2, or higher.");
11
    exit(ERROR_EXE_MACHINE_TYPE_MISMATCH);
12
  }
13
14
  // Convert argv to to UTF8
15
  char** argv = new char*[argc + 1];
16
  for (int i = 0; i < argc; i++) {
17
    // Compute the size of the required buffer
18
    DWORD size = WideCharToMultiByte(CP_UTF8,
19
                                     0,
20
                                     wargv[i],
21
                                     -1,
22
                                     nullptr,
23
                                     0,
24
                                     nullptr,
25
                                     nullptr);
26
    if (size == 0) {
27
      // This should never happen.
28
      fprintf(stderr, "Could not convert arguments to utf8.");
29
      exit(1);
30
    }
31
    // Do the actual conversion
32
    argv[i] = new char[size];
33
    DWORD result = WideCharToMultiByte(CP_UTF8,
34
                                       0,
35
                                       wargv[i],
36
                                       -1,
37
                                       argv[i],
38
                                       size,
39
                                       nullptr,
40
                                       nullptr);
41
    if (result == 0) {
42
      // This should never happen.
43
      fprintf(stderr, "Could not convert arguments to utf8.");
44
      exit(1);
45
    }
46
  }
47
  argv[argc] = nullptr;
48
  // Now that conversion is done, we can finally start.
49
  return node::Start(argc, argv);
50
}
51
#else
52
// UNIX
53
1729
int main(int argc, char *argv[]) {
54
  // Disable stdio buffering, it interacts poorly with printf()
55
  // calls elsewhere in the program (e.g., any logging from V8.)
56
1729
  setvbuf(stdout, nullptr, _IONBF, 0);
57
1729
  setvbuf(stderr, nullptr, _IONBF, 0);
58
1729
  return node::Start(argc, argv);
59
}
60
#endif