Project

General

Profile

Actions

Bug #10582

closed

String#chomp strips off more newlines than its documentation states

Added by javawizard (Alex Boyd) over 9 years ago. Updated about 9 years ago.

Status:
Closed
Assignee:
Target version:
ruby -v:
ruby 2.2.0dev (2014-12-04 trunk 48708) [x86_64-darwin14]
[ruby-core:66753]

Description

Given an empty string as its parameter, String#chomp strips off as many trailing newlines as are present, plus a preceding carriage return if one exists:

irb(main):001:0> "foo\n\n\n".chomp
=> "foo\n\n"
irb(main):002:0> "foo\n\n\n".chomp ''
=> "foo"
irb(main):003:0> "foo\r\n\n\n".chomp ''
=> "foo"

This should either be mentioned as part of String#chomp's documentation, or removed.


Files

780.patch (1.79 KB) 780.patch hsbt (Hiroshi SHIBATA), 01/27/2015 12:20 PM

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

  • Assignee changed from matz (Yukihiro Matsumoto) to zzak (zzak _)
  • Target version set to 2.2.0
  • Category set to doc
  • Status changed from Open to Assigned

Updated by javawizard (Alex Boyd) over 9 years ago

Looks good to me. Thanks!

Updated by hsbt (Hiroshi SHIBATA) about 9 years ago

  • File 780.patch 780.patch added
  • Status changed from Assigned to Closed
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: DONTNEED

Updated by usa (Usaku NAKAMURA) about 9 years ago

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

Updated by usa (Usaku NAKAMURA) about 9 years ago

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

ruby_2_0_0 r49733 merged revision(s) 48747.

Updated by nagachika (Tomoyuki Chikanaga) about 9 years ago

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

Backported into ruby_2_1 branch at r49911.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0