Hi, I guess the backslash should not be used as the separator for strsplit() in compareVersion(), because the period in [.] is no longer a metacharacter (no need to "escape" it using a backslash): https://github.com/wch/r-source/blob/trunk/src/library/utils/R/packages.R#L866-L867> compareVersionfunction (a, b) { .... a <- as.integer(strsplit(a, "[\\.-]")[[1L]]) b <- as.integer(strsplit(b, "[\\.-]")[[1L]]) .... <environment: namespace:utils> A similar regular expression problem also exists in the Sweave syntax (for \Sexpr{}), and I have reported it once. It was fixed but the fix was immediately reverted for some reason: https://github.com/wch/r-source/commit/52b0a46e15136a7f9e4777e9960fdda6d84880c0 Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Web: http://yihui.name
On 24/04/2014, 1:11 PM, Yihui Xie wrote:> Hi, > > I guess the backslash should not be used as the separator for > strsplit() in compareVersion(), because the period in [.] is no longer > a metacharacter (no need to "escape" it using a backslash): > https://github.com/wch/r-source/blob/trunk/src/library/utils/R/packages.R#L866-L867 > >> compareVersion > function (a, b) > { > .... > a <- as.integer(strsplit(a, "[\\.-]")[[1L]]) > b <- as.integer(strsplit(b, "[\\.-]")[[1L]]) > .... > <environment: namespace:utils>Could you post an example where this causes trouble, or are you just suggesting this as a way to make the source a little cleaner?> > A similar regular expression problem also exists in the Sweave syntax > (for \Sexpr{}), and I have reported it once. It was fixed but the fix > was immediately reverted for some reason: > https://github.com/wch/r-source/commit/52b0a46e15136a7f9e4777e9960fdda6d84880c0A link to your report would be more useful, if it included an example where the bad regexp causes trouble. Duncan Murdoch
Maybe Matching Threads
- Recommended way of requiring packages of a certain version?
- Check for updates under Windows (Was: a reliable way to check the latest version of R on CRAN?)
- a reliable way to check the latest version of R on CRAN?
- Consider getNamespaceVersion() returning a numeric_version
- R Regular Expressions - Metacharacters