8000 * file.c: fixes to compile on mswin32. Patch from U. Nakamura · documenting-ruby/ruby@4a71766 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a71766

Browse files
committed
* file.c: fixes to compile on mswin32. Patch from U. Nakamura
<usa at garbagecollect.jp>. [ruby-dev:35127] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_5@17397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent c503b65 commit 4a71766

File tree

3 files changed

+41
-66
lines changed

3 files changed

+41
-66
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Wed Jun 18 13:19:55 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
2+
3+
* file.c: fixes to compile on mswin32. Patch from U. Nakamura
4+
<usa at garbagecollect.jp>. [ruby-dev:35127]
5+
16
Tue Jun 17 22:14:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
27

38
* configure.in (LIBPATHFLAG, RPATHFLAG): no needs to be quoted,

file.c

Lines changed: 32 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
#include "missing/file.h"
1717
#endif
1818
#ifdef __CYGWIN__
19+
#define OpenFile WINAPI_OpenFile
1920
#include <windows.h>
2021
#include <sys/cygwin.h>
22+
#undef OpenFile
2123
#endif
2224

23-
#define OpenFile rb_io_t
2425
#include "ruby.h"
2526
#include "rubyio.h"
2627
#include "rubysig.h"
@@ -2329,18 +2330,6 @@ rb_file_s_umask(argc, argv)
23292330
# endif
23302331
#endif
23312332

2332-
#if defined _WIN32 || defined __CYGWIN__
2333-
#define USE_NTFS 1
2334-
#else
2335-
#define USE_NTFS 0
2336-
#endif
2337-
2338-
#if USE_NTFS
2339-
#define istrailinggabage(x) ((x) == '.' || (x) == ' ')
2340-
#else
2341-
#define istrailinggabage(x) 0
2342-
#endif
2343-
23442333
#ifdef DOSISH_DRIVE_LETTER
23452334
static inline int
23462335
has_drive_letter(buf)
@@ -2452,9 +2441,8 @@ rb_path_last_separator(path)
24522441
return last;
24532442
}
24542443

2455-
#define chompdirsep rb_path_end
24562444
char *
2457-
rb_path_end(path)
2445+
chompdirsep(path)
24582446
const char *path;
24592447
{
24602448
while (*path) {
@@ -2469,35 +2457,20 @@ rb_path_end(path)
24692457
}
24702458
return (char *)path;
24712459
}
2472-
2473-
#if USE_NTFS
2474-
static char *
2475-
ntfs_tail(const char *path)
2460+
2461+
char *
2462+
rb_path_end(path)
2463+
const char *path;
24762464
{
2477-
while (*path && *path != ':') {
2478-
if (istrailinggabage(*path)) {
2479-
const char *last = path++;
2480-
while (istrailinggabage(*path)) path++;
2481-
if (!*path || *path == ':') return (char *)last;
2482-
}
2483-
else if (isdirsep(*path)) {
2484-
const char *last = path++;
2485-
while (isdirsep(*path)) path++;
2486-
if (!*path) return (char *)last;
2487-
if (*path == ':') path++;
2488-
}
2489-
else {
2490-
path = CharNext(path);
2491-
}
2492-
}
2493-
return (char *)path;
2465+
if (isdirsep(*path)) path++;
2466+
return chompdirsep(path);
24942467
}
2495-
#endif
24962468

24972469
#if USE_NTFS
24982470
static char *
24992471
ntfs_tail(const char *path)
25002472
{
2473+
while (*path == '.') path++;
25012474
while (*path && *path != ':') {
25022475
if (istrailinggabage(*path)) {
25032476
const char *last = path++;
@@ -2527,10 +2500,6 @@ ntfs_tail(const char *path)
25272500
p = buf + bdiff;\
25282501
pend = buf + buflen;\
25292502
}\
2530-
rb_str_resize(result, buflen);\
2531-
buf = RSTRING(result)->ptr;\
2532-
p = buf + bdiff;\
2533-
pend = buf + buflen;\
25342503
} while (0)
25352504

25362505
#define BUFINIT() (\
@@ -2769,53 +2738,54 @@ file_expand_path(fname, dname, result)
276 B83A 92738

27702739
#if USE_NTFS
27712740
*p = '\0';
2772-
if (!strpbrk(b = buf, "*?")) {
2741+
if ((s = strrdirsep(b = buf)) != 0 && !strpbrk(s, "*?")) {
27732742
size_t len;
27742743
WIN32_FIND_DATA wfd;
27752744
#ifdef __CYGWIN__
2776-
int lnk_added = 0;
2745+
int lnk_added = 0, is_symlink = 0;
27772746
struct stat st;
2778-
char w32buf[MAXPATHLEN], sep = 0;
2779-
p = 0;
2747+
char w32buf[MAXPATHLEN];
2748+
p = (char *)s;
27802749
if (lstat(buf, &st) == 0 && S_ISLNK(st.st_mode)) {
2781-
p = strrdirsep(buf);
2782-
if (!p) p = skipprefix(buf);
2783-
if (p) {
2784-
sep = *p;
2785-
*p = '\0';
2786-
}
2750+
is_symlink = 1;
2751+
*p = '\0';
27872752
}
2788-
if (cygwin_conv_to_win32_path(buf, w32buf) == 0) {
2753+
if (cygwin_conv_to_win32_path((*buf ? buf : "/"), w32buf) == 0) {
27892754
b = w32buf;
27902755
}
2791-
if (p) *p = sep;
2792-
else p = buf;
2793-
if (b == w32buf) {
2756+
if (is_symlink && b == w32buf) {
2757+
*p = '\\';
27942758
strlcat(w32buf, p, sizeof(w32buf));
27952759
len = strlen(p);
27962760
if (len > 4 && strcasecmp(p + len - 4, ".lnk") != 0) {
27972761
lnk_added = 1;
27982762
strlcat(w32buf, ".lnk", sizeof(w32buf));
27992763
}
28002764
}
2765+
*p = '/';
28012766
#endif
28022767
HANDLE h = FindFirstFile(b, &wfd);
28032768
if (h != INVALID_HANDLE_VALUE) {
28042769
FindClose(h);
2805-
p = strrdirsep(buf);
28062770
len = strlen(wfd.cFileName);
28072771
#ifdef __CYGWIN__
28082772
if (lnk_added && len > 4 &&
28092773
strcasecmp(wfd.cFileName + len - 4, ".lnk") == 0) {
2810-
len -= 4;
2774+
wfd.cFileName[len -= 4] = '\0';
28112775
}
2776+
#else
2777+
p = (char *)s;
28122778
#endif
2813-
if (!p) p = buf;
2814-
buflen = ++p - buf + len;
2815-
rb_str_resize(result, buflen);
2779+
++p;
2780+
BUFCHECK(bdiff + len >= buflen);
28162781
memcpy(p, wfd.cFileName, len + 1);
28172782
p += len;
28182783
}
2784+
#ifdef __CYGWIN__
2785+
else {
2786+
p += strlen(p);
2787+
}
2788+
#endif
28192789
}
28202790
#endif
28212791

@@ -3051,7 +3021,7 @@ rb_file_s_extname(klass, fname)
30513021
if (!p)
30523022
p = name;
30533023
else
3054-
p++;
3024+
name = ++p;
30553025

30563026
e = 0;
30573027
while (*p) {
@@ -3081,7 +3051,7 @@ rb_file_s_extname(klass, fname)
30813051
break;
30823052
p = CharNext(p);
30833053
}
3084-
if (!e || e+1 == p) /* no dot, or the only dot is first or end? */
3054+
if (!e || e == name || e+1 == p) /* no dot, or the only dot is first or end? */
30853055
return rb_str_new(0, 0);
30863056
extname = rb_str_new(e, p - e); /* keep the dot, too! */
30873057
OBJ_INFECT(extname, fname);

version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#define RUBY_VERSION "1.8.5"
2-
#define RUBY_RELEASE_DATE "2008-06-17"
2+
#define RUBY_RELEASE_DATE "2008-06-18"
33
#define RUBY_VERSION_CODE 185
4-
#define RUBY_RELEASE_CODE 20080617
5-
#define RUBY_PATCHLEVEL 224
4+
#define RUBY_RELEASE_CODE 20080618
5+
#define RUBY_PATCHLEVEL 225
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8
99
#define RUBY_VERSION_TEENY 5
1010
#define RUBY_RELEASE_YEAR 2008
1111
#define RUBY_RELEASE_MONTH 6
12-
#define RUBY_RELEASE_DAY 17
12+
#define RUBY_RELEASE_DAY 18
1313

1414
#ifdef RUBY_EXTERN
1515
RUBY_EXTERN const char ruby_version[];

0 commit comments

Comments
 (0)
0