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

253 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 11acb7f7bc
[Bug #19167] Remove useless conversion of classes for special const 2022-12-09 22:11:44 +09:00
S-H-GAMELINKS 1f4f6c9832 Using UNDEF_P macro 2022-11-16 18:58:33 +09:00
Nobuyoshi Nakada 576bdec03f [Bug #18973] Promote US-ASCII to ASCII-8BIT when adding 8-bit char 2022-08-31 17:27:59 +09:00
Nobuyoshi Nakada 9dc60653db Extract `update_coderange` macro
Which restarts scanning the code range in unscanned part.
2022-08-31 17:27:59 +09:00
Nobuyoshi Nakada b043dd9c5d
Check the room including the space to fill 2022-08-21 20:06:39 +09:00
Nobuyoshi Nakada 1a2f99275b [Bug #18958] format string must be ASCII compatible 2022-08-20 10:06:40 +09:00
Nobuyoshi Nakada d2483393cb [Bug #18956] Negative codepoints are invalid characters 2022-08-20 10:06:16 +09:00
Nobuyoshi Nakada 1ef49de834 [Bug #18955] format single character for `%c` 2022-08-20 03:57:13 +09:00
Nobuyoshi Nakada ce384ef5a9 [Bug #18955] Check length of argument for `%c` in proper encoding 2022-08-20 03:57:13 +09:00
Nobuyoshi Nakada 99116da7f0 Scan the code range of the last added portion 2022-08-19 03:05:53 +09:00
Nobuyoshi Nakada f34280ec6b Scan the code range of the formatted portion 2022-08-19 03:05:53 +09:00
Jean Boussier b0b9f7201a rb_str_resize: Only clear coderange on truncation
If we are expanding the string or only stripping extra capacity
then coderange won't change, so clearing it is wasteful.
2022-08-18 10:09:08 +02:00
Nobuyoshi Nakada ddb81b9307
Extract common code from `rb_enc_vsprintf` and `rb_str_vcatf` 2022-08-17 17:40:59 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Nobuyoshi Nakada 04be8e84db
Use C99-defined macros to classify a floating-point number 2021-08-27 12:41:30 +09:00
Nobuyoshi Nakada c38c2d8ee2 Moved exported symbols in internal/util.h to ruby/util.h
[Feature #18051]
2021-08-24 10:37:41 +09:00
Nobuyoshi Nakada eec45a93ef
Escape unprintable chars only, without surrounding quotes 2021-07-24 14:31:41 +09:00
Nobuyoshi Nakada 75f60e5a46 Sort out quad_t related macros 2021-07-22 15:41:42 +09:00
Nobuyoshi Nakada 36d1bb720c
sprintf.c: Removed conflicting definition 2020-09-28 12:51:53 +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 bdf3032e35
Make temporary lock string encoding free
As a temporary lock string is hidden, it can not have instance
variables, including non-inlined encoding index.
2020-02-12 19:58:22 +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
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind
version guards.  This affects all code in lib, including some
libraries that may want to support older versions of Ruby.
2019-11-18 01:00:25 +02:00
卜部昌平 0766f67168 move docs around [ci skip]
To properly generate documents.
2019-08-29 18:34:09 +09:00
Yusuke Endoh ba94404f70 Add /* fall through */ comments
to suppress some Coverity Scan warnings
2019-07-14 14:04:19 +09:00
stomar 75e5a91e92 sprintf.c: fix typo
* sprintf.c: [DOC] fix typo.
  Patch by Lazarus Lazaridis (iridakos).  [Fix GH-1789]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-22 19:41:06 +00:00
nobu c05fa459bb quote symbols
* sprintf.c (ruby__sfvextra): quote symbols as identifiers.

* string.c (rb_id_quote_unprintable): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-14 02:35:51 +00:00
nobu d4d966f967 sprintf.c: overflow check
* sprintf.c (ruby_do_vsnprintf): pathologically, get rid of
  negative value when the result length exceeds INT_MAX.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-09 03:15:20 +00:00
nobu e9cb552ec9 internal.h: remove dependecy on ruby/encoding.h
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 06:24:11 +00:00
nobu 13f5dcb9f2 error.c: KeyError#receiver and KeyError#key
* error.c: new method KeyError#receiver and KeyError#key.
  [Feature #12063]

* hash.c: make KeyError object with receiver and key.

* sprintf.c: ditto.

Author:    ksss <co000ri@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-18 08:05:53 +00:00
nobu 067d9e9ce9 sprintf.c: NULL as str
* sprintf.c (ruby_vsnprintf, ruby_snprintf): allow NULL as str,
  just count the expected buffer size.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-09 09:16:59 +00:00
nobu 8238987903 suppress warnings when RUBY_USE_SETJMPEX
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-02 03:02:22 +00:00
kazu d9d2bbe4b9 Improve error message
ref [Bug #13761]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-31 03:35:22 +00:00
nobu 53737990fe sprintf.c: width too big
* sprintf.c (rb_str_format): explicitly reject too big negative
  width, instead of an empty string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-23 09:44:48 +00:00
nobu c854fde373 sprintf.c: remove redundant condition
* sprintf.c (rb_str_format): when `t + 1 == end` (or `t < end`),
  `*t == '%'` is always true.  [ruby-core:80153] [Bug #13315]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26 06:39:49 +00:00
eregon fd8df3ab3d Raise ArgumentError if sprintf format string ends with %
* Add tests and specs. See ruby/spec#401.
  Patch by Yuta Iwama and Shintaro Morikawa.
  [ruby-core:80153] [Bug #13315] [Fix GH-1560]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25 15:33:28 +00:00
nobu 99a105c82f sprintf.c: remove unused variable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-28 11:42:58 +00:00
nobu efdc6d78ac sprintf.c: ruby_ultoa
* sprintf.c (ruby_ultoa): prefixed to get rid of conflict with
  a MSVC library function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-28 05:08:44 +00:00
nobu fb7c7d1e79 sprintf.c: format by utility functions
* sprintf.c (rb_str_format, fmt_setup): format by utility
  functions in vsnprintf.c instead of `snprintf`.

* sprintf.c (rb_str_format): format and append by `rb_str_catf`
  instead of formatting by `snprintf` and then copy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-28 02:10:51 +00:00
nobu be2e146a55 sprintf.c: fix one-off bug
* sprintf.c (rb_str_format): `CHECK` just before `FILL_`, but
  after another `PUSH`.  fix one-off bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-28 02:05:54 +00:00
nobu be7309ddf6 Refactor "%f" % Inf/NaN
* sprintf.c (rb_str_format): as for non-finite float, calculate
  the exact needed size with the space flag.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-23 01:04:40 +00:00
nobu 6f8f950cc3 Fix space flag when Inf/NaN and width==3
* sprintf.c (rb_str_format): while `"% 2f"` and `"% 4f"` result in
  `" Inf"` and `" Inf"` respectively, `"% 3f"` results in
  `"Inf"` (no space).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-23 01:04:39 +00:00
nobu 57d6dd5a46 Avoid integer overflow in sprintf()
merged ff03a9a61c

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-20 01:36:08 +00:00
nobu f31bb33a3b sprintf.c: string limits
* sprintf.c (ruby__sfvwrite): use long instead of size_t due to
  string limits.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-20 01:33:08 +00:00
nobu f30ed02b8a sprintf.c: use FILL
* sprintf.c (rb_str_format): use FILL and FILL_ macros instead of
  while loop.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-19 12:46:31 +00:00
nobu a41d569e66 sprintf.c: fix out-of-bound access
* sprintf.c (rb_str_format): get rid of out-of-bound access when
  single % at the end.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-13 14:59:08 +00:00
shyouhei c56edb9a59 revert RB_FIXABLE related changesets [Bug #13288][Bug #13293][Bug #13294]
This commit is auto-generated using following command:

svn diff -r57807:57788 include internal.h bignum.c numeric.c compile.c insns.def object.c sprintf.c | patch -p0


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-09 02:31:23 +00:00
shyouhei 74cdd893eb optimize FIXABLE macro
Looking at the source code, FIXABLE tends to be just before LOING2FIX
to check applicability of that operation.  Why not try computing first
then check for overflow, which should be optimial.

I also tried the same thing for unsigned types but resulted in slower
execution.  It seems RB_POSFIXABLE() is fast enough on modern CPUs.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-06 11:14:05 +00:00