[Pgfsweave-commits] r13 - in pkg: . R exec inst/doc inst/doc/figs inst/misc inst/misc/vignette-src man src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Apr 4 23:04:43 CEST 2010


Author: cameronbracken
Date: 2010-04-04 23:04:43 +0200 (Sun, 04 Apr 2010)
New Revision: 13

Added:
   pkg/inst/misc/test-for-pgf.tex
Modified:
   pkg/ChangeLog
   pkg/DESCRIPTION
   pkg/NEWS
   pkg/R/cacheSweaveUnexportedFunctions.R
   pkg/R/pgfSweaveDriver.R
   pkg/R/zzz.R
   pkg/README
   pkg/exec/pgfsweave-script.R
   pkg/inst/doc/figs/fig-normalSweave.pdf
   pkg/inst/doc/figs/fig-pgfSweave-hist.pdf
   pkg/inst/doc/figs/fig-pgfSweave-tikz-hist.pdf
   pkg/inst/doc/pgfSweave.Rnw
   pkg/inst/misc/vignette-src/Makefile
   pkg/inst/misc/vignette-src/pgfSweave-vignette-source.Rnw
   pkg/man/pgfSweave.Rd
   pkg/src/Makevars
Log:
Merge branch 'master' into r-forge-local

Conflicts:
	ChangeLog
	inst/doc/figs/fig-normalSweave.pdf
	inst/doc/pgfSweave-example.pdf
	inst/doc/pgfSweave.pdf

Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2009-12-25 20:40:27 UTC (rev 12)
+++ pkg/ChangeLog	2010-04-04 21:04:43 UTC (rev 13)
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
 commit 82cc2fd18794b91439e84120172991ec230a9b36
 Merge: d790e2d 09fc61a
 Author: cameronbracken <cameronbracken at edb9625f-4e0d-4859-8d74-9fd3b1da38cb>
@@ -2,3 +3,108 @@
 Date:   Sat Dec 5 19:01:42 2009 +0000
+=======
+commit 481238dfd60acd0d34d94e4ab0d982dd28dc67be
+Author: cameronbracken <cameron.bracken at gmail.com>
+Date:   Sun Apr 4 14:19:59 2010 -0600
 
+    Code chunks no longer need to be labeled
+
+ NEWS                                               |    7 +
+ R/cacheSweaveUnexportedFunctions.R                 |    5 +-
+ R/pgfSweaveDriver.R                                |  970 ++++++++++----------
+ inst/misc/vignette-src/Makefile                    |    2 +-
+ .../vignette-src/pgfSweave-vignette-source.Rnw     |    1 +
+ 5 files changed, 480 insertions(+), 505 deletions(-)
+
+commit 63435c5aa3ad9f722c3414c7d334d09502d7c530
+Author: cameronbracken <cameron.bracken at gmail.com>
+Date:   Sun Apr 4 12:40:34 2010 -0600
+
+    Minor edits to docs
+
+ README                  |    7 +++++--
+ exec/pgfsweave-script.R |    2 +-
+ man/pgfSweave.Rd        |   12 +++++++++---
+ 3 files changed, 15 insertions(+), 6 deletions(-)
+
+commit 2223ef242be27cec4a250a79948861577ac10f52
+Merge: c3461dd 94c62bf
+Author: cameronbracken <cameron.bracken at gmail.com>
+Date:   Sun Apr 4 12:34:07 2010 -0600
+
+    Merge branch 'master' of github.com:cameronbracken/pgfSweave
+
+commit c3461dd65d21b3ec979c0464a97bbcecb7cc9e7a
+Author: cameronbracken <cameron.bracken at gmail.com>
+Date:   Sun Apr 4 12:32:38 2010 -0600
+
+    Fix Makevars for building on Solaris
+
+ src/Makevars |    4 ----
+ 1 files changed, 0 insertions(+), 4 deletions(-)
+
+commit 94c62bfe979aface376e39fe336fe37599532deb
+Author: cameronbracken <cameron.bracken at gmail.com>
+Date:   Tue Feb 23 11:48:26 2010 -0700
+
+    Minor tweaks to NEWS, DESCRIPTION, README and vignette
+
+ ChangeLog                                          |   20 ++++++++++++++++++++
+ DESCRIPTION                                        |   18 ++++++++++++------
+ NEWS                                               |   13 ++++++++++---
+ README                                             |    2 --
+ inst/doc/figs/fig-normalSweave.pdf                 |  Bin 3140 -> 3071 bytes
+ inst/doc/figs/fig-pgfSweave-hist.pdf               |  Bin 17594 -> 17644 bytes
+ inst/doc/figs/fig-pgfSweave-tikz-hist.pdf          |  Bin 28974 -> 28919 bytes
+ inst/doc/pgfSweave-example.pdf                     |  Bin 88333 -> 88546 bytes
+ inst/doc/pgfSweave.Rnw                             |    9 ++++-----
+ inst/doc/pgfSweave.pdf                             |  Bin 290255 -> 290456 bytes
+ inst/misc/vignette-src/Makefile                    |    4 ++--
+ .../vignette-src/pgfSweave-vignette-source.Rnw     |    5 ++---
+ 12 files changed, 50 insertions(+), 21 deletions(-)
+
+commit d970329d43165aab65424d1a16fda0c1030bd2f5
+Author: cameronbracken <cameron.bracken at gmail.com>
+Date:   Tue Feb 23 01:57:06 2010 -0700
+
+    Check for correct pgf version on startup. Show correct filenames for examples in vignette.
+
+ ChangeLog                                          |   20 ++++++++
+ R/zzz.R                                            |   49 ++++++++++++++++++++
+ inst/doc/figs/fig-normalSweave.pdf                 |  Bin 2929 -> 3140 bytes
+ inst/doc/figs/fig-pgfSweave-hist.pdf               |  Bin 17330 -> 17594 bytes
+ inst/doc/figs/fig-pgfSweave-tikz-hist.pdf          |  Bin 28698 -> 28974 bytes
+ inst/doc/pgfSweave-example.pdf                     |  Bin 88108 -> 88333 bytes
+ inst/doc/pgfSweave.Rnw                             |    5 +-
+ inst/doc/pgfSweave.pdf                             |  Bin 289735 -> 290255 bytes
+ inst/example/pgfSweave-example.tex                 |   44 ------------------
+ inst/misc/test-for-pgf.tex                         |    6 ++
+ inst/misc/vignette-src/Makefile                    |    4 +-
+ .../vignette-src/pgfSweave-vignette-source.Rnw     |    6 ++-
+ 12 files changed, 84 insertions(+), 50 deletions(-)
+
+commit 8b646513162b8486904ddbd916becc9d75602040
+Author: cameronbracken <cameron.bracken at gmail.com>
+Date:   Fri Dec 25 12:32:28 2009 -0800
+
+    New release 1.0.3 for CRAN, see NEWS file
+
+ ChangeLog                                          |  250 +++++++++++++-------
+ DESCRIPTION                                        |    2 +-
+ NEWS                                               |    9 +
+ README                                             |    5 -
+ exec/pgfsweave-script.R                            |   10 +-
+ inst/doc/figs/fig-normalSweave.pdf                 |  Bin 3048 -> 2929 bytes
+ inst/doc/figs/fig-pgfSweave-hist.pdf               |  Bin 17299 -> 17330 bytes
+ inst/doc/figs/fig-pgfSweave-tikz-hist.pdf          |  Bin 28663 -> 28698 bytes
+ inst/doc/pgfSweave-example.pdf                     |  Bin 86755 -> 88108 bytes
+ inst/doc/pgfSweave.Rnw                             |   40 ++--
+ inst/doc/pgfSweave.pdf                             |  Bin 277215 -> 289735 bytes
+ .../vignette-src/pgfSweave-vignette-source.Rnw     |   42 ++--
+ 12 files changed, 233 insertions(+), 125 deletions(-)
+
+commit 648d3068935afa77325696f95614ddf302903bff
+Author: cameronbracken <cameron.bracken at gmail.com>
+Date:   Sun Dec 6 01:59:47 2009 -0700
+>>>>>>> master
+
     Merge branch 'master' into r-forge-local

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2009-12-25 20:40:27 UTC (rev 12)
+++ pkg/DESCRIPTION	2010-04-04 21:04:43 UTC (rev 13)
@@ -1,14 +1,20 @@
 Package: pgfSweave
 Type: Package
 Title: Quality speedy graphics compilation with Sweave
-Version: 1.0.3
-Date: 2009-04-30
+Version: 1.0.5
+Date: 2010-01-23
 Author: Cameron Bracken <cameron.bracken at gmail.com> and Charlie Sharpsteen <source at sharpsteen.net>
 Maintainer: Cameron Bracken <cameron.bracken at gmail.com> 
-Depends: utils, stashR, filehash, tikzDevice, cacheSweave, getopt
-Imports: digest, tools
-SystemRequirement: pgf (>=2.00) (http://sourceforge.net/projects/pgf/) for the vignette.
-Description:  The pgfSweave package provides capabilities for 'caching' graphics generated with Sweave.  Using pgfSweave, figure labels are converted to LaTeX strings so not only do they match the style of the document but math can be put in labels. pgfSweave provides a new driver for Sweave (pgfSweaveDriver) and new chunk options tikz, pgf and external on top of the cache option provided by cacheSweave. This package is built upon cacheSweave and therefore also Sweave.
+Depends: stashR, filehash, tikzDevice, cacheSweave, getopt
+Imports: digest, tools, utils
+SystemRequirement: pgf (>=2.00) (http://sourceforge.net/projects/pgf/) for the vignette and for externalization.
+Description:  The pgfSweave package provides capabilities for 'caching' 
+      graphics generated with Sweave.  Using pgfSweave, figure labels are 
+      converted to LaTeX strings so not only do they match the style of the 
+      document but math can be put in labels. pgfSweave provides a new driver 
+      for Sweave (pgfSweaveDriver) and new chunk options tikz, pgf and 
+      external on top of the cache option provided by cacheSweave. 
+      This package is built upon cacheSweave and therefore also Sweave.
 License: GPL
 LazyLoad: yes
 URL: https://r-forge.r-project.org/projects/pgfsweave/

Modified: pkg/NEWS
===================================================================
--- pkg/NEWS	2009-12-25 20:40:27 UTC (rev 12)
+++ pkg/NEWS	2010-04-04 21:04:43 UTC (rev 13)
@@ -1,6 +1,18 @@
 Please see the README directory for development info
 
 --------------------------
+Version 1.0.5 - 2010-04-04
+--------------------------
+* Unlabeled code chunks are now allowed
+* Fix for building on Solaris
+
+--------------------------
+Version 1.0.4 - 2009-01-23
+--------------------------
+* Check for PGF > 2.00 on startup or fail to load
+* Fixes for examples in vignette
+
+--------------------------
 Version 1.0.3 - 2009-12-24
 --------------------------
 * Fix bug where externalization did not work if pdf and eps were not
@@ -10,8 +22,9 @@
 * Better install script for command line interface
 
 --------------------------
-Version 1.0 - 2009-10-14
+Version 1.0.0 - 2009-10-14
 --------------------------
+* First CRAN Release
 * The new package tikzDevice is now used by default instead of eps2pgf.  The 
   pgf option is still available but the use of tikzDevice is reccommended.
 * Updates to the vignette
@@ -26,7 +39,7 @@
 Version 0.7.2 - 2009-06-22
 --------------------------
 * Thanks to Charlie's ingenuity, pgfSweave now creates a symlink in $RHOME/bin 
-  to pgfsweave-script.R upon installation.  The result is that 
+  to pgfsweave-script.R upon source installation.  The result is that 
   `R CMD pgfsweave` 
   can now be used to compile!
 * New git repo for experimental features:
@@ -46,7 +59,7 @@
 * More work on vignette
 
 --------------------------
-Version 0.7 - 2009-02-19 
+Version 0.7.0 - 2009-02-19 
 --------------------------
 * Vignette is somewhat complete
 * Robust shell script for compiling in exec/ directory

Modified: pkg/R/cacheSweaveUnexportedFunctions.R
===================================================================
--- pkg/R/cacheSweaveUnexportedFunctions.R	2009-12-25 20:40:27 UTC (rev 12)
+++ pkg/R/cacheSweaveUnexportedFunctions.R	2010-04-04 21:04:43 UTC (rev 13)
@@ -181,12 +181,13 @@
         }
         ## Write out map file entry
         mapFile <- object[["mapFile"]]
-        mapEntry <- data.frame(chunk = options$label,
+        mapEntry <- data.frame(chunk = ifelse(is.null(options$label),
+                                           chunkprefix,options$label),
                                chunkprefix = chunkprefix,
                                fig = figname,
                                cacheDB = dbName,
                                time = Sys.time())
         write.dcf(mapEntry, file = mapFile, append = TRUE, width = 2000)
-    cat("\n", file = mapFile, append = TRUE)
+        cat("\n", file = mapFile, append = TRUE)
         options
 }

Modified: pkg/R/pgfSweaveDriver.R
===================================================================
--- pkg/R/pgfSweaveDriver.R	2009-12-25 20:40:27 UTC (rev 12)
+++ pkg/R/pgfSweaveDriver.R	2010-04-04 21:04:43 UTC (rev 13)
@@ -1,6 +1,6 @@
 ######################################################################
 ## Copyright (C) 2008, Cameron Bracken <cameron.bracken at gmail.com>
-##                     Charlie Sharpsteen <source at shaprpsteen.net>
+##             Charlie Sharpsteen <source at shaprpsteen.net>
 ##
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -23,16 +23,16 @@
 ## Sweave driver function.
 
 pgfSweaveDriver <- function() {
-        list(
-             setup = pgfSweaveSetup,
-             runcode = pgfSweaveRuncode,
-             writedoc = utils::RweaveLatexWritedoc,
-             finish = utils::RweaveLatexFinish,
-             checkopts = utils::RweaveLatexOptions
-             )
+    list(
+       setup = pgfSweaveSetup,
+       runcode = pgfSweaveRuncode,
+       writedoc = utils::RweaveLatexWritedoc,
+       finish = utils::RweaveLatexFinish,
+       checkopts = utils::RweaveLatexOptions
+       )
 }
 
-        
+    
 source('R/cacheSweaveUnexportedFunctions.R')
 
 
@@ -59,110 +59,108 @@
 
 
 pgfSweaveEvalWithOpt <- function (expr, options) {
-        chunkDigest <- options$chunkDigest
-        
-        ## 'expr' is a single expression, so something like 'a <- 1'
-        res <- NULL
-        chunkChanged <- TRUE
+  chunkDigest <- options$chunkDigest
+  
+  ## 'expr' is a single expression, so something like 'a <- 1'
+  res <- NULL
+  chunkChanged <- TRUE
 
-        if(!options$eval)
-                return(res)
-        if(options$cache) {
-                cachedir <- getCacheDir()
-
-                ## Create database name from chunk label and MD5
-                ## digest
-                dbName <- makeChunkDatabaseName(cachedir, options,
-                                                        chunkDigest)
-                exprDigest <- mangleDigest(digest(expr))
-
-                ## Create 'stashR' database
-                db <- new("localDB", dir = dbName, name = basename(dbName))
-
-                ## If the current expression is not cached, then
-                ## evaluate the expression and dump the resulting
-                ## objects to the database.  Otherwise, just read the
-                ## vector of keys from the database
-
-                if(!dbExists(db, exprDigest)){
-                    keys <- try({
-                                evalAndDumpToDB(db, expr, exprDigest)
-                                }, silent = TRUE)
-                }
-                else{
-                    keys <- dbFetch(db, exprDigest)
-                    chunkChanged <- FALSE
-                }
-                
-
-                ## If there was an error then just return the
-                ## condition object and let Sweave deal with it.
-                if(inherits(keys, "try-error"))
-                        return(list(err=keys,chunkChanged=chunkChanged))
-
-                dbLazyLoad(db, globalenv(), keys)
-        }
-        else {
-                ## If caching is turned off, just evaluate the expression
-                ## in the global environment
-                res <- try(.Internal(eval.with.vis(expr, .GlobalEnv,
-                                                   baseenv())),
-                           silent=TRUE)
-                if(inherits(res, "try-error"))
-                        return(list(err=res,chunkChanged=chunkChanged))
-                if(options$print | (options$term & res$visible))
-                        print(res$value)
-        }
-        list(err=res,chunkChanged=chunkChanged)
+  if(!options$eval)
+      return(res)
+  if(options$cache) {
+    cachedir <- getCacheDir()
+  
+    ## Create database name from chunk label and MD5
+    ## digest
+    dbName <- makeChunkDatabaseName(cachedir, options,chunkDigest)
+    exprDigest <- mangleDigest(digest(expr))
+  
+    ## Create 'stashR' database
+    db <- new("localDB", dir = dbName, name = basename(dbName))
+  
+    ## If the current expression is not cached, then
+    ## evaluate the expression and dump the resulting
+    ## objects to the database.  Otherwise, just read the
+    ## vector of keys from the database
+  
+    if(!dbExists(db, exprDigest)){
+      keys <- try({
+        evalAndDumpToDB(db, expr, exprDigest)
+        }, silent = TRUE)
+    }
+    else{
+      keys <- dbFetch(db, exprDigest)
+      chunkChanged <- FALSE
+    }
+    
+  
+    ## If there was an error then just return the
+    ## condition object and let Sweave deal with it.
+    if(inherits(keys, "try-error"))
+      return(list(err=keys,chunkChanged=chunkChanged))
+  
+    dbLazyLoad(db, globalenv(), keys)
+  }
+  else {
+      ## If caching is turned off, just evaluate the expression
+      ## in the global environment
+      res <- try(.Internal(eval.with.vis(expr, .GlobalEnv,baseenv())),silent=TRUE)
+      
+      if(inherits(res, "try-error"))
+        return(list(err=res,chunkChanged=chunkChanged))
+      if(options$print | (options$term & res$visible))
+        print(res$value)
+  }
+  list(err=res,chunkChanged=chunkChanged)
 }
 
 ## Add the 'pgf' and 'external' and 'pdflatex' option to the list
 pgfSweaveSetup <- function(file, syntax,
-                            output=NULL, quiet=FALSE, debug=FALSE, echo=TRUE,
-                            eval=TRUE, split=FALSE, stylepath=TRUE, 
-                            pdf=FALSE, eps=FALSE, cache=FALSE, pgf=FALSE, 
-                            tikz=TRUE, external=FALSE, tex.driver="pdflatex")
+              output=NULL, quiet=FALSE, debug=FALSE, echo=TRUE,
+              eval=TRUE, split=FALSE, stylepath=TRUE, 
+              pdf=FALSE, eps=FALSE, cache=FALSE, pgf=FALSE, 
+              tikz=TRUE, external=FALSE, tex.driver="pdflatex")
 {
 
-        out <- utils::RweaveLatexSetup(file, syntax, output=output, quiet=quiet,
-                                       debug=debug, echo=echo, eval=eval,
-                                       split=split, stylepath=stylepath, pdf=pdf,
-                                       eps=eps)
+    out <- utils::RweaveLatexSetup(file, syntax, output=output, quiet=quiet,
+                     debug=debug, echo=echo, eval=eval,
+                     split=split, stylepath=stylepath, pdf=pdf,
+                     eps=eps)
 
-        ######################################################################
-        ## Additions here [RDP]
-        ## Add the (non-standard) options for code chunks with caching
-        out$options[["cache"]] <- cache
+    ######################################################################
+    ## Additions here [RDP]
+    ## Add the (non-standard) options for code chunks with caching
+    out$options[["cache"]] <- cache
 
-        ## The pgfSweave options [CWB]
-        out$options[["pgf"]] <- pgf
-        out$options[["tikz"]] <- tikz
-        out$options[["external"]] <- external
-        out[["tex.driver"]] <- tex.driver
-        ## end [CWB]
+    ## The pgfSweave options [CWB]
+    out$options[["pgf"]] <- pgf
+    out$options[["tikz"]] <- tikz
+    out$options[["external"]] <- external
+    out[["tex.driver"]] <- tex.driver
+    ## end [CWB]
 
-        ## We assume that each .Rnw file gets its own map file
-        out[["mapFile"]] <- makeMapFileName(file)
-        file.create(out[["mapFile"]])  ## Overwrite an existing file
-        ## End additions [RDP]
-        
-        ## [CWB]  create a shell script with a command for each modified
-        ##        graphic 
-        out[["shellFile"]] <- makeExternalShellScriptName(file)
-        out[["srcfileName"]] <- sub("\\.Rnw$", "\\.tex", file)
-        file.create(out[["shellFile"]])  ## Overwrite an existing file
-        ######################################################################
+    ## We assume that each .Rnw file gets its own map file
+    out[["mapFile"]] <- makeMapFileName(file)
+    file.create(out[["mapFile"]])  ## Overwrite an existing file
+    ## End additions [RDP]
+    
+    ## [CWB]  create a shell script with a command for each modified
+    ##      graphic 
+    out[["shellFile"]] <- makeExternalShellScriptName(file)
+    out[["srcfileName"]] <- sub("\\.Rnw$", "\\.tex", file)
+    file.create(out[["shellFile"]])  ## Overwrite an existing file
+    ######################################################################
 
-        out
+    out
 }
 
 makeExternalShellScriptName <- function(Rnwfile) {
-        shellfile <- sub("\\.Rnw$", "\\.sh", Rnwfile)
+    shellfile <- sub("\\.Rnw$", "\\.sh", Rnwfile)
 
-        ## Don''t clobber
-        if(identical(shellfile, Rnwfile))
-                shellfile <- paste(Rnwfile, "sh", sep = ".")
-        shellfile
+    ## Don''t clobber
+    if(identical(shellfile, Rnwfile))
+        shellfile <- paste(Rnwfile, "sh", sep = ".")
+    shellfile
 }
 
 
@@ -174,409 +172,377 @@
 ## chunk level.  The code has been copied from R 2.5.0.
 
 pgfSweaveRuncode <- function(object, chunk, options) {
-        
-        if(!(options$engine %in% c("R", "S"))){
-                return(object)
-        }
-
-        if(!object$quiet){
-                cat(formatC(options$chunknr, width=2), ":")
-                if(options$echo) cat(" echo")
-                if(options$keep.source) cat(" keep.source")
-                if(options$eval){
-                        if(options$print) cat(" print")
-                        if(options$term) cat(" term")
-                        cat("", options$results)
-                        if(options$fig){
-                                if(options$eps) cat(" eps")
-                                if(options$pdf) cat(" pdf")
-                                if(options$pgf) cat(" pgf")
-                                if(options$tikz | options$external) cat(" tikz")
-                                if(options$external) cat(" external")
-                        }
-                }
-                if(!is.null(options$label))
-                        cat(" (label=", options$label, ")", sep="")
-                cat("\n")
-        }
-
-        chunkprefix <- RweaveChunkPrefix(options)
-
-        if(options$split){
-                ## [x][[1]] avoids partial matching of x
-                chunkout <- object$chunkout[chunkprefix][[1]]
-                if(is.null(chunkout)){
-                        chunkout <- file(paste(chunkprefix, "tex", sep="."), 
-                                                                        "w")
-                        if(!is.null(options$label))
-                                object$chunkout[[chunkprefix]] <- chunkout
-                }
-        }
-        else    chunkout <- object$output
-
-        saveopts <- options(keep.source=options$keep.source)
-        on.exit(options(saveopts))
-
-        SweaveHooks(options, run=TRUE)
     
-        ## parse entire chunk block
-        chunkexps <- try(parse(text=chunk), silent=TRUE)
-        RweaveTryStop(chunkexps, options)
+  if(!(options$engine %in% c("R", "S"))){
+    return(object)
+  }
 
-        ## [CWB] Create a DB entry which is simply the digest of the text of 
-        ## the chunk so that if anything has changed the chunk will be 
-        ## recognised as having a change if ANYTHING gets changed, even white 
-        ## space. this still doesnt fix the problem of actually caching the 
-        ## plotting commands and others which do not create objects in the 
-        ## global environment when they are evaluated but at least the figures 
-        ## will get regenerated.
-        chunkTextEvalString <- paste("chunkText <- '", 
-                                        digest(paste(chunk,collapse='')), 
-                                        "'", sep='')
-        #print(chunkTextEvalString)
-        if(substr(chunk[1],1,9)!='chunkText')
-                chunk <- c(chunkTextEvalString, chunk)
-        ## end [CWB]
- 
-        ## Adding my own stuff here [RDP]
-        ## Add 'chunkDigest' to 'options'
-        options <- writeChunkMetadata(object, chunk, options)
-        ## End adding my own stuff [RDP]
+  if(!object$quiet){
+    cat(formatC(options$chunknr, width=2), ":")
+    if(options$echo) cat(" echo")
+    if(options$keep.source) cat(" keep.source")
+    if(options$eval){
+      if(options$print) cat(" print")
+      if(options$term) cat(" term")
+      cat("", options$results)
+      if(options$fig){
+        if(options$eps) cat(" eps")
+        if(options$pdf) cat(" pdf")
+        if(options$pgf) cat(" pgf")
+        if(options$tikz | options$external) cat(" tikz")
+        if(options$external) cat(" external")
+      }
+    }
+    if(!is.null(options$label))
+      cat(" (label=", options$label, ")", sep="")
+      cat("\n")
+  }
 
-        openSinput <- FALSE
-        openSchunk <- FALSE
+  chunkprefix <- RweaveChunkPrefix(options)
 
-        if(length(chunkexps)==0)
-                return(object)
+  if(options$split){
+    ## [x][[1]] avoids partial matching of x
+    chunkout <- object$chunkout[chunkprefix][[1]]
+    if(is.null(chunkout)){
+      chunkout <- file(paste(chunkprefix, "tex", sep="."), "w")
+        if(!is.null(options$label))
+          object$chunkout[[chunkprefix]] <- chunkout
+    }
+  }
+  else  chunkout <- object$output
 
-        srclines <- attr(chunk, "srclines")
-        linesout <- integer(0)
-        srcline <- srclines[1]
+  saveopts <- options(keep.source=options$keep.source)
+  on.exit(options(saveopts))
 
-        srcrefs <- attr(chunkexps, "srcref")
-        if (options$expand)
-                lastshown <- 0
-        else
-                lastshown <- srcline - 1
-        thisline <- 0
-        for(nce in 1:length(chunkexps)){
-                ce <- chunkexps[[nce]]
-                if (nce <= length(srcrefs) && 
-                    !is.null(srcref <- srcrefs[[nce]])) {
-                        if (options$expand) {
-                                srcfile <- attr(srcref, "srcfile")
-                                showfrom <- srcref[1]
-                                showto <- srcref[3]
-                        } else {
-                                srcfile <- object$srcfile
-                                showfrom <- srclines[srcref[1]]
-                                showto <- srclines[srcref[3]]
-                        }
-                        dce <- getSrcLines(srcfile, lastshown+1, showto)
-                        leading <- showfrom-lastshown
-                        lastshown <- showto
-                        srcline <- srclines[srcref[3]]
-                        while (length(dce) 
-                                && length(grep("^[ \\t]*$", dce[1]))) {
-                                dce <- dce[-1]
-                                leading <- leading - 1
-                        }
-                } else {
-                        dce <- deparse(ce, 
-                                    width.cutoff = 0.75*getOption("width"))
-                        leading <- 1
-                }
-                if(object$debug)
-                        cat("\nRnw> ", paste(dce, collapse="\n+  "),"\n")
-                if(options$echo && length(dce)){
-                        if(!openSinput){
-                                if(!openSchunk){
-                                        cat("\\begin{Schunk}\n",
-                                            file=chunkout, append=TRUE)
-                                        linesout[thisline + 1] <- srcline
-                                        thisline <- thisline + 1
-                                        openSchunk <- TRUE
-                                }
-                                cat("\\begin{Sinput}",
-                                    file=chunkout, append=TRUE)
-                                openSinput <- TRUE
-                        }
-                        cat("\n", paste(getOption("prompt"), dce[1:leading], 
-                                        sep="", collapse="\n"),
-                            file=chunkout, append=TRUE, sep="")
-                        if (length(dce) > leading)
-                                cat("\n", paste(getOption("continue"), 
-                                                dce[-(1:leading)], sep="",
-                                                collapse="\n"),
-                                    file=chunkout, append=TRUE, sep="")
-                        linesout[thisline + 1:length(dce)] <- srcline
-                        thisline <- thisline + length(dce)
-                }
+  SweaveHooks(options, run=TRUE)
 
-                ## tmpcon <- textConnection("output", "w")
-                ## avoid the limitations (and overhead) of output text
-                ## connections
-                tmpcon <- file()
-                sink(file=tmpcon)
-                err <- NULL
-                
-                ## [RDP] change this line to use my EvalWithOpt function
-                if(options$eval) err <- pgfSweaveEvalWithOpt(ce, options)
-                ## [CWB] added another output specifying if the code chunk
-                ##       was changed or not. This was an ititial attempt to 
-                ##       improve cacheSweave''s  recognition of chages in a
-                ##       code chunk though it is defunct now.
-                chunkChanged <- FALSE#err$chunkChanged
-                err <- err$err
-                ## [CWB] end
-                ## [RDP] end change
+  ## parse entire chunk block
+  chunkexps <- try(parse(text=chunk), silent=TRUE)
+  RweaveTryStop(chunkexps, options)
 
-                cat("\n") # make sure final line is complete
-                sink()
-                output <- readLines(tmpcon)
-                close(tmpcon)
-                ## delete empty output
-                if(length(output)==1 & output[1]=="") output <- NULL
+  ## [CWB] Create a DB entry which is simply the digest of the text of 
+  ## the chunk so that if anything has changed the chunk will be 
+  ## recognised as having a change if ANYTHING gets changed, even white 
+  ## space. this still doesnt fix the problem of actually caching the 
+  ## plotting commands and others which do not create objects in the 
+  ## global environment when they are evaluated but at least the figures 
+  ## will get regenerated.
+  chunkTextEvalString <- paste("chunkText <- '", 
+    digest(paste(chunk,collapse='')), "'", sep='')
+  #print(chunkTextEvalString)
+  if(substr(chunk[1],1,9)!='chunkText')
+    chunk <- c(chunkTextEvalString, chunk)
+  ## end [CWB]
 
-                RweaveTryStop(err, options)
+  ## Adding my own stuff here [RDP]
+  ## Add 'chunkDigest' to 'options'
+  options <- writeChunkMetadata(object, chunk, options)
+  ## End adding my own stuff [RDP]
 
-                if(object$debug)
-                        cat(paste(output, collapse="\n"))
+  openSinput <- FALSE
+  openSchunk <- FALSE
 
-                if(length(output)>0 & (options$results != "hide")){
+  if(length(chunkexps)==0)
+    return(object)
 
-                        if(openSinput){
-                                cat("\n\\end{Sinput}\n", file=chunkout,
-                                                            append=TRUE)
-                                linesout[thisline + 1:2] <- srcline
-                                thisline <- thisline + 2
-                                openSinput <- FALSE
-                        }
-                        if(options$results=="verbatim"){
-                                if(!openSchunk){
-                                        cat("\\begin{Schunk}\n",
-                                            file=chunkout, append=TRUE)
-                                        linesout[thisline + 1] <- srcline
-                                        thisline <- thisline + 1
-                                        openSchunk <- TRUE
-                                }
-                                cat("\\begin{Soutput}\n",
-                                    file=chunkout, append=TRUE)
-                                linesout[thisline + 1] <- srcline
-                                thisline <- thisline + 1
-                        }
+  srclines <- attr(chunk, "srclines")
+  linesout <- integer(0)
+  srcline <- srclines[1]
 
-                        output <- paste(output,collapse="\n")
-                        if(options$strip.white %in% c("all", "true")){
-                                output <- sub("^[[:space:]]*\n", "", output)
-                                output <- sub("\n[[:space:]]*$", "", output)
-                                if(options$strip.white=="all")
-                                        output <- sub("\n[[:space:]]*\n", 
-                                                            "\n", output)
-                        }
-                        cat(output, file=chunkout, append=TRUE)
-                        count <- sum(strsplit(output, NULL)[[1]] == "\n")
-                        if (count > 0) {
-                                linesout[thisline + 1:count] <- srcline
-                                thisline <- thisline + count
-                        }
-
-                        remove(output)
-
-                        if(options$results=="verbatim"){
-                                cat("\n\\end{Soutput}\n", file=chunkout, 
-                                                            append=TRUE)
-                                linesout[thisline + 1:2] <- srcline
-                                thisline <- thisline + 2
-                        }
-                }
+  srcrefs <- attr(chunkexps, "srcref")
+  if (options$expand)
+    lastshown <- 0
+  else
+    lastshown <- srcline - 1
+  thisline <- 0
+  for(nce in 1:length(chunkexps)){
+    ce <- chunkexps[[nce]]
+    if (nce <= length(srcrefs) && 
+      !is.null(srcref <- srcrefs[[nce]])) {
+        if (options$expand) {
+          srcfile <- attr(srcref, "srcfile")
+          showfrom <- srcref[1]
+          showto <- srcref[3]
+        } else {
+          srcfile <- object$srcfile
+          showfrom <- srclines[srcref[1]]
+          showto <- srclines[srcref[3]]
         }
-
-        if(openSinput){
-                cat("\n\\end{Sinput}\n", file=chunkout, append=TRUE)
-                linesout[thisline + 1:2] <- srcline
-                thisline <- thisline + 2
+        dce <- getSrcLines(srcfile, lastshown+1, showto)
+        leading <- showfrom-lastshown
+        lastshown <- showto
+        srcline <- srclines[srcref[3]]
+        while (length(dce) 
+          && length(grep("^[ \\t]*$", dce[1]))) {
+          dce <- dce[-1]
+          leading <- leading - 1
         }
-
-        if(openSchunk){
-                cat("\\end{Schunk}\n", file=chunkout, append=TRUE)
-                linesout[thisline + 1] <- srcline
-                thisline <- thisline + 1
+    } else {
+      dce <- deparse(ce, width.cutoff = 0.75*getOption("width"))
+      leading <- 1
+    }
+    if(object$debug)
+      cat("\nRnw> ", paste(dce, collapse="\n+  "),"\n")
+    if(options$echo && length(dce)){
+      if(!openSinput){
+        if(!openSchunk){
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/pgfsweave -r 13


More information about the Pgfsweave-commits mailing list