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

427 Коммитов

Автор SHA1 Сообщение Дата
nobu 5fd589287d time.c: add example [ci skip]
* time.c (time_asctime): [DOC] add ctime example, not only
  asctime.  [ruby-core:75126] [Bug #12310]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-22 11:34:05 +00:00
nobu 5396d8a1ab strftime.c: format in String
* strftime.c (rb_strftime_with_timespec): append formatted results
  to the given string with expanding, and also deal with NUL chars.
* strftime.c (rb_strftime, rb_strftime_timespec): return formatted
  string, not the length put in the given buffer.
* time.c (rb_strftime_alloc): no longer needs to retry with
  reallocating buffers.
* time.c (time_strftime): no longer needs to split by NUL chars.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-23 11:57:01 +00:00
usa 15af93fcc8 * time.c (wmul): wrong condition.
fixed many test failures on 32bit and LLP64 platforms.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-22 02:41:24 +00:00
usa 6957898ad0 * time.c (wdiv, wmod): wdivmod0() assumes the 3rd and the 4th arguments
are valid pointers.
  maybe checking them in wdivmod0() is better manner, but I guess that
  passing real dummy pointers may be faster than checking and branching
  in wdivmod0().
  this commit fixes SEGV on 32bit and LLP64 platforms.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-22 01:37:01 +00:00
usa 0dbbcdb6bb * time.c (divmodv): void function never returns any value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-22 01:24:55 +00:00
naruse 520650798c fix typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 19:14:27 +00:00
naruse 03d0501f51 * time.c (MUL_OVERFLOW_FIXWV_P): defined for FIXWV.
* time.c (wmul): use MUL_OVERFLOW_FIXWV_P and only switch.

* time.c (wmul): use mul which has Fixnum optimization.

* time.c (rb_time_magnify): If WIDEVALUE_IS_WIDER, wmul() has the same
  optimized logic, else mul() has also the similar logic for Fixnum.

* time.c (rb_time_unmagnify): almost ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 18:57:30 +00:00
naruse 74d7b281d3 fix typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 18:57:25 +00:00
naruse 849bbc6566 * time.c (divmodv): add the case both arguments are Fixnum.
* time.c (wquo): use quo which has Fixnum optimization.

* time.c (wdivmod0): added for WIDEVALUE_IS_WIDER.

* time.c (wdivmod): use wdivmod0 and divmodv.
  divmodv has Fixnum optimization.

* time.c (wdiv): use wdivmod0 and div to avoid the use of divmodv which
  calls id_quo whose return value is array.

* time.c (wmod): use wdivmod0 and mod to avoid the use of divmodv which
  calls id_quo whose return value is array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 18:19:15 +00:00
naruse 51c4ffa45b * internal.h (rb_fix_divmod_fix): like r54213, use FIX2NUM only if
x == FIXNUM_MIN && y == -1. This must be a rare case and it is
  expected compiler to handle well.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 13:36:03 +00:00
nobu 2118eccc77 time.c (quo): fix missing return
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 13:31:30 +00:00
naruse 654788793d fix commit miss
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 13:21:12 +00:00
naruse f5715289ac * time.c (mod): Add Fixnum case.
* time.c (quo): c can be Fixnum except a == FIXNUM_MIN && b == -1.
  Such case can be optimized out because quo()'s argument is constant.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 13:17:45 +00:00
nobu ce5ba9197d time.c (mul): fix missing return.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-20 11:26:17 +00:00
naruse 148f1b9d57 * internal.h (DLONG): defined if long is 32bit (and LONG_LONG is 64bit;
but LONG_LONG is always defined as 64bit), or there's int128_t.

* internal.h (DL2NUM): defined if DLONG is defined.

* internal.h (rb_fix_mul_fix): defined for `Fixnum * Fixnum`.

* insns.def (opt_mul): use rb_fix_mul_fix().

* numeric.c (fix_mul): ditto.

* time.c (mul): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-20 11:10:43 +00:00
naruse cb390bef8a * time.c (add): remove FIXABLE() which is in LONG2NUM().
* time.c (sub): ditto.

* time.c (mul): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-20 09:47:20 +00:00
naruse 4eb908d21a * time.c (LOCALTIME): organize #ifdefs.
* time.c (GMTIME): define only ifndef HAVE_STRUCT_TM_TM_GMTOFF.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 19:06:33 +00:00
naruse 9a8b21446e * configure.in (rb_cv_member_struct_tm_tm_gmtoff): For Linux (glibc)
define _BSD_SOURCE for time.h to define struct tm.tm_gmtoff.

* time.c: define _BSD_SOURCE at the top.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-18 19:06:32 +00:00
hsbt 8709f42ff2 * time.c: Minor typo in Time#dst? documentation.
[ci skip][fix GH-1290]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-15 00:56:45 +00:00
naruse 911b1c6b06 * time.c (rb_time_timespec_new): swap utc and localtime
to generate gmt flag by INT_MAX - gmtoff.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10 05:36:47 +00:00
naruse f1df08e76d * time.c (rb_timespec_now): added.
* time.c (rb_time_timespec_new): added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-10 02:59:47 +00:00
naruse 2b15d16987 fix comment: tobj->gmt is 0:localtime 1:utc 2:fixoff 3:init
see also TIME_UTC_P and TIME_LOCALTIME_P

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-09 17:18:35 +00:00
nobu 4191a6b90d preserve encodings in error messages
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28 02:40:46 +00:00
akr 3093ffab83 * time.c (time_getlocaltime): [DOC] Add examples of valid utc_offset
formats.
  [ruby-core:68306] [Misc #10905] Patch by Charles Korn.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-14 11:10:49 +00:00
normal f6cd582505 variable.c: avoid compatibility table with generic ivars
This recovers and improves performance of Marshal.dump/load on
Time objects compared to when we implemented generic ivars
entirely using st_table.

This also recovers some performance on other generic ivar objects,
but does not bring bring Marshal.dump/load performance up to
previous speeds.

benchmark results:
minimum results in each 10 measurements.
Execution time (sec)
		name    trunk   geniv   after
marshal_dump_flo        0.343   0.334   0.335
marshal_dump_load_geniv 0.487   0.527   0.495
marshal_dump_load_time  1.262   1.401   1.257

Speedup ratio: compare with the result of `trunk' (greater is better)
		name    geniv   after
marshal_dump_flo        1.026   1.023
marshal_dump_load_geniv 0.925   0.985
marshal_dump_load_time  0.901   1.004

* include/ruby/intern.h (rb_generic_ivar_table): deprecate
* internal.h (rb_attr_delete): declare
* marshal.c (has_ivars): use rb_ivar_foreach
  (w_ivar): ditto
  (w_object): update for new interface
* time.c (time_mload): use rb_attr_delete
* variable.c (generic_ivar_delete): implement
  (rb_ivar_delete): ditto
  (rb_attr_delete): ditto
  [ruby-core:69323] [Feature #11170]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 00:20:15 +00:00
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