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

72 Коммитов

Автор SHA1 Сообщение Дата
nobu dc54e38041 strftime.c: Bignum conversion
* strftime.c (format_value): convert from Bignum to String,
  instead of rb_str_format.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-24 15:49:43 +00:00
nobu 2460214780 strftime.c: set buffer length
* strftime.c (FMTV): set the buffer length before appending to
  keep just put part.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-24 15:12:56 +00:00
nobu 7d488c4e4e strftime.c: refine r54248
* strftime.c (FMT_PRECISION): eliminate side effects.
  [Bug #12213]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-24 15:01:39 +00:00
nobu 20215f0181 strftime.c: remove recursive-assignments
* strftime.c (FMT, FMTV): remove recursive-assignments to get rid
  of undefined behavior.  [ruby-core:74532] [Bug #12213]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-24 13:38:20 +00:00
nobu 743f2bf879 strftime.c: fix FMTV
* strftime.c (FMT_PADDING): extract format for padding.
* strftime.c (FMT_PRECISION): extract precision formula.
* strftime.c (FMTV): append formatted string to expand the result.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-24 08:44:03 +00:00
nobu 44a247c745 strftime.c: case conversion
* strftime.c (STRFTIME): deal with case conversion flags for
  recursive formats.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-24 05:20:22 +00:00
nobu f3de12aa6b strftime.c: fix false failure
* strftime.c (rb_strftime_with_timespec): remove unnecessary
  check, as `s` equals to `endp` when recursed STRFTIME resized
  the capacity same as the size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-24 02:43:34 +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
akr 14e72b1cde * strftime.c (rb_strftime_with_timespec): Test yday range.
[ruby-core:44088] [Bug #6247] reported by Ruby Submit.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-06 16:02:46 +00:00
nobu 31bea5d436 unecessary macros and K&R style coding
* strftime.c: remove unnecessary macros to check traditional C.
  https://github.com/ruby/ruby/pull/46 by lateau (Daehyub Kim).
* vsnprintf.c: remove K&R.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-16 00:46:12 +00:00
nobu 39a3d1793b strftime.c: triple colons modifier
partially borrowed from ext/date.

* strftime.c (rb_strftime_with_timespec): support GNU extension triple
  colons modifier.  [EXPERIMENTAL]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-29 08:28:13 +00:00
nobu 241902e709 strftime.c: fix locale modifier
partially borrowed from ext/date.

* strftime.c (rb_strftime_with_timespec): check conversion with locale
  modifier.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-29 08:28:09 +00:00
nobu 60683816be strftime.c: fix colon modifier.
partially borrowed from ext/date.

* strftime.c (rb_strftime_with_timespec): colons are valid only for
  'z' and must come just before it.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-29 08:28:04 +00:00
nobu 49479c2dcc strftime.c: linux style
* strftime.c (rb_strftime_with_timespec): fix indentation using linux
  style.  this file is not written in ruby-style.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-28 04:54:04 +00:00
nobu e0ffb9b59b * strftime.c (rb_strftime_with_timespec): fix carrir-up bug and
overwrite '+' with '-' if negative offset less than a hour.
  [ruby-core:44447][Bug #6323]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-19 07:33:55 +00:00
nobu 442fefc78a * strftime.c (rb_strftime_with_timespec): add an interim digit for
the timezone offset which is less than an hour.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-18 01:23:00 +00:00
nobu 43dbbefbdf * strftime.c (rb_strftime_with_timespec): fix padding of time zone
offset.  [ruby-dev:43287][Bug #4458]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-17 13:18:51 +00:00
naruse 23b2808693 * strftime.c (rb_strftime_with_timespec): get enc argument to specify
the encoding of the format. On Windows (at least Japanese Windows),
  Time#strftime("%Z") includes non ASCII in locale encoding (CP932).
  So convert locale to default internal. [ruby-core:39092] [Bug #5226]

* strftime.c (rb_strftime): ditto.

* strftime.c (rb_strftime_timespec): ditto.

* internal.h (rb_strftime_timespec): follow above.

* time.c (rb_strftime_alloc): ditto.

* time.c (strftimev): ditto.

* time.c (time_strftime): ditto.

* time.c (time_to_s): the resulted string of Time#to_s is always
  ascii only, so this should be US-ASCII.

* time.c (time_asctime): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-27 09:18:18 +00:00
ngoto cf310f9741 * strftime.c (NEEDS): avoid SEGV due to integer overflow in sparc-solaris2.10
and i686-linux.  fix [Bug #4456] [ruby-dev:43284]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30 13:41:45 +00:00
yugui 8fa30bbd48 * strftime.c (rb_strftime_with_timespec): improved style consistency.
constified some variables.

* test/test_time.rb (TestTime#test_huge_precision): test for #4456.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 03:59:36 +00:00
naruse 63f39fcb40 * random.c (random_rand): remove unused variables.
* struct.c (rb_struct_define_without_accessor): ditto.

* strftime.c (rb_strftime_with_timespec): ditto.

* sprintf.c: ditto.

* time.c (time_asctime): remove useless GetTimeval().

* thread_pthread.c: cast to (void *) for %p.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-25 07:56:42 +00:00
matz 1df42597d1 cancel subversion backfire. sorry
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:44:45 +00:00
matz eb807d42ec * gc.c (rb_gc_set_params): allow GC parameter configuration by
environment variables.  based on a patch from funny-falcon at
  https://gist.github.com/856296, but honors safe level.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:39:39 +00:00
naruse 7bb73a0852 * strftime.c (STRFTIME): return 0 and ERANGE when precision is too
large. [ruby-dev:43284] fixes #4456

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-03 05:28:00 +00:00
akr 2418e5ca83 * strftime.c (rb_strftime_with_timespec): %G produces 4 digits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-30 07:10:55 +00:00
akr ccc55bb7c3 * strftime.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-01 02:45:04 +00:00
akr 98c8e1cd91 * strftime.c (rb_strftime_with_timespec): suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-08 01:08:27 +00:00
akr d06a6b22f5 * strftime.c (rb_strftime_with_timespec): fix precision handling for
%:z and %::z.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-10 12:43:54 +00:00
akr e51e679f14 * strftime.c: unused declarations removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-09 13:33:39 +00:00
akr 85f10041b2 * strftime.c (rb_strftime_with_timespec): clear colons at unknown
directive.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-09 12:21:26 +00:00
akr 6f1c1b496e * strftime.c: don't call tzset. strftime.c doesn't depend on
the global timezone.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-09 12:04:26 +00:00
akr 9818dd26e5 unused code removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-08 13:05:41 +00:00
akr a5d37d10a9 * strftime.c (rb_strftime_with_timespec): support %:z and %::z.
[ruby-dev:41841]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-07 21:07:01 +00:00
akr fbc42054e8 * time.c: less bignum allocations.
* strftime.c (rb_strftime_timespec): defined to avoid rational for
  nano second resolution time.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-31 12:34:31 +00:00
muraken e4d8dc5c46 * bignum.c, node.h, strftime.c, enc/trans/utf8_mac.trans: added explicit casts for supplessing warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-25 03:08:28 +00:00
naruse c121f78b9a * strftime.c: %l should be 1..12 instead of 0..12 [ruby-core:27072]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-06 14:55:22 +00:00
nobu 4d786d21e3 * removed spaces just before tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-26 05:25:08 +00:00
akr 54370de9f4 * strftime.c: %Y format a year with 4 digits at least.
* lib/time.rb: format a year with 4 digits at least.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-24 11:34:45 +00:00
akr b9e0294eda fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
akr f64e076260 * time.c: support fixed UTC offset. [ruby-dev:38326]
(leap_year_v_p): new macro.
  (TIME_FIXOFF_P): new macro.
  (TIME_SET_FIXOFF): new macro.
  (time_init_0): renamed from time_init.
  (time_set_utc_offset): new function.
  (vtm_add_offset): new function.
  (utc_offset_arg): new function.
  (time_init_1): new function.
  (time_init): call time_init_0 or time_init_1 according argc.
  (validate_utc_offset): new function.
  (time_localtime_m): new function.
  (time_fixoff): new function.
  (time_getlocaltime): take optional UTC offset argument.
  (time_get_tm): support fixed UTC offset time.
  (Init_Time): make Time#{initialize,localtime,getlocal} varargs.

* strftime.c (rb_strftime): vtm->zone can be NULL now.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-12 12:07:49 +00:00
nobu d5704eb61a * time.c (localtime_with_gmtoff): fixed cross function jump.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-22 00:27:33 +00:00
akr 3bc16f62c1 * time.c: remove time_t restriction from Time class.
* timev.h: new file to define struct vtm.

* strftime.c: format struct vtm instead of struct tm.

* ext/syck/rubyext.c (mktime_do): don't use time_t;

[ruby-dev:38191]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-21 14:56:59 +00:00
nobu 22cde7b682 * dir.c, dln.c, parse.y, re.c, ruby.c, sprintf.c, strftime.c,
string.c, util.c, variable.c: use strlcpy, memcpy and snprintf
  instead of strcpy, strncpy and sprintf.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-17 01:29:17 +00:00
nobu d1abc53721 * array.c, bignum.c, dln.c, error.c, gc.c, io.c, marshal.c,
numeric.c, pack.c, strftime.c, string.c, thread.c, transcode.c,
  transcode_data.h, util.c, variable.c, vm_dump.c,
  include/ruby/encoding.h, missing/crypt.c, missing/vsnprintf.c:
  suppress VC type warnings.  [ruby-core:22726]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-12 09:16:15 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
akr 6fcaf92943 * strftime.c (rb_strftime): use locale insensitive functions for tr_TR
locale.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-23 10:13:11 +00:00
tadf 24a6416355 * strftime.c (rb_strftime): should add padding for %%.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-27 12:43:05 +00:00
matz b0f3bd5d25 * strftime.c (STRFTIME): use rb_strftime() recursively, instead of
platform's strftime().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-26 14:30:25 +00:00
matz 6099790621 * strftime.c (STRFTIME): should add padding for %[xXrR] etc.
[ruby-dev:37185] fix: #792

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-25 15:28:22 +00:00
matz 446ea127c3 * strftime.c (rb_strftime): should not swallow incomplete
formatter, e.g. "%E".  [ruby-dev:37170] fix: #787

* strftime.c (rb_strftime): clear flags before processing unknown
  formatter, e.g. "%i".  [ruby-dev:37180]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-25 14:24:47 +00:00