[interchange] Clear or don't check $@ in cases where eval is not called
Jon Jensen <[email protected]> Thu, 02 Nov 2017 05:54:25 +0000
| Newsgroups | gmane.comp.web.interchange.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 9bba0b5e907712fdc14cd6c947ffb83489efd66d Author: Jon Jensen <[email protected]> Date: Wed Nov 1 19:15:24 2017 -0600 Clear or don't check $@ in cases where eval is not called The contents of $@ are unknown if eval isn't run, so we can't rely on it unless we set it ourselves. lib/Vend/Config.pm | 14 ++++++-------- lib/Vend/DbSearch.pm | 9 +++++---- lib/Vend/Glimpse.pm | 8 +++++--- lib/Vend/RefSearch.pm | 6 ++++-- lib/Vend/Search.pm | 6 ++++-- lib/Vend/Session.pm | 4 +++- lib/Vend/Ship.pm | 4 +++- lib/Vend/TextSearch.pm | 7 ++++--- 8 files changed, 34 insertions(+), 24 deletions(-) --- diff --git a/lib/Vend/Config.pm b/lib/Vend/Config.pm index 662beec..69bdd8c 100644 --- a/lib/Vend/Config.pm +++ b/lib/Vend/Config.pm @@ -54,7 +54,7 @@ use Vend::Data; use Vend::Cron; use Vend::CharSet (); -$VERSION = '2.249'; +$VERSION = '2.250'; my %CDname; my %CPname; @@ -787,10 +787,8 @@ sub global_chunk { eval { $GlobalRead->($lvar, $value); }; - if($@ =~ /Duplicate\s+usertag/i) { - next; - } - if($@) { + if ($@) { + next if $@ =~ /Duplicate\s+usertag/i; ::logDebug("error running global $lvar: $@"); } } @@ -865,9 +863,7 @@ sub code_from_file { eval { $GlobalRead->($lvar, $value); }; - if($@ =~ /Duplicate\s+usertag/i) { - next; - } + next if $@ =~ /Duplicate\s+usertag/i; } close SYSTAG; close NEWTAG; @@ -2201,6 +2197,8 @@ sub parse_action { $sub =~ s/^\s*((?s:.)*\S)\s*//; $sub = $1; + # clear errors for code paths below that don't call eval or reval + undef $@; if($sub !~ /\s/) { no strict 'refs'; if($sub =~ /::/ and ! $C) { diff --git a/lib/Vend/DbSearch.pm b/lib/Vend/DbSearch.pm index 6ff26ad..1532cea 100644 --- a/lib/Vend/DbSearch.pm +++ b/lib/Vend/DbSearch.pm @@ -2,7 +2,7 @@ # # Adapted for use with Interchange from Search::TextSearch # -# Copyright (C) 2002-2007 Interchange Development Group +# Copyright (C) 2002-2017 Interchange Development Group # Copyright (C) 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify @@ -25,7 +25,7 @@ require Vend::Search; @ISA = qw(Vend::Search); -$VERSION = substr(q$Revision: 2.27 $, 10); +$VERSION = '2.28'; use Search::Dict; use strict; @@ -198,7 +198,9 @@ sub search { if ($s->{mv_search_error}) { return $s; } - + + # clear errors for non-eval code paths below + undef $@; if ($s->{mv_coordinate}) { undef $f; } @@ -219,7 +221,6 @@ sub search { ), @pats )}; } - $@ and return $s->search_error("Function creation: $@"); my $qual; diff --git a/lib/Vend/Glimpse.pm b/lib/Vend/Glimpse.pm index 33ca3d6..97606c6 100644 --- a/lib/Vend/Glimpse.pm +++ b/lib/Vend/Glimpse.pm @@ -2,7 +2,7 @@ # # Adapted for use with Interchange from Search::Glimpse # -# Copyright (C) 2002-2007 Interchange Development Group +# Copyright (C) 2002-2017 Interchange Development Group # Copyright (C) 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify @@ -24,7 +24,7 @@ package Vend::Glimpse; require Vend::Search; @ISA = qw(Vend::Search); -$VERSION = substr(q$Revision: 2.16 $, 10); +$VERSION = '2.17'; use strict; use Vend::File; use Vend::Util; @@ -189,6 +189,8 @@ sub search { my $joiner = $s->{mv_orsearch}[0] ? ',' : ';'; + # clear errors for non-eval code paths below + undef $@; if ($s->{mv_coordinate}) { undef $f; } @@ -213,8 +215,8 @@ sub search { ), @pats )}; } - $@ and return $s->search_error("Function creation: $@"); + local($/) = $s->{mv_record_delim} || "\n"; $s->save_specs(); diff --git a/lib/Vend/RefSearch.pm b/lib/Vend/RefSearch.pm index e58b0b6..d5e9b5b 100644 --- a/lib/Vend/RefSearch.pm +++ b/lib/Vend/RefSearch.pm @@ -2,7 +2,7 @@ # # Adapted for use with Interchange from Search::TextSearch # -# Copyright (C) 2002-2007 Interchange Development Group +# Copyright (C) 2002-2017 Interchange Development Group # Copyright (C) 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify @@ -25,7 +25,7 @@ require Vend::Search; @ISA = qw(Vend::Search); -$VERSION = substr(q$Revision: 2.11 $, 10); +$VERSION = '2.12'; use strict; no warnings qw(uninitialized numeric); @@ -129,6 +129,8 @@ sub search { @pats = $s->spec_check(@specs); + # clear errors for non-eval code path + undef $@; if ($s->{mv_coordinate}) { undef $f; } diff --git a/lib/Vend/Search.pm b/lib/Vend/Search.pm index 6689aef..10f5300 100644 --- a/lib/Vend/Search.pm +++ b/lib/Vend/Search.pm @@ -964,8 +964,10 @@ EOF ::logDebug("filter function code is: $f") if $Global::DebugFile and $CGI::values{debug}; use locale; - $f = eval $f if $f and ! ref $f; - die($@) if $@; + if ($f and ! ref $f) { + $f = eval $f; + die($@) if $@; + } my $relate; if(scalar @code > 1) { $relate = 'return ( '; diff --git a/lib/Vend/Session.pm b/lib/Vend/Session.pm index a70387a..7eb23e2 100644 --- a/lib/Vend/Session.pm +++ b/lib/Vend/Session.pm @@ -1,6 +1,6 @@ # Vend::Session - Interchange session routines # -# Copyright (C) 2002-2013 Interchange Development Group +# Copyright (C) 2002-2017 Interchange Development Group # Copyright (C) 1996-2002 Red Hat, Inc. # # This program was originally based on Vend 0.2 and 0.3 @@ -466,6 +466,8 @@ sub read_session { #::logDebug ("Session:\n$s\n"); return new_session($seed) unless $s; + + undef $@; $Vend::Session = ref $s ? $s : evalr($s); die "Could not eval '$s' from session dbm: $@\n" if $@; diff --git a/lib/Vend/Ship.pm b/lib/Vend/Ship.pm index 9dd417d..160339d 100644 --- a/lib/Vend/Ship.pm +++ b/lib/Vend/Ship.pm @@ -1,6 +1,6 @@ # Vend::Ship - Interchange shipping code # -# Copyright (C) 2002-2015 Interchange Development Group +# Copyright (C) 2002-2017 Interchange Development Group # Copyright (C) 1996-2002 Red Hat, Inc. # # This program was originally based on Vend 0.2 and 0.3 @@ -329,6 +329,8 @@ sub read_shipping { $zone = $1 if ! $zone; next if defined $zones{$zone}; my $ref; + # clear errors for non-eval code paths below + undef $@; if ($o->{zone}) { $ref = {}; my @common = qw/ diff --git a/lib/Vend/TextSearch.pm b/lib/Vend/TextSearch.pm index 910b25f..b931c18 100644 --- a/lib/Vend/TextSearch.pm +++ b/lib/Vend/TextSearch.pm @@ -2,7 +2,7 @@ # # Adapted for use with Interchange from Search::TextSearch # -# Copyright (C) 2002-2008 Interchange Development Group +# Copyright (C) 2002-2017 Interchange Development Group # Copyright (C) 1996-2002 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify @@ -27,7 +27,7 @@ require Exporter; use vars qw(@ISA); @ISA = qw(Vend::Search); -$VERSION = substr(q$Revision: 2.18 $, 10); +$VERSION = '2.19'; use Search::Dict; use strict; @@ -144,6 +144,8 @@ sub search { @pats = $s->spec_check(@specs); + # clear errors for non-eval code paths + undef $@; if ($s->{mv_coordinate}) { undef $f; } @@ -164,7 +166,6 @@ sub search { ), @pats )}; } - $@ and return $s->search_error("Function creation: $@"); local($/) = $s->{mv_record_delim} || "\n";