summaryrefslogtreecommitdiff
path: root/src/pprint
diff options
context:
space:
mode:
authorShaked Flur2017-12-16 16:41:23 +0000
committerShaked Flur2017-12-16 16:41:23 +0000
commitd7ce278ada49cbfdeeec35d12f86bcea56b4a6c9 (patch)
tree4f7536a2e9d74510fe8b911f10f7601b46d3df84 /src/pprint
parent8dde03d441a322fc489e4d25e16cd75d02f64474 (diff)
compatibility with OCaml 4.06.0;
imported new version of PPrint (20171003)
Diffstat (limited to 'src/pprint')
-rwxr-xr-xsrc/pprint/src/META2
-rw-r--r--src/pprint/src/Makefile15
-rw-r--r--src/pprint/src/PPrint.ml10
-rw-r--r--src/pprint/src/PPrintCombinators.ml10
-rw-r--r--src/pprint/src/PPrintCombinators.mli12
-rw-r--r--src/pprint/src/PPrintEngine.ml61
-rw-r--r--src/pprint/src/PPrintEngine.mli10
-rw-r--r--src/pprint/src/PPrintOCaml.ml10
-rw-r--r--src/pprint/src/PPrintOCaml.mli10
-rw-r--r--src/pprint/src/PPrintRenderer.ml10
-rw-r--r--src/pprint/src/PPrintTest.ml10
11 files changed, 88 insertions, 72 deletions
diff --git a/src/pprint/src/META b/src/pprint/src/META
index b7d43d40..4a966166 100755
--- a/src/pprint/src/META
+++ b/src/pprint/src/META
@@ -2,4 +2,4 @@ requires = ""
description = "The PPrint pretty-printing library"
archive(byte) = "PPrintLib.cma"
archive(native) = "PPrintLib.cmxa"
-version = "20140424"
+version = "20171003"
diff --git a/src/pprint/src/Makefile b/src/pprint/src/Makefile
index f56f4d88..3bfa12df 100644
--- a/src/pprint/src/Makefile
+++ b/src/pprint/src/Makefile
@@ -1,6 +1,6 @@
-.PHONY: all install clean doc test
+.PHONY: all install uninstall reinstall clean doc test bench
-OCAMLBUILD := ocamlbuild -use-ocamlfind -cflags "-g" -lflags "-g" -classic-display
+OCAMLBUILD := ocamlbuild -use-ocamlfind -classic-display
OCAMLFIND := ocamlfind
DOCDIR := doc
MAIN := PPrintTest
@@ -14,6 +14,14 @@ install: all
$(patsubst %,_build/%,$(TO_BUILD)) \
_build/PPrintLib.a _build/*.cmx _build/*.cmi
+# [make uninstall] attempts to uninstall, but succeeds even if uninstallation
+# fails (probably because the package was not installed in the first place).
+uninstall:
+ ocamlfind remove pprint || true
+
+reinstall: uninstall
+ @ $(MAKE) install
+
clean:
rm -f *~
rm -rf doc
@@ -33,3 +41,6 @@ test: all
$(OCAMLBUILD) $(MAIN).native
./$(MAIN).native
+bench: all
+ $(OCAMLBUILD) -tag use_unix PPrintBench.native
+ time ./PPrintBench.native
diff --git a/src/pprint/src/PPrint.ml b/src/pprint/src/PPrint.ml
index ae1ff709..46d732b1 100644
--- a/src/pprint/src/PPrint.ml
+++ b/src/pprint/src/PPrint.ml
@@ -2,12 +2,12 @@
(* *)
(* PPrint *)
(* *)
-(* Francois Pottier, INRIA Paris-Rocquencourt *)
-(* Nicolas Pouillard, IT University of Copenhagen *)
+(* François Pottier, Inria Paris *)
+(* Nicolas Pouillard *)
(* *)
-(* Copyright 2007-2014 INRIA. All rights reserved. This file is *)
-(* distributed under the terms of the CeCILL-C license, as described *)
-(* in the file LICENSE. *)
+(* Copyright 2007-2017 Inria. All rights reserved. This file is *)
+(* distributed under the terms of the GNU Library General Public *)
+(* License, with an exception, as described in the file LICENSE. *)
(* *)
(**************************************************************************)
diff --git a/src/pprint/src/PPrintCombinators.ml b/src/pprint/src/PPrintCombinators.ml
index 39b99b9c..70499878 100644
--- a/src/pprint/src/PPrintCombinators.ml
+++ b/src/pprint/src/PPrintCombinators.ml
@@ -2,12 +2,12 @@
(* *)
(* PPrint *)
(* *)
-(* Francois Pottier, INRIA Paris-Rocquencourt *)
-(* Nicolas Pouillard, IT University of Copenhagen *)
+(* François Pottier, Inria Paris *)
+(* Nicolas Pouillard *)
(* *)
-(* Copyright 2007-2014 INRIA. All rights reserved. This file is *)
-(* distributed under the terms of the CeCILL-C license, as described *)
-(* in the file LICENSE. *)
+(* Copyright 2007-2017 Inria. All rights reserved. This file is *)
+(* distributed under the terms of the GNU Library General Public *)
+(* License, with an exception, as described in the file LICENSE. *)
(* *)
(**************************************************************************)
diff --git a/src/pprint/src/PPrintCombinators.mli b/src/pprint/src/PPrintCombinators.mli
index ef2b44ea..c538cb35 100644
--- a/src/pprint/src/PPrintCombinators.mli
+++ b/src/pprint/src/PPrintCombinators.mli
@@ -2,12 +2,12 @@
(* *)
(* PPrint *)
(* *)
-(* Francois Pottier, INRIA Paris-Rocquencourt *)
-(* Nicolas Pouillard, IT University of Copenhagen *)
+(* François Pottier, Inria Paris *)
+(* Nicolas Pouillard *)
(* *)
-(* Copyright 2007-2014 INRIA. All rights reserved. This file is *)
-(* distributed under the terms of the CeCILL-C license, as described *)
-(* in the file LICENSE. *)
+(* Copyright 2007-2017 Inria. All rights reserved. This file is *)
+(* distributed under the terms of the GNU Library General Public *)
+(* License, with an exception, as described in the file LICENSE. *)
(* *)
(**************************************************************************)
@@ -133,7 +133,7 @@ val words: string -> document list
character that satisfies the predicate [ok]. The substrings thus obtained
are turned into documents, and a list of documents is returned. No
information is lost: the concatenation of the documents yields the
- original string. This code is not UTF-8 aware. *)
+ original string. This code is not UTF-8 aware. *)
val split: (char -> bool) -> string -> document list
(** [flow sep docs] separates the documents in the list [docs] with the
diff --git a/src/pprint/src/PPrintEngine.ml b/src/pprint/src/PPrintEngine.ml
index cfa8474a..2a78363d 100644
--- a/src/pprint/src/PPrintEngine.ml
+++ b/src/pprint/src/PPrintEngine.ml
@@ -2,12 +2,12 @@
(* *)
(* PPrint *)
(* *)
-(* Francois Pottier, INRIA Paris-Rocquencourt *)
-(* Nicolas Pouillard, IT University of Copenhagen *)
+(* François Pottier, Inria Paris *)
+(* Nicolas Pouillard *)
(* *)
-(* Copyright 2007-2014 INRIA. All rights reserved. This file is *)
-(* distributed under the terms of the CeCILL-C license, as described *)
-(* in the file LICENSE. *)
+(* Copyright 2007-2017 Inria. All rights reserved. This file is *)
+(* distributed under the terms of the GNU Library General Public *)
+(* License, with an exception, as described in the file LICENSE. *)
(* *)
(**************************************************************************)
@@ -57,7 +57,13 @@ end
class channel_output channel = object
method char = output_char channel
- method substring = output channel
+ method substring = output_substring channel
+ (* We used to use [output], but, as of OCaml 4.02 and with -safe-string
+ enabled, the type of [output] has changed: this function now expects
+ an argument of type [bytes]. The new function [output_substring] must
+ be used instead. Furthermore, as of OCaml 4.06, -safe-string is enabled
+ by default. In summary, we require OCaml 4.02, use [output_substring],
+ and enable -safe-string. *)
end
class buffer_output buffer = object
@@ -152,21 +158,21 @@ end
type document =
- (* [Empty] is the empty document. *)
+ (* [Empty] is the empty document. *)
| Empty
- (* [Char c] is a document that consists of the single character [c]. We
- enforce the invariant that [c] is not a newline character. *)
+ (* [Char c] is a document that consists of the single character [c]. We
+ enforce the invariant that [c] is not a newline character. *)
| Char of char
- (* [String (s, ofs, len)] is a document that consists of the portion of
- the string [s] delimited by the offset [ofs] and the length [len]. We
- assume, but do not check, that this portion does not contain a newline
- character. *)
+ (* [String s] is a document that consists of just the string [s]. We
+ assume, but do not check, that this string does not contain a newline
+ character. [String] is a special case of [FancyString], which takes up
+ less space in memory. *)
- | String of string * int * int
+ | String of string
(* [FancyString (s, ofs, len, apparent_length)] is a (portion of a) string
that may contain fancy characters: color escape characters, UTF-8 or
@@ -252,7 +258,8 @@ let rec requirement = function
0
| Char _ ->
1
- | String (_, _, len)
+ | String s ->
+ String.length s
| FancyString (_, _, _, len)
| Blank len ->
len
@@ -268,7 +275,7 @@ let rec requirement = function
infinity
| Cat (req, _, _)
| Nest (req, _, _)
- | Group (req, _)
+ | Group (req, _)
| Align (req, _) ->
(* These nodes store their requirement -- which is computed when the
node is constructed -- so as to allow us to answer in constant time
@@ -293,14 +300,8 @@ let char c =
let space =
char ' '
-let substring s ofs len =
- if len = 0 then
- empty
- else
- String (s, ofs, len)
-
let string s =
- substring s 0 (String.length s)
+ String s
let fancysubstring s ofs len apparent_length =
if len = 0 then
@@ -308,6 +309,9 @@ let fancysubstring s ofs len apparent_length =
else
FancyString (s, ofs, len, apparent_length)
+let substring s ofs len =
+ fancysubstring s ofs len len
+
let fancystring s apparent_length =
fancysubstring s 0 (String.length s) apparent_length
@@ -467,8 +471,9 @@ let rec pretty
(* assert (ok state flatten); *)
continue output state cont
- | String (s, ofs, len) ->
- output#substring s ofs len;
+ | String s ->
+ let len = String.length s in
+ output#substring s 0 len;
state.column <- state.column + len;
(* assert (ok state flatten); *)
continue output state cont
@@ -566,8 +571,9 @@ let rec compact output doc cont =
| Char c ->
output#char c;
continue output cont
- | String (s, ofs, len) ->
- output#substring s ofs len;
+ | String s ->
+ let len = String.length s in
+ output#substring s 0 len;
continue output cont
| FancyString (s, ofs, len, apparent_length) ->
output#substring s ofs len;
@@ -634,4 +640,3 @@ module ToFormatter =
type channel = Format.formatter
let output = new formatter_output
end)
-
diff --git a/src/pprint/src/PPrintEngine.mli b/src/pprint/src/PPrintEngine.mli
index 7f6fcf35..eda61a6c 100644
--- a/src/pprint/src/PPrintEngine.mli
+++ b/src/pprint/src/PPrintEngine.mli
@@ -2,12 +2,12 @@
(* *)
(* PPrint *)
(* *)
-(* Francois Pottier, INRIA Paris-Rocquencourt *)
-(* Nicolas Pouillard, IT University of Copenhagen *)
+(* François Pottier, Inria Paris *)
+(* Nicolas Pouillard *)
(* *)
-(* Copyright 2007-2014 INRIA. All rights reserved. This file is *)
-(* distributed under the terms of the CeCILL-C license, as described *)
-(* in the file LICENSE. *)
+(* Copyright 2007-2017 Inria. All rights reserved. This file is *)
+(* distributed under the terms of the GNU Library General Public *)
+(* License, with an exception, as described in the file LICENSE. *)
(* *)
(**************************************************************************)
diff --git a/src/pprint/src/PPrintOCaml.ml b/src/pprint/src/PPrintOCaml.ml
index 88e039ce..bee5f2a3 100644
--- a/src/pprint/src/PPrintOCaml.ml
+++ b/src/pprint/src/PPrintOCaml.ml
@@ -2,12 +2,12 @@
(* *)
(* PPrint *)
(* *)
-(* Francois Pottier, INRIA Paris-Rocquencourt *)
-(* Nicolas Pouillard, IT University of Copenhagen *)
+(* François Pottier, Inria Paris *)
+(* Nicolas Pouillard *)
(* *)
-(* Copyright 2007-2014 INRIA. All rights reserved. This file is *)
-(* distributed under the terms of the CeCILL-C license, as described *)
-(* in the file LICENSE. *)
+(* Copyright 2007-2017 Inria. All rights reserved. This file is *)
+(* distributed under the terms of the GNU Library General Public *)
+(* License, with an exception, as described in the file LICENSE. *)
(* *)
(**************************************************************************)
diff --git a/src/pprint/src/PPrintOCaml.mli b/src/pprint/src/PPrintOCaml.mli
index e1395203..119bca23 100644
--- a/src/pprint/src/PPrintOCaml.mli
+++ b/src/pprint/src/PPrintOCaml.mli
@@ -2,12 +2,12 @@
(* *)
(* PPrint *)
(* *)
-(* Francois Pottier, INRIA Paris-Rocquencourt *)
-(* Nicolas Pouillard, IT University of Copenhagen *)
+(* François Pottier, Inria Paris *)
+(* Nicolas Pouillard *)
(* *)
-(* Copyright 2007-2014 INRIA. All rights reserved. This file is *)
-(* distributed under the terms of the CeCILL-C license, as described *)
-(* in the file LICENSE. *)
+(* Copyright 2007-2017 Inria. All rights reserved. This file is *)
+(* distributed under the terms of the GNU Library General Public *)
+(* License, with an exception, as described in the file LICENSE. *)
(* *)
(**************************************************************************)
diff --git a/src/pprint/src/PPrintRenderer.ml b/src/pprint/src/PPrintRenderer.ml
index 9096eada..3449d6c3 100644
--- a/src/pprint/src/PPrintRenderer.ml
+++ b/src/pprint/src/PPrintRenderer.ml
@@ -2,12 +2,12 @@
(* *)
(* PPrint *)
(* *)
-(* Francois Pottier, INRIA Paris-Rocquencourt *)
-(* Nicolas Pouillard, IT University of Copenhagen *)
+(* François Pottier, Inria Paris *)
+(* Nicolas Pouillard *)
(* *)
-(* Copyright 2007-2014 INRIA. All rights reserved. This file is *)
-(* distributed under the terms of the CeCILL-C license, as described *)
-(* in the file LICENSE. *)
+(* Copyright 2007-2017 Inria. All rights reserved. This file is *)
+(* distributed under the terms of the GNU Library General Public *)
+(* License, with an exception, as described in the file LICENSE. *)
(* *)
(**************************************************************************)
diff --git a/src/pprint/src/PPrintTest.ml b/src/pprint/src/PPrintTest.ml
index 3e4fb2c9..37444127 100644
--- a/src/pprint/src/PPrintTest.ml
+++ b/src/pprint/src/PPrintTest.ml
@@ -2,12 +2,12 @@
(* *)
(* PPrint *)
(* *)
-(* Francois Pottier, INRIA Paris-Rocquencourt *)
-(* Nicolas Pouillard, IT University of Copenhagen *)
+(* François Pottier, Inria Paris *)
+(* Nicolas Pouillard *)
(* *)
-(* Copyright 2007-2014 INRIA. All rights reserved. This file is *)
-(* distributed under the terms of the CeCILL-C license, as described *)
-(* in the file LICENSE. *)
+(* Copyright 2007-2017 Inria. All rights reserved. This file is *)
+(* distributed under the terms of the GNU Library General Public *)
+(* License, with an exception, as described in the file LICENSE. *)
(* *)
(**************************************************************************)