From P.Dalgaard at biostat.ku.dk  Wed Jan 16 11:56:16 2008
From: P.Dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Wed, 16 Jan 2008 11:56:16 +0100
Subject: [Rd] %s in filename when opening device causes crash (PR#10571)
In-Reply-To: <14877649.post@talk.nabble.com>
References: <20080114145006.C745B2834629@mail.pubhealth.ku.dk>	<20080114175023.B5B242834612@mail.pubhealth.ku.dk>	<478BA787.8060806@biostat.ku.dk>	<Pine.LNX.4.64.0801141824520.12548@gannet.stats.ox.ac.uk>
	<14877649.post@talk.nabble.com>
Message-ID: <478DE2D0.5060405@biostat.ku.dk>

Richard Cotton wrote:
>
> Prof Brian Ripley wrote:
>   
>>> Yes. The problem is of course that we do want a sprintf() format there
>>> for "Rplot%03d.pdf" et al. One  option would be to escape "%" except
>>> when in (regexp) "%[0-9]*d", which seems nontrivial, but not impossible.
>>>       
>> But there are other integer formats (%i, %u, %x, %X), and other flags (# 
>> might be useful).  So the list of valid inputs is also rather long.  It 
>> would be tedious to do at C level, but a check in the R-level wrapper 
>> would be easier (if not 'simple').
>>
>>     
>
> Having just worked my way through the alphabet, I can say that it is only
> the letters 's' and 'n' that cause any problems.  Thus, if you do decide to
> handle the error in the R wrapper functions, the regex for bad inputs is
> fairly straightforward "%[#[:blank:]\\+\\-]*[[:digit:]]*[sn]".
>   
Not quite. The floating point formats are also problematic; you may
fetch 8 bytes where only 4 was allocated. Also, %%s should not be
forbidden. Anyways, I believe Brian has this in hand.

-- 
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



[Rd] %s in filename when opening device causes crash (PR#10571)
Peter Dalgaard