This commit is contained in:
blueloveTH 2024-06-02 23:29:20 +08:00
parent 426993552c
commit 2ea64ce41f
3 changed files with 37 additions and 29 deletions

View File

@ -2,3 +2,5 @@
BasedOnStyle: Google
IndentWidth: 4
UseTab: Never
IndentPPDirectives: BeforeHash

View File

@ -15,7 +15,8 @@ def get_all_files(root: str):
yield fullpath
if __name__ == '__main__':
files = list(get_all_files('src'))
files = []
# files.extend(get_all_files('include'))
# files.extend(get_all_files('src'))
files.extend(get_all_files('src2'))
files.extend(get_all_files('include'))
subprocess.run(['clang-format-15', '-i'] + files, check=True)
subprocess.run(['clang-format', '-i'] + files, check=True)

View File

@ -1,5 +1,5 @@
#include <fstream>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <sstream>
@ -24,10 +24,13 @@ std::string pkpy_platform_getline(bool* eof){
wss << buf;
}
std::wstring wideInput = wss.str();
int length = WideCharToMultiByte(CP_UTF8, 0, wideInput.c_str(), (int)wideInput.length(), NULL, 0, NULL, NULL);
int length =
WideCharToMultiByte(CP_UTF8, 0, wideInput.c_str(),
(int)wideInput.length(), NULL, 0, NULL, NULL);
std::string output;
output.resize(length);
WideCharToMultiByte(CP_UTF8, 0, wideInput.c_str(), (int)wideInput.length(), &output[0], length, NULL, NULL);
WideCharToMultiByte(CP_UTF8, 0, wideInput.c_str(), (int)wideInput.length(),
&output[0], length, NULL, NULL);
if (!output.empty() && output.back() == '\r') output.pop_back();
return output;
}
@ -97,12 +100,14 @@ int main(int argc, char** argv){
std::cerr << "Failed to open file: " << argv_1 << std::endl;
return 3;
}
std::string src((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
std::string src((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
file.close();
pkpy_set_main_argv(vm, argc, argv);
bool ok = pkpy_exec_2(vm, src.c_str(), filepath.filename().string().c_str(), 0, NULL);
bool ok = pkpy_exec_2(vm, src.c_str(),
filepath.filename().string().c_str(), 0, NULL);
if (!ok) pkpy_clear_error(vm, NULL);
pkpy_delete_vm(vm);
return ok ? 0 : 1;