aboutsummaryrefslogtreecommitdiffstats
path: root/pack.c
Commit message (Collapse)AuthorAgeFilesLines
* * expand tabs.svn2018-10-171-7/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* infect taint flag on Array#pack and String#unpacknagachika2018-10-171-0/+7
| | | | | | | | | | with the directives "B", "b", "H" and "h". * pack.c (pack_pack, pack_unpack_internal): infect taint flag. * test/ruby/test_pack.rb: add test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* UNREACHABLE_RETURNnobu2018-07-241-1/+1
| | | | | | | * include/ruby/ruby.h (UNREACHABLE_RETURN): UNREACHABLE at the end of non-void functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack/unpack M only handles LF line breaks [Feature #14352]naruse2018-04-191-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: fix underflownobu2018-03-281-1/+1
| | | | | | | * pack.c (pack_unpack_internal): get rid of underflow. https://hackerone.com/reports/298246 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: remove dependecy on ruby/encoding.hnobu2018-01-091-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Workaround for optimization bug of Oracle Developer Studio 12.4-12.6ngoto2017-12-191-2/+3
| | | | | | | | | | * pack.c (pack_unpack, AVOID_CC_BUG): Very ugly workaround for optimization bug of Oracle Developer Studio (Oracle Solaris Studio) 12.4, 12.5, and 12.6 on Solaris 10 with -xO4 optimization option. [Bug #11684] [ruby-core:84351] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: unpack "M" may be ASCII onlynobu2017-09-291-3/+5
| | | | | | | * pack.c (pack_unpack_internal): set ASCII only properly on "M", may be ASCII only. [ruby-core:83055] [Bug #13949] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Workaround for optimization bug of Oracle Solaris Studio 12.4 and 12.5ngoto2017-04-141-2/+2
| | | | | | | | | | * pack.c (pack_unpack, AVOID_CC_BUG): Very ugly workaround for optimization bug of Oracle Solaris Studio 12.4 and 12.5 (Oracle Developer Studio 12.5) on Solaris with -xO4 optimization option. [Bug #11684] [ruby-core:80690] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* backward.h: 2.2 deprecated featuresnobu2017-02-211-12/+0
| | | | | | | * include/ruby/backward.h (DECLARE_DEPRECATED_FEATURE): move features deprecated at 2.2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* DEPRECATED_INTERNAL_FEATUREnobu2017-02-171-2/+2
| | | | | | | | | * error.c (ruby_deprecated_internal_feature): renamed, to explicitly represent deprecation. * internal.h (DEPRECATED_INTERNAL_FEATURE): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: avoid returning uninitialized Stringrhe2016-12-261-4/+8
| | | | | | | | | | Fix unpacking with 'b', 'B', 'h' and 'H' format. Do not return an uninitialized String to Ruby before filling the content bytes. Fixes r11175 ("pack.c (pack_unpack): execute block if given with unpacked value instead of creating an array", 2006-10-15). [ruby-core:78841] [Bug #13075] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove unused variablenaruse2016-12-011-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* String#unpack1 [Feature #12752]naruse2016-12-011-125/+155
| | | | | | Returns the first value of String#unpack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove `offset:` from `Array#pack`usa2016-12-011-30/+9
| | | | | | | * pack.c (pack_pack): can use `@` instead of `offset:`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Supports `buffer` and `offset` in `Array#pack`usa2016-12-011-5/+56
| | | | | | | | * pack.c (pack_pack): Supports `buffer` and `offset` in `Array#pack`. [Feature #12754] [ruby-dev:49798] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: simplifynobu2016-11-121-13/+3
| | | | | | | | | | * pack.c (str_associate): remove unnecessary branch. the argument must be a plain vanilla string object. * pack.c (str_associated): use rb_ivar_lookup to give the undefined value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] table format refined.akr2016-10-251-166/+156
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] add description of j and J for unpack.akr2016-10-251-0/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (pack_pack): use union instead of bare variable to easenaruse2016-07-051-149/+54
| | | | | | | | | optimizations and avoid assigning x87 floating point number. [ruby-core:74496] [Bug #12209] * pack.c (pack_unpack): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: ONLY_FOR_INTERNAL_USEnobu2016-04-271-4/+2
| | | | | | | | * error.c (ruby_only_for_internal_use): raise fatal error when deprecated function only for internal use is called, not just a warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: check index rangenobu2015-12-131-5/+5
| | | | | | | | * pack.c (pack_pack): always check index range against the receiver array length, which can be shortened by elements conversion. reported by Marcin 'Icewall' Noga of Cisco Talos. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (pack_unpack, AVOID_CC_BUG): Very ugly workaround forngoto2015-11-131-1/+11
| | | | | | | | optimization bug of Oracle Solaris Studio 12.4 on Solaris with -xO4 optimization option. [Bug #11684] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (pack_{un,}pack): new template character `j` and `J`, pointerusa2015-06-121-13/+47
| | | | | | | | | | with signed and unsigned integers. * NEWS: mention bout this featre. [Feature #11215] [ruby-dev:49015] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: hexdigitnobu2015-02-131-1/+1
| | | | | | * 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: Include ruby.h and ruby/encoding.h to beakr2014-11-151-2/+0
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: escape and encodingnobu2014-11-061-3/+12
| | | | | | | * pack.c (pack_pack): escape unprintable characters and preserve the encoding of warning message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (pack_unpack): Add casts for char references for 'u'.akr2014-10-171-16/+16
| | | | | | | | Fix line ending recognition algorithm. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (pack_unpack): Add casts for char references for 'b' and 'h'.akr2014-10-171-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * Avoid undefined behaviors found by gcc -fsanitize=undefined.akr2014-10-171-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* pack.c: no nil.taintnobu2014-09-101-1/+1
| | | | | | * pack.c (pack_pack): nil is not taintable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c (encodes): name a magic numbernobu2014-08-041-6/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: fix buffer overrunnobu2014-07-111-3/+5
| | | | | | | * pack.c (encodes): fix buffer overrun by tail_lf. Thanks to Mamoru Tasaka and Tomas Hoger. [ruby-core:63604] [Bug #10019] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (BUFSIZE): Unused macro removed.akr2014-05-111-10/+0
| | | | | | | | | | | | | | | | * 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
* * pack.c (swaps): Unused macro removed.akr2014-05-111-32/+0
| | | | | | | | | | (swapi): Ditto. (swapl): Ditto. (swapll): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: hide associated objectsnobu2014-02-051-1/+1
| | | | | | | | | | | * marshal.c (to_be_skipped_id): ignore anonymous attributes. * pack.c (Init_pack): use anonymous ID so that associated objects do not appear in the packed result. * parse.y (rb_make_internal_id): return an anonymous ID for internal use. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: use ivar for associated objectsnobu2014-02-041-4/+45
| | | | | | | | * pack.c (str_associate, str_associated): keep associated objects in an instance variables, instead of in the internal structure. * string.c (rb_str_associate, rb_str_associated): deprecate. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * dir.c, pack.c, ruby.c, struct.c, vm_eval.c: use RARRAY_CONST_PTR().glass2013-11-081-4/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (ruby_digit36_to_number_table): Declared.akr2013-07-031-13/+5
| | | | | | | | | | | | * util.c (ruby_digit36_to_number_table): Moved from scan_digits. * bignum.c (conv_digit): Use ruby_digit36_to_number_table. * pack.c (hex2num): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (pack_unpack): Remove specialized unpackers for integers.akr2013-06-221-131/+19
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (num2i32): Removed.akr2013-06-221-90/+11
| | | | | | | | (pack_pack): Don't use num2i32. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_pack): Specialized packers implemented.akr2013-06-211-37/+0
| | | | | | | | | | | | | | | | | (HOST_BIGENDIAN_P): New macro. (ALIGNOF): New macro. (CLEAR_LOWBITS): New macro. (FILL_LOWBITS): New macro. (swap_bdigit): New macro. (bary_2comp): Returns an int. * internal.h (swap16): Moved from pack.c (swap32): Ditto. (swap64): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (pack_pack): Move the implementation for 'c' directive afterakr2013-06-211-8/+15
| | | | | | | | pack_integer label. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_2comp): Extracted from get2comp.akr2013-06-161-3/+2
| | | | | | | | | | | | | | | | | | | | (integer_unpack_num_bdigits): Extracted from rb_integer_unpack_internal. (bary_unpack_internal): Renamed from bary_unpack and support INTEGER_PACK_2COMP. (bary_unpack): New function to validate arguments and invoke bary_unpack_internal. (rb_integer_unpack_internal): Removed. (rb_integer_unpack): Invoke bary_unpack_internal. (rb_integer_unpack_2comp): Removed. * internal.h (rb_integer_unpack_2comp): Removed. * pack.c: Follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (INTEGER_PACK_2COMP): Defined.akr2013-06-161-2/+3
| | | | | | | | | | | | | | | | | | (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
* * bignum.c (rb_integer_unpack_2comp): New function.akr2013-06-121-28/+6
| | | | | | | | | | | | | | | | | (rb_integer_unpack_internal): Extracted from rb_integer_unpack and nlp_bits_ret argument added. (integer_unpack_num_bdigits_small): nlp_bits_ret argument added to return number of leading padding bits. (integer_unpack_num_bdigits_generic): Ditto. * internal.h (rb_integer_unpack_2comp): Declared. * pack.c (pack_unpack): Use rb_integer_unpack_2comp and rb_integer_unpack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * pack.c (pack_pack): Use rb_integer_pack_2comp.akr2013-06-121-23/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (INTEGER_PACK_NEGATIVE): Defined.akr2013-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | | (rb_integer_unpack): sign argument removed. * bignum.c (rb_integer_unpack): sign argument removed. Non-negative integers generated by default. INTEGER_PACK_NEGATIVE flag is used to generate non-positive integers. * pack.c (pack_unpack): Follow the above change. * random.c (int_pair_to_real_inclusive): Ditto. (make_seed_value): Ditto. (mt_state): Ditto. (limited_big_rand): Ditto. * marshal.c (r_object0): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_integer_pack): Returns sign instead of words.akr2013-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | (absint_numwords_generic): Follow the above change. (big2str_base_powerof2): Follow the above change. * internal.h: Ditto. * hash.c (rb_hash): Ditto. * pack.c (pack_pack): Ditto. * random.c (int_pair_to_real_inclusive): Ditto. (rand_init): Ditto. (random_load): Ditto. (limited_big_rand): Ditto. * time.c (v2w_bignum): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_absint_numwords): Renamed from rb_absint_size_in_word.akr2013-06-091-1/+1
| | | | | | | | | | | | | * internal.h (rb_absint_numwords): Follow the above change. * pack.c (pack_pack): Ditto. * random.c (rand_init): Ditto. (limited_big_rand): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e