From 958b524bca7eb7daabc618e187fc978cd097a406 Mon Sep 17 00:00:00 2001 From: landry Date: Wed, 27 Mar 2013 21:23:38 +0000 Subject: [PATCH] Unbreak now that we have a working p5-Gtk2 \o/ --- .../patches/patch-lib_XKCD_Core_pm | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 misc/xkcd-viewer/patches/patch-lib_XKCD_Core_pm diff --git a/misc/xkcd-viewer/patches/patch-lib_XKCD_Core_pm b/misc/xkcd-viewer/patches/patch-lib_XKCD_Core_pm new file mode 100644 index 00000000000..2438aaccd4b --- /dev/null +++ b/misc/xkcd-viewer/patches/patch-lib_XKCD_Core_pm @@ -0,0 +1,49 @@ +$OpenBSD: patch-lib_XKCD_Core_pm,v 1.1 2013/03/27 21:23:38 landry Exp $ +Fix breakage - code assumed xkcd would never reach 1000th comic :) +--- lib/XKCD/Core.pm.orig Wed Mar 27 22:21:00 2013 ++++ lib/XKCD/Core.pm Wed Mar 27 22:21:14 2013 +@@ -38,7 +38,7 @@ sub GetTotal { + my $self = shift; + my $progressbar = shift; + my $content = _GetData('http://xkcd.com', $progressbar) || return 0; +- $content =~ / http:\/\/xkcd.com\/(\d{1,3})\//; ++ $content =~ / http:\/\/xkcd.com\/(\d{1,5})\//; + $self->{total} = $1; + $self->{number} = $self->{total}; + return $self; +@@ -89,7 +89,7 @@ sub GetRandom { + my $self = shift; + my $progressbar = shift; + my $content = _GetData('http://dynamic.xkcd.com/comic/random/', $progressbar); +- $content =~ / http:\/\/xkcd.com\/(\d{1,3})\//; ++ $content =~ / http:\/\/xkcd.com\/(\d{1,5})\//; + $self->{number} = $1; + return $self; + } +@@ -112,7 +112,7 @@ sub SaveImage { + my $file = shift || "/tmp/xkcd" . $self->{number} if ($self->{number}); + my $progressbar = shift; + $self->{file} = $file; +- if (($file) && (-e $file) && ($file =~ /xkcd\d{1,3}/)) { ++ if (($file) && (-e $file) && ($file =~ /xkcd\d{1,5}/)) { + return $file; + } + $self->GetDirectLink || return 0; +@@ -198,7 +198,7 @@ sub _GetResults { + my $search = shift || return; + my $current_page = shift || 1; + my $content = _GetData("http://www.ohnorobot.com/index.pl?e=0;show=advanced;n=0;m=0;d=0;s=" . $search . ";p=" . $current_page . ";Search=Search;b=0;comic=56;t=0"); +- my $search_regex = '

(.+?)<\/a><\/p>'; ++ my $search_regex = '

(.+?)<\/a><\/p>'; + my %results; + + while ($content =~ /$search_regex/) { +@@ -249,7 +249,7 @@ sub SetNumber { + my $self = shift; + if (@_) { + my $new_num = shift; +- $self->{number} = $new_num if (($new_num =~ /\d{1,3}/) && ($new_num <= $self->{total})); ++ $self->{number} = $new_num if (($new_num =~ /\d{1,5}/) && ($new_num <= $self->{total})); + } + return $self; + }