Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

emulate POSIX defn of diff -b

git-svn-id: https://svn.r-project.org/R/trunk@62407 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information...
commit fcef74e0274649ca853396e90e5f07f81f4ed30b 1 parent bb63464
ripley authored
View
4 doc/NEWS.Rd
@@ -32,6 +32,10 @@
\item \code{chooseCRANmirror()} and \code{chooseBioCmirror()} gain
an \code{ind} argument (like \code{setRepositories()}).
+
+ \item \code{tools::Rdiff(useDiff = FALSE)} is closer to the POSIX
+ definition of \command{diff -b} (as distinct from the description
+ in the \command{man} pages of most systems).
}
}
View
8 src/library/tools/R/testing.R
@@ -156,8 +156,12 @@ Rdiff <- function(from, to, useDiff = FALSE, forEx = FALSE, nullPointers=TRUE, L
right <- clean2(right)
}
if (!useDiff && (length(left) == length(right))) {
- bleft <- gsub("[[:space:]]+", " ", left)
- bright <- gsub("[[:space:]]+", " ", right)
+ ## The idea is to emulate diff -b, as documented by POSIX:
+ ## http://pubs.opengroup.org/onlinepubs/9699919799/utilities/diff.html
+ bleft <- gsub("[[:space:]]*$", "", left)
+ bright <- gsub("[[:space:]]*$", "", right)
+ bleft <- gsub("[[:space:]]+", " ", bleft)
+ bright <- gsub("[[:space:]]+", " ", bright)
if(all(bleft == bright))
return(if(Log) list(status = 0L, out = character()) else 0L)
cat("\n")
View
13 src/library/tools/man/Rdiff.Rd
@@ -26,6 +26,7 @@ Rdiff(from, to, useDiff = FALSE, forEx = FALSE,
differences found?}
}
\details{
+
The \R startup banner and any timing information from \command{R CMD
BATCH} are removed from both files, together with lines about
loading packages. UTF-8 fancy quotes (see \code{\link{sQuote}}) and
@@ -35,12 +36,12 @@ Rdiff(from, to, useDiff = FALSE, forEx = FALSE,
(e.g. \code{<environment: 0x12345678>}) are mapped to
\code{0x00000000}. The files are then compared line-by-line. If
there are the same number of lines and \code{useDiff} is false, a
- simple \command{diff}-like display of differences is printed (which
- ignores differences in consecutive spaces), otherwise \command{diff
- -bw} is called on the edited files. (This tries to ignore all
- differences in whitespace: note that flag \option{-w} is not
- required by POSIX but is supported by GNU, Solaris and FreeBSD
- versions.)
+ simple \command{diff -b} -like display of differences is printed
+ (which ignores trailing spaces and differences in numbers of
+ consecutive spaces), otherwise \command{diff -bw} is called on the
+ edited files. (This tries to ignore all differences in whitespace:
+ note that flag \option{-w} is not required by POSIX but is supported
+ by GNU, Solaris and FreeBSD versions.)
This can compare uncompressed PDF files, ignoring differences in
creation and modification dates.
Please sign in to comment.
Something went wrong with that request. Please try again.