Project

General

Profile

Actions

Bug #11766

closed

sprintf formatting Rationals as floats produces garbage

Added by heftig (Jan Steffens) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
[ruby-core:71806]

Description

Test case:

"%8.1f %8.1f" % [1r, 1r]

Expected:

"     1.0      1.0"

Actual result:

"              \u0000\u0000\u0000"

Updated by heftig (Jan Steffens) over 8 years ago

Another case:

"ABC%8.1fDEF" % [1r]

Expected:

"ABC     1.0DEF"

Actual result:

"ABC     \u0000\u0000\u0000DEF"
Actions #2

Updated by nobu (Nobuyoshi Nakada) over 8 years ago

  • Status changed from Open to Closed

Applied in changeset r52869.


sprintf.c: fix garbage inserted with Rational

  • 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]

Updated by nagachika (Tomoyuki Chikanaga) over 8 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 8 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE

Backported into ruby_2_2 branch at r52874.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0