Skip to content

Commit

Permalink
Fixed incorrect formatting of results from string concatenation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkitchin committed Apr 27, 2011
1 parent a050654 commit 768e231
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions OrcScala/src/orc/lib/math/Add.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public Object evaluate(final Args args) throws TokenException {
try {
// the first argument is a string
final String a = args.stringArg(0);
return a + String.valueOf(args.getArg(1));
return a + orc.values.Format.formatValueR(args.getArg(1), false);
} catch (final TokenException _3) {
// the second argument is a string
final String b = args.stringArg(1);
return String.valueOf(args.getArg(0)) + b;
return orc.values.Format.formatValueR(args.getArg(0), false) + b;
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions OrcScala/src/orc/values/Format.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,24 @@ package orc.values
*/
object Format {

def formatValue(v: Any): String =

def formatValue(v: Any): String = {
// Escape strings by default
formatValue(v, true)
}

def formatValue(v: Any, escapeStrings: Boolean): String =
v match {
case null => "null"
case l: List[_] => "[" + formatSequence(l) + "]"
case s: String => unparseString(s)
case s: String => if (escapeStrings) { unparseString(s) } else s
case orcv: OrcValue => orcv.toOrcSyntax()
case other => other.toString()
}

// For Java callers:
def formatValueR(v: AnyRef): String = formatValue(v)
def formatValueR(v: AnyRef, escapeStrings: Boolean): String = formatValue(v, escapeStrings)

def formatSequence(vs : List[_]) =
vs match {
Expand Down

0 comments on commit 768e231

Please sign in to comment.