File: reg-IO.R

package info (click to toggle)
r-base 3.1.1-1%2Bdeb8u1
  • links: PTS
  • area: main
  • in suites: jessie
  • size: 85,436 kB
  • ctags: 35,389
  • sloc: ansic: 306,779; fortran: 91,908; sh: 11,216; makefile: 5,311; yacc: 4,994; tcl: 4,562; objc: 746; perl: 655; asm: 553; java: 31; sed: 6
file content (60 lines) | stat: -rw-r--r-- 1,393 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
## NB: this file must be a DOS (CRLF) format file

## Keep comments and original formatting
options(keep.source=TRUE)

## simple tests that multiple lines are read correctly
print(2+3)
print(4+5)

## generate some files to source

z <- c("# line 1", "2+3", "ls()", "pi", "# last line")

## ========  LF file
cat(z, file="testIO.R", sep="\n")
readLines("testIO.R")
source("testIO.R", echo=TRUE)
unlink("testIO.R")

## ======== LF file, incomplete final line
zz <- file("testIO.R", "wt")
cat(z, file=zz, sep="\n")
cat("5+6", file=zz)
close(zz)
readLines("testIO.R")
source("testIO.R", echo=TRUE)
unlink("testIO.R")

## ======== CRLF file
cat(z, file="testIO.R", sep="\r\n")
source("testIO.R", echo=TRUE)
readLines("testIO.R")
unlink("testIO.R")

## ======== CRLF file, incomplete final line
zz <- file("testIO.R", "wt")
cat(z, file=zz, sep="\r\n")
cat("5+6", file=zz)
close(zz)
readLines("testIO.R")
source("testIO.R", echo=TRUE)
unlink("testIO.R")

## ======== CR file
cat(z, file="testIO.R", sep="\r")
readLines("testIO.R")
source("testIO.R", echo=TRUE)
unlink("testIO.R")

## ======== CR file, incomplete final line
zz <- file("testIO.R", "wt")
cat(z, file=zz, sep="\r")
cat("\r5+6", file=zz)
close(zz)
readLines("testIO.R")
source("testIO.R", echo=TRUE)
unlink("testIO.R")

## end of reg-IO.R: the next line has no EOL chars
2 + 2