mirror of
https://github.com/aimrebirth/tools.git
synced 2026-04-15 01:43:25 +00:00
Minor improvements in beautifier.
This commit is contained in:
parent
5e9b0d1e06
commit
165d48d8a5
2 changed files with 16 additions and 2 deletions
|
|
@ -79,8 +79,13 @@ struct script
|
||||||
const std::string space = " ";
|
const std::string space = " ";
|
||||||
int brace_count = 0;
|
int brace_count = 0;
|
||||||
int proc_started = 0;
|
int proc_started = 0;
|
||||||
|
bool proc_started_now = false;
|
||||||
for (auto &line : lines)
|
for (auto &line : lines)
|
||||||
{
|
{
|
||||||
|
if (proc_started_now && line.find("{") != line.npos)
|
||||||
|
{
|
||||||
|
proc_started--;
|
||||||
|
}
|
||||||
if (brace_count > 0 || proc_started > 0)
|
if (brace_count > 0 || proc_started > 0)
|
||||||
{
|
{
|
||||||
auto space_count = brace_count + proc_started;
|
auto space_count = brace_count + proc_started;
|
||||||
|
|
@ -97,8 +102,11 @@ struct script
|
||||||
line.find("()") != line.npos)
|
line.find("()") != line.npos)
|
||||||
{
|
{
|
||||||
proc_started++;
|
proc_started++;
|
||||||
|
proc_started_now = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (proc_started_now)
|
||||||
|
proc_started_now = false;
|
||||||
if (line.find("END") != line.npos && proc_started == 1)
|
if (line.find("END") != line.npos && proc_started == 1)
|
||||||
{
|
{
|
||||||
proc_started--;
|
proc_started--;
|
||||||
|
|
@ -130,6 +138,12 @@ struct script
|
||||||
replace_all(s, "\nIF", "\n\nIF");
|
replace_all(s, "\nIF", "\n\nIF");
|
||||||
replace_all(s, "PROC", "PROC ");
|
replace_all(s, "PROC", "PROC ");
|
||||||
replace_all(s, "END\nPROC", "END\n\nPROC");
|
replace_all(s, "END\nPROC", "END\n\nPROC");
|
||||||
|
replace_all(s, "|", " || ");
|
||||||
|
replace_all(s, "&", " && ");
|
||||||
|
replace_all(s, "(", "( ");
|
||||||
|
replace_all(s, ")", " )");
|
||||||
|
replace_all(s, ",", ", ");
|
||||||
|
replace_all(s, "!", "! ");
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
@for /r %%v in (*.scr) do script2txt.exe "%%v"
|
@for /r %%v in (*.scr) do @script2txt.exe "%%v"
|
||||||
@for /r %%v in (*.QST) do script2txt.exe "%%v"
|
@for /r %%v in (*.QST) do @script2txt.exe "%%v"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue