-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c++
30 lines (26 loc) · 952 Bytes
/
main.c++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <string>
std::string with_end_statements(std::istream&);
#ifdef _WIN32
# include <io.h> // _setmode
# include <fcntl.h>
static void use_newlines_without_linefeeds_in_output()
{
(void)_setmode(_fileno(stdout), O_BINARY);
(void)_setmode(_fileno(stderr), O_BINARY);
}
#endif
int main(int, const char* const argv[])
try
{
#ifdef _WIN32
use_newlines_without_linefeeds_in_output(); // Unix-style line endings are used when running on Windows in case the generated script ever needs to be run on Unix; Vim on Unix will throw "E492: Not an editor command: ^M" on reading a Vim script file with Windows-style line endings. (It's ok to use Unix-style line endings on Windows though.)
#endif
std::cout << "\" THIS WAS GENERATED BY " << argv[0] << "\n\n"
<< with_end_statements(std::cin);
}
catch (const char* const exception)
{
std::cerr << argv[0] << ": " << exception << '\n';
return 1;
}