aboutsummaryrefslogtreecommitdiffstats
path: root/sprintf.c
Commit message (Collapse)AuthorAgeFilesLines
* sprintf.c: refactor Rational fnobu2016-03-271-25/+23
| | | | | | | * sprintf.c (rb_str_format): refactor floating point format of Rational by using gereric Integer functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: fix buffer overflownobu2016-03-271-1/+1
| | | | | | | | * sprintf.c (rb_str_format): fix buffer overflow, length must be greater than precision. reported by William Bowling <will AT wbowling.info>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: simplifynobu2016-03-271-9/+2
| | | | | | * sprintf.c (rb_str_format): remove repeated calculations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: Rational f by generic Integer functionsnobu2016-03-271-10/+7
| | | | | | | | * sprintf.c (rb_str_format): convert Rational to floating point format by using gereric Integer functions, not by methods which can be overwritten. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: exact numbernobu2016-01-141-3/+9
| | | | | | * sprintf.c (rb_str_format): format exact number more exactly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: fix garbage inserted with Rationalnobu2015-12-031-7/+10
| | | | | | | | * sprintf.c (rb_str_format): fix wrong shifting position in Rational conversion when not at the beginning of the result. [ruby-core:71806] [Bug #11766] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c: rb_sym_internnobu2015-11-301-3/+3
| | | | | | | * symbol.c (rb_sym_intern): rename from rb_cstr_intern and add variants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: nil value is validnobu2015-11-111-6/+14
| | | | | | | | * sprintf.c (rb_str_format): look up the key, then get default value and raise KeyError if the returned value is nil. [ruby-dev:49338] [Ruby trunk - Bug #11677] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: hash default valuenobu2015-11-111-5/+5
| | | | | | | | * sprintf.c (rb_str_format): respect default value of a hash. no longer raises KeyError unless the default value of the hash is nil. [ruby-core:71354] [Bug #11661] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vsnprintf.c: constifynobu2015-09-281-1/+1
| | | | | | * vsnprintf.c (FILE::vextra): constify the return value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* preserve encodings in error messagesnobu2015-09-281-0/+20
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: rb_inspect returns a stringnobu2015-06-261-2/+6
| | | | | | | * sprintf.c (rb_str_format): rb_inspect() always returns a string. rb_obj_as_string() has no more effect. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: ruby specific functionsnobu2015-02-221-0/+33
| | | | | | | * sprintf.c (ruby_vsnprintf, ruby_snprintf): move ruby specific functions from vsnprintf.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: hexdigitnobu2015-02-131-0/+2
| | | | | | * util.c (hexdigit): extract identical constants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Gather declarations in non-header files.akr2014-11-181-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-3/+1
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* ruby.h: add mark to PRIsVALUEnobu2014-11-041-0/+3
| | | | | | | | | * include/ruby/ruby.h (PRIsVALUE), vsnprintf.c (BSD_vfprintf): add RUBY_PRI_VALUE_MARK to reduce danger of accidental conflict with plain "%i". binary incompatible with extension libraries using PRIsVALUE and built for 2.1 and earlier. [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: integer overflownobu2014-09-161-3/+3
| | | | | | | * sprintf.c (rb_str_format): fix a possible integer overflow and suppress implicit conversion warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: improve rational 'f' formatnobu2014-09-141-13/+39
| | | | | | | * sprintf.c (rb_str_format): rational 'f' format works for more values. [fix GH-717] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: fix conditionnobu2014-08-191-1/+1
| | | | | | | * sprintf.c (rb_str_format): fix condition to round. [ruby-core:64454] [Bug #10151] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: rational 'f' formatnobu2014-08-181-0/+67
| | | | | | | * sprintf.c (rb_str_format): support rational 'f' format. [ruby-core:64382] [Bug #10136] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: remove magic numbersnobu2014-08-181-2/+3
| | | | | | | * sprintf.c (rb_str_format): name default float precision and remove unused initial value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * sprintf.c (rb_str_format): like r47006, get rid ofktsj2014-07-301-2/+2
| | | | | | function calls in RSTRING_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y: change Symbol <-> ID relationship to avoidko12014-07-091-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exposing IDs from collectable symbols. [Bug #10014] Now, rb_check_id() returns 0 if corresponding symbol is pinned dynamic symbol. There is remaining intern_cstr_without_pindown(), it can return IDs from collectable symbols. We must be careful to use it (only used in parse.y). I think it should be removed if it does not have impact for performance. * parse.y: add: * STATIC_SYM2ID() * STATIC_ID2SYM() rename: * rb_pin_dynamic_symbol() -> dsymbol_pindown() * internal.h: remove: * rb_check_id_without_pindown() * rb_sym2id_without_pindown() add: * rb_check_symbol() * rb_check_symbol_cstr() * load.c: use rb_check_id() or rb_check_id_cstr(). * object.c: ditto. * struct.c: ditto. * thread.c: ditto. * vm_method.c: ditto. * string.c (sym_find): use only rb_check_symbol(). * sprintf.c (rb_str_format): use rb_check_symbol_cstr(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: skip non-interned namenobu2014-07-081-7/+8
| | | | | | | * sprintf.c (rb_str_format): get rid of accessing by symbol of invalid ID, when the name is not interned. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: check_name_argnobu2014-07-021-4/+12
| | | | | | * sprintf.c (check_name_arg): utility function for GETNAMEARG(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: check_pos_argnobu2014-07-021-6/+17
| | | | | | * sprintf.c (check_pos_arg): utility function for GETPOSARG(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: check_next_argnobu2014-07-021-4/+12
| | | | | | * sprintf.c (check_next_arg): utility function for GETNEXTARG(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: get_numnobu2014-07-021-13/+21
| | | | | | * sprintf.c (get_num): utility function for GETNUM(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: unnumbered asterisk with numbered argumentnobu2014-06-261-1/+4
| | | | | | | | * sprintf.c (GETASTER): should not use the numbered argument to be formatted, raise ArgumentError instead. [ruby-dev:48330] [Bug #9982] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: remove extra parenthesesnobu2014-06-261-1/+1
| | | | | | | * sprintf.c (GETASTER): remove extra parentheses from the second argument so that the error message does not contain them. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* encoding.h: constify rb_encodingnobu2014-06-021-2/+2
| | | | | | | * include/ruby/encoding.h: constify `rb_encoding` itself, not only arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* constify rb_encoding and OnigEncodingnobu2014-06-011-2/+2
| | | | | | | * include/ruby/encoding.h: constify `rb_encoding` arguments. * include/ruby/oniguruma.h: constify `OnigEncoding` arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y: support Symbol GC. [ruby-trunk Feature #9634]nari2014-03-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See this ticket about Symbol GC. * include/ruby/ruby.h: Declare few functions. * rb_sym2id: almost same as old SYM2ID but support dynamic symbols. * rb_id2sym: almost same as old ID2SYM but support dynamic symbols. * rb_sym2str: almost same as `rb_id2str(SYM2ID(sym))` but not pin down a dynamic symbol. Declare a new struct. * struct RSymbol: represents a dynamic symbol as object in Ruby's heaps. Add few macros. * STATIC_SYM_P: check a static symbol. * DYNAMIC_SYM_P: check a dynamic symbol. * RSYMBOL: cast to RSymbol * gc.c: declare RSymbol. support T_SYMBOL. * internal.h: Declare few functions. * rb_gc_free_dsymbol: free up a dynamic symbol. GC call this function at a sweep phase. * rb_str_dynamic_intern: convert a string to a dynamic symbol. * rb_check_id_without_pindown: not pinning function. * rb_sym2id_without_pindown: ditto. * rb_check_id_cstr_without_pindown: ditto. * string.c (Init_String): String#intern and String#to_sym use rb_str_dynamic_intern. * template/id.h.tmpl: use LSB of ID as a flag for determining a static symbol, so we shift left other ruby_id_types. * string.c: use rb_sym2str instead `rb_id2str(SYM2ID(sym))` to avoid pinning. * load.c: use xx_without_pindown function at creating temporary ID to avoid pinning. * object.c: ditto. * sprintf.c: ditto. * struct.c: ditto. * thread.c: ditto. * variable.c: ditto. * vm_method.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.akr2014-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (BIGNUM_EMBED_LEN_NUMBITS): Renamed from RBIGNUM_EMBED_LEN_NUMBITS. (BIGNUM_EMBED_LEN_MAX): Renamed from RBIGNUM_EMBED_LEN_MAX. (BIGNUM_SIGN_BIT): Renamed from RBIGNUM_SIGN_BIT. (BIGNUM_SIGN): Renamed from RBIGNUM_SIGN. (BIGNUM_SET_SIGN): Renamed from RBIGNUM_SET_SIGN. (BIGNUM_POSITIVE_P): Renamed from RBIGNUM_POSITIVE_P. (BIGNUM_NEGATIVE_P): Renamed from RBIGNUM_NEGATIVE_P. (BIGNUM_EMBED_FLAG): Renamed from RBIGNUM_EMBED_FLAG. (BIGNUM_EMBED_LEN_MASK): Renamed from RBIGNUM_EMBED_LEN_MASK. (BIGNUM_EMBED_LEN_SHIFT): Renamed from RBIGNUM_EMBED_LEN_SHIFT. (BIGNUM_LEN): Renamed from RBIGNUM_LEN. (RBIGNUM_DIGITS): Renamed from RBIGNUM_DIGITS. (BIGNUM_LENINT): Renamed from RBIGNUM_LENINT. * bignum.c: Follow the above change. * gc.c: Ditto. * marshal.c: Ditto. * math.c: Ditto. * numeric.c: Ditto. * random.c: Ditto. * rational.c: Ditto. * sprintf.c: Ditto. * ext/-test-/bignum/bigzero.c: Ditto. * ext/-test-/bignum/intpack.c: Ditto. * ext/bigdecimal/bigdecimal.c: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: QUOTE flagnobu2013-07-301-0/+1
| | | | | | | * sprintf.c (ruby__sfvextra): add QUOTE flag to escape unprintable characters. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * sprintf.c: Fix typo patch by @hynkle [Fixes GH-357]zzak2013-07-111-1/+1
| | | | | | | https://github.com/ruby/ruby/pull/357 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (INTEGER_PACK_2COMP): Defined.akr2013-06-161-2/+2
| | | | | | | | | | | | | | | | | | (rb_integer_pack_2comp): Removed. * bignum.c (bary_pack): Support INTEGER_PACK_2COMP. (rb_integer_pack): Invoke bary_pack directly. (rb_integer_pack_2comp): Removed. (rb_integer_pack_internal): Ditto. (absint_numwords_generic): Follow the above change. * pack.c (pack_pack): Ditto. * sprintf.c (rb_str_format): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * sprintf.c (rb_str_format): Fix a dynamic format string.akr2013-06-121-6/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_integer_pack_internal): Renamed from rb_integer_packakr2013-06-111-122/+97
| | | | | | | | | | | | | | | | | | | and overflow_2comp argument added. (rb_integer_pack): Just call rb_integer_pack_internal. (rb_integer_pack_2comp): New function. * internal.h (rb_integer_pack_2comp): Declared. * sprintf.c (rb_str_format): Use rb_integer_pack and rb_integer_pack_2comp to format binary/octal/hexadecimal integers. (ruby_digitmap): Declared. (remove_sign_bits): Removed. (BITSPERDIG): Ditto. (EXTENDSIGN): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: constify RBasic::klass and addko12013-05-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RBASIC_CLASS(obj) macro which returns a class of `obj'. This change is a part of RGENGC branch [ruby-trunk - Feature #8339]. * object.c: add new function rb_obj_reveal(). This function reveal interal (hidden) object by rb_obj_hide(). Note that do not change class before and after hiding. Only permitted example is: klass = RBASIC_CLASS(obj); rb_obj_hide(obj); .... rb_obj_reveal(obj, klass); TODO: API design. rb_obj_reveal() should be replaced with others. TODO: modify constified variables using cast may be harmful for compiler's analysis and optimizaton. Any idea to prohibt inserting RBasic::klass directly? If rename RBasic::klass and force to use RBASIC_CLASS(obj), then all codes such as `RBASIC(obj)->klass' will be compilation error. Is it acceptable? (We have similar experience at Ruby 1.9, for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)". * internal.h: add some macros. * RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal object. * RBASIC_SET_CLASS(obj, cls) set RBasic::klass. * RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS without write barrier (planned). * RCLASS_SET_SUPER(a, b) set super class of a. * array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c, file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c, parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c, string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c: Use above macros and functions to access RBasic::klass. * ext/coverage/coverage.c, ext/readline/readline.c, ext/socket/ancdata.c, ext/socket/init.c, * ext/zlib/zlib.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (MUL_OVERFLOW_INT_P): New macro.akr2013-04-091-3/+7
| | | | | | | | * sprintf.c (GETNUM): Don't overflow on signed integer multiplication. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: infectnobu2012-08-151-0/+1
| | | | | | | | * sprintf.c (ruby__sfvextra): the result should be infected by the given strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: coderange fixnobu2012-08-151-0/+1
| | | | | | | | * sprintf.c (ruby__sfvwrite): set buffer length and exclude uninitialized garbage to get correct coderange. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use rb_check_hash_typenobu2012-06-261-1/+1
| | | | | | | | | * class.c (rb_scan_args): use rb_check_hash_type. * process.c (rb_exec_getargs): ditto. * sprintf.c (get_hash): ditto. * string.c (rb_str_sub_bang, str_gsub): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* sprintf.c: inspect by plusnobu2012-05-241-2/+7
| | | | | | | | * sprintf.c (ruby__sfvextra): [EXPERIMENTAL] use inspect instead of to_s if plus flag is given. * vsnprintf.c (BSD_vfprintf): pass sign flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Feature #5896nobu2012-05-241-2/+45
| | | | | | | | * vsnprintf.c (BSD_vfprintf): [EXPERIMENTAL] object representation in rb_enc_vsprintf(). [Feature #5896] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y (rb_check_id_cstr): new function to check if ID isnobu2012-04-111-2/+5
| | | | | | | registered with NUL-terminated C string. * sprintf.c (rb_str_format): avoid inadvertent symbol creation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * sprintf.c (rb_str_format): fix exception message encoding.nobu2012-04-111-9/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * sprintf.c (rb_str_format): fix error message.nobu2012-04-111-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e