Skip to content

Commit f2084b2

Browse files
author
hornik
committed
Have read.dcf() recognize comment lines (PR#18903, by Dirk Eddelbuettel and Laurent Gatto).
git-svn-id: https://svn.r-project.org/R/trunk@88273 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent db0e268 commit f2084b2

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/library/base/R/dcf.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ function(file, fields = NULL, all = FALSE, keep.white = NULL)
7575

7676
lines <- readLines(file, skipNul = TRUE, encoding = "bytes")
7777

78+
## Ignore comment lines.
79+
lines <- lines[!startsWith(lines, "#")]
80+
7881
## Try to find out about invalid things: mostly, lines which do not
7982
## start with blanks but have no ':' ...
8083
ind <- grep(paste0("^[^", ascii_blank, "][^:]*$"), lines)

src/library/base/man/dcf.Rd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ write.dcf(x, file = "", append = FALSE, useBytes = FALSE,
106106
\url{https://www.debian.org/doc/debian-policy/ch-controlfields.html}.
107107

108108
Note that \R does not require encoding in UTF-8, which is a recent
109-
Debian requirement. Nor does it use the Debian-specific sub-format
110-
which allows comment lines starting with \samp{#}.
109+
Debian requirement.
111110
}
112111

113112
\note{

src/main/dcf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ attribute_hidden SEXP do_readDCF(SEXP call, SEXP op, SEXP args, SEXP env)
149149
field_fold = true;
150150
n_eblanklines = 0;
151151
}
152+
} else if(line[0] == '#') {
153+
/* Ignore comment lines */
152154
} else {
153155
blank_skip = false;
154156
if(tre_regexecb(&contline, line, 1, regmatch, 0) == 0) {

0 commit comments

Comments
 (0)