[Sciviews-commits] r134 - in pkg: svMisc svMisc/R svMisc/man svSocket svSocket/man svSocket/testCLI

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 28 13:45:43 CEST 2009


Author: phgrosjean
Date: 2009-05-28 13:45:43 +0200 (Thu, 28 May 2009)
New Revision: 134

Modified:
   pkg/svMisc/DESCRIPTION
   pkg/svMisc/NEWS
   pkg/svMisc/R/Parse.R
   pkg/svMisc/man/captureAll.Rd
   pkg/svSocket/DESCRIPTION
   pkg/svSocket/NEWS
   pkg/svSocket/man/processSocket.Rd
   pkg/svSocket/testCLI/testCLI.R
Log:
Bug correction in Parse(), REPL example added to processSocket()

Modified: pkg/svMisc/DESCRIPTION
===================================================================
--- pkg/svMisc/DESCRIPTION	2009-05-21 17:55:53 UTC (rev 133)
+++ pkg/svMisc/DESCRIPTION	2009-05-28 11:45:43 UTC (rev 134)
@@ -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-47
-Date: 2009-01-23
+Version: 0.9-48
+Date: 2009-05-28
 Author: Philippe Grosjean, Romain Francois & Kamil Barton
 Maintainer: Philippe Grosjean <phgrosjean at sciviews.org>
 License: GPL (>= 2)

Modified: pkg/svMisc/NEWS
===================================================================
--- pkg/svMisc/NEWS	2009-05-21 17:55:53 UTC (rev 133)
+++ pkg/svMisc/NEWS	2009-05-28 11:45:43 UTC (rev 134)
@@ -1,5 +1,10 @@
 = svMisc News
 
+== Changes in svMisc 0.9-48
+
+* Parse() does not detect incomplete R code any more, fixed (PhG)
+
+
 == Changes in svMisc 0.9-47
 
 * objList(), print.objectList() and write.objList() reworked (PhG)

Modified: pkg/svMisc/R/Parse.R
===================================================================
--- pkg/svMisc/R/Parse.R	2009-05-21 17:55:53 UTC (rev 133)
+++ pkg/svMisc/R/Parse.R	2009-05-28 11:45:43 UTC (rev 134)
@@ -12,8 +12,8 @@
     # Determine if this code is correctly parsed
 	if (inherits(expr, "try-error")) {
 		# Determine if it is incorrect code, or incomplete line!
-		toSearch <- paste("\n", length(strsplit(text, "\n")[[1]]) + 1, ":",
-			sep = "")
+		toSearch <- paste(": ", length(strsplit(text, "\n")[[1]]) +
+            1, ":0:", sep = "")
         if (length(grep(toSearch, expr)) == 1) return(NA) else return(expr)
     }
     # There is still a case of incomplete code not catch: incomplete strings

Modified: pkg/svMisc/man/captureAll.Rd
===================================================================
--- pkg/svMisc/man/captureAll.Rd	2009-05-21 17:55:53 UTC (rev 133)
+++ pkg/svMisc/man/captureAll.Rd	2009-05-28 11:45:43 UTC (rev 134)
@@ -7,7 +7,7 @@
 \description{
   This function captures results of evaluating an R expression the same way as
   it would be done in a R console. The result is in a character string. Errors,
-  warnings and other consitions are treated as usual, including the delayed
+  warnings and other conditions are treated as usual, including the delayed
   display of the warnings if \code{options(warn = 0)}.
 }
 
@@ -30,7 +30,7 @@
 \examples{
 writeLines(captureAll(1+1))
 writeLines(captureAll(Parse("search()")))
-  
+
 \dontrun{
 writeLines(captureAll(Parse('1:2 + 1:3')))
 writeLines(captureAll(Parse("badname")))

Modified: pkg/svSocket/DESCRIPTION
===================================================================
--- pkg/svSocket/DESCRIPTION	2009-05-21 17:55:53 UTC (rev 133)
+++ pkg/svSocket/DESCRIPTION	2009-05-28 11:45:43 UTC (rev 134)
@@ -2,8 +2,8 @@
 Title: SciViews GUI API - R Socket Server
 Depends: R (>= 2.6.0), tcltk, svMisc
 Description: Implements a simple socket server allowing to connect GUI clients to R
-Version: 0.9-43
-Date: 2009-01-22
+Version: 0.9-44
+Date: 2009-05-28
 Author: Philippe Grosjean
 Maintainer: Philippe Grosjean <phgrosjean at sciviews.org>
 License: GPL (>= 2)

Modified: pkg/svSocket/NEWS
===================================================================
--- pkg/svSocket/NEWS	2009-05-21 17:55:53 UTC (rev 133)
+++ pkg/svSocket/NEWS	2009-05-28 11:45:43 UTC (rev 134)
@@ -1,11 +1,17 @@
 = svSocket News
 
 == Changes in svSocket 0.9-43
+* Example added in processSocket(), implementing a simple REPL
+
+
+== Changes in svSocket 0.9-43
 * Polishing package for CRAN submission
 
+
 == Changes in svSocket 0.9-42
 * Made compatible with R 2.6.x (previous package was R >= 2.7.0).
 
+
 == Changes in svSocket 0.9-41
 
 * Correction in startSocketServer(): the SocketServerProc function was not
@@ -17,6 +23,7 @@
     Error in ngettext(1, "Error: ", domain = "R") :
       argument "msg2" is missing, with no default
 
+
 == Changes in svSocket 0.9-40
 
 This is the first version distributed on R-forge. It is completely refactored

Modified: pkg/svSocket/man/processSocket.Rd
===================================================================
--- pkg/svSocket/man/processSocket.Rd	2009-05-21 17:55:53 UTC (rev 133)
+++ pkg/svSocket/man/processSocket.Rd	2009-05-28 11:45:43 UTC (rev 134)
@@ -37,15 +37,15 @@
   not specify an identifier, the name of your socket will be used. Since socket
   names can be reused, you should always reinitialize the configuration of your
   server the first time you connect to it.
-  
+
   Then, sending \code{<<<esc>>>} breaks current multiline code submission and
   flushes the multiline buffer.
-  
+
   The sequence \code{<<<q>>>} at the beginning of a command indicates that the
   server wants to disconnect once the command is fully treated by R. Similarly,
   the sequence \code{<<<Q>>>} tels the server to disconnect the client before
   processing the command (no error message is returned to the client!).
-  
+
   It is easy to turn the server to evaluate R code (including multiline code)
   and return the result and disconnect by using the \code{<<<e>>>} sequence at
   the beginning of a command. Using the \code{<<<h>>>} or \code{<<<H>>>}
@@ -56,13 +56,13 @@
   like contextual help, calltips, completion lists, etc.). Note that using
   these modes in a server that is, otherwise, configured as a multi-line server
   does not break current multi-line buffer.
-  
+
   The other sequences that can be used are: \code{<<<s>>>} for a placeholder to
   configurate the current server (with configuration parameters after it), and
   \code{<<<n>>>} to indicate a newline in your code (submitting two lines of
   code as a single one; also works with servers configured as single-line
   evaluators).
-  
+
   To debug the R socket server and inspect how commands send by a client are
   interpreted by this function, use \code{options(debug.Socket = TRUE)}. This
   function uses \code{Parse()} and \code{captureAll()} in order to evaluate
@@ -73,6 +73,24 @@
 \author{Philippe Grosjean (\email{phgrosjean at sciviews.org})}
 
 \seealso{ \code{\link{startSocketServer}}, \code{\link{sendSocketClients}},
-  \code{\link[svMisc]{Parse}}, \code{\link[svMisc]{captureAll}} }
+  \code{\link[svMisc]{parSocket}}, \code{\link[svMisc]{Parse}},
+  \code{\link[svMisc]{captureAll}} }
 
+\examples{
+\dontrun{
+# A simple REPL (R eval/process loop) using basic features of processSocket()
+repl <- function ()
+{
+	pars <- parSocket("repl", "", bare = FALSE)  # Parameterize the loop
+	cat("Enter R code, hit <ESC> to exit\n> ")   # First prompt
+	repeat {
+		entry <- readLines(n = 1) 				 # Read a line of entry
+		if (entry == "") entry <- "<<<esc>>>"    # Exit from multiline mode
+		cat(processSocket(entry, "repl", ""))    # Process the entry
+	}
+}
+repl()
+}
+}
+
 \keyword{ IO }

Modified: pkg/svSocket/testCLI/testCLI.R
===================================================================
--- pkg/svSocket/testCLI/testCLI.R	2009-05-21 17:55:53 UTC (rev 133)
+++ pkg/svSocket/testCLI/testCLI.R	2009-05-28 11:45:43 UTC (rev 134)
@@ -39,7 +39,7 @@
     cat(cmd[i], "\n", sep = "", file = out)
     if (cmd0 == "") cmd0 <- cmd[i] else
         cmd0 <- paste(cmd0, cmd[i], sep = "<<<n>>>")
-    res <- processSocket(cmd0)
+    res <- processSocket(cmd0, "", "")
     if (res != "+ ") cmd0 <- "" # Not a multipline command
     cat(res, file = out)
 }



More information about the Sciviews-commits mailing list