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

91 Коммитов

Автор SHA1 Сообщение Дата
卜部昌平 31a770ac48 rb_strftime_with_timespec: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
Nobuyoshi Nakada 2f1895fa15
Fixed formatted substring expansion [Bug #16767] 2020-04-08 01:13:03 +09:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
nobu fa8b08b424 Prefer `rb_fstring_lit` over `rb_fstring_cstr`
The former states explicitly that the argument must be a literal,
and can optimize away `strlen` on all compilers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 09:59:22 +00:00
k0kubun 5d85a46e0c revert r64957 [ci skip]
r64956 didn't work either...
This means that svn.ruby-lang.org/ruby is not executing the latest git
hook on git.ruby-lang.org/ruby-commit-hook.

Tentatively I backported the changes of auto-style.rb in
git.ruby-lang.org/ruby-commit-hook to git.ruby-lang.org/scripts.

I hope this commit won't be rolled back by svn bot...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 04:30:07 +00:00
svn e94b5221c4 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 03:11:37 +00:00
k0kubun 042718c2ad revert r64955
r64954 didn't work...

In this commit, I'm experimenting
https://git.ruby-lang.org/ruby-commit-hook.git/commit/svn-utils/bin/auto-style.rb?id=2a1a17da1c163e8fc4321759d95057441ddf2c0a

We can distinguish possible 2 issues by this commit.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 03:11:36 +00:00
svn dde4a171db * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 02:55:07 +00:00
k0kubun ca8b54b6dc partially revert r64953
"expand tabs" is not intended to be applied to strftime.c, because its
c-file-style is "linux", not "ruby".

It's explicitly excluded to expand tabs
https://git.ruby-lang.org/ruby-commit-hook.git/tree/svn-utils/bin/auto-style.rb#n195
but it didn't work.
I fixed the issue in
https://git.ruby-lang.org/ruby-commit-hook.git/commit/svn-utils/bin/auto-style.rb?id=844e0d42de11ad4c549bfbdd752a21df2823c18c
so let me try to revert the strftime.c change to keep the tabs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 02:55:06 +00:00
svn b8fbe8b59f * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 02:35:33 +00:00
nobu ee58c638b8 Timezone support by Time [Feature #14850]
* strftime.c (rb_strftime): support timezone object by `%z`.

* time.c (time_init_1, time_new_timew, time_getlocaltime): accept
  timezone object as `off`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 02:35:31 +00:00
akr 277cedb84c Store String as zone in struct vtm.
This removes zone_table and use fstring instead.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-08 10:00:43 +00:00
nobu 6924066a65 adjust styles [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-10 00:39:26 +00:00
nobu 7e1c65dccd vsnprintf.c: prefix with precision
* vsnprintf.c (BSD_vfprintf): sign and hex-prefix should not be
  counted in precision.  [ruby-dev:47714] [Bug #8916]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-29 09:47:42 +00:00
normal 9eb94b4dc1 deduplicate static rb_str_format format strings
Anybody who hits these code paths can hit them again in the
future, so try deduplicating across multiple runs of these
methods to reduce garbage.

* string.c (str_upto_each): fstring on "%.*d"
* strftime.c (rb_strftime_with_timespec): fstring on "%0*d"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-17 00:55:55 +00:00
nobu 0c22cfd0ce strftime.c: limit result size
* strftime.c (rb_strftime_with_timespec): limit the result string
  size by the format length, to get rid of unlimited memory use.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-14 13:22:09 +00:00
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