[ruby-core:74576] [Ruby trunk Bug#12202] nkf.c static void mime_putc the variable being used for loop used for outer loop too

From: fanantoxa@...
Date: 2016-03-25 20:05:08 UTC
List: ruby-core #74576
Issue #12202 has been updated by Anton Sivakov.


Shyouhei Urabe wrote:
> This is (surprisingly) safe, because that `mimeout_state.count = 0;` line purposefully terminates outer loop.  It works as expected; just in a ultimately complicated way.

Is this ok? It can be complicated for understanding. Should I close this bug or try refactor?

----------------------------------------
Bug #12202: nkf.c  static void mime_putc the variable being used for loop used for outer loop too
https://bugs.ruby-lang.org/issues/12202#change-57704

* Author: Anton Sivakov
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
~~~
for (i=0;i<mimeout_state.count;i++) {
  if (SP<mimeout_state.buf[i] && mimeout_state.buf[i]<DEL) {
    eof_mime();
    for (i=0;i<mimeout_state.count;i++) {
      (*o_mputc)(mimeout_state.buf[i]);
      base64_count++;
    }
    mimeout_state.count = 0;
  }
}
~~~

Variable 'i' here used for outer and inner loop.
Also variable mimeout_state.count can be changed within a loop it can affect outer loop



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next