From c00ef709855f9ae64d1d95fce78c1cfd57073098 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 18 Feb 2009 03:01:03 +0000 Subject: * file.c (file_expand_path): suppress a warning. named magic numbers. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- file.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'file.c') diff --git a/file.c b/file.c index 4155d33a1..29d401016 100644 --- a/file.c +++ b/file.c @@ -2780,7 +2780,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) } #if USE_NTFS else { - do *++s; while (istrailinggabage(*s)); + do ++s; while (istrailinggabage(*s)); } #endif break; @@ -2831,12 +2831,18 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) if (s > b) { #if USE_NTFS + static const char prime[] = ":$DATA"; + enum {prime_len = sizeof(prime) -1}; endpath: - if (s > b + 6 && strncasecmp(s - 6, ":$DATA", 6) == 0) { + if (s > b + prime_len && strncasecmp(s - prime_len, prime, prime_len) == 0) { /* alias of stream */ /* get rid of a bug of x64 VC++ */ - if (*(s-7) == ':') s -= 7; /* prime */ - else if (memchr(b, ':', s - 6 - b)) s -= 6; /* alternative */ + if (*(s - (prime_len+1)) == ':') { + s -= prime_len + 1; /* prime */ + } + else if (memchr(b, ':', s - prime_len - b)) { + s -= prime_len; /* alternative */ + } } #endif BUFCHECK(bdiff + (s-b) >= buflen); -- cgit