Граф коммитов

402 Коммитов

Автор SHA1 Сообщение Дата
naruse 1e4172467f * win32/Makefile.sub: MSVC14 have struct timespec.
* win32/rtname.cmd: support vcruntime140.dll.

* time.c (localtime_with_gmtoff_zone): MSVC14 doesn't have tzname and
  daylight but have _tzname and _daylight.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-23 19:51:18 +00:00
nobu 004ce53b25 time.c: locale time zone name
* time.c (time_zone_name): should be US-ASCII only if all 7-bits,
  otherwise locale encoding.  [ruby-core:68230] [Bug #10887]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-24 02:49:51 +00:00
naruse 5b4afd0281 zone may be ASCII-8BIT on Windows [Bug #10887]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-23 09:32:27 +00:00
eregon 9759173cfc * time.c: zone encoding should be US-ASCII if all 7-bits. Fix r46907.
* test/ruby/test_time.rb, test/ruby/test_time_tz.rb: Update tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-22 22:26:55 +00:00
akr 9bbe6b9d0c * time.c (timelocalw): Set tm_isdst field -1 if vtm->isdst is
VTM_ISDST_INITVAL.  This bug is introduced at packing struct
  vtm (r45155).
  [ruby-core:67345] [Bug #10698] Reported by Boris Ruf.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-06 12:41:20 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
nobu 1e4292a9d0 time.c: indent
* time.c (find_time_t): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-27 08:08:32 +00:00
akr 15bfc6ffbf * time.c (time_s_mkutc): [DOC] Time.utc's 10 arguments form
doesn't examine wday, yday, isdst and tz.
  (time_s_mktime): [DOC] Time.mktime's 10 arguments form
  doesn't examine wday, yday and tz.
  Suggested by naruse.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-27 03:48:42 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
akr 6c41b73dec update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-04 14:20:56 +00:00
akr 1efb3c31b7 * Avoid undefined behaviors found by gcc -fsanitize=undefined.
gcc (Debian 4.9.1-16) 4.9.1

* include/ruby/ruby.h (INT2FIX): Avoid undefined behavior.

* node.h (nd_set_line): Ditto.

* pack.c (encodes): Ditto.
  (pack_unpack): Ditto.

* regint.h (BIT_STATUS_AT): Ditto.
  (BS_BIT): Ditto.

* time.c (time_mdump): Ditto.
  (time_mload): Ditto.

* vm_core.h (VM_FRAME_MAGIC_MASK): Ditto.

* vm_trace.c (recalc_add_ruby_vm_event_flags): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-17 08:50:01 +00:00
glass 5697b2f013 * time.c: raise exception when minutes of utc_offset is out of 00-59.
patch is from Kenichi Kamiya.
  [ruby-dev:47539] [Bug #8679]

* test/ruby/test_time.rb: test for above.
  patch is from Kenichi Kamiya.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21 16:58:47 +00:00
normal 6c396e94f9 time.c: DATA_PTR is never NULL
* time.c (time_mark): remove NULL check
  (time_memsize): ditto
  (time_free): remove, use RUBY_TYPED_DEFAULT_FREE instead
  [Feature #10219]

Tiny improvement on my old Phenom II X4 945 system:
$ ruby --disable=gems -e '6000000.times { Time.now }'
before: 2.51user 0.00system 0:02.51elapsed 100%CPU
 after: 2.45user 0.00system 0:02.45elapsed 100%CPU

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 06:01:36 +00:00
akr 092c647cb7 * time.c (rb_time_unmagnify_to_float): Avoid double rounding.
Reported by Tsuyoshi Sawada.
  https://bugs.ruby-lang.org/issues/10135#note-1



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-26 11:48:21 +00:00
normal ed2e8b2e70 time.c (time_timespec): fix tv_nsec overflow
test/ruby/test_float.rb (test_sleep_with_Float) causes tv_nsec
to hit 1000000000 exactly.  This bug is currently hidden from
our test by the platform-dependent native_cond_timeout
functions, but a future native_cond_timedwait implementation may
prefer relative timeouts to match ConditionVariable#wait
semantics more closely.
[Bug #10144]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-16 01:27:19 +00:00
akr 05e756f367 Revert r46977. [ruby-core:63857] [Bug #10071]
The removed comment is useful to understand the behind idea to
solve the year 2038 problem.

The broken link is replaced to refer the internet archive.
0eed69757d (commitcomment-7166665)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-14 13:10:07 +00:00
zzak ea418dda41 * time.c: [DOC] Clarify %Y in strftime, which can accept any digits
and will output at least 4 digits as the year. Reported by Yury
  Trofimenko [Bug #8941]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-27 20:58:05 +00:00
zzak 0eed69757d * time.c: [DOC] Remove dead link and old bug report, which hasn't been
reproduced in a few years. Reported by Federico Builes [Bug #10071]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-27 20:14:11 +00:00
nobu 2e8ce8899a time.c: unnecessary encoding
* time.c (time_zone_name): remove unnecessary encoding and
  conversion if it is 7bit-ascii only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-23 07:20:39 +00:00
akr dd5d029db0 * compile.c (BUFSIZE): Unused macro removed.
* vm.c (BUFSIZE): Ditto.

* pack.c (INT64toNUM): Ditto.
  (UINT64toNUM): Ditto.
  (BYTEWIDTH): Ditto.

* time.c (lshift): Ditto.
  (UINT64toNUM): Ditto.
  (id_lshift): Unused variable removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-11 13:29:16 +00:00
nobu 0989529f88 time.c: fix underflow of unsigned integers
* time.c (vtm_add_offset): get rid of underflow of unsigned
  integers.  fix up r45155.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-02 18:43:23 +00:00
nobu c23a9376ca time.c: fix non-terminated string
* time.c (month_arg, time_strftime): RSTRING_PTR() may not be
  NUL-terminated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 15:09:49 +00:00
normal e0a0edf548 time.c: freeze and preserve marshal-loaded time zone
We need to prevent vtm.zone from pointing to a GC-ed string buffer.
The rb_copy_generic_ivar call misses it because get_attr deleted it.
Thanks to nobu for the rb_str_new_frozen suggestion.

* time.c (time_mload): freeze and preserve marshal-loaded time zone
* test/ruby/test_time.rb: add test for GC on loaded object
  [Bug #9652]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-19 08:19:13 +00:00
nobu fc23374f06 [DOC] add links to `Object#hash`
add links to `Object#hash` to each #`hash` methods rdocs.
[Fixes GH-567]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14 01:27:43 +00:00
akr abb0286b72 [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 16:01:54 +00:00
nobu cc216f9aae adjust indent and style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:14 +00:00
nobu df9199d468 configure.in, win32/Makefile.sub: PACKED_STRUCT with VC
* configure.in (PACKED_STRUCT): check VC pragma too, and make
  function-style macro.

* win32/Makefile.sub (PACKED_STRUCT): enable with VC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-25 07:00:10 +00:00
normal 131e4bec04 time: only use packed struct on x86*
* configure.in: define PACKED_STRUCT_UNALIGNED for x86*
* timev.h (struct vtm): use PACKED_STRUCT_UNALIGNED
* time.c (struct time_object): ditto
  [Bug #9558] non-x86 cannot safely access unaligned addresses

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-24 11:10:11 +00:00
normal b2f3063cae time: rearrange+pack vtm and time_object structs
struct time_object shrinks from 88 to 46 bytes on my 64-bit system.

* configure.in: use -Wno-packed-bitfield-compat for GCC 4.4+
  use __attribute__((packed)) if available
* timev.h: shrink and pack struct vtm
* time.c: pack struct time_object and adjust/introduce helpers
  [ruby-core:60794]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-24 03:38:14 +00:00
akr caa3c88040 * time.c (v2w): Normalize a rational value to an integer if possible.
[ruby-core:58070] [Bug #9059] reported by Isaac Schwabacher.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-30 03:22:23 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
safe functions during garbage collection such as xfree().
  On default, T_DATA objects are freed at same points as fianlizers.
  This approach protects issues such as reported by [ruby-dev:35578].
  However, freeing T_DATA objects immediately helps heap usage.
  Most of T_DATA (in other words, most of dfree functions) are safe.
  However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default
  for safety.
* cont.c: ditto.
* dir.c: ditto.
* encoding.c: ditto.
* enumerator.c: ditto.
* error.c: ditto.
* file.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* iseq.c: ditto.
* marshal.c: ditto.
* parse.y: ditto.
* proc.c: ditto.
* process.c: ditto.
* random.c: ditto.
* thread.c: ditto.
* time.c: ditto.
* transcode.c: ditto.
* variable.c: ditto.
* vm.c: ditto.
* vm_backtrace.c: ditto.
* vm_trace.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* ext/objspace/objspace.c: ditto.
* ext/stringio/stringio.c: ditto.
* ext/strscan/strscan.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 11:16:54 +00:00
akr 888e5cbbe7 * process.c: Remove spaces between SI prefix and unit to follow
SI brochure.
  http://www.bipm.org/en/si/si_brochure/
  https://www.nmij.jp/library/units/si/

* time.c: Ditto.

* ext/socket/ancdata.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-09 12:33:36 +00:00
nobu 5685abe6c3 time.c: ignore invalid data
* time.c (time_mload): ignore invalid offset and zone.
  [ruby-core:56648] [Bug #8795]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-17 13:20:50 +00:00
ktsj f9cbf0e89f * time.c (get_timeval, get_new_timeval): use rb_obj_class()
instead of CLASS_OF() because CLASS_OF() may return
  a singleton class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-09 01:56:51 +00:00
akr fef170e87c * time.c (time_overflow_p): Avoid signed integer overflow.
(rb_time_new): Fix overflow condition.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-08 12:59:21 +00:00
akr 685597fdc1 Fix the previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-08 12:34:30 +00:00
akr 319dc9f6c6 * time.c (time_overflow_p): Avoid signed integer overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-08 12:13:04 +00:00
zzak 0ea2ae132f * time.c: [DOC] Typo in Time overview by @sparr [Fixes GH-374]
https://github.com/ruby/ruby/pull/374


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06 13:39:15 +00:00
akr a338c4ed5d Unused variable removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 16:37:37 +00:00
akr b23d9a8a63 * bignum.c (validate_integer_pack_format): Don't require a word order
flag if numwords is 1 or less.
  (absint_numwords_generic): Don't specify a word order for
  rb_integer_pack.

* hash.c (rb_hash): Ditto.

* time.c (v2w_bignum): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 14:40:16 +00:00
akr 0e8caa7d0f * bignum.c (rb_integer_pack): Returns sign instead of words.
(absint_numwords_generic): Follow the above change.
  (big2str_base_powerof2): Follow the above change.

* internal.h: Ditto.

* hash.c (rb_hash): Ditto.

* pack.c (pack_pack): Ditto.

* random.c (int_pair_to_real_inclusive): Ditto.
  (rand_init): Ditto.
  (random_load): Ditto.
  (limited_big_rand): Ditto.

* time.c (v2w_bignum): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 10:37:39 +00:00
akr 837392b452 * bignum.c (rb_integer_pack): numwords_allocated argument removed.
* internal.h (rb_integer_pack): Follow the above change.

* hash.c (rb_hash): Ditto.

* time.c (v2w_bignum): Ditto.

* pack.c (pack_pack): Ditto.

* random.c (int_pair_to_real_inclusive): Ditto.
  (rand_init): Ditto.
  (random_load): Ditto.
  (limited_big_rand): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09 05:53:00 +00:00
akr 874f10cbf2 * time.c (v2w): Use rb_absint_size instead of RBIGNUM_LEN.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 13:31:35 +00:00
akr f1a6b64b1d * time.c (v2w_bignum): Simplified using rb_integer_pack.
(rb_big_abs_find_maxbit): Removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 12:48:39 +00:00
akr 747894a32d * bignum.c (rb_absint_singlebit_p): New function.
* internal.h (rb_absint_singlebit_p): Declared.

* time.c (v2w_bignum): Use rb_absint_singlebit_p instead of
  rb_big_abs_find_minbit.
  (rb_big_abs_find_minbit): Removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 12:05:57 +00:00
akr af612be8e0 * time.c (rb_big_abs_find_maxbit): Use rb_absint_size.
(bdigit_find_maxbit): Removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 11:25:07 +00:00
ktsj edb98f8b91 fix typos. Patch by k_takata.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19 03:10:21 +00:00
akr a4460ddb48 * time.c (localtime_with_gmtoff_zone): musl libc may return NULL for
tm_zone.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-01 12:12:25 +00:00
akr f674d8623d * time.c (time_strftime): Describe %L and %N truncates digits under
the specified length.
  [ruby-core:52130] [Bug #7829]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04 13:37:22 +00:00
nobu 77ff241fa0 timev.h: move time_t stuffs
* timev.h (TYPEOF_TIMEVAL_TV_SEC, unsigned_time_t): move from time.c.

* thread.c: use definitions in timev.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:08:36 +00:00