mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43: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
|
// write script
|
||||||
{
|
{
|
||||||
filename += ".txt";
|
filename += ".txt";
|
||||||
if (std::ofstream ofile(filename); ofile) {
|
if (std::ofstream ofile(filename, std::ios::binary); ofile) {
|
||||||
std::string indent, space = " "s;
|
std::string indent, space = " "s;
|
||||||
auto inc = [&]() {
|
auto inc = [&]() {
|
||||||
indent += space;
|
indent += space;
|
||||||
|
|
@ -56,12 +56,19 @@ int main(int argc, char *argv[]) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
int procs{};
|
int procs{};
|
||||||
|
bool prev_newline{};
|
||||||
for (auto &&l : lines) {
|
for (auto &&l : lines) {
|
||||||
|
auto else_ = l == "ELSE"sv;
|
||||||
auto proc = l.starts_with("PROC"sv);
|
auto proc = l.starts_with("PROC"sv);
|
||||||
auto end = l == "END"sv;
|
auto end = l == "END"sv;
|
||||||
auto lbrace = l == "{"sv;
|
auto lbrace = l == "{"sv;
|
||||||
auto rbrace = l == "}"sv;
|
auto rbrace = l == "}"sv;
|
||||||
|
|
||||||
|
if (else_ && prev_newline) {
|
||||||
|
ofile.seekp(-1, std::ios::cur);
|
||||||
|
}
|
||||||
|
prev_newline = false;
|
||||||
|
|
||||||
if (rbrace) {
|
if (rbrace) {
|
||||||
if (!dec()) {
|
if (!dec()) {
|
||||||
ofile << "// script2txt2 comment: unbalanced!\n";
|
ofile << "// script2txt2 comment: unbalanced!\n";
|
||||||
|
|
@ -75,8 +82,9 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
ofile << indent << l << "\n";
|
ofile << indent << l << "\n";
|
||||||
|
|
||||||
if (end && indent.empty()) {
|
if ((end || rbrace) && indent.empty()) {
|
||||||
//ofile << "\n";
|
ofile << "\n";
|
||||||
|
prev_newline = true;
|
||||||
}
|
}
|
||||||
if (end && procs) {
|
if (end && procs) {
|
||||||
procs = 0;
|
procs = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue