summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-18 03:01:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-18 03:01:03 +0000
commit17aa3d898da249ddd1478b21de6187bfdd873497 (patch)
tree6671c99e21f3a0d2f0fabe5d72d518d788463112 /file.c
parente5edfbf2074d2c99c7c0128688367c28fd911a26 (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.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/file.c b/file.c
index 4155d33a1c..29d401016b 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);