summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-26 13:24:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-26 13:24:17 +0000
commit1b00c45dc0a70f1d6b454cd8132e872a6a5fd385 (patch)
tree766301d8352eeafe6795934a0b7f5e6eb2023ad1 /file.c
parent5d276ea14a84de7fd204dfd635ac7b6d17ea9039 (diff)
* file.c (file_expand_path): get rid of warnings caused by
-Wdeclaration-after-statement on cygwin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/file.c b/file.c
index 1630ac1676..2bc3e4b050 100644
--- a/file.c
+++ b/file.c
@@ -3093,7 +3093,15 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result)
if ((s = strrdirsep(b = buf)) != 0 && !strpbrk(s, "*?")) {
size_t len;
WIN32_FIND_DATA wfd;
+ HANDLE h;
#ifdef __CYGWIN__
+#ifdef HAVE_CYGWIN_CONV_PATH
+ char *w32buf = NULL;
+ const int flags = CCP_POSIX_TO_WIN_A | CCP_RELATIVE;
+#else
+ char w32buf[MAXPATHLEN];
+#endif
+ const char *path;
ssize_t bufsize;
int lnk_added = 0, is_symlink = 0;
struct stat st;
@@ -3105,10 +3113,8 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result)
lnk_added = 1;
}
}
- const char *path = *buf ? buf : "/";
+ path = *buf ? buf : "/";
#ifdef HAVE_CYGWIN_CONV_PATH
- char *w32buf = NULL;
- const int flags = CCP_POSIX_TO_WIN_A | CCP_RELATIVE;
bufsize = cygwin_conv_path(flags, path, NULL, 0);
if (bufsize > 0) {
bufsize += len;
@@ -3119,7 +3125,6 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result)
}
}
#else
- char w32buf[MAXPATHLEN];
bufsize = MAXPATHLEN;
if (cygwin_conv_to_win32_path(path, w32buf) == 0) {
b = w32buf;
@@ -3137,7 +3142,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result)
}
*p = '/';
#endif
- HANDLE h = FindFirstFile(b, &wfd);
+ h = FindFirstFile(b, &wfd);
if (h != INVALID_HANDLE_VALUE) {
FindClose(h);
len = strlen(wfd.cFileName);