From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA09365; Fri, 26 Sep 2003 20:02:51 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 UAA22787 for ; Fri, 26 Sep 2003 20:02:49 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h8QI2nH00478 for ; Fri, 26 Sep 2003 20:02:49 +0200 (MET DST) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1A2wvY-0003nT-00 for ; Fri, 26 Sep 2003 19:02:48 +0100 Date: Fri, 26 Sep 2003 19:02:48 +0100 To: caml-list@inria.fr Subject: [Caml-list] Printf question Message-ID: <20030926180248.GA14053@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; printf:01 printf:01 placeholder:01 formatter:01 clue:01 implemented:01 trickery:01 freshmeat:01 autoconf:01 automake:01 compiles:01 rpms:01 ltd:98 compiler:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I want to write a function which is a bit like Printf.printf, but handles the %s placeholder differently. It needs to do SQL-style escaping, eg: my_printf "The string: %s" "string with 'quotes'" would return the string: The string: 'string with ''quotes''' (hope I've got that right ...) Anyway, it looks like this should be possible, and possibly even quite simple, with a custom formatter. Can anyone give me a clue about this? Is Printf.printf implemented in pure OCaml, or does it require trickery in the compiler to work? The code is scarily complex ... Rich. -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles, RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners