summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/indexer.php27
1 files changed, 10 insertions, 17 deletions
diff --git a/inc/indexer.php b/inc/indexer.php
index 8174f73d0..954512673 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -391,26 +391,19 @@ function idx_writeIndexLine($fh,$line,$pid,$count){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function idx_updateIndexLine($line,$pid,$count){
- $line = trim($line);
- $updated = array();
- if($line != ''){
- $parts = explode(':',$line);
- // remove doc from given line
- foreach($parts as $part){
- if($part == '') continue;
- list($doc,$cnt) = explode('*',$part);
- if($doc != $pid){
- $updated[] = $part;
- }
- }
+ if ($line == ''){
+ $newLine = "\n";
+ }else{
+ $newLine = preg_replace('/(^|:)'.preg_quote($pid, '/').'\*\d*/', '', $line);
}
-
- // add doc
if ($count){
- $updated[] = "$pid*$count";
+ if (strlen($newLine) > 1){
+ return "$pid*$count:".$newLine;
+ }else{
+ return "$pid*$count".$newLine;
+ }
}
-
- return join(':',$updated)."\n";
+ return $newLine;
}
/**