From c62c24ca42bee905f1e94af5004d0cb460bc2c54 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sat, 15 May 2010 00:39:19 +0000 Subject: [PATCH] Better handling of undo -- if just undo, then show undone code; otherwise, if undo and substitution, execute --- modules/ideone.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/ideone.pl b/modules/ideone.pl index eb4a4e95..12b767fc 100755 --- a/modules/ideone.pl +++ b/modules/ideone.pl @@ -14,6 +14,8 @@ my $pass = 'test'; my $soap = SOAP::Lite->new(proxy => 'http://ideone.com/api/1/service'); my $result; +my $MAX_UNDO_HISTORY = 100; + my $output = ""; my $nooutput = 'No output.'; @@ -204,16 +206,22 @@ while($subcode =~ s/^\s*(and)?\s*undo//) { open FILE, "> ideone_last_code.txt"; -unshift @last_code, $code unless ($got_undo and not $got_sub); +unless ($got_undo and not $got_sub) { + unshift @last_code, $code; +} my $i = 0; foreach my $line (@last_code) { - last if(++$i > 10); + last if(++$i > $MAX_UNDO_HISTORY); print FILE "$line\n"; } - close FILE; +if($got_undo and not $got_sub) { + print "$nick: $code\n"; + exit 0; +} + open FILE, ">> ideone_log.txt"; print FILE "$nick: $code\n";