From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id EAFEABB9C for ; Thu, 24 Nov 2005 12:30:21 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jAOBULQA025832 for ; Thu, 24 Nov 2005 12:30:21 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA20815 for ; Thu, 24 Nov 2005 12:30:21 +0100 (MET) Received: from mail.tcs.inf.tu-dresden.de (tcs01.inf.tu-dresden.de [141.76.75.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAOBUK2i023713 for ; Thu, 24 Nov 2005 12:30:20 +0100 Received: from localhost (localhost [127.0.0.1]) by mail.tcs.inf.tu-dresden.de (Sun Java System Messaging Server 6.1 HotFix 0.06 (built Nov 11 2004)) with ESMTP id <0IQG00G6WIMKMN00@mail.tcs.inf.tu-dresden.de> for caml-list@inria.fr; Thu, 24 Nov 2005 12:30:20 +0100 (MET) Received: from tcs01.inf.tu-dresden.de ([127.0.0.1]) by localhost (mail.tcs.inf.tu-dresden.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 24569-01 for ; Thu, 24 Nov 2005 12:30:19 +0100 (MET) Received: from ithif59.inf.tu-dresden.de (ithif59.inf.tu-dresden.de [141.76.75.59]) by mail.tcs.inf.tu-dresden.de (Sun Java System Messaging Server 6.1 HotFix 0.06 (built Nov 11 2004)) with ESMTPS id <0IQG00GA0IMJLD00@mail.tcs.inf.tu-dresden.de> for caml-list@inria.fr; Thu, 24 Nov 2005 12:30:19 +0100 (MET) Received: from tews by ithif59.inf.tu-dresden.de with local (Exim 4.50) id 1EfFIx-00013o-Ce for caml-list@inria.fr; Thu, 24 Nov 2005 12:30:19 +0100 Date: Thu, 24 Nov 2005 12:30:19 +0100 From: Hendrik Tews Subject: Re: [Caml-list] Camlp4 in a Unix pipe In-reply-to: <4384522B.3010309@barettadeit.com> To: Ocaml Message-id: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Virus-Scanned: amavisd-new at tcs.inf.tu-dresden.de References: <437C91B0.9030507@barettadeit.com> <43834A5C.3050109@barettadeit.com> <4383605A.7030309@bik-gmbh.de> <4384522B.3010309@barettadeit.com> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 X-Miltered: at nez-perce with ID 4385A44D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4385A44C.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; hendrik:01 tews:01 tews:01 caml-list:01 camlp:01 baretta:01 baretta:01 barettadeit:01 camlp:01 cmo:01 cmo:01 argl:01 pcaml:01 val:01 val:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Alessandro Baretta writes: I'm not sure I understand your point. My original attempt at this problem was the following: cat - | camlp4 pa_o.cmo pr_o.cmo If you don't set a filename nothing is done, see function go in camlp4/camlp4/argl.ml: if Pcaml.input_file.val <> "" then match file_kind.val with [ Intf -> process_intf () | Impl -> process_impl () ] else () (the input_file reference is set via -intf, -impl and from arguments ending in .ml or .mli) This seemed strange to me, because, according the camlp4 manpage Agreed, the docs could be more precise. But all the camlp4 docs are quite outdated. alex@alex:~/void$ cat - | camlp4 pa_o.cmo pr_r.cmo -impl /dev/stdin let 1 = 1;; I/O error: Illegal seek pr_r and pr_o contain seek's to copy parts of source (for instance comments) into the output. It will work if you use another printer. alex@alex:~/void$ cat - | camlp4 pa_o.cmo pr_r.cmo -impl - The '-' option to camlp4 is undocumented, as far as I can see from the I wouldn't say '-' is an option, rather it is a special filename, see parse_file in camlp4/camlp4/argl.ml: let name = Pcaml.input_file.val in do { Pcaml.warning.val := print_warning; let ic = if name = "-" then stdin else open_in_bin name in Alessandro Baretta continues: found this clue. Also, if '-' means to read from stdin, as is the case with many command line tools, why should this work any better than Because the offending seeks are covered by if's, like in apply_printer, camlp4/etc/pr_o.ml: if Pcaml.input_file.val <> "-" && Pcaml.input_file.val <> "" then do { Bye, Hendrik