Spiros Eliopoulos
11cbedf115
expose function to flush formatter's internal queue
...
Previous to this commit the Format API did not allow the user to flush a
formatter's internal queue without also flushing the formatter's output
stream. This was a problem for custom formatters that may have been used
in conjunction with kfprintf or ikfprintf. When the continuation was
called, the formatter's queue of operations may not have been flushed.
The only way that the user could force a queue flush was to call
pp_print_flush, forcing the user to introduce a blocking call before it
was necessary, regardless of other buffer state within the system.
Exposing the internal queue flushing operation solves this problem.
Names may be changed to protect aesthetic sensibilities.
2016-04-04 08:51:48 -04:00
Damien Doligez
5401ce8473
Update headers for the new license.
...
Remains to be done: remove all headers in testsuite/tests.
2016-02-18 16:59:16 +01:00
pierreweis
699b223217
Careful code review/rewriting. Moving obsolete stuff to the proper devoted section. Documentation.
2015-12-24 13:54:16 +01:00
Mark Shinwell
347fec44fb
Add Format.kasprintf and fix Misc.fatal_errorf to use it
2015-12-23 10:47:31 +00:00
Gabriel Scherer
b2e81d7800
Merge pull request #267 from yallop/faster-ifprintf
...
A more efficient implementation of ifprintf
2015-10-31 16:54:40 +01:00
alainfrisch
a127e661b2
Code cleanup: replace let-binding of type unit with sequence.
2015-10-27 11:28:36 +01:00
Jeremy Yallop
19301282d5
Use make_iprintf to build Format.ikfprintf and Format.ifprintf.
2015-10-27 00:02:45 +00:00
Pierre Weis
e02d472aa4
Renaming: flush_buf_formatter into flush_buffer_formatter.
...
flush_str_formatter rewritten using flush_buffer_formatter.
Consistent naming of pretty-printer formatter as ppf not strange x or o
parameters.
Function ksprintf purposedly defines a new continuation embedding the old
one.
Function asprintf rewritten in a more natural way; spurious pp_flush_queue
deleted in the conitnuation, since it is already done via following
flush_buffer_formatter call.
Indent.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16429 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-09-21 17:08:11 +00:00
Gabriel Scherer
926cc79f1c
PR#6824: fix buffer sharing on partial application of Format.asprintf
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@16043 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2015-04-26 20:00:57 +00:00
Damien Doligez
cbfe627f92
merge changes from branch 4.02 from branching (rev 14852) to 4.02.0+rc1 (rev 15121)
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15125 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-08-22 13:45:02 +00:00
Gabriel Scherer
49d3f7b9f8
PR#6418: support "@[<hov %d>" in the new format implementation (Benoît Vaugon)
...
The bootstrap procedure, as for commit trunk@14973 (see there for
detailed build instructions), requires to first commit a temporary
patch:
> diff -Naur old/typing/typecore.ml new/typing/typecore.ml
> --- old/typing/typecore.ml 2014-06-11 18:16:24.851647309 +0200
> +++ new/typing/typecore.ml 2014-06-11 18:15:50.075646418 +0200
> @@ -2758,16 +2758,9 @@
> let mk_int n = mk_cst (Const_int n)
> and mk_string str = mk_cst (Const_string (str, None))
> and mk_char chr = mk_cst (Const_char chr) in
> - let mk_block_type bty = match bty with
> - | Pp_hbox -> mk_constr "Pp_hbox" []
> - | Pp_vbox -> mk_constr "Pp_vbox" []
> - | Pp_hvbox -> mk_constr "Pp_hvbox" []
> - | Pp_hovbox -> mk_constr "Pp_hovbox" []
> - | Pp_box -> mk_constr "Pp_box" []
> - | Pp_fits -> mk_constr "Pp_fits" [] in
> let rec mk_formatting_lit fmting = match fmting with
> - | Open_box (org, bty, idt) ->
> - mk_constr "Open_box" [ mk_string org; mk_block_type bty; mk_int idt ]
> + | Open_box _ ->
> + assert false
> | Close_box ->
> mk_constr "Close_box" []
> | Close_tag ->
> @@ -2950,6 +2943,19 @@
> mk_constr "Alpha" [ mk_fmt rest ]
> | Theta rest ->
> mk_constr "Theta" [ mk_fmt rest ]
> + | Formatting_lit (Open_box (org, _bty, _idt), rest) ->
> + mk_constr "Formatting_gen" [
> + mk_constr "Open_box" [
> + mk_constr "Format" [
> + mk_constr "String_literal" [
> + mk_string "<>";
> + mk_constr "End_of_format" [];
> + ];
> + mk_string "@[<>";
> + ]
> + ];
> + mk_fmt rest;
> + ]
> | Formatting_lit (fmting, rest) ->
> mk_constr "Formatting_lit" [ mk_formatting_lit fmting; mk_fmt rest ]
> | Formatting_gen (fmting, rest) ->
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14984 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-06-14 21:08:50 +00:00
Gabriel Scherer
7cb9d0d84e
PR#6418: fix format regression on "@{<..%d..%s..>" (Benoît Vaugon)
...
To be able to compile this patch, you should temporarily apply the
following patch to bootstrap the format type change:
> diff -Naur old/typing/typecore.ml new/typing/typecore.ml
> --- old/typing/typecore.ml 2014-06-06 03:37:03.240926150 +0200
> +++ new/typing/typecore.ml 2014-06-06 03:37:24.696926699 +0200
> @@ -2956,7 +2956,7 @@
> | Theta rest ->
> mk_constr "Theta" [ mk_fmt rest ]
> | Formatting (fmting, rest) ->
> - mk_constr "Formatting" [ mk_formatting fmting; mk_fmt rest ]
> + mk_constr "Formatting_lit" [ mk_formatting fmting; mk_fmt rest ]
> | Reader rest ->
> mk_constr "Reader" [ mk_fmt rest ]
> | Scan_char_set (width_opt, char_set, rest) ->
Bootstrap process:
make core
apply the patch above
make core
make promote-cross
make partialclean
revert the patch above, apply the commit
make partialclean
make core
make coreboot
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14973 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-06-09 13:53:47 +00:00
Gabriel Scherer
3ffa399b37
Use a nominal datatype for CamlinternalFormat.format6
...
This should make the type-checking of formats simpler and more robust:
instead of trying to find a pair as previously, we can now use the
path of the format6 type directly.
A nice side-effect of the change is that the internal definition of
formats (as a pair) is not printed in error messages anymore.
Because format6 is in fact defined in the CamlinternalFormatBasics
submodule of Pervasives, and has an alias at the toplevel of
Pervasives, error messages still expand the definition:
> Error: This expression has type
> ('a, 'b, 'c, 'd, 'd, 'a) format6 =
> ('a, 'b, 'c, 'd, 'd, 'a) CamlinternalFormatBasics.format6
> but an expression was expected of type ...
Passing the option `-short-paths` does avoid this expansion and
returns exactly the same error message as 4.01:
> Error: This expression has type ('a, 'b, 'c, 'd, 'd, 'a) format6
> but an expression was expected of type ...
(To get this error message without -short-paths, one would need to
define format6 directly in Pervasives; but this type is mutually
recursive with several GADT types that we don't want to add in the
Pervasives namespace unqualified. This is why I'll keep the alias
for now.)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14868 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-05-14 15:07:13 +00:00
Gabriel Scherer
0e1584665e
fix a regression in Format formatting printing routines
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14842 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-05-12 15:38:37 +00:00
Gabriel Scherer
72669307e8
second part of Benoît Vaugon's format+gadts patch
...
To finish the bootstrap cycle, run:
make library-cross
make promote
make partialclean
make core
make library-cross
make promote-cross
make partialclean
make ocamlc ocamllex ocamltools
make library-cross
make promote
make partialclean
make core
make compare
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14810 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-05-12 15:37:37 +00:00
Damien Doligez
5b8df637d2
merge branch "safe-string"
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14705 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2014-04-29 11:56:17 +00:00
Gabriel Scherer
8ba031a7db
Format: pp_print_list and pp_print_text, contributed by Daniel Bünzli
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14123 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-09-13 15:55:41 +00:00
Pierre Weis
626c696aee
Wrong quoting chase.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13717 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-05-29 18:03:55 +00:00
Damien Doligez
db9ea0df59
PR#6024: Format syntax for printing @ is incompatible with 3.12.1
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13713 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-05-29 15:56:25 +00:00
Pierre Weis
faf9cb478d
Revert sprintf type. Add a new function to support %a conversions in sprintf functionality.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13609 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-04-25 09:14:09 +00:00
Pierre Weis
a79b51b675
Complete rewriting of Format.mk_printf. Convergence between Printf and Format codes.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13606 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-04-24 14:56:25 +00:00
Pierre Weis
1d1d751326
PR#5973 (old @ escape was still implemented in Format) + bootstrap.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13601 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2013-04-23 21:44:30 +00:00
Damien Doligez
def31744f9
remove all $Id keywords
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13013 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-10-15 17:50:56 +00:00
Pierre Weis
2b94ebecf8
Additional documentation for format strings.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12407 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2012-04-27 09:56:05 +00:00
Pierre Weis
2a2fcade52
Bug #4380 .
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11243 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-10-25 13:13:54 +00:00
Damien Doligez
3b507dd1aa
renaming of Objective Caml to OCaml and cleanup of copyright headers
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11156 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-07-27 14:17:02 +00:00
Pierre Weis
c5289420e9
Module Printf, Format, and Scanf are printed in -w A warning mode. This found an old and subtle bug in Format; for other modules, the code is clearer and cleaner!
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11100 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2011-06-20 21:46:20 +00:00
Pierre Weis
b443ee91ff
Documentation. Adding a <<deprecated>> section to list deprecated stuff out of the way from the regular stuff.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10348 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-03 09:18:20 +00:00
Pierre Weis
e9de1fb06b
PR#5023. Adding some documentation words for function set_formatter_output_channel.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10346 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-05-03 07:09:33 +00:00
Pierre Weis
95d686c9d0
Compatible version.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10261 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2010-04-15 08:39:16 +00:00
Pierre Weis
cec0afc076
Introducing output meanings to subsume set/get_[all_]formatter_output_functions.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9436 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2009-11-30 23:21:49 +00:00
Pierre Weis
1e6f95e975
Introducing formatter output meanings.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9433 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2009-11-30 22:04:17 +00:00
Pierre Weis
6aa6323477
A simpler implementation for ifprintf.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9328 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2009-09-10 07:41:58 +00:00
Pierre Weis
b549b3ee9e
Addition of ikprintf as suggested in FR#0004859.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9327 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2009-09-09 15:15:03 +00:00
Pierre Weis
c195fae7ff
One step further to unification printf/format: *printf functions get exactly the same types.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9308 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2009-07-03 10:32:45 +00:00
Damien Doligez
ed32f569e3
merge changes from ocaml3110 to ocaml3111rc0
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9270 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2009-05-20 11:52:42 +00:00
Pierre Weis
a548eb3a13
Understanding the notion of standard channel for Format and Scanf.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9166 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2009-01-25 22:46:15 +00:00
Pierre Weis
11373835cd
indent.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9120 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2008-11-08 14:58:40 +00:00
Pierre Weis
2c1693ee00
Added a comment for correction of BR #4041 .
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8998 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2008-09-08 12:30:19 +00:00
Pierre Weis
0c49b27a78
Merge between head and 3.10.2.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8891 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2008-06-16 13:04:46 +00:00
Damien Doligez
9ea5edac9a
merge changes 3.10.0 -> 3.10.1
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8768 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2008-01-11 16:13:18 +00:00
Pierre Weis
771646e79a
Fix bug #4273 .
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@8213 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2007-05-08 21:30:01 +00:00
Pierre Weis
236baa6ee4
Encapsulation of system specific exports in module Printf.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7735 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2006-11-17 08:34:05 +00:00
Pierre Weis
044ac2610c
New function ifprintf that does not print. (See request #0004031.)
...
Ifprintf is a one-liner using implementation tools from Printf, whereas it is
not possible to write it in pure Caml.
Useful to conditionally ignore printing.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7717 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2006-11-06 09:12:53 +00:00
Pierre Weis
cf0590146f
Code review before adding new typing of format string.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7396 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2006-05-04 12:52:22 +00:00
Pierre Weis
176b3c0da8
Module Sformat is internal to printf. Better typing specifications of functions working with format strings.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7374 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2006-04-05 11:49:07 +00:00
Pierre Weis
129535d070
Correcting bug for %{ conversions.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7300 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2006-01-04 08:50:40 +00:00
Pierre Weis
0e1fb05fc7
The type Printf.sz is used for indexes; hence its renaming to becomes
...
Printf.index.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7083 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2005-09-26 10:13:08 +00:00
Pierre Weis
339b08f82f
Closing a long standing bug in the implementation of printf-like
...
functions: partially applied printf functions were printing material
as soon as the first argument was applied (and even before: printing
started as soon as the format string was provided).
This is the first step towards the implementation of $ formats
(i.e. formats that can access directly to any of their arguments,
using a $n notation to denote the nth argument (``a la Yacc'')). This
is supposed to be mandatory to internationalisation of messages.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7060 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2005-09-20 17:18:03 +00:00
Pierre Weis
93474822f4
Documentation.
...
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7059 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
2005-09-20 08:41:09 +00:00