【Kareha】 Comma Thread Syntax? (26)

22 Name: Mr VacBob!JqK7T7zan. 2005-01-21 23:40 ID:4GAOAN4q (Replies) [Del]

The >> posting regex being used right now matches every comma in an anchor, even if it's at the end and doesn't mean anything. This screws up some sentences a little:
"What this all really means, though, is that you, >>1, should just stick with today's special."

I can't get one to work; it seems to need at least extended regexp syntax, and I don't know enough of that to do something useful.

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;

}

11 Name: !WAHa.06x36 2005-01-13 08:07 ID:Nzgs9ur2 (Replies) [Del]

Yeah, I'm not too fond of the replies link either, but it does make the feature much more accessible. If the reply number wasn't already used for the quoting, I'd use that. Can anyone think up any other more elegant way to do this?

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