[Seqinr-commits] r1790 - www/src/config

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jun 6 13:50:09 CEST 2014


Author: jeanlobry
Date: 2014-06-06 13:50:09 +0200 (Fri, 06 Jun 2014)
New Revision: 1790

Modified:
   www/src/config/commonrnw.rnw
Log:
bug fixed to get current file name

Modified: www/src/config/commonrnw.rnw
===================================================================
--- www/src/config/commonrnw.rnw	2014-06-06 11:32:53 UTC (rev 1789)
+++ www/src/config/commonrnw.rnw	2014-06-06 11:50:09 UTC (rev 1790)
@@ -29,13 +29,25 @@
 <<options, echo=FALSE, fig=FALSE, results=hide, eval=TRUE>>=
 options(prompt=" ", continue=" ", width = 77)
 .RversionName <-strsplit(R.version.string, ",")[[1]]
-if (as.numeric(R.version[["major"]])+as.numeric(R.version[["minor"]])/100 >=2.09 ) {
-    framenumber<-4
+.CurFileName <- NULL
+.PrefixName <- NULL
+.GetFileName <- function() {
+  syscalls <- as.character(sys.calls())
+  .FrameNumber <- sort(c( grep("Sweave\\(", syscalls),
+                     grep("function \\(file, driver = RweaveLatex\\(", syscalls)
+                   ))[1]
+  if (!is.na(.FrameNumber)) {
+    .CurFileName <- get("srcFilenames", env = sys.frame(.FrameNumber))
+    .PrefixName <-strsplit(.CurFileName, "\\.")[[1]][1]
   } else {
-    framenumber<-3
+    .CurFileName <- "unknownfile"
+    .PrefixName <- "unknownfile"
+  }
+  assign(".CurFileName", .CurFileName, envir=parent.env(environment()))
+  assign(".PrefixName", .PrefixName, envir=parent.env(environment()))
 }
-.CurFileName <- get("file", env = parent.frame(framenumber))
-.PrefixName <-strsplit(.CurFileName, "\\.")[[1]][1]
+.GetFileName()
+rm(".GetFileName")
 r <- getOption("repos")
 r["CRAN"] <- "http://cran.univ-lyon1.fr"
 options(repos = r)



More information about the Seqinr-commits mailing list