[Sciviews-commits] r74 - in pkg/svMisc: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 19 17:16:18 CET 2008


Author: romain
Date: 2008-11-19 17:16:18 +0100 (Wed, 19 Nov 2008)
New Revision: 74

Modified:
   pkg/svMisc/DESCRIPTION
   pkg/svMisc/R/descFun.R
Log:
using the zip.file.extract to look into help files the same way help does so thatit extracts the file from Rhelp.zip if there the help pages are zipped

Modified: pkg/svMisc/DESCRIPTION
===================================================================
--- pkg/svMisc/DESCRIPTION	2008-11-19 14:50:02 UTC (rev 73)
+++ pkg/svMisc/DESCRIPTION	2008-11-19 16:16:18 UTC (rev 74)
@@ -3,8 +3,8 @@
 Imports: utils, methods
 Depends: R (>= 2.6.0)
 Description: Supporting functions for the GUI API (various utilitary functions)
-Version: 0.9-46
-Date: 2008-10-13
+Version: 0.9-47
+Date: 2008-11-19
 Author: Philippe Grosjean
 Maintainer: Philippe Grosjean <phgrosjean at sciviews.org>
 License: GPL (>= 2)

Modified: pkg/svMisc/R/descFun.R
===================================================================
--- pkg/svMisc/R/descFun.R	2008-11-19 14:50:02 UTC (rev 73)
+++ pkg/svMisc/R/descFun.R	2008-11-19 16:16:18 UTC (rev 74)
@@ -61,8 +61,26 @@
 			lib.loc = lib.loc, chmhelp = FALSE, htmlhelp = FALSE))
 	}
 	if (length(File) == 0) return(rep("", length(args)))
+	
+	# doing the same as help to extract the file if it is in a zip 
+	File <- zip.file.extract(File, "Rhelp.zip")
+	   
+	# guess the encoding (from print.help_files_with_topic)
+	first <- readLines( File, n = 1)
+	enc <- if (length(grep("\\(.*\\)$", first)) > 0)                                                                                                            
+    sub("[^(]*\\((.*)\\)$", "\\1", first)                                                                         
+  else ""                                                                                                         
+  if (enc == "utf8")                                                                                              
+    enc <- "UTF-8"                                                                                                
+  if (.Platform$OS.type == "windows" && enc ==                                                                    
+    "" && l10n_info()$codepage < 1000)                                                                            
+    enc <- "CP1252"
+	File. <- file( File, encoding = enc, open = "r" )
+	
 	# Read content of the text file
-	Data <- scan(File, what = character(), sep ="\n", quiet = TRUE)
+	Data <- scan(File., what = character(), sep = "\n" )
+	close( File. )
+	
 	# Get the Arguments: section
 	argsStart <- (1:length(Data))[Data == "_\bA_\br_\bg_\bu_\bm_\be_\bn_\bt_\bs:"]
 	if (length(argsStart) == 0)	# Not found
@@ -70,7 +88,7 @@
 	# Eliminate everything before this section
 	Data <- Data[(argsStart[1] + 1):length(Data)]
 	# Check where next section starts
-	nextSection <- (1:length(Data))[regexpr("^_\\b", Data) > -1]
+	nextSection <- suppressWarnings( (1:length(Data))[regexpr("^_\\b", Data) > -1] )
 	if (length(nextSection) > 0)	# Cut everything after this section
 		Data <- Data[1:(nextSection[1] - 1)]
 	# Split description by arguments. Looks like: "^ *argument[, argument]: " + desc



More information about the Sciviews-commits mailing list