【Kareha】 Comma Thread Syntax? (26)

20 Name: !WAHa.06x36 2005-01-20 06:59 ID:31LyLntx (Replies) [Del]

I scan the entire thread. I figured it's done seldom enough that speed isn't crucial. It's not THAT slow, either, at least not with my data storage setup (keeping posts on separate single lines of a HTML file).

Here's the relevant code (@page contains the lines of the current thread page, $num is the argument to q, @posts is filled with a list of which posts to display, $replyrange_re is a regexp to match the >> syntax, in_range() checks if a certain post number is contained in a >> reference.

push @posts,$num;
OUTER: foreach my $post (1..$total)
{
next if($post eq $num);
while($page[$post+1]=~/>>($replyrange_re)/g)
{
if(in_range($num,$1)) { push @posts,$post; next OUTER; }
}
}

Here's in_range():

sub in_range($$)
{

my ($num,$ranges)=@_;
foreach my $range (split /(,|,)/,$ranges)
{
if($range=~/^([0-9]*)-([0-9]*)$/)
{
my $start=($1 or 1);
my $end=($2 or 1000000); # arbitary large number
		($start,$end)=($end,$start) if($start>$end);
		return 1 if($num>=$start and $num<=$end);
}
elsif($range=~/^([0-9]+)$/)
{
return 1 if($num==$1);
}
#elsif($range=~/^l([0-9]+)$/i) {} # l ranges never match
#elsif($range=~/^r([0-9]*)$/i) {} # r ranges never match
#elsif($range=~/^q([0-9]+)$/i) {} # q ranges never match
}
return 0;

}

13 Name: Mr VacBob!JqK7T7zan. 2005-01-13 12:28 ID:LDDx8kYI (Replies) [Del]

>>12
I was thinking of 2ch browser-like programs. Being able to query for every reply to a certain post is easier on bandwidth and CPU on both sides than HTML scraping.

4 Name: Mr VacBob!JqK7T7zan.!!47oS1MzU 2005-01-12 13:07 ID:rGCo5B4Y [Del]

I've been thinking of more extensions to that. The only useful one that I can think of is 'qX', which would display every post with an anchor to X. That would be kind of slow, though.

This thread has been closed. You cannot post in this thread any longer.