|
8 | 8 | #include <cstdlib> |
9 | 9 | #include <unordered_map> |
10 | 10 | #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 |
12 | 19 | //檢查dll依賴:objdump -p cppsp_compiler.exe | findstr ".dll" |
13 | 20 |
|
14 | 21 | namespace fs = std::filesystem; |
@@ -200,16 +207,18 @@ std::string parseIni(const std::string& path, const std::string& flag) { |
200 | 207 | std::ifstream infile(path); |
201 | 208 | if (!infile) return ""; |
202 | 209 |
|
203 | | - std::string line; |
204 | | - std::getline(infile, line); |
| 210 | + std::string line; |
| 211 | + std::string result; |
| 212 | + while(std::getline(infile, line)){ |
205 | 213 | std::stringstream ss(line); |
206 | 214 | std::string token; |
207 | | - std::string result; |
208 | 215 | while (std::getline(ss, token, ',')) { |
209 | 216 | if (!token.empty()) { |
210 | | - result += flag + "\"" + token + "\" "; |
| 217 | + result += flag+ "\"" + token + "\" "; |
211 | 218 | } |
212 | 219 | } |
| 220 | + |
| 221 | + } |
213 | 222 | return result; |
214 | 223 | } |
215 | 224 | // 判斷字串是否為布林值 |
@@ -248,6 +257,7 @@ int main(int argc, char* argv[]) { |
248 | 257 | double iorf = std::stod(cur); |
249 | 258 | if (iorf == (int)iorf) out += "{ int _t = " + cur + "; printf(\"%d\", _t); }\n"; |
250 | 259 | else out += "{ double _t = " + cur + "; printf(\"%g\", _t); }\n"; } |
| 260 | + else if(cur[0]== 'L') out +=(Ifiostream)? "std::wcout<<"+cur+";\n" :"wprintf("+cur+");\n"; |
251 | 261 | else if(Ifiostream==true) out +="std::cout<<"+cur+";\n"; |
252 | 262 | else { out += "printf(" + cur + ");\n";} |
253 | 263 | } |
@@ -367,8 +377,8 @@ if (!comment && importline.find("import ") != std::string::npos) { |
367 | 377 | outfile << "\nreturn 0;\n}\n"; |
368 | 378 | if(enableoverwrite) outfile << "*/"; |
369 | 379 | 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"); |
372 | 382 |
|
373 | 383 | // 讀 include.ini 和 lib.ini |
374 | 384 | std::string includeFlags = parseIni("include.ini", "-I"); |
|
0 commit comments