From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 50BBA17DCAB4 for ; Wed, 20 Jan 2016 11:09:35 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id C773BB5D843 for ; Wed, 20 Jan 2016 11:43:13 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 2B8D518CC7B1 for ; Wed, 20 Jan 2016 11:43:14 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id DD8E4120440; Wed, 20 Jan 2016 11:43:12 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by neon.ruby-lang.org (Postfix) with ESMTP id 8420512040B for ; Wed, 20 Jan 2016 11:43:09 +0900 (JST) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A63C41F434; Wed, 20 Jan 2016 02:43:08 +0000 (UTC) Date: Wed, 20 Jan 2016 02:43:08 +0000 From: Eric Wong To: ruby-core@ruby-lang.org Message-ID: <20160120024308.GA5484@dcvr.yhbt.net> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-ML-Name: ruby-core X-Mail-Count: 72959 Subject: [ruby-core:72959] Re: [Ruby trunk - Feature #12010] [Assigned] Exclude dot and dotdot from Dir#each X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" naruse@airemix.jp wrote: > Dir#each and Dir#read) (including Dir.entries, Dir.foreach and other methods) return "." and ".." at first. > But through the all real use case "." and ".." are useless. > How about excluding them? If Ruby were a new language, yes. But I think it is too risky, now. > +#define DIR_IS_DOT_OR_DOTDOT(dp) ((dp)->d_name[0] == '.' && \ > + ((dp)->d_name[1] == '\0' || ((dp)->d_name[1] == '.' && (dp)->d_name[2] == '\0'))) Anyways, I prefer we reduce macro usage and use static inline functions to avoid potential side effects, extra '\' and parentheses.