From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19831 invoked by alias); 12 Jan 2017 15:51:13 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40336 Received: (qmail 25702 invoked from network); 12 Jan 2017 15:51:13 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(-0.7/5.0):. Processed in 1.839331 secs); 12 Jan 2017 15:51:13 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=PodRKynM0Y3ympu piEAiOz4ztwQ=; b=KPYgBzWO1Mrdlue3LqoH1BzaWfdijZ5yVrvzZ3T6FXScwC3 qcoQ83R73aOS3B28iAr/wPtmDtfUjaeHrEsY0JJFJaPuoaUKm7bfvPBATTjNs0vz Tu/wGA8hhTpwLNIuecGmbhmb+kctK/Qwx9V9aTOhp07OIQ5eVcTJsXc9NORA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=PodRKynM0Y3ymp upiEAiOz4ztwQ=; b=e/ycL6lhoDP5HHN61oXFpQvZcYIJQi9Fz2wryIKE1rX5hm UsBI6B84e/rtDgb8z35nvtS7OcfJ/6IExfQuVl2Abm1x2WpQlbRuTbbrNjooGf8L yTEYHg/3NwfF3nHeXghYvOnWdpo8Oe/vchT0BVOnsPdTp0EuPd5P43mRjsAUk= X-ME-Sender: X-Sasl-enc: y5Ugzw3qh3IkQeVkWWLor+CUxWVSAZuFzpRgq2P2gtFr 1484235862 Date: Thu, 12 Jan 2017 15:40:57 +0000 From: Daniel Shahaf To: Peter Stephenson Cc: Zsh Hackers' List Subject: Re: PATCH: autoload with explicit path Message-ID: <20170112154057.GA4899@fujitsu.shahaf.local2> References: <20170112125602.4fa64dc6@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170112125602.4fa64dc6@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.23 (2014-03-12) Peter Stephenson wrote on Thu, Jan 12, 2017 at 12:56:02 +0000: > The problem is the overloading of filename in struct shfunc. If the > function was alrady loaded, which is the case if it contains an > explicit autoload -X (rather than one generated internally by looking > at the flags for an undefined function), then the filename indicates the > location of the source for the function. If this came from a file with > an absolute path, and there was no explicit directory path in the > autoload -X statement, the file path was erroneously taken as a > directory for loading. > > This adds an explicit flag to indicate filename is being used for that > purpose, unsetting it when the filename is set to the file's path. I would suggest using two separate struct members, rather than one whose semantics depend on a flag. It'd be too easy to forget to check the flag in some (existing or future) location. E.g., struct shfunc { char *filename1; /* Name of file located in */ char *filename2; /* Name of file to autoload from */ }; We could also put these two members in a union{} if they are mutually exclusive (if at least one of them is NULL at all times).