json-stream-printer.sml.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --- json-stream-printer.sml.orig 2020-04-08 19:00:10.000000000 +0200
  2. +++ json-stream-printer.sml 2020-07-03 15:23:14.218708000 +0200
  3. @@ -70,7 +70,7 @@
  4. then TextIO.output(strm, String.extract(tenSpaces, 10-n, NONE))
  5. else (TextIO.output(strm, tenSpaces); prIndent(n-10))
  6. in
  7. - prIndent ((!indent+offset) * 2)
  8. + prIndent (!indent+offset)
  9. end
  10. fun incIndent (P{indent, ...}, n) = indent := !indent + n;
  11. @@ -108,14 +108,14 @@
  12. fun tr (i, chrs) = (case getWChar i
  13. of SOME(wchr, i) => if (wchr <= 0w126)
  14. then (case UTF8.toAscii wchr
  15. - of #"\"" => "\\\""
  16. - | #"\\" => "\\\\"
  17. - | #"/" => "\\/"
  18. - | #"\b" => "\\b"
  19. - | #"\f" => "\\f"
  20. - | #"\n" => "\\n"
  21. - | #"\r" => "\\r"
  22. - | #"\t" => "\\t"
  23. + of #"\"" => tr(i, "\\\"" :: chrs)
  24. + | #"\\" => tr(i, "\\\\" :: chrs)
  25. + | #"/" => tr(i, "\\/" :: chrs)
  26. + | #"\b" => tr(i, "\\b" :: chrs)
  27. + | #"\f" => tr(i, "\\f" :: chrs)
  28. + | #"\n" => tr(i, "\\n" :: chrs)
  29. + | #"\r" => tr(i, "\\r" :: chrs)
  30. + | #"\t" => tr(i, "\\t" :: chrs)
  31. | c => if (wchr < 0w32)
  32. then tr(i, F.format "\\u%04x" [F.WORD wchr] :: chrs)
  33. else tr(i, str c :: chrs)
  34. @@ -131,7 +131,7 @@
  35. of CLOSED => raise Fail "closed printer"
  36. | _ => (
  37. optComma p;
  38. - pr (p, "{"); incIndent(p, 2); nl p;
  39. + pr (p, "{"); incIndent(p, 1); nl p;
  40. ctx := FIRST(OBJECT(!ctx)))
  41. (* end case *))
  42. @@ -148,7 +148,7 @@
  43. fun endObject (p as P{ctx, ...}) = let
  44. fun prEnd ctx' = (
  45. ctx := ctx';
  46. - indent(p, ~1); pr(p, "}"); decIndent (p, 2))
  47. + decIndent (p, 1); indent(p, 0); pr(p, "}"))
  48. in
  49. case !ctx
  50. of CLOSED => raise Fail "closed printer"
  51. @@ -163,14 +163,14 @@
  52. of CLOSED => raise Fail "closed printer"
  53. | _ => (
  54. optComma p;
  55. - pr (p, "["); incIndent(p, 2); nl p;
  56. + pr (p, "["); incIndent(p, 1); nl p;
  57. ctx := FIRST(ARRAY(!ctx)))
  58. (* end case *))
  59. fun endArray (p as P{ctx, ...}) = let
  60. fun prEnd ctx' = (
  61. ctx := ctx';
  62. - indent(p, ~1); pr(p, "]"); decIndent (p, 2))
  63. + decIndent (p, 1); indent(p, 0); pr(p, "]"))
  64. in
  65. case !ctx
  66. of CLOSED => raise Fail "closed printer"