From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 3583A7F02D for ; Thu, 9 Oct 2014 13:09:05 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of matthieu.dubuget@gmail.com) identity=pra; client-ip=209.85.212.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="matthieu.dubuget@gmail.com"; x-sender="matthieu.dubuget@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of matthieu.dubuget@gmail.com designates 209.85.212.174 as permitted sender) identity=mailfrom; client-ip=209.85.212.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="matthieu.dubuget@gmail.com"; x-sender="matthieu.dubuget@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f174.google.com) identity=helo; client-ip=209.85.212.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="matthieu.dubuget@gmail.com"; x-sender="postmaster@mail-wi0-f174.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnABAO5rNlTRVdSum2dsb2JhbABfhDmDBtBpFgERAQEBAQEGCwsJFCyEHBEdARscAgMSEA8CBRYLAgsDAgECARERAQUBIg0IAQEeiAcBAxEEAaFjgx1uizCBcoMQiBAKGScNZ4YWAQUOgR6SFoFUBZJ+ikeHZIw3QYUWaoEGI4EhAQEB X-IPAS-Result: AnABAO5rNlTRVdSum2dsb2JhbABfhDmDBtBpFgERAQEBAQEGCwsJFCyEHBEdARscAgMSEA8CBRYLAgsDAgECARERAQUBIg0IAQEeiAcBAxEEAaFjgx1uizCBcoMQiBAKGScNZ4YWAQUOgR6SFoFUBZJ+ikeHZIw3QYUWaoEGI4EhAQEB X-IronPort-AV: E=Sophos;i="5.04,684,1406584800"; d="scan'208";a="100200761" Received: from mail-wi0-f174.google.com ([209.85.212.174]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 Oct 2014 13:09:04 +0200 Received: by mail-wi0-f174.google.com with SMTP id cc10so12753939wib.7 for ; Thu, 09 Oct 2014 04:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=N1TiSUpEesFMrb8vQKtGNj1unUIQoSYy8gtZkWjIUi8=; b=ZsudaTcrcPV9aS2DPm4AyQXvD+KU3B62M6Jrvt2YsvO5ZlTWPDV7y3dzy6QoDMHQTi qdANXBIJWJNmFmCLUqAGfOUotl67n5eJFm+escKBpi5o84ohqet4GCblzhZKV4gvEVrn Ouhuoho5sTI8cjriW++fAa/g7XSRgCiLx5uLs1OB39qm/75AtafPmmWC01N6IuUkky39 zrZKUDTqdz/UMleUVU0hzN8aAL2e/GAIL8yFmGWwsKJORSOR3M/iDdudS25RhPh+Kjnm uKq20q6EDvtBjRmJGUzmmFgy2jPFK/03qDOIscMMHe45pbjoT8G3balSHL+McfkevVy5 jweg== X-Received: by 10.194.134.100 with SMTP id pj4mr17679974wjb.72.1412852944565; Thu, 09 Oct 2014 04:09:04 -0700 (PDT) Received: from [172.17.1.47] (papillon.metalscan.fr. [178.22.148.54]) by mx.google.com with ESMTPSA id n5sm21628973wix.0.2014.10.09.04.09.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Oct 2014 04:09:02 -0700 (PDT) Message-ID: <54366CCC.3050607@gmail.com> Date: Thu, 09 Oct 2014 13:09:00 +0200 From: Matthieu Dubuget User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: caml-list Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [Caml-list] Format java-like comment block Hello, I'm trying to output lines of text in a java-like comment block using Format (Ocaml 4.01.0). It should start with '/**'. Each line should begin with ' *'. And the comment should be closed with ' */'. Since I was not able to achieve this, I wrote a flat example (see below). It's output is as expected: ``` ...........................................................................= ... /** Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin faucibus tempor est sit amet laoreet. Suspendisse lacinia commodo */ ...........................................................................= ... ``` If I uncomment the commented lines, I would have expected something like: ``` ...........................................................................= ... /** * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin faucibus * tempor est sit amet laoreet. Suspendisse lacinia commodo */ ...........................................................................= ... ``` but instead, I'm obtaining: ...........................................................................= ... /** * Lorem ipsum dolor sit amet, consectetur adipiscing elit. * Proin faucibus tempor est sit amet * laoreet. Suspendisse * lacinia commodo */ ...........................................................................= ... Is it a bug or a misunderstanding? ```ocaml let _ =3D let mymargin =3D 78 in let add_rule b marg =3D Buffer.add_string b "\n"; Buffer.add_string b (String.make marg '.'); Buffer.add_string b "\n" in (* let stars =3D "* " in *) let b =3D Buffer.create 100 in let f =3D Format.formatter_of_buffer b in Format.pp_set_margin f mymargin; add_rule b mymargin; Format.pp_open_box f 3; Format.pp_print_string f " /**"; Format.pp_force_newline f (); Format.pp_open_box f 0; (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "Lorem"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "ipsum"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "dolor"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "sit"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "amet,"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "consectetur"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "adipiscing"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "elit."; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "Proin"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "faucibus"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "tempor"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "est"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "sit"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "amet"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "laoreet."; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "Suspendisse"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "lacinia"; Format.pp_print_space f (); (* Format.pp_print_if_newline f (); *) (* Format.pp_print_string f stars; *) Format.pp_print_string f "commodo"; Format.pp_force_newline f (); Format.pp_print_string f "*/"; Format.pp_print_newline f (); add_rule b mymargin; Buffer.contents b |> print_endline ``` --=20 Matthieu Dubuget