search for: srcfile

Displaying 20 results from an estimated 120 matches for "srcfile".

2009 May 21
3
file descriptor leak in getSrcLines in R 2.10.0 svn 48590
...used it. The function that triggered the problem printed the output of a call to parse(). Each time one prints a srcref a connection is opened and not closed. It looks like it happens in as.character.srcref's call to getSrcLines, which has some logic I don't understand about closing 'srcfile' on exit only if !.is.Open(srcfile): > getSrcLines function (srcfile, first, last) { if (first > last) return(character(0L)) if (!.isOpen(srcfile)) on.exit(close(srcfile)) conn <- open(srcfile, first) lines <- readLines(conn, n = last - first + 1L, w...
2013 Jan 14
1
Issue with getParserData in R3.0.0
...I am migrating my package lambda.r to R3.0.0 and am experiencing some issues with the getParserData function (which replaces the parser package). Basically the function works in the R shell but fails when either called from RUnit or from R CMD check. I've narrowed it down to the function getSrcfile, which is returning different values depending on the code path. From the command line (works okay): debug: srcfile <- getSrcfile(x) Browse[2]> debug: if (is.null(srcfile)) return(NULL) else data <- srcfile$parseData Browse[2]> srcfile <text> When running from the Runit script...
2013 Jun 24
0
sys.source() does not provide the parsing info to eval()
...(parse(text=code)) > OUTPUT: Dotted pair list of 3 $ : language eval(parse(text = code)) $ : language eval(expr, envir, enclos) $ :length 1 (function() print(str(sys.calls())))() ..- attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 1 1 42 1 42 1 1 .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x7f42951fc388> As you can see, when using eval() directly, the expression/call has the parsing information available in the "srcref" attribute, but not when using sys.source() Looking at sys.source() implementa...
2019 Jan 02
6
[Bug 13735] New: Synchronize files when the sending side has newer change times while modification times and sizes are identical on both sides
...dated with new content in a build chain while forcibly preserving a specific mtime. To the best of my knowledge, rsync does not have any option to transfer these files in an efficient manner. I illustrate the issue below: # Create two different files with same size echo 'new content' > srcfile echo 'old content' > destfile # Set identical mtime for both files: Update srcfile's mtime to match destfile's mtime touch -mr destfile srcfile # At this point, srcfile and destfile have: # - identical size # - identical mtime # - different content # - srcfile's ctime is ne...
2009 Feb 12
1
Why is srcref of length 6 and not 4 ?
...mp/test.R) : <file> f <- function( x, y = 2 ){ z <- x + y print( z ) } </file> I get this in R 2.7.2 : > p <- parse( "/tmp/test.R" ) > str( attr( p, "srcref" ) ) List of 1 $ :Class 'srcref' atomic [1:4] 1 1 4 1 .. ..- attr(*, "srcfile")=Class 'srcfile' length 4 <environment> and this in R-devel : > p <- parse( "/tmp/test.R" ) > str( attr(p, "srcref") ) List of 1 $ :Class 'srcref' atomic [1:6] 1 1 4 1 1 1 .. ..- attr(*, "srcfile")=Class 'srcfile' <...
2006 Mar 25
2
R gets slow
...ened){ Sys.sleep(1); conn <- try(socketConnection(server = TRUE, port = 7890, blocking = TRUE, open = "ab"), silent = FALSE); isOpened = !inherits(conn, "try-error"); isOpened = isOpened && isOpen(conn); } print("Waitting for source"); srcFile = readLines(conn, n = 1) print(srcFile) continue = srcFile != "--close" if(continue){ print("Executing source"); error <- try(source(srcFile), silent = FALSE); if(inherits(error, "try-error")){ writeLines("ERROR", conn) } prin...
2004 May 07
1
meetme conf-background.agi
...*********************************************************************** #!/usr/bin/perl -w $aginame="conf-background.agi"; use File::Copy cp; use Asterisk::AGI; $AGI = new Asterisk::AGI; my %input = $AGI->ReadParse(); print STDERR "Dialing your number\n"; $srcfile="/tmp/mycall"; $dstfile="/var/spool/asterisk/outgoing/mycall"; open(MYCALL,">$srcfile") || die "Cant't open file :$srcfile $!\n"; print MYCALL "Channel:Zap/1/13\n"; print MYCALL "MaxRetries:2\n"; print MYCALL "RetryTime:60...
2004 May 10
1
AGI.pm wait_for_digit() not working for me!!!
...$AGI->receive_char('600'); $char=chr($AGI->wait_for_digit('600')); print STDERR "input form rec char : $char\n"; if($char eq "*") { print STDERR "Dialing your number\n"; $srcfile="/tmp/mycall"; $dstfile="/var/spool/asterisk/outgoing/mycall"; open(MYCALL,">$srcfile") || die "Cant't open file :$srcfile $!\n"; print MYCALL "Channel:IAX2/bali:bali\@nain/25\@atif\n";...
2009 Oct 30
1
.Rprofile replacement function setwd() causing errors
...e::getwd()) ) }, "base") However, this causes errors in some cases where setwd is used by other functions, particularly example(): > library(HistData) > example(Snow) Error in setwd(olddir) : cannot change working directory > traceback() 6: setwd(olddir) 5: open.srcfile(srcfile, first) 4: open(srcfile, first) 3: getSrcLines(srcfile, lastshown + 1, srcref[3L]) 2: source(zfile, local, echo = echo, prompt.echo = paste(prompt.prefix, getOption("prompt"), sep = ""), continue.echo = paste(prompt.prefix, getOption("continue"),...
2019 Jul 05
0
parse() drops parse data when encountering `` (bug?)
...int output also looks more limited than a regular parser error which leads me to suspect this is a bug. If this is the case could someone with the authority please add it to R's bug tracker? My reprex follows. Thanks, Miles ``` r target_text <- "foo = 1 `` {r} foo = 2" tstfile = srcfile(tempfile()) parse(text = target_text, keep.source = TRUE, srcfile = tstfile) #> Error in parse(text = target_text, keep.source = TRUE, srcfile = tstfile): attempt to use zero-length variable name getParseData(tstfile) #> NULL target_text2 <- "foo = 1 {r} foo = 2" ts...
2007 Jul 13
1
parse(text=...) and the srcfile attribute
Hi, I'm trying to understand whether the new source file references can help me with something I want to do. Let's say I have foo <- parse(text = " a <- 1; b <- 2**2 a + b ") I now wish to recover the sources for the parsed expressions. I can get them one at a time: > foo[[2]] b <- 2^2 > as.character(attr(foo, "srcref")[[2]]) [1] "b <-
2012 Feb 08
0
Error in data.frame(srcfile = NA_character_ ...) using R CMD check
...14.1 (2011-12-22) * using platform: i386-pc-mingw32 (32-bit) * using session charset: ISO8859-1 * checking for file 'pkg/DESCRIPTION' ... OK * this is package 'disco' version '1.1' ... (all OK's here) * checking R code for possible problems ... NOTE Error in data.frame(srcfile = NA_character_, frow = NA_integer_, lrow = NA_integer_, : node stack overflow Calls: <Anonymous> ... as.data.frame -> as.data.frame.list -> eval -> eval -> data.frame Execution halted I tried to find a solution but I couldn't find any extra information on this. A previous...
2010 Mar 12
1
problem with parse(text=quote(name))
...xt=as.name("name") makes parse() prompt for input from the command line and then it returns a parse of the initial characters of 'name' (depending on how many characters were typed at the prompt). E.g., > parse(text=quote(myName)) ?1/3 expression(myN) attr(,"srcfile") <text> > parse(text=quote(myName)) ?1/34 expression(myNa) attr(,"srcfile") <text> > parse(text=quote(myName)) ?1/345 expression(myNam) attr(,"srcfile") <text> where the ? lines are where parse prompted for input...
2012 Jan 11
1
parse( connection) and source-keeping
In R <= 2.13.x, calling 'parse( con)' where 'con' is a connection, 'options( keep.source)' is TRUE, and default 'srcfile' would preserve the source. In R >= 2.14.1, it doesn't. > tf <- tempfile() > options( keep.source=TRUE) > texto <- c( 'function() { # comment', '}') > parse( text=texto) expression(function() { # comment }) > cat( texto, file=tf, sep='\n') &...
2007 Sep 24
1
parse in text function of plots, confusing behaviour
HI all, I'm failing to understand why the following is happening. In this plot I rely on two text functions both using parse. The second one works properly by writing a gamma symbol 5 times, the first one only works properly four times. The only difference is that I add a string to the paste function of that which does work properly. Why does it behave like this? thanks so much! Michael
2011 Nov 19
0
Problems with new srcref warnings in R 2.14 (development)
...elopers, Print method for function now tries to open the source file associated with srcref of the function. It outputs only the warning, if file cannot be open, and forgets to print the function definition. Example: eval(parse(text = "tf <- function(a){ b <- a^4 b }", srcfile = srcfile("xxx at 17"))) > tf <srcref: file "xxx at 17" chars 1:7 to 4:1> Warning message: In file(srcfile$filename, open = "rt", encoding = encoding) : cannot open file 'xxx at 17': No such file or directory First, the function definition is not p...
2006 Nov 25
2
Source references from the parser
I have just committed some changes to R-devel (which will become R 2.5.0 next spring) to add source references to parsed R code. Here's a description of the scheme: The design is done through 2 old-style classes. "srcfile" corresponds to a source file: it contains a filename, the working directory in which that filename is to be interpreted, the last modified timestamp of the file at the time the object is created, plus some internal components. It is implemented as an environment so that there can be multiple...
2010 May 18
2
automate curve drawing on nls() object
...on: If I do this: substitute(expression(c + (d - c)/(1 + (x/e)^b)),as.list(coef(obj))) I will get: "expression(0.698704171233635 + (102.861317499063 - 0.698704171233635)/(1 + (x/135.937317917920)^-1.14164217993857))" But if I do: substitute(parse(text=as.character(obj$call$formula[3]),srcfile=NULL),as.list(coef(obj))) I only get: "parse(text = as.character(obj$call$formula[3]), srcfile = NULL)" as a result, not have b,c,d,e replaced by coefficient values. where parse(text=as.character(obj$call$formula[3]),srcfile=NULL) returns the wanted expression: "expression(c...
2011 Feb 03
1
bug in codetools/R CMD check?
...her package writers haven't noticed similiar problems before: diff -ur codetools/R/codetools.R codetools-fix/R/codetools.R --- codetools/R/codetools.R 2011-01-07 15:52:58.000000000 +0000 +++ codetools-fix/R/codetools.R 2011-02-03 10:03:54.000000000 +0000 @@ -823,8 +823,9 @@ new <- list(srcfile = if (is.null(w$srcfile)) NA_character_ else w$srcfile, frow = if (is.null(w$frow)) NA_integer_ else w$frow, lrow = if (is.null(w$lrow)) NA_integer_ else w$lrow) + new <- as.data.frame(new, stringsAsFactors = FALSE) if (is.null(value)) - value &lt...
2014 Mar 05
1
[PATCH] Code coverage support proof of concept
...ame), lines2, R_Cov_freqs_hash); + lines = lines2; + UNPROTECT(1); + } + + INTEGER(lines)[line]++; +} + +/* maybe store a new srcref in R_Cov_freqs_hash */ +static void record_code_coverage(SEXP srcref) +{ + if (srcref && !isNull(srcref)) { + int fnum, line = asInteger(srcref); + + SEXP srcfile = getAttrib(srcref, R_SrcfileSymbol); + const char *filename; + + if (!srcfile || TYPEOF(srcfile) != ENVSXP) return; + srcfile = findVar(install("filename"), srcfile); + if (TYPEOF(srcfile) != STRSXP || !length(srcfile)) return; + + filename = CHAR(STRING_ELT(srcfile, 0)); + cov_sto...