mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-14 17:33:25 +00:00
Misc.
This commit is contained in:
parent
161cd9d95e
commit
55e95ba805
1 changed files with 11 additions and 3 deletions
|
|
@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {
|
|||
// write script
|
||||
{
|
||||
filename += ".txt";
|
||||
if (std::ofstream ofile(filename); ofile) {
|
||||
if (std::ofstream ofile(filename, std::ios::binary); ofile) {
|
||||
std::string indent, space = " "s;
|
||||
auto inc = [&]() {
|
||||
indent += space;
|
||||
|
|
@ -56,12 +56,19 @@ int main(int argc, char *argv[]) {
|
|||
return false;
|
||||
};
|
||||
int procs{};
|
||||
bool prev_newline{};
|
||||
for (auto &&l : lines) {
|
||||
auto else_ = l == "ELSE"sv;
|
||||
auto proc = l.starts_with("PROC"sv);
|
||||
auto end = l == "END"sv;
|
||||
auto lbrace = l == "{"sv;
|
||||
auto rbrace = l == "}"sv;
|
||||
|
||||
if (else_ && prev_newline) {
|
||||
ofile.seekp(-1, std::ios::cur);
|
||||
}
|
||||
prev_newline = false;
|
||||
|
||||
if (rbrace) {
|
||||
if (!dec()) {
|
||||
ofile << "// script2txt2 comment: unbalanced!\n";
|
||||
|
|
@ -75,8 +82,9 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
ofile << indent << l << "\n";
|
||||
|
||||
if (end && indent.empty()) {
|
||||
//ofile << "\n";
|
||||
if ((end || rbrace) && indent.empty()) {
|
||||
ofile << "\n";
|
||||
prev_newline = true;
|
||||
}
|
||||
if (end && procs) {
|
||||
procs = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue