Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!apple!sun-barr!newstop!texsun!convex!tchrist From: tchrist@convex.com (Tom Christiansen) Newsgroups: comp.lang.perl Subject: core dumping bug w/ sort? Message-ID: <100180@convex.convex.com> Date: 22 Feb 90 11:36:08 GMT Sender: news@convex.com Reply-To: tchrist@convex.Com (Tom Christiansen) Organization: Convex Computer Corp, Richardson, TX Lines: 37 Here is a reduced piece of code that will generate a quick core dump on a Sun and a Convex. Just clip and run. The weird thing is that the sort sub seems is being called with null args that just aren't in the passed list. I suppose it's possible that I'm doing something stupid here, but even if so, I don't really think I deserve a coredump. --tom #================= CLIP HERE ============================================= # $MANSECT = "1nlp6823457tX"; # Add 'X' to avoid core dump $MANSECT = "1nlp6823457t"; # notice no 'X' here; we're going to dump core @foo = &sortem; print "foo is @foo\n"; sub sortem { @list = ('foo.3', 'bar.X'); return sort bysection @list; } sub bysection { print STDERR "comparing \"$a\" with \"$b\"\n"; $a1 = index($MANSECT,substr($a,rindex($a,'.')+1,1)); $a2 = index($MANSECT,substr($b,rindex($b,'.')+1,1)); if ($a1 == $a2) { return 0; } else { return ($a2 < 0 || $a1 < $a2) ? -1 : 1; } } #================= CLIP HERE ============================================= -- Tom Christiansen {uunet,uiucdcs,sun}!convex!tchrist Convex Computer Corporation tchrist@convex.COM "EMACS belongs in : Editor too big!"