File tree 1 file changed +18
-4
lines changed
modules/symja-evaluator/src/main/java/com/symja/evaluator
1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 1
1
package com .symja .evaluator ;
2
2
3
+ import org .matheclipse .core .basic .Config ;
3
4
import org .matheclipse .core .form .output .OutputFormFactory ;
4
5
import org .matheclipse .core .form .tex .TeXFormFactory ;
5
6
import org .matheclipse .core .interfaces .IExpr ;
7
+ import org .matheclipse .parser .client .ParserConfig ;
6
8
7
9
public class OutputForm {
10
+
8
11
public static String toString (IExpr result ) {
9
12
if (result == null ) {
10
13
return "" ;
11
14
}
12
15
try {
13
- OutputFormFactory outputFormFactory = OutputFormFactory .get (true , false );
14
- return outputFormFactory .toString (result );
16
+ OutputFormFactory outputFormFactory = OutputFormFactory .get (ParserConfig .PARSER_USE_LOWERCASE_SYMBOLS , false );
17
+ String string = outputFormFactory .toString (result );
18
+
19
+ if (string .length () > Config .MAX_OUTPUT_SIZE ) {
20
+ return "Max output size " + Config .MAX_OUTPUT_SIZE + " characters exceeded" ;
21
+ }
22
+
23
+ return string ;
15
24
} catch (Exception e ) {
16
- return "Error" ;
25
+ return "Error: " + e . getMessage () ;
17
26
}
18
27
}
19
28
@@ -27,9 +36,14 @@ public static String toLatex(IExpr expr) {
27
36
if (teXFormFactory .convert (buffer , expr )) {
28
37
return buffer .toString ();
29
38
}
39
+
40
+ if (buffer .length () > Config .MAX_OUTPUT_SIZE ) {
41
+ return "Max output size " + Config .MAX_OUTPUT_SIZE + " characters exceeded" ;
42
+ }
43
+
30
44
return "Error" ;
31
45
} catch (Exception e ) {
32
- return "Error" ;
46
+ return "Error: " + e . getMessage () ;
33
47
}
34
48
}
35
49
}
You can’t perform that action at this time.
0 commit comments