sync with 766647f: prompt, only 1 file, flush on err

This commit is contained in:
2025-11-18 23:55:37 +08:00
parent 7a0044914c
commit b5983f505f

View File

@@ -262,6 +262,8 @@ void output_object(PycRef<PycObject> obj, PycModule* mod, int indent,
int main(int argc, char* argv[])
{
fputs("LilRan's fork of Pycdc, output will be written to <filename>.das and <filename>.cdc.py\n", stderr);
const char* infile = nullptr;
const char* outfile = nullptr;
bool marshalled = false;
@@ -304,8 +306,12 @@ int main(int argc, char* argv[])
} else if (argv[arg][0] == '-') {
fprintf(stderr, "Error: Unrecognized argument %s\n", argv[arg]);
return 1;
} else {
} else if (!infile) {
infile = argv[arg];
} else {
fprintf(stderr, "Error: Only one input file allowed, got %s and %s\n",
infile, argv[arg]);
return 1;
}
}
@@ -361,6 +367,8 @@ int main(int argc, char* argv[])
output_object(mod.code().try_cast<PycObject>(), &mod, 0, disasm_flags,
das_out_file);
} catch (std::exception& ex) {
das_out_file.flush();
das_out_file.close();
fprintf(stderr, "Error disassembling %s: %s\n", infile, ex.what());
return 1;
}
@@ -375,6 +383,8 @@ int main(int argc, char* argv[])
try {
decompyle(mod.code(), &mod, dc_out_file);
} catch (std::exception& ex) {
dc_out_file.flush();
dc_out_file.close();
fprintf(stderr, "Error decompyling %s: %s\n", infile, ex.what());
return 1;
}