mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* time.c (search_time_t): support non 32bit time_t environments.
* win32/Makefile.sub (config.h): VC++8 has ``long long'' type. * win32/Makefile.sub (config.h): VC++8's time_t is 64bit value. * win32/win32.c (rb_w32_utime): drop read-only attribute before changing file time. all changes are backported from CVS HEAD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
981f3b3db4
commit
4b7ecb15d1
4 changed files with 41 additions and 12 deletions
13
ChangeLog
13
ChangeLog
|
|
@ -1,3 +1,16 @@
|
|||
Tue Feb 14 14:01:17 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* time.c (search_time_t): support non 32bit time_t environments.
|
||||
|
||||
* win32/Makefile.sub (config.h): VC++8 has ``long long'' type.
|
||||
|
||||
* win32/Makefile.sub (config.h): VC++8's time_t is 64bit value.
|
||||
|
||||
* win32/win32.c (rb_w32_utime): drop read-only attribute before
|
||||
changing file time.
|
||||
|
||||
all changes are backported from CVS HEAD.
|
||||
|
||||
Tue Feb 14 11:21:38 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* io.c (argf_forward): should not use frame->argv.
|
||||
|
|
|
|||
24
time.c
24
time.c
|
|
@ -486,6 +486,16 @@ tmcmp(a, b)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if SIZEOF_TIME_T == SIZEOF_LONG
|
||||
typedef unsigned long unsigned_time_t;
|
||||
#elif SIZEOF_TIME_T == SIZEOF_INT
|
||||
typedef unsigned int unsigned_time_t;
|
||||
#elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
|
||||
typedef unsigned LONG_LONG unsigned_time_t;
|
||||
#else
|
||||
# error cannot find integer type which size is same as time_t.
|
||||
#endif
|
||||
|
||||
static time_t
|
||||
search_time_t(tptr, utc_p)
|
||||
struct tm *tptr;
|
||||
|
|
@ -499,12 +509,12 @@ search_time_t(tptr, utc_p)
|
|||
find_dst = 0 < tptr->tm_isdst;
|
||||
|
||||
#ifdef NEGATIVE_TIME_T
|
||||
guess_lo = 1L << (8 * sizeof(time_t) - 1);
|
||||
guess_lo = (time_t)~((unsigned_time_t)~(time_t)0 >> 1);
|
||||
#else
|
||||
guess_lo = 0;
|
||||
#endif
|
||||
guess_hi = ((time_t)-1) < ((time_t)0) ?
|
||||
(1UL << (8 * sizeof(time_t) - 1)) - 1 :
|
||||
(time_t)((unsigned_time_t)~(time_t)0 >> 1) :
|
||||
~(time_t)0;
|
||||
|
||||
guess = timegm_noleapsecond(tptr);
|
||||
|
|
@ -1255,16 +1265,6 @@ time_to_s(time)
|
|||
return rb_str_new(buf, len);
|
||||
}
|
||||
|
||||
#if SIZEOF_TIME_T == SIZEOF_LONG
|
||||
typedef unsigned long unsigned_time_t;
|
||||
#elif SIZEOF_TIME_T == SIZEOF_INT
|
||||
typedef unsigned int unsigned_time_t;
|
||||
#elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
|
||||
typedef unsigned LONG_LONG unsigned_time_t;
|
||||
#else
|
||||
# error cannot find integer type which size is same as time_t.
|
||||
#endif
|
||||
|
||||
static VALUE
|
||||
time_add(tobj, offset, sign)
|
||||
struct time_object *tobj;
|
||||
|
|
|
|||
|
|
@ -204,17 +204,28 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub
|
|||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_MEMORY_H 1
|
||||
!if $(MSC_VER) >= 1400
|
||||
#define HAVE_LONG_LONG 1
|
||||
!endif
|
||||
#define HAVE_OFF_T 1
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_LONG 4
|
||||
!if $(MSC_VER) >= 1400
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
!else
|
||||
#define SIZEOF_LONG_LONG 0
|
||||
!endif
|
||||
#define SIZEOF___INT64 8
|
||||
#define SIZEOF_OFF_T 4
|
||||
#define SIZEOF_VOIDP 4
|
||||
#define SIZEOF_FLOAT 4
|
||||
#define SIZEOF_DOUBLE 8
|
||||
!if $(MSC_VER) >= 1400
|
||||
#define SIZEOF_TIME_T 8
|
||||
!else
|
||||
#define SIZEOF_TIME_T 4
|
||||
!endif
|
||||
#define HAVE_PROTOTYPES 1
|
||||
#define TOKEN_PASTE(x,y) x##y
|
||||
#define HAVE_STDARG_PROTOTYPES 1
|
||||
|
|
|
|||
|
|
@ -3504,6 +3504,9 @@ rb_w32_utime(const char *path, struct utimbuf *times)
|
|||
}
|
||||
|
||||
RUBY_CRITICAL({
|
||||
const DWORD attr = GetFileAttributes(path);
|
||||
if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY))
|
||||
SetFileAttributes(path, attr & ~FILE_ATTRIBUTE_READONLY);
|
||||
hFile = CreateFile(path, GENERIC_WRITE, 0, 0, OPEN_EXISTING,
|
||||
IsWin95() ? 0 : FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
|
|
@ -3517,6 +3520,8 @@ rb_w32_utime(const char *path, struct utimbuf *times)
|
|||
}
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY))
|
||||
SetFileAttributes(path, attr);
|
||||
});
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue