The bits that need changing.
To fix bug 1:
PHP Code:
if (strstr($line, "}")) {
$tab--;
}
which fines the } and increase the tabbing by 1
and
PHP Code:
if (strstr($line, "{")) {
$tab++;
}
that decrease the tabbing by one.
The script is cycling through line by line so it is checking for the } or { and changing the tab setting for that.
I tried to do a regex on it but I don't like them and what i tried was not working.
To fix the others is not easy because you have to insert lines.
PHP Code:
}
if (!((strstr($line, "\")) OR (strstr($line, "####")))) {
$new_file .= growstring("\t", $tab);
}
$new_file .= trim($line) . "\n";
if (strstr($line, "{")) {
$tab++;
}
}
is where you are doing it.
I would guess the logic would be:
1) do the regex to match if ($action == "do") { echo "do"; }
2) Split it so that you have
if ($action == "do") { as one line
echo "do"; as another
and } as another
the change the code to:
PHP Code:
if (our_new_regex) {
$new_file .= growstring("\t", $tab);
$new_file .= "first part of array from regex\n";
$tab++;
$new_file .= growstring("\t", $tab);
$new_file .= "2nd part of regex\n";
$tab--;
$new_file .= growstring("\t", $tab);
$new_file .= "3rd part of regex\n";
} else {
if (!((strstr($line, "\")) OR (strstr($line, "####")))) {
$new_file .= growstring("\t", $tab);
}
$new_file .= trim($line) . "\n";
if (strstr($line, "{")) {
$tab++;
}
}
} // end bracket from new processing just added.
Bookmarks