summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSBeans <info@kayakporn.com>2012-11-28 10:46:51 +0000
committerSBeans <info@kayakporn.com>2012-11-28 10:46:51 +0000
commitef86f6e9a29a631c7df62dd55fd5edbdfab53d55 (patch)
treee3fee43c347abe8db091fe54515bbf2106a7c1c0
parentde4ed030647a8067ecc26121bc635195b9a4c6eb (diff)
Fixed -l (showing more than 5 results) and -r (not displaying text of deleted line).
-rw-r--r--blasource.php17
1 files changed, 9 insertions, 8 deletions
diff --git a/blasource.php b/blasource.php
index f634584..5cc8793 100644
--- a/blasource.php
+++ b/blasource.php
@@ -9,8 +9,9 @@
// 0.1.1 Fixed -l option for listing for sources.
// 0.1.2 Checked -l page number to see if there are any results.
// 0.2.0 Fixed -l so it shows 5 results. Added -c Count added -r remove and updated help
+ // 0.2.1 Fixed -l (showing too many results) and -r (Not showing text of removed line
- $version = "BlaSource Version: 0.2.0";
+ $version = "BlaSource Version: 0.2.1";
// get the input
$stdin = read_stdin();
@@ -46,7 +47,7 @@
exec("echo $line >> blatemp.txt");
$lineNo++;
}
- else
+ else if ($line != "")
{
$stringRemove = $line;
$lineNo++;
@@ -56,11 +57,11 @@
echo "Removed line " . $lineToRemove . ": " . $stringRemove. ".";
break;
case "-l":
- $last = str_replace(":", "",exec("grep -n \"\" blasource.txt | tail -n 1")) / 5;
- $look = 0;
+ $last = str_replace(":", "",exec("grep -n \"\" blasource.txt | tail -n 1")) / 5 + 1;
+ $page = 0;
if(!isset($stdin[$i+1]))
{
- $look = 1;
+ $page = 1;
}
else
{
@@ -72,14 +73,14 @@
}
else
{
- $look = $stdin[$i+1];
+ $page = $stdin[$i+1];
$i++;
}
}
- $X = ($look*5)-5;
- for($j=0;$j<6;$j++)
+ $X = ($page*5)-5;
+ for($j=1;$j<6;$j++)
{
$bla = $j+$X;
$temp = exec("grep -n \"\" blasource.txt | head -n" . $bla . " | tail -n1") . " ";