From: Eric Wong <normalperson@...>
Date: 2016-01-20T02:43:08+00:00
Subject: [ruby-core:72959] Re: [Ruby trunk - Feature #12010] [Assigned] Exclude dot and dotdot from Dir#each

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.

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>