From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kenichi Handa Newsgroups: gmane.emacs.devel Subject: Recent change to file-chase-links has a bug Date: Wed, 9 Apr 2003 16:10:47 +0900 (JST) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200304090710.QAA15874@etlken.m17n.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII X-Trace: main.gmane.org 1049872337 23285 80.91.224.249 (9 Apr 2003 07:12:17 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 9 Apr 2003 07:12:17 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Apr 09 09:12:15 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1939kl-00063Q-00 for ; Wed, 09 Apr 2003 09:12:15 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 1939p8-0007ZR-00 for ; Wed, 09 Apr 2003 09:16:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 1939kH-0001Mu-08 for emacs-devel@quimby.gnus.org; Wed, 09 Apr 2003 03:11:45 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 1939jt-0000vq-00 for emacs-devel@gnu.org; Wed, 09 Apr 2003 03:11:21 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 1939je-000066-00 for emacs-devel@gnu.org; Wed, 09 Apr 2003 03:11:09 -0400 Original-Received: from tsukuba.m17n.org ([192.47.44.130]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 1939jT-0008B5-00 for emacs-devel@gnu.org; Wed, 09 Apr 2003 03:10:55 -0400 Original-Received: from fs.m17n.org (fs.m17n.org [192.47.44.2])h397Amo12556 for ; Wed, 9 Apr 2003 16:10:48 +0900 (JST) (envelope-from handa@m17n.org) Original-Received: from etlken.m17n.org (etlken.m17n.org [192.47.44.125]) by fs.m17n.org (8.11.6/3.7W-20010823150639) with ESMTP id h397AmA29139 for ; Wed, 9 Apr 2003 16:10:48 +0900 (JST) Original-Received: (from handa@localhost) by etlken.m17n.org (8.8.8+Sun/3.7W-2001040620) id QAA15874; Wed, 9 Apr 2003 16:10:47 +0900 (JST) Original-To: emacs-devel@gnu.org User-Agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:13067 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:13067 This change has a bug. 2003-04-08 Richard M. Stallman [...] * files.el (file-chase-links): New arg LIMIT. After that many iterations, just return what we've got. Now the code is as below: (defun file-chase-links (filename &optional limit) "Chase links in FILENAME until a name that is not a link. Unlike `file-truename', this does not check whether a parent directory name is a symbolic link. If the optional argument LIMIT is a number, it means chase no more than that many links and then stop." (let (tem (newname filename) (count 0) (max (max limit 100))) (while (and (or (null limit) (< count limit)) (setq tem (file-symlink-p newname))) (save-match-data (if (= count max) (error "Apparent cycle of symbolic links for %s" filename)) At least, (max limit 100) must be: (max (if (numberp limit) limit 0) 100) Otherwise, for instance, C-x 4 a signals an error. And, if the docstring is correct, actually the code must be something like this: (defun file-chase-links (filename &optional limit) [...] (let (tem (newname filename) (count 0) (max 100) (while (and (or (not (numberp limit)) (< count limit)) (setq tem (file-symlink-p newname))) (save-match-data (if (= count max) (error "Apparent cycle of symbolic links for %s" filename)) But, I have not yet installed that fix because it seems that the original line "(max (max limit 100))" suggests some other intention, e.g., "don't allow a limit less than 100". --- Ken'ichi HANDA handa@m17n.org