summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2015-05-29 16:55:23 +0100
committerChristopher Smith <chris@jalakai.co.uk>2015-05-29 16:55:23 +0100
commite12c5ac781d560502d478775502df70cd80472de (patch)
tree01c29375b4cf46a737709e01bb39c801adfe45b1 /inc
parent3dfe7d64760baa568018c1d6d311c26d1a2da098 (diff)
downloadrpg-e12c5ac781d560502d478775502df70cd80472de.tar.gz
rpg-e12c5ac781d560502d478775502df70cd80472de.tar.bz2
Minor Refactoring
- put test comments in more appropriate spot - move appending replacement line alongside its search/delete code
Diffstat (limited to 'inc')
-rw-r--r--inc/io.php14
1 files changed, 7 insertions, 7 deletions
diff --git a/inc/io.php b/inc/io.php
index c559feb17..4c7fb094f 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -324,14 +324,14 @@ function io_replaceInFile($file, $oldline, $newline, $regex=false, $maxlines=0)
$lines[$i] = preg_replace($pattern, $replace, $line, -1, $matched);
if ($matched) $count++;
}
- } else {
- $lines = ($maxlines == 0) ?
- preg_grep($pattern, $lines, PREG_GREP_INVERT) :
- preg_replace($pattern, $replace, $lines);
- }
+ } else if ($maxlines == 0) {
+ $lines = preg_grep($pattern, $lines, PREG_GREP_INVERT);
- if($maxlines == 0 && ((string)$newline) !== '') {
- $lines[] = $newline;
+ if ((string)$newline !== ''){
+ $lines[] = $newline;
+ }
+ } else {
+ $lines = preg_replace($pattern, $replace, $lines);
}
if(count($lines)){