Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed CLI print helper to not stack overflow.

  • Loading branch information...
commit 3e365fc2d9b15b2f7ca5fefd27bb221467a0be0e 1 parent adc133b
Josh Suereth jsuereth authored
Showing with 11 additions and 6 deletions.
  1. +11 −6 reporter/src/main/scala/ssol/tools/mima/cli/Main.scala
17 reporter/src/main/scala/ssol/tools/mima/cli/Main.scala
View
@@ -61,15 +61,20 @@ class Main(args: List[String]) extends {
/** Converts a problem to a human-readable mapped string. */
private def printProblem(p: core.Problem): String = {
- def wrap(words: Seq[String]): Seq[Seq[String]] =
- if(words.isEmpty) Seq.empty
+ def wrap(words: Seq[String], result: List[String] = Nil): Seq[String] =
+ if(words.isEmpty) result.reverse
else {
// This is so painfully slow, it hurts.
- val output = (words.inits dropWhile { x => x.map(_.length).sum + x.length > 77 }).next
- output +: wrap(words.drop(output.length))
+ val output = {
+ val tmp = (words.inits dropWhile { x => x.map(_.length).sum + x.length > 77 }).next
+ if(tmp.isEmpty) Seq(words.head)
+ else tmp
+ }
+ val line = output mkString " "
+ val rest = words drop output.length
+ wrap(rest, line :: result)
}
- def wrapString(s: String) =
- wrap(s split "\\s") map (_ mkString " ")
+ def wrapString(s: String) = wrap(s split "\\s")
wrapString(" * " + p.description) mkString "\n "
}
Please sign in to comment.
Something went wrong with that request. Please try again.