Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[String] Fixed a crash when parsing an empty documentation comment. #50

Merged
merged 1 commit into from
May 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## Master

##### Breaking

None.

##### Enhancements

None.

##### Bug Fixes

* Fixed a crash when parsing an empty documentation comment.
[JP Simard](https://github.com/jpsim)
[#236](https://github.com/realm/jazzy/issues/236)


## 0.4.3

##### Breaking
Expand Down
3 changes: 3 additions & 0 deletions Source/SourceKittenFramework/String+SourceKitten.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ extension NSString {
:param: characterSet Character set to check for membership.
*/
public func stringByTrimmingTrailingCharactersInSet(characterSet: NSCharacterSet) -> String {
if length == 0 {
return self as String
}
var charBuffer = [unichar](count: length, repeatedValue: 0)
getCharacters(&charBuffer)
for newLength in reverse(1...length) {
Expand Down
1 change: 1 addition & 0 deletions Source/SourceKittenFrameworkTests/StringTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class StringTests: XCTestCase {
}

func testStringByTrimmingTrailingCharactersInSet() {
XCTAssertEqual("".stringByTrimmingTrailingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()), "")
XCTAssertEqual(" a ".stringByTrimmingTrailingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()), " a")
}

Expand Down