From wdunlap at tibco.com  Tue Nov 17 17:57:07 2009
From: wdunlap at tibco.com (William Dunlap)
Date: Tue, 17 Nov 2009 08:57:07 -0800
Subject: [Rd] make.packages.html
In-Reply-To: <4B027FED.5020900@stats.uwo.ca>
References: <971536df0911170233w71d062cr2bcc9e6246aa0b13@mail.gmail.com>
	<4B027FED.5020900@stats.uwo.ca>
Message-ID: <77EB52C6DD32BA4D87471DCD70C8D700022871D2@NA-PA-VBE03.na.tibco.com>


> -----Original Message-----
> From: r-devel-bounces at r-project.org 
> [mailto:r-devel-bounces at r-project.org] On Behalf Of Duncan Murdoch
> Sent: Tuesday, November 17, 2009 2:50 AM
> To: Gabor Grothendieck
> Cc: r-devel at r-project.org
> Subject: Re: [Rd] make.packages.html
> 
> On 17/11/2009 5:33 AM, Gabor Grothendieck wrote:
> > In "R version 2.10.0 Patched (2009-11-15 r50445)" on Windows Vista
> > upon issuing help.start() and clicking on Packages I get this.
> > 
> > Packages in C:\Users\Gabor\Documents\R\win-library\2.10
> > 
> > C:\Users\Gabor\Documents/R/win-library/2.10/AER/DESCRIPTION -- Title
> > is missing --
> > 
> C:\Users\Gabor\Documents/R/win-library/2.10/akima/DESCRIPTION -- Title
> > is missing --
> > C:\Users\Gabor\Documents/R/win-library/2.10/car/DESCRIPTION -- Title
> > is missing --
> > C:\Users\Gabor\Documents/R/win-library/2.10/caroline/DESCRIPTION --
> > Title is missing --
> > ...
> > 
> > Looking at make.packages.html in utils, this code:
> > 
> >     for (lib in lib.loc) {
> >         pg <- Sys.glob(file.path(lib, "*", "DESCRIPTION"))
> >         pkgs[[lib]] <- sort(sub(paste(lib, "([^/]*)", 
> "DESCRIPTION$",
> >             sep = "/"), "\\1", pg))
> >     }
> > 
> > has the problem that lib can contain regular expression 
> characters but
> > is used in the pattern of sub.  This could be changed to 
> the following
> > which does not use lib in any pattern. Only the pkgs[[lib]]<-
> > statement is changed relative to the original:
> > 
> >     for (lib in lib.loc) {
> >         pg <- Sys.glob(file.path(lib, "*", "DESCRIPTION"))
> >         pkgs[[lib]] <- sort(sub(".*[\\/]", "", 
> sub(".DESCRIPTION$", "", pg)))
> >     }
> 
> Thanks, I'll take a look.

Hadley Wickham asked last week about a function that escaped
all the regular-expression special characters in a
string, so one could use gsub with fixed=TRUE,
and I suggested

   asFixedRegex <- function(pattern) {
      gsub("([][^${}().?*+|\\])", "\\\\\\1", pattern)
   }

(I left out the | in the original mail).  asFixedRegex()
could be used to fix this problem by changing 'lib' to
'asFixedRegex(lib)' in the offending call to sub
  sub(paste(asFixedRegex(lib), "([^/]*)", "DESCRIPTION$", sep = "/"),
     "\\1", pg)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> 
> Duncan Murdoch
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 



[Rd] make.packages.html
William Dunlap