From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10188 invoked from network); 20 Apr 2004 12:10:13 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 20 Apr 2004 12:10:13 -0000 Received: (qmail 10479 invoked by alias); 20 Apr 2004 12:10:04 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19801 Received: (qmail 10456 invoked from network); 20 Apr 2004 12:10:03 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 20 Apr 2004 12:10:03 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 20 Apr 2004 12:10:3 -0000 Received: (qmail 28741 invoked from network); 20 Apr 2004 12:10:03 -0000 Received: from lhuumrelay3.lnd.ops.eu.uu.net (62.189.58.19) by a.mx.sunsite.dk with SMTP; 20 Apr 2004 12:10:00 -0000 Received: from MAILSWEEPER01.csr.com (mailhost1.csr.com [62.189.183.235]) by lhuumrelay3.lnd.ops.eu.uu.net (8.11.0/8.11.0) with ESMTP id i3KC9Xv18290 for ; Tue, 20 Apr 2004 12:09:33 GMT Received: from EXCHANGE02.csr.com (unverified [192.168.137.45]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Tue, 20 Apr 2004 13:09:06 +0100 Received: from csr.com ([192.168.144.127]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 20 Apr 2004 13:10:13 +0100 To: zsh-workers@sunsite.dk Subject: Re: Bug/misfeature with autoloaded TRAPxxx functions In-reply-to: "Bart Schaefer"'s message of "Tue, 13 Apr 2004 05:15:24 -0000." <1040413051524.ZM19991@candle.brasslantern.com> Date: Tue, 20 Apr 2004 13:09:32 +0100 Message-ID: <13673.1082462972@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 20 Apr 2004 12:10:13.0631 (UTC) FILETIME=[6F5808F0:01C426D0] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.2 required=6.0 tests=EXCUSE_16 autolearn=no version=2.63 X-Spam-Hits: 0.2 Bart Schaefer wrote: > ... autoloaded TRAP functions don't work... I don't think this ever got added... It might be as simple as the following, which seems to work. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.114 diff -u -r1.114 builtin.c --- Src/builtin.c 6 Apr 2004 09:25:18 -0000 1.114 +++ Src/builtin.c 20 Apr 2004 12:05:12 -0000 @@ -2499,14 +2499,32 @@ /* no flags, so just print */ shfunctab->printnode((HashNode) shf, pflags); } else if (on & PM_UNDEFINED) { + int signum, ok = 1; + /* Add a new undefined (autoloaded) function to the * * hash table with the corresponding flags set. */ shf = (Shfunc) zshcalloc(sizeof *shf); shf->flags = on; shf->funcdef = mkautofn(shf); - shfunctab->addnode(shfunctab, ztrdup(*argv), shf); - if (OPT_ISSET(ops,'X') && eval_autoload(shf, shf->nam, ops, func)) - returnval = 1; + + if (!strncmp(*argv, "TRAP", 4) && + (signum = getsignum(*argv + 4)) != -1) { + if (settrap(signum, shf->funcdef)) { + freeeprog(shf->funcdef); + zfree(shf, sizeof(*shf)); + returnval = 1; + ok = 0; + } + else + sigtrapped[signum] |= ZSIG_FUNC; + } + + if (ok) { + shfunctab->addnode(shfunctab, ztrdup(*argv), shf); + if (OPT_ISSET(ops,'X') && + eval_autoload(shf, shf->nam, ops, func)) + returnval = 1; + } } else returnval = 1; } -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************