diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-18 03:01:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-18 03:01:03 +0000 |
commit | 17aa3d898da249ddd1478b21de6187bfdd873497 (patch) | |
tree | 6671c99e21f3a0d2f0fabe5d72d518d788463112 /file.c | |
parent | e5edfbf2074d2c99c7c0128688367c28fd911a26 (diff) |
* file.c (file_expand_path): suppress a warning. named magic
numbers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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); |