Skip to content

Commit 38734dc

Browse files
authored
Add files via upload
1 parent fe0d8b9 commit 38734dc

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

cppsp_compiler.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
#include <cstdlib>
99
#include <unordered_map>
1010
#include <functional>
11-
11+
bool isWindows=false;bool isMac=false;bool isLinux =false;
12+
#if defined(_WIN32) || defined(_WIN64)
13+
#define isWindows 1
14+
#elif defined(__APPLE__) && defined(__MACH__)
15+
#define isMac 1
16+
#elif defined(__linux__)
17+
#define isLinux 1
18+
#endif
1219
//檢查dll依賴:objdump -p cppsp_compiler.exe | findstr ".dll"
1320

1421
namespace fs = std::filesystem;
@@ -200,16 +207,18 @@ std::string parseIni(const std::string& path, const std::string& flag) {
200207
std::ifstream infile(path);
201208
if (!infile) return "";
202209

203-
std::string line;
204-
std::getline(infile, line);
210+
std::string line;
211+
std::string result;
212+
while(std::getline(infile, line)){
205213
std::stringstream ss(line);
206214
std::string token;
207-
std::string result;
208215
while (std::getline(ss, token, ',')) {
209216
if (!token.empty()) {
210-
result += flag + "\"" + token + "\" ";
217+
result += flag+ "\"" + token + "\" ";
211218
}
212219
}
220+
221+
}
213222
return result;
214223
}
215224
// 判斷字串是否為布林值
@@ -248,6 +257,7 @@ int main(int argc, char* argv[]) {
248257
double iorf = std::stod(cur);
249258
if (iorf == (int)iorf) out += "{ int _t = " + cur + "; printf(\"%d\", _t); }\n";
250259
else out += "{ double _t = " + cur + "; printf(\"%g\", _t); }\n"; }
260+
else if(cur[0]== 'L') out +=(Ifiostream)? "std::wcout<<"+cur+";\n" :"wprintf("+cur+");\n";
251261
else if(Ifiostream==true) out +="std::cout<<"+cur+";\n";
252262
else { out += "printf(" + cur + ");\n";}
253263
}
@@ -367,8 +377,8 @@ if (!comment && importline.find("import ") != std::string::npos) {
367377
outfile << "\nreturn 0;\n}\n";
368378
if(enableoverwrite) outfile << "*/";
369379
outfile.close();
370-
371-
fs::path exePath = cpsPath.parent_path() / (cpsPath.stem().string() );// .exe後綴 : + ".exe");
380+
std::string local=(isMac || isLinux)? "./":"";
381+
fs::path exePath = cpsPath.parent_path() / (local+cpsPath.stem().string() );// .exe後綴 : + ".exe");
372382

373383
// 讀 include.ini 和 lib.ini
374384
std::string includeFlags = parseIni("include.ini", "-I");

cppsp_compiler.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)