diff -Nru r-base-3.1.0/config.site r-base-3.1.1/config.site --- r-base-3.1.0/config.site 2014-03-12 23:03:34.000000000 +0000 +++ r-base-3.1.1/config.site 2014-06-04 22:15:07.000000000 +0000 @@ -257,3 +257,7 @@ ## CXX1XPICFLAGS= ## SHLIB_CXXIXLD= ## SHLIB_CXXiXLDFLAGS= + +## Additional libraries to link the internet module against. +## Some claim Solaris needs -lsocket -lnsl +## INTERNET_LIBS= diff -Nru r-base-3.1.0/configure r-base-3.1.1/configure --- r-base-3.1.0/configure 2014-04-02 22:16:29.000000000 +0000 +++ r-base-3.1.1/configure 2014-07-02 22:16:35.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for R 3.1.0. +# Generated by GNU Autoconf 2.69 for R 3.1.1. # # Report bugs to . # @@ -729,8 +729,8 @@ # Identity of this package. PACKAGE_NAME='R' PACKAGE_TARNAME='R' -PACKAGE_VERSION='3.1.0' -PACKAGE_STRING='R 3.1.0' +PACKAGE_VERSION='3.1.1' +PACKAGE_STRING='R 3.1.1' PACKAGE_BUGREPORT='http://bugs.r-project.org' PACKAGE_URL='http://www.r-project.org' @@ -921,6 +921,7 @@ BUILD_CYGWIN_TRUE DYLIB_UNDEFINED_ALLOWED_FALSE DYLIB_UNDEFINED_ALLOWED_TRUE +INTERNET_LIBS XMKMF R_SYSTEM_ABI OBJCXXFLAGS @@ -1790,7 +1791,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures R 3.1.0 to adapt to many kinds of systems. +\`configure' configures R 3.1.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1865,7 +1866,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of R 3.1.0:";; + short | recursive ) echo "Configuration of R 3.1.1:";; esac cat <<\_ACEOF @@ -1878,7 +1879,7 @@ attempt to compile support for Rprofmem(), tracemem() [no] --enable-R-framework[=DIR] - MacOS X only: build R framework (if possible), and + OS X only: build R framework (if possible), and specify its installation prefix [yes, /Library/Frameworks] --enable-R-shlib build the shared/dynamic library 'libR' [no] @@ -1909,7 +1910,7 @@ --with-lapack use system LAPACK library (if available), or specify it [no] --with-readline use readline library [yes] - --with-aqua MacOS X only: use Aqua (if available) [yes] + --with-aqua OS X only: use Aqua (if available) [yes] --with-tcltk use Tcl/Tk (if available), or specify its library dir [yes] --with-tcl-config=TCL_CONFIG @@ -2098,7 +2099,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -R configure 3.1.0 +R configure 3.1.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -3250,7 +3251,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by R $as_me 3.1.0, which was +It was created by R $as_me 3.1.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3762,10 +3763,10 @@ ## with 13 being 10.9. We no longer support < 10.4 (Tiger) ## http://en.wikipedia.org/wiki/Darwin_OS darwin1.*) - as_fn_error $? "The earliest supported MacOS X is 10.4. + as_fn_error $? "The earliest supported OS X is 10.4. ;; darwin567*" "$LINENO" 5 - as_fn_error $? "The earliest supported MacOS X is 10.4. + as_fn_error $? "The earliest supported OS X is 10.4. ;; aix123*|aix4.01*" "$LINENO" 5 ## These need a form of linking we no longer support @@ -3947,7 +3948,7 @@ ## Allow the user to specify building R as a shared library. -## (but a 'dynamic library' in the terminology of Mac OS X). +## (but a 'dynamic library' in the terminology of OS X). ## ## Building a framework implies building R shared libraries, hence the ## strange default. @@ -4098,7 +4099,7 @@ use_blas=unset fi -# default is "no" except on MacOS X +# default is "no" except on OS X ## LAPACK. @@ -4114,7 +4115,7 @@ use_lapack=unset fi -# default is "no" except on MacOS X +# default is "no" except on OS X ## Readline. @@ -9085,13 +9086,13 @@ else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:9088: $ac_compile\"" >&5) + (eval echo "\"\$as_me:9089: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:9091: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:9092: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:9094: output\"" >&5) + (eval echo "\"\$as_me:9095: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -11943,11 +11944,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11946: $lt_compile\"" >&5) + (eval echo "\"\$as_me:11947: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:11950: \$? = $ac_status" >&5 + echo "$as_me:11951: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12282,11 +12283,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12285: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12286: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12289: \$? = $ac_status" >&5 + echo "$as_me:12290: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12387,11 +12388,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12390: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12391: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12394: \$? = $ac_status" >&5 + echo "$as_me:12395: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12442,11 +12443,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12445: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12446: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12449: \$? = $ac_status" >&5 + echo "$as_me:12450: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -14809,7 +14810,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 14812 "configure" +#line 14813 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14905,7 +14906,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 14908 "configure" +#line 14909 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16854,11 +16855,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16857: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16858: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16861: \$? = $ac_status" >&5 + echo "$as_me:16862: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16953,11 +16954,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16956: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16957: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16960: \$? = $ac_status" >&5 + echo "$as_me:16961: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17005,11 +17006,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:17008: $lt_compile\"" >&5) + (eval echo "\"\$as_me:17009: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:17012: \$? = $ac_status" >&5 + echo "$as_me:17013: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18385,11 +18386,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18388: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18389: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:18392: \$? = $ac_status" >&5 + echo "$as_me:18393: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -18484,11 +18485,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18487: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18488: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:18491: \$? = $ac_status" >&5 + echo "$as_me:18492: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18536,11 +18537,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18539: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18540: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:18543: \$? = $ac_status" >&5 + echo "$as_me:18544: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -20722,7 +20723,7 @@ case "${host_os}" in darwin*) - ## MacOS <= 10.2 dlcompat, >= 10.3 included dlcompat in libSystem + ## OS X <= 10.2 dlcompat, >= 10.3 included dlcompat in libSystem { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 $as_echo_n "checking for library containing dlopen... " >&6; } if ${ac_cv_search_dlopen+:} false; then : @@ -21113,7 +21114,7 @@ use_readline="${ac_cv_lib_readline_rl_callback_read_char}" fi - ## the NetBSD version as used in MacOS X does not have this + ## the NetBSD version as used in OS X does not have this for ac_func in history_truncate_file do : ac_fn_c_check_func "$LINENO" "history_truncate_file" "ac_cv_func_history_truncate_file" @@ -23251,7 +23252,7 @@ # flags. r_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $r_verb" -(eval echo $as_me:23254: \"$ac_link\") >&5 +(eval echo $as_me:23255: \"$ac_link\") >&5 r_c_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$r_c_v_output" >&5 CFLAGS=$r_save_CFLAGS @@ -23326,7 +23327,7 @@ # flags. r_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $r_cv_prog_c_v" -(eval echo $as_me:23329: \"$ac_link\") >&5 +(eval echo $as_me:23330: \"$ac_link\") >&5 r_c_v_output=`eval $ac_link 5>&1 2>&1 | grep -v 'Driving:'` echo "$r_c_v_output" >&5 CFLAGS=$r_save_CFLAGS @@ -26333,7 +26334,7 @@ esac fi ## some linkers are broken and need to be set to a specific - ## Mac OS X version to work better + ## OS X version to work better case "${host_os}" in darwin8*) # this is the 'old' way and it doesn't work with recent gcc as the driver @@ -26745,6 +26746,10 @@ fi fi +## some claim Solaris needs -lsocket -lnsl (PR#15815) +: ${INTERNET_LIBS="${internet_libs}"} + + if test "x${dylib_undefined_allowed}" = xyes; then DYLIB_UNDEFINED_ALLOWED_TRUE= DYLIB_UNDEFINED_ALLOWED_FALSE='#' @@ -28277,7 +28282,7 @@ fi done -## clock_gettime is POSIX 1993, but not on MacOS X +## clock_gettime is POSIX 1993, but not on OS X ## Some OSes need -lrt: Linux (for glibc versions before 2.17), Solaris, ## not FreeBSD. ## Unsurprising, as POSIX 2008 moved it from its timers section to base. @@ -29602,7 +29607,7 @@ ## check for vecLib framework (potentially to be used for BLAS) ## in theory vecLib is platform-independent, in practice only -## Apple's Mac OS X is known to provide it +## Apple's OS X is known to provide it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cblas_cdotu_sub in vecLib framework" >&5 $as_echo_n "checking for cblas_cdotu_sub in vecLib framework... " >&6; } if ${r_cv_check_fw_vecLib+:} false; then : @@ -30619,7 +30624,7 @@ ## LAPACK. -## The default has already been set on MacOS X: otherwise it is "no" +## The default has already been set on OS X: otherwise it is "no" ## and so this test fails. if test "${use_lapack}" = "yes"; then @@ -32651,7 +32656,7 @@ CAIROX11_CPPFLAGS=`"${PKGCONF}" --cflags ${xmodlist}` case "${host_os}" in darwin*) - ## This is for static MacOS build + ## This is for static OS X build CAIRO_LIBS=`"${PKGCONF}" --static --libs ${modlist}` CAIROX11_LIBS=`"${PKGCONF}" --static --libs ${xmodlist}` ;; @@ -36480,11 +36485,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:36483: $lt_compile\"" >&5) + (eval echo "\"\$as_me:36488: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:36487: \$? = $ac_status" >&5 + echo "$as_me:36492: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -36579,11 +36584,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:36582: $lt_compile\"" >&5) + (eval echo "\"\$as_me:36587: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:36586: \$? = $ac_status" >&5 + echo "$as_me:36591: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -36631,11 +36636,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:36634: $lt_compile\"" >&5) + (eval echo "\"\$as_me:36639: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:36638: \$? = $ac_status" >&5 + echo "$as_me:36643: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -39975,7 +39980,7 @@ LTLIBTHREAD= fi fi - # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the + # OSF/1 4.0 and OS X 10.1 lack the pthread_rwlock_t type and the # pthread_rwlock_* functions. ac_fn_c_check_type "$LINENO" "pthread_rwlock_t" "ac_cv_type_pthread_rwlock_t" "#include " @@ -43454,7 +43459,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by R $as_me 3.1.0, which was +This file was extended by R $as_me 3.1.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -43521,7 +43526,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -R config.status 3.1.0 +R config.status 3.1.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru r-base-3.1.0/configure.ac r-base-3.1.1/configure.ac --- r-base-3.1.0/configure.ac 2014-03-12 23:03:32.000000000 +0000 +++ r-base-3.1.1/configure.ac 2014-06-13 22:15:18.000000000 +0000 @@ -79,10 +79,10 @@ ## with 13 being 10.9. We no longer support < 10.4 (Tiger) ## http://en.wikipedia.org/wiki/Darwin_OS darwin1.*) - AC_MSG_ERROR([The earliest supported MacOS X is 10.4.] + AC_MSG_ERROR([The earliest supported OS X is 10.4.] ;; darwin[[567]]*) - AC_MSG_ERROR([The earliest supported MacOS X is 10.4.] + AC_MSG_ERROR([The earliest supported OS X is 10.4.] ;; aix[123]*|aix4.[01]*) ## These need a form of linking we no longer support @@ -220,7 +220,7 @@ ## Allow the user to specify building an R framework (Darwin). AC_ARG_ENABLE([R-framework], -[AS_HELP_STRING([--enable-R-framework@<:@=DIR@:>@],[MacOS X only: build R framework (if possible), and specify +[AS_HELP_STRING([--enable-R-framework@<:@=DIR@:>@],[OS X only: build R framework (if possible), and specify its installation prefix @<:@yes, /Library/Frameworks@:>@])], [want_R_framework="${enableval}"], [want_R_framework=yes]) @@ -253,7 +253,7 @@ AM_CONDITIONAL(WANT_R_FRAMEWORK, [test "x${want_R_framework}" = xyes]) ## Allow the user to specify building R as a shared library. -## (but a 'dynamic library' in the terminology of Mac OS X). +## (but a 'dynamic library' in the terminology of OS X). ## ## Building a framework implies building R shared libraries, hence the ## strange default. @@ -339,14 +339,14 @@ [AS_HELP_STRING([--with-blas],[use system BLAS library (if available), or specify it @<:@no@:>@])], [R_ARG_USE(blas)], [use_blas=unset]) -# default is "no" except on MacOS X +# default is "no" except on OS X ## LAPACK. AC_ARG_WITH([lapack], [AS_HELP_STRING([--with-lapack],[use system LAPACK library (if available), or specify it @<:@no@:>@])], [R_ARG_USE(lapack)], [use_lapack=unset]) -# default is "no" except on MacOS X +# default is "no" except on OS X ## Readline. AC_ARG_WITH([readline], @@ -356,7 +356,7 @@ ## Aqua. AC_ARG_WITH([aqua], -[AS_HELP_STRING([--with-aqua],[MacOS X only: use Aqua (if available) @<:@yes@:>@])], +[AS_HELP_STRING([--with-aqua],[OS X only: use Aqua (if available) @<:@yes@:>@])], [if test "${withval}" = no; then want_aqua=no else @@ -732,7 +732,7 @@ AC_CHECK_LIB(m, sin) case "${host_os}" in darwin*) - ## MacOS <= 10.2 dlcompat, >= 10.3 included dlcompat in libSystem + ## OS X <= 10.2 dlcompat, >= 10.3 included dlcompat in libSystem AC_SEARCH_LIBS(dlopen, dl,,[AC_MSG_ERROR([Your OS X is too old.])]) ## SI says we want '-lcc_dynamic' on Darwin, although currently ## http://developer.apple.com/documentation/MacOSX/ has nothing @@ -768,7 +768,7 @@ AC_CHECK_LIB(readline, rl_callback_read_char) use_readline="${ac_cv_lib_readline_rl_callback_read_char}" fi - ## the NetBSD version as used in MacOS X does not have this + ## the NetBSD version as used in OS X does not have this AC_CHECK_FUNCS(history_truncate_file) if test "${use_readline}" = no; then AC_MSG_ERROR([--with-readline=yes (default) and headers/libs are not available]) @@ -1335,7 +1335,7 @@ esac fi ## some linkers are broken and need to be set to a specific - ## Mac OS X version to work better + ## OS X version to work better case "${host_os}" in darwin8*) # this is the 'old' way and it doesn't work with recent gcc as the driver @@ -1708,6 +1708,10 @@ fi fi +## some claim Solaris needs -lsocket -lnsl (PR#15815) +: ${INTERNET_LIBS="${internet_libs}"} +AC_SUBST(INTERNET_LIBS) + AM_CONDITIONAL(DYLIB_UNDEFINED_ALLOWED, [test "x${dylib_undefined_allowed}" = xyes]) AM_CONDITIONAL(BUILD_CYGWIN, [test "x${is_cygwin}" = xyes]) @@ -1888,7 +1892,7 @@ R_CHECK_FUNCS([sched_setaffinity sched_getaffinity], [#include ]) ## utime was declared obsolescent in POSIX 2008 (use utimes instead) R_CHECK_FUNCS([utime], [#include ]) -## clock_gettime is POSIX 1993, but not on MacOS X +## clock_gettime is POSIX 1993, but not on OS X ## Some OSes need -lrt: Linux (for glibc versions before 2.17), Solaris, ## not FreeBSD. ## Unsurprising, as POSIX 2008 moved it from its timers section to base. @@ -2056,7 +2060,7 @@ ## check for vecLib framework (potentially to be used for BLAS) ## in theory vecLib is platform-independent, in practice only -## Apple's Mac OS X is known to provide it +## Apple's OS X is known to provide it R_CHECK_FRAMEWORK(cblas_cdotu_sub, vecLib) ## BLAS. @@ -2190,7 +2194,7 @@ AM_CONDITIONAL(USE_EXTERNAL_BLAS, [test "${acx_blas_ok}" = "yes"]) ## LAPACK. -## The default has already been set on MacOS X: otherwise it is "no" +## The default has already been set on OS X: otherwise it is "no" ## and so this test fails. if test "${use_lapack}" = "yes"; then R_LAPACK_LIBS diff -Nru r-base-3.1.0/debian/changelog r-base-3.1.1/debian/changelog --- r-base-3.1.0/debian/changelog 2014-07-10 18:26:18.000000000 +0000 +++ r-base-3.1.1/debian/changelog 2014-07-10 18:26:19.000000000 +0000 @@ -1,9 +1,21 @@ -r-base (3.1.0-1lucid0) lucid; urgency=low +r-base (3.1.1-1lucid0) lucid; urgency=low * Compilation for Ubuntu 10.04.4 LTS * debian/control: Downgrade libtiff5 to libtiff4. - -- Michael Rutter Thu, 10 Apr 2014 18:37:12 +0000 + -- Michael Rutter Thu, 10 Jul 2014 18:15:40 +0000 + +r-base (3.1.1-1) unstable; urgency=low + + * New upstream version released this morning + + -- Dirk Eddelbuettel Thu, 10 Jul 2014 05:04:12 -0500 + +r-base (3.1.0.20140705-1) unstable; urgency=low + + * Initial rc build (r66073) of R 3.1.1 expected for July 10 + + -- Dirk Eddelbuettel Sat, 05 Jul 2014 10:48:31 -0500 r-base (3.1.0-1) unstable; urgency=low diff -Nru r-base-3.1.0/doc/CRAN_mirrors.csv r-base-3.1.1/doc/CRAN_mirrors.csv --- r-base-3.1.0/doc/CRAN_mirrors.csv 2014-04-04 22:15:03.000000000 +0000 +++ r-base-3.1.1/doc/CRAN_mirrors.csv 2014-05-20 22:15:08.000000000 +0000 @@ -23,6 +23,7 @@ "China (Xiamen)",China,Xiamen,http://mirrors.xmu.edu.cn/CRAN/,"Xiamen University","admin # Xdmc.org",1,cn "Colombia (Bogota)",Colombia,Bogota,http://www.laqee.unal.edu.co/CRAN/,"National University of Colombia","Ernesto Parra Rincon ",1,co "Colombia (Cali)",Colombia,Cali,http://www.icesi.edu.co/CRAN/,"Icesi University","adminred # Icesi.edu.co",1,co +"Czech Republic","Czech Republic","Prague",http://mirrors.nic.cz/R/,"CZ.NIC, Prague","mirrors # nic.cz",1,cz Denmark,Denmark,Aalborg,http://mirrors.dotsrc.org/cran/,"dotsrc.org, Aalborg","mirror # dotsrc.org",1,dk Ecuador,Ecuador,Guayaquil,http://cran.espol.edu.ec/,"Escuela Superior Politecnica del Litoral","jrodrig # espol.edu.ec",1,ec "France (Lyon 1)",France,Lyon,http://cran.univ-lyon1.fr/,"Dept. of Biometry & Evol. Biology, University of Lyon","Jean Thioulouse ",1,fr @@ -55,7 +56,6 @@ "Netherlands (Utrecht)",Netherlands,Utrecht,http://cran-mirror.cs.uu.nl/,"Utrecht University","webmaster # cs.uu.nl",1,nl "New Zealand","New Zealand",Auckland,http://cran.stat.auckland.ac.nz/,"University of Auckland","w.schmidt # auckland.ac.nz",1,nz Norway,Norway,Bergen,http://cran.uib.no/,"University of Bergen","sundrift # It.uib.no",1,no -Philippines,Philippines,"Quezon City",http://cran.stat.upd.edu.ph/,"University of the Philippines and PREGINET","edward.p.santos # Up.edu.ph",1,ph Poland,Poland,Wroclaw,http://r.meteo.uni.wroc.pl/,"University of Wroclaw","Paweł Netzel ",1,pl Portugal,Portugal,Porto,http://cran.dcc.fc.up.pt/,"University of Porto","labcc # labcc.dcc.fc.up.pt",1,pt Russia,Russia,Moscow,http://cran.gis-lab.info/,GIS-Lab.info,"sim # gis-lab.info",1,ru @@ -63,6 +63,7 @@ Slovakia,Slovakia,Bratislava,http://cran.fyxm.net/,"FYXM.net, Bratislava","docko # docko.sk",1,sk "South Africa (Cape Town)","South Africa","Cape Town",http://r.adu.org.za/,"University of Cape Town","michael.brooks # uct.ac.za",1,za "South Africa (Johannesburg)","South Africa",Johannesburg,http://cran.mirror.ac.za/,"TENET, Johannesburg","Patrick Holahan ",1,za +"Spain (A Coruña)","Spain","A Coruña",http://ftp.cixug.es/CRAN,"Oficina de software libre (CIXUG)","",1,es "Spain (Madrid)",Spain,Madrid,http://cran.es.r-project.org/,"Spanish National Research Network, Madrid","Jose Manuel Macias ",1,es Sweden,Sweden,Uppsala,http://ftp.sunet.se/pub/lang/CRAN/,"Swedish University Computer Network, Uppsala","Goran Brostrom ",1,se Switzerland,Switzerland,Zuerich,http://stat.ethz.ch/CRAN/,"ETH Zuerich","Martin.Maechler # R-project.org",1,ch @@ -71,6 +72,7 @@ Thailand,Thailand,Hatyai,http://mirrors.psu.ac.th/pub/cran/,"Prince of Songkla University, Hatyai","wipat.s # psu.ac.th",1,th Turkey,Turkey,Denizli,http://cran.pau.edu.tr,"Pamukkale University, Denizli","Ugur Zeybek ",1,tr "UK (Bristol)",UK,Bristol,http://www.stats.bris.ac.uk/R/,"University of Bristol","Guy Nason ",1,uk +"UK (Cambridge)",UK,"Cambridge",http://mirrors.ebi.ac.uk/CRAN/,"EMBL-EBI (European Bioinformatics Institute)","Andrew Tikhonov ",1,uk "UK (London)",UK,London,http://cran.ma.imperial.ac.uk/,"Imperial College London","s.rochford # imperial.ac.uk",1,uk "UK (London)",UK,"London",http://mirror.mdx.ac.uk/R/,"Middlesex University London","Louis Slabbert ",1,uk "UK (St Andrews)",UK,"St Andrews",http://star-www.st-andrews.ac.uk/cran/,"St Andrews University","Lee Kelvin ",1,uk diff -Nru r-base-3.1.0/doc/FAQ r-base-3.1.1/doc/FAQ --- r-base-3.1.0/doc/FAQ 2014-04-10 07:01:17.000000000 +0000 +++ r-base-3.1.1/doc/FAQ 2014-07-10 07:01:18.000000000 +0000 @@ -1,6 +1,6 @@ R FAQ Frequently Asked Questions on R -Version 3.1.2014-04-05 +Version 3.1.2014-07-03 Kurt Hornik @@ -256,7 +256,7 @@ 2.3 What is the current version of R? ===================================== -The current released version is 3.1.0. Based on this +The current released version is 3.1.1. Based on this `major.minor.patchlevel' numbering scheme, there are two development versions of R, a patched version of the current release (`r-patched') and one working towards the next minor or eventually major (`r-devel') releases diff -Nru r-base-3.1.0/doc/html/NEWS.html r-base-3.1.1/doc/html/NEWS.html --- r-base-3.1.0/doc/html/NEWS.html 2014-04-10 07:05:07.000000000 +0000 +++ r-base-3.1.1/doc/html/NEWS.html 2014-07-10 07:05:12.000000000 +0000 @@ -8,6 +8,332 @@

R News

+

../../html/logo.jpg CHANGES IN R 3.1.1

+ + + +

NEW FEATURES

+ + +
    +
  • When attach() reports conflicts, it does so +compatibly with library() by using message(). +

    +
  • +
  • R CMD Sweave no longer cleans any files by +default, compatibly with versions of R prior to 3.1.0. There are +new options --clean, --clean=default and +--clean=keepOuts. +

    +
  • +
  • tools::buildVignette() and tools::buildVignettes() +with clean = FALSE no longer remove any created files. +buildvignette() gains a keep argument for more +cleaning customization. +

    +
  • +
  • The Bioconductor ‘version’ used by +setRepositories() can now be set by environment variable +R_BIOC_VERSION at runtime, not just when R is installed. +(It has been stated that Bioconductor will switch from +‘version’ 2.14 to ‘version’ 3.0 during the lifetime +of the R 3.1 series.) +

    +
  • +
  • Error messages from bugs in embedded Sexpr code +in Sweave documents now report the source location. +

    +
  • +
  • type.convert(), read.table() and similar +read.*() functions get a new numerals argument, +specifying how numeric input is converted when its conversion to +double precision loses accuracy. The default value, +"allow.loss" allows accuracy loss, as in R versions before +3.1.0. +

    +
  • +
  • For some compilers, integer addition could overflow without +a warning. R's internal code for both integer addition and +subtraction is more robust now. (PR#15774) +

    +
  • +
  • The function determining the default number of knots for +smooth.spline() is now exported, as .nknots.smspl(). +

    +
  • +
  • dbeta(, a,b), pbeta(), qbeta() and +rbeta() are now defined also for a = 0, b = 0, +or infinite a and b (where they typically returned +NaN before). +

    +
  • +
  • Many package authors report that the RStudio graphics device +does not work correctly with their package's use of +dev.new(). The new option dev.new(noRStudioGD = + TRUE) replaces the RStudio override by the default device as +selected by R itself, still respecting environment variables +R_INTERACTIVE_DEVICE and R_DEFAULT_DEVICE. +

    +
  • +
  • readRDS() now returns visibly. +

    +
  • +
  • Modifying internal logical scalar constants now results in +an error instead of a warning. +

    +
  • +
  • install.packages(repos = NULL) now accepts +http:// or ftp:// URLs of package archives as well +as file paths, and will download as required. In most cases +repos = NULL can be deduced from the extension of the URL. +

    +
  • +
  • The warning when using partial matching with the $ +operator on data frames is now only given when +options("warnPartialMatchDollar") is TRUE. +

    +
  • +
  • Package help requests like package?foo now +try the package foo whether loaded or not. +

    +
  • +
  • General help requests now default to trying all loaded +packages, not just those on the search path. +

    +
  • +
  • Added a new function promptImport(), to generate a +help page for a function that was imported from another package +(and presumably re-exported, or help would not be needed). +

    +
+ + + + +

INSTALLATION and INCLUDED SOFTWARE

+ + +
    +
  • configure option --with-internal-tzcode +can now be used with variable rsharedir. +

    +
  • +
  • The included version of PCRE has been updated to 8.35. +

    +
  • +
  • There is a new target make uninstall-libR to +remove an installed shared/static ‘libR’. +

    +

    make install-libR now works if a sub-architecture is +used, although the user will need to specify libdir +differently for different sub-architectures. +

    +
  • +
  • There is more extensive advice on which LaTeX packages are +required to install R or to make package manuals (as done by +R CMD check) in the ‘Writing R Extensions’ +manual. +

    +
  • +
  • Compilers/linkers were handling the visibility controls in +‘src/extra/xz’ inconsistently (and apparently in some cases +incorrectly), so it has been simplified. (PR#15327) +

    +
  • +
  • (Windows) There is updated support for the use of ICU for +collation: see the ‘R Installation and Administration Manual’. +

    +
+ + + + +

BUG FIXES

+ + +
    +
  • dbinom(x, n), pbinom(), dpois(), etc, +are slightly less restrictive in checking if n is +integer-valued. (Wish of PR#15734.) +

    +
  • +
  • pchisq(x, df, ncp, log.p = TRUE) is more accurate and +no longer underflows for small x and ncp < 80, e.g, +for pchisq(1e-5, df = 100, ncp = 1, log = TRUE). +(Based on PR#15635 and a suggestion by Roby Joehanes.) +

    +
  • +
  • The s (“step into”) command in the debugger +would cause R to step into expressions evaluated there, +not just into functions being debugged. (PR#15770) +

    +
  • +
  • The C code used by strptime() rejected time-zone +offsets of more than +1200 (+1245, +1300 and ++1400 can occur). (PR#15768) +

    +
  • +
  • (Windows only.) +png(type = "cairo", antialias = "gray") +was not accepted. (PR#15760) +

    +
  • +
  • Use of save(..., envir=) with named objects could +fail. (PR#15758) +

    +
  • +
  • Sweave() mis-parsed Sexpr expressions that +contained backslashes. (PR#15779) +

    +
  • +
  • The return value from options(foo = NULL) was not +the previous value of the option. (PR#15781) +

    +
  • +
  • enc2utf8() and enc2native() did not always +mark the encoding of the return values when it was known. +

    +
  • +
  • dnbinom(x, size = <large>, mu, log = TRUE) no longer +underflows to -Inf for large mu, thanks to a suggestion +from Alessandro Mammana (MPI MolGen, Berlin). +

    +
  • +
  • pbeta(x, a, b, log = TRUE) no longer behaves +discontinuously (in a small x-region) because of denormalized +numbers. Also, pbeta(1-1e-12, 1e30, 1.001, log=TRUE) now +terminates “in real time”. +

    +
  • +
  • The "CRAN" filter (see available.packages()) +no longer removes duplicates other than of packages on CRAN, and +does not fail if there is no CRAN repository in +getOption("repos"). +

    +
  • +
  • The device listing from dev2bitmap() and +bitmap() was truncated to 1000 characters: modern versions +of GhostScript on most platforms have many more devices. +

    +
  • +
  • (Windows.) Commands such as Sys.which() and +pipe() which needed to find the full path to a command +could segfault if the ‘long’ path name was much longer than +the ‘short’ path name (which Sys.which() returns), +as the behaviour of the Windows API call had changed. +

    +
  • +
  • R CMD build will fail with an error if one of the +packages specified in the VignetteBuilder field is not +installed. (Without loading those packages it cannot be +ascertained which files are intended to be vignettes. This means +that the VignetteBuilder packages have to be installed for +package checking too.) +(Wish of PR#15775.) +

    +
  • +
  • Misguided attempts to use chull() with non-finite +points now give an error (related to PR#15777). +

    +
  • +
  • For a formula with exactly 32 variables the 32nd variable +was aliased to the intercept in some C-level computations of +terms, so that for example attempting to remove it would remove +the intercept instead (and leave a corrupt internal structure). +(PR#15735) +

    +
  • +
  • anyDuplicated() silently returned wrong values when +the first duplicate was at an index which was too large to be +stored in an integer vector (although a lot of RAM and patience +would have been needed to encounter this). +

    +
  • +
  • tools::Rd2ex(commentDontrun = FALSE) failed if the +block had only one line. +

    +
  • +
  • Hexadecimal constants such as 0x110p-5L which were +incorrectly qualified by L were parsed incorrectly since R +3.0.0, with a slightly garbled warning. (PR#15753) +

    +
  • +
  • system() returned success on some platforms even if +the system was unable to launch a process. (PR#15796) +

    +
  • +
  • (Windows Rgui console.) Unbuffered output was +sometimes not output immediately if the prompt was not on the last +line of the console. +

    +
  • +
  • The built-in help server did not declare the encoding for +the ‘DESCRIPTION’ or other text files to be the package +encoding, so non-ASCII characters could be displayed incorrectly. +

    +
  • +
  • R is now trying harder to not cleanup child processes +that were not spawned by mcparallel() on platforms that +provide information about the source process of the SIGCHLD +signal. This allows 3rd party libraries to manage the exit status +of children that they spawn without R interfering. +

    +
  • +
  • mcmapply() was only parallelizing if the number of +jobs was bigger than the number of cores. It now parallelizes if +the number of jobs is more than one. +

    +
  • +
  • Auto-printing would re-evaluate its argument when trying to +dispatch to a print method. This is now avoided when possible. +

    +
  • +
  • Unserializing (including load() and readRDS()) +could silently return incorrect numeric values from ASCII saves if +there was a read error. +

    +
  • +
  • getParseData() could return incorrect values for +the parents of some elements. (Reported by Andrew Redd.) +

    +
  • +
  • Attempting to use data frames of 2^31 or more rows with +merge() or to create a merged data frame of that size now +gives a clearer error message. +

    +
  • +
  • parse() did not check its file argument was a +connection if it was not a character string, so +e.g. parse(FALSE) attempted to read from stdin. +

    +

    Nor did dump() and dput(). +

    +
  • +
  • The "help.try.all.packages" option was ignored when +the shortcut syntax for help was used, e.g. ?foo. +

    +
  • +
  • A potential segfault in string allocation has been fixed. +(Found by Radford Neal.) +

    +
  • +
  • Potential memory protection errors in sort() and +D() have been fixed. (Found by Radford Neal.) +

    +
  • +
  • Fixed a lack of error checking in graphics event functions. +(Found by Radford Neal; a different patch used here than the +one in pqR.) +

    +
  • +
  • numericDeriv() sometimes miscalculated the gradient. +(PR#15849, reported originally by Radford Neal) +

    +
+ + + +

../../html/logo.jpg CHANGES IN R 3.1.0

@@ -144,9 +470,9 @@ errors and so not used on OS X.)

Currently time_t is usually long and hence 64-bit on -Unix-alike 64-bit platforms: however it several cases the -time-zone database is 32-bit. On R for Windows it is 64-bit (for -both architectures as from this version). +Unix-alike 64-bit platforms: however in several cases the +time-zone database is 32-bit. For R for Windows it is 64-bit +(for both architectures as from this version).

  • The "save.defaults" option can include a value for @@ -1520,8 +1846,8 @@

  • The default ‘version’ of Bioconductor for its packages has been changed to the upcoming 2.13, but this -can be set by the environment variable R_BIOC_VERSION, e.g. -in file ‘Renviron.site’. +can be set by the environment variable R_BIOC_VERSION when +R is installed.

  • @@ -3382,11 +3708,11 @@
      -
    • -

      Older news can be found in text format in files +

    • Older news can be found in text format in files NEWS.0, NEWS.1 -and NEWS.2 in the ‘doc’ directory. News in HTML format for -R versions from 2.10.0 to 2.15.3 is in +and NEWS.2 +in the ‘doc’ directory. News in HTML format for +R versions from 2.10.0 to 2.15.3 is in NEWS.2.html.

    diff -Nru r-base-3.1.0/doc/html/R-admin.html r-base-3.1.1/doc/html/R-admin.html --- r-base-3.1.0/doc/html/R-admin.html 2014-04-10 07:10:22.000000000 +0000 +++ r-base-3.1.1/doc/html/R-admin.html 2014-07-10 07:10:25.000000000 +0000 @@ -7,7 +7,7 @@ g77, f77, xlf, frt, pgf77, cf77, fort77, fl32, -af77 (in that order)39, and use whichever is found first; if none is found, +af77 (in that order)40, and use whichever is found first; if none is found, R cannot be compiled. However, if CC is gcc, the matching FORTRAN compiler @@ -3577,7 +3625,7 @@

    Some of the FORTRAN code makes use of COMPLEX*16 variables, which is a Fortran 90 extension. This is checked for at configure -time40, but you may need to avoid +time41, but you may need to avoid compiler flags asserting FORTRAN 77 compliance.

    Compiling the version of LAPACK in the R sources also requires some @@ -3773,7 +3821,7 @@

    When X11 was designed, most displays were around 75dpi, whereas today they are of the order of 100dpi or more. If you find that X11() -is reporting41 missing font sizes, especially larger ones, it is likely +is reporting42 missing font sizes, especially larger ones, it is likely that you are not using scalable fonts and have not installed the 100dpi versions of the X11 fonts. The names and details differ by system, but will likely have something like Fedora's @@ -3876,7 +3924,7 @@ the best possible performance on the machine on which R is being installed: if the compilation is for a site-wide installation, it may still be desirable to use something like --mtume=core2.42 It is also possible to increase the +-mtume=core2.43 It is also possible to increase the optimization levels to -O3: however for many versions of the compilers this has caused problems in at least one CRAN package. @@ -4040,7 +4088,7 @@ --with-aqua (which is the default): quartz() then becomes the default device when running R at the console and X11 would only be used for the data editor/viewer. (This needs an -Objective-C compiler43 which can compile the code for quartz().) +Objective-C compiler44 which can compile the code for quartz().)

    Use --without-aqua if you want a standard Unix-alike build: apart from disabling quartz() and the ability to use the build @@ -4106,8 +4154,8 @@

    with clang and clang++ from Xcode 5, and the Fortran compiler from -http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2. -Apple's build of clang has no OpenMP support. +http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2.45 Apple's +build of clang has no OpenMP support.

    Pre-compiled versions of many of the Useful libraries and programs are available from http://r.research.att.com/libs/. You will @@ -4123,7 +4171,7 @@

    to provide potentially higher-performance versions of the BLAS and LAPACK routines. (Use of Accelerate with --with-lapack does not work on Snow Leopard: it may work there -without.)44 +without.)46

    Looking at the top of /Library/Frameworks/R.framework/Resources/etc/Makeconf @@ -4139,11 +4187,16 @@

    The TeX implementation used by the developers is MacTeX (http://www.tug.org/mactex/): the full installation is about 4GB, -but a smaller version (ca 300MB) is available at +but a smaller version is available at http://www.tug.org/mactex/morepackages.html: you will need to add -some packages, e.g. inconsolata, texinfo and -upquote. ‘TeX Live Utility’ (available via the MacTeX -front page) provides a graphical means to manage TeX packages. +some packages, e.g. for the 2014 version we needed to add +cm-super, ec, helvetic, inconsolata and +texinfo which brought this to about 380MB (or package +texinfo and the collections collection-fontsrecommended, +collection-fontsextra and collection-latexextra which will +take this up to about 1GB). ‘TeX Live Utility’ (available +via the MacTeX front page) provides a graphical means to manage +TeX packages.

    @@ -4208,8 +4261,8 @@ after an update to Mavericks, you are advised to re-install them.) They are not available under the ‘Downloads’ preference pane in Xcode. -

    To use the compilers Xcode 5 provides and the recommended Fortran -compiler, have in config.site something like +

    To use the compilers from the command-line tools for Xcode 5 with the +recommended Fortran compiler, have in config.site something like

         CC=clang
          CXX=clang++
    @@ -4218,8 +4271,8 @@
          OBJC=clang
     

    (CC=gcc and CXX=g++ are slightly different front-ends to -the same compilers.) Some versions of the CRAN binary package -installer for `Snow Leopard' changes the settings in etc/Makeconf +the same compilers.) Recent versions of the CRAN binary package +installer for `Snow Leopard' change the settings in etc/Makeconf to

         CC = gcc -arch x86_64 -std=gnu99
          CXX g++ -arch x86_64
    @@ -4247,9 +4300,7 @@
     
         --with-tcl-config=/usr/local/lib/tclConfig.sh
          --with-tk-config=/usr/local/lib/tkConfig.sh
     
    -

    Note that this expects a fully-updated X11 installation: it was built -against the Apple X11 from Snow Leopard, but XQuartz will work if recent -enough (e.g. version 2.7.4). +

    Note that this expects a fully-updated X11 installation.

    There is also a native (`Aqua') version of Tcl/Tk which produces widgets in the native OS X style: this will not work with R.app because of @@ -4330,17 +4381,25 @@

         ./configure --enable-R-framework
     
    -

    This is only needed if you want to build R for use with the -R.app console, and implies --enable-R-shlib to build -R as a dynamic library. This option configures R to be built and -installed as a framework called R.framework. The default -installation path for R.framework is /Library/Frameworks -but this can be changed at configure time by specifying the flag +

    (This is intended to be used with an Apple toolchain: other compilers may +not support frameworks correctly.) + +

    It is only needed if you want to build R for use with the R.app +console, and implies --enable-R-shlib to build R as a +dynamic library. This option configures R to be built and installed +as a framework called R.framework. The default installation path +for R.framework is /Library/Frameworks but this can be +changed at configure time by specifying the flag --enable-R-framework[=DIR] or at install time as

         make prefix=/where/you/want/R.framework/to/go install
     
    -

    +

    Note that installation as a framework is non-standard (especially to a +non-standard location) and utilities may not support it (e.g. the +pkg-config file libR.pc will be put somewhere unknown +to pkg-config). + +

    C.3.8 Building R.app

    @@ -4420,9 +4479,16 @@ you find time-zone abbreviations being given odd values (as has been seen on 64-bit builds without it). -

    When using the Oracle compilers45 do not specify -fast, as this +

    When using the Oracle compilers47 do not specify -fast, as this disables IEEE arithmetic and make check will fail. +

    It has been reported that some Solaris installations need + +

         INTERNET_LIBS="-lsocket -lnsl"
    +
    +

    on the configure command line or in file config.site; +however, there have been many successful installs without this. +

    A little juggling of paths was needed to ensure GNU libiconv (in /usr/local) was used rather than the Solaris iconv: @@ -4463,11 +4529,11 @@

    Currently ‘amd64’ and ‘sparcv9’ builds work out-of-the-box with Sun Studio 12u1 but not Solaris Studio 12.2 and -later: libRblas.so and lapack.so are generated with code +12.3: libRblas.so and lapack.so are generated with code that causes relocation errors (which is being linked in from the Fortran -libraries). This means that building R as a shared library may be -impossible with Solaris Studio >= 12.2. For a standard build the trick -seems to be to manually set FLIBS to avoid the troublesome +libraries). This means that building 64-bit R as a shared library +may be impossible with Solaris Studio >= 12.2. For a standard build the +trick seems to be to manually set FLIBS to avoid the troublesome libraries. For example, on ‘amd64’ set in config.site something like @@ -4551,7 +4617,7 @@ it can also be set up to use GNU ld, but that has not been tested. -

    Compilation for a 32-bit Sparc target with gcc 4.8.2 +

    Compilation for a 32-bit Sparc target with gcc 4.9.0 needed

         CPPFLAGS=-I/opt/csw/include
    @@ -4572,7 +4638,7 @@
        

    The compilation can be tuned to a particular cpu: the CRAN check system uses -mtune=niagara2. -

    Compilation for an ‘x86’ target with gcc 4.8.2 +

    Compilation for an ‘x86’ target with gcc 4.9.0 needed

         CC="/opt/csw/gcc4/bin/gcc -m32"
    @@ -4586,7 +4652,7 @@
     32-bit gcc, and we need /opt/csw/lib in
     R_LD_LIBRARY_PATH.)
     
    -   

    For an ‘amd64’ target with gcc 4.8.2 +

    For an ‘amd64’ target with gcc 4.9.0 we used

         CC="/opt/csw/gcc4/bin/gcc -m64"
    @@ -4755,7 +4821,7 @@
     that some C99 long double mathematical functions are missing, so
     configuring with --disable-long-double was required.
     
    -   

    Only building as a shared library can possibly work,46 so use e.g. +

    Only building as a shared library can possibly work,48 so use e.g.

         ./configure --disable-nls --enable-R-shlib FLIBS=-lgfortran
          make
    @@ -4859,7 +4925,7 @@
     
        

    We have found that the build process for R is quite sensitive to the choice of tools: please follow our instructions exactly, -even to the choice of particular versions of the tools.47 The build process for add-on packages is somewhat more +even to the choice of particular versions of the tools.49 The build process for add-on packages is somewhat more forgiving, but we recommend using the exact toolset at first, and only substituting other tools once you are familiar with the process. @@ -4869,7 +4935,7 @@

    We have collected most of the necessary tools (unfortunately not all, due to license or size limitations) into an executable installer -named48 Rtools31.exe, +named50 Rtools31.exe, available from http://CRAN.R-project.org/bin/windows/Rtools/. You should download and run it, choosing the default “Package authoring installation” to build add-on packages, or the “full installation” if @@ -4910,7 +4976,7 @@

    It is essential that the directory containing the command line tools comes first or second in the path: there are typically like-named -tools49 in other directories, and they will not +tools51 in other directories, and they will not work. The ordering of the other directories is less important, but if in doubt, use the order above. @@ -4926,11 +4992,20 @@

    D.1 LaTeX

    The ‘MiKTeX’ (http://www.miktex.org/) distribution of -LaTeX includes a suitable port of pdftex. The `basic' version -of ‘MiKTeX’ almost suffices (the grid vignettes need -fancyvrb.sty), but it will install the 15Mb ‘lm’ package if -allowed to (although that is not actually used). The Rtools*.exe -installer does not include any version of LaTeX. +LaTeX includes a suitable port of pdftex. This can be set up +to install extra packages `on the fly', which is the simplest way to use +it (and the default). The `basic' version of ‘MiKTeX’ almost +suffices: when last tested packages + +

         epsf fancyvrb inconsolata listings mptopdf natbib upquote url
    +
    +

    needed to be added (on the fly or via the ‘MiKTeX’ Package +Manager) to install R. In any case ensure that the inconsolata +package is installed—you can check with the ‘MiKTeX’ Package +Manager. + +

    The Rtools*.exe installer does not include any version of +LaTeX.

    It is also possible to use the TeXLive distribution from http://www.tug.org/texlive/. @@ -4938,15 +5013,13 @@

    Please read Making the manuals about how to make fullrefman.pdf and set the environment variable R_RD4PDF suitably; ensure you have the required fonts installed or that ‘MiKTeX’ is set up to -install LaTeX packages on first use. (In any case ensure that the -inconsolata package is installed—you can check with the MiKTeX -Package Manager.) +install LaTeX packages on first use.

    D.2 The Inno Setup installer

    -

    To make the installer package (R-3.1.0-win.exe) we +

    To make the installer package (R-3.1.1-win.exe) we currently require the Unicode version of Inno Setup 5.3.7 or later from http://jrsoftware.org/. This is not included in Rtools*.exe. @@ -5024,7 +5097,7 @@

    This toolchain uses multilib: that is there is a single front-end such as gcc.exe for each of the compilers and 32-bit (the -default) and 64-bit compilation are selected by the flags50 -m32 and -m64 +default) and 64-bit compilation are selected by the flags52 -m32 and -m64 respectively. The tools are all 32-bit Windows executables and should be able to run on any current version of Windows—however you do need a 64-bit version of Windows to build 64-bit R as the build process runs @@ -5217,164 +5290,172 @@

    [5] for example, if you configured R with --without-recommended.

    -

    [6] on a +

    [6] Instructions on how to install the latest +version are at +http://www.ctan.org/tex-archive/fonts/inconsolata/.

    + +

    [7] on a Unix-alike, ‘inconsolata’ is omitted if not found by configure.

    -

    [7] The linktoc +

    [8] The linktoc settings require hyperref version 6.78f or newer; with older versions of hyperref use linktocpage=false to hyperlink the text.

    -

    [8] do not use this if -configure option --with-internal-tzcode was used.

    +

    [9] This will be needed if more than one +sub-architecture is to be installed.

    -

    [9] with possible values +

    [10] with possible values ‘i386’, ‘x64’, ‘32’ and ‘64’.

    -

    [10] mainly on RedHat and Fedora, whose layout is described +

    [11] mainly on RedHat and Fedora, whose layout is described here.

    -

    [11] How to prepare such a directory is described in file +

    [12] How to prepare such a directory is described in file src/extra/tzone/Notes in the R sources.

    -

    [12] unless they were excluded in the build.

    +

    [13] unless they were excluded in the build.

    -

    [13] its binding is locked once the startup files have been +

    [14] its binding is locked once the startup files have been read, so users cannot easily change it.

    -

    [14] If a proxy needs to be set, see +

    [15] If a proxy needs to be set, see ?download.file.

    -

    [15] for a small number of +

    [16] for a small number of CRAN packages where this is known to be safe and is needed by the autobuilder this is the default. Look at the source of tools:::.install_packages for the list. It can also be specified in the package's DESCRIPTION file.

    -

    [16] or by adding it in +

    [17] or by adding it in a file such as etc/i386/Makevars.site, which does not exist by default.

    -

    [17] `X/Open Portability Guide', which has +

    [18] `X/Open Portability Guide', which has had several versions.

    -

    [18] On some systems setting +

    [19] On some systems setting LC_ALL or LC_MESSAGES to ‘C’ disables LANGUAGE.

    -

    [19] If you try changing from French +

    [20] If you try changing from French to Russian except in a UTF-8 locale, you will most likely find messages change to English.

    -

    [20] the +

    [21] the language written in England: some people living in the USA appropriate this name for their language.

    -

    [21] with +

    [22] with Americanisms.

    -

    [22] also known as +

    [23] also known as IEEE 754

    -

    [23] at least when storing quantities: the on-FPU +

    [24] at least when storing quantities: the on-FPU precision is allowed to vary

    -

    [24] e.g. Bessel, beta and gamma functions

    +

    [25] e.g. Bessel, beta and gamma functions

    -

    [25] including copying MkRules.dist to +

    [26] including copying MkRules.dist to MkRule.local and selecting the architecture.

    -

    [26] also known as +

    [27] also known as IEEE 754

    -

    [27] Note +

    [28] Note that C11 compilers need not be C99-compliant: R requires support for double complex and variable-length arrays which are optional in C11 but is mandatory in C99.

    -

    [28] -std=c99 excludes POSIX +

    [29] -std=c99 excludes POSIX functionality, but config.h will turn on all GNU extensions to include the POSIX functionality.

    -

    [29] specifically, the C99 +

    [30] specifically, the C99 functionality of headers wchar.h and wctype.h, types wctans_t and mbstate_t and functions mbrtowc, mbstowcs, wcrtomb, wcscoll, wcstombs, wctrans, wctype, and iswctype.

    -

    [30] including the opendir, readdir, +

    [31] including the opendir, readdir, closedir, popen, stat, glob, access, getcwd and chdir system calls, and either putenv or setenv.

    -

    [31] such as +

    [32] such as realpath, symlink.

    -

    [32] Such as +

    [33] Such as GNU tar 1.15 or later, bsdtar (from http://code.google.com/p/libarchive/, as used by FreeBSD and OS 10.6 and later) or tar from the Heirloom Toolchest (http://heirloom.sourceforge.net/tools.html).

    -

    [33] texi2dvi is normally a +

    [34] texi2dvi is normally a shell script. Some versions, e.g. that from texinfo 4.13a and 5.2, need to be run under bash rather than a Bourne shell as on, say, Solaris.

    -

    [34] also known as ttf-mscorefonts-installer in the +

    [35] also known as ttf-mscorefonts-installer in the Debian/Ubuntu world: see also http://en.wikipedia.org/wiki/Core_fonts_for_the_Web.

    -

    [35] ttf-liberation +

    [36] ttf-liberation in Debian/Ubuntu.

    -

    [36] which is what is supplied with R: PCRE must be built +

    [37] which is what is supplied with R: PCRE must be built with UTF-8 support (not the default) and support for Unicode properties is assumed by some R packages. Neither are tested by configure.

    -

    [37] Using the Oracle Solaris Studio +

    [38] Using the Oracle Solaris Studio cc and f95 compilers

    -

    [38] We have measured 15–20% on ‘i686’ Linux +

    [39] We have measured 15–20% on ‘i686’ Linux and around 10% on ‘x86_64’ Linux.

    -

    [39] On HP-UX fort77 is the +

    [40] On HP-UX fort77 is the POSIX compliant FORTRAN compiler, and comes after g77.

    -

    [40] as well as its equivalence to the Rcomplex +

    [41] as well as its equivalence to the Rcomplex structure defined in R_ext/Complex.h.

    -

    [41] for example, X11 font at size 14 could not +

    [42] for example, X11 font at size 14 could not be loaded.

    -

    [42] or -mtune=corei7 for Intel Core +

    [43] or -mtune=corei7 for Intel Core i3/15/17 with gcc >= 4.6.0.

    -

    [43] These days that is defined by Apple's +

    [44] These days that is defined by Apple's implementation of clang, so it is strongly recommended to use that.

    -

    [44] It is reported that for some non-Apple toolchains +

    [45] This +is a tarball which needs to be unpacked in the Terminal by e.g. +sudo tar -zxf gfortran-4.8.2-darwin13.tar.bz2 -C /.

    + +

    [46] It is reported that for some non-Apple toolchains CPPFLAGS needed to contain -D__ACCELERATE__.

    -

    [45] including gcc for +

    [47] including gcc for Sparc from Oracle.

    -

    [46] Windows +

    [48] Windows DLLs need to have all links resolved at build time and so cannot resolve against R.bin.

    -

    [47] For +

    [49] For example, the Cygwin version of make 3.81 fails to work correctly.

    -

    [48] for R 3.0.0 and later.

    +

    [50] for R 3.0.0 and later.

    -

    [49] such as sort, find and perhaps +

    [51] such as sort, find and perhaps make.

    -

    [50] these +

    [52] these flags apply to the compilers: some of the tools use different flags. 32-bit builds are the default.

    diff -Nru r-base-3.1.0/doc/manual/R-admin.texi r-base-3.1.1/doc/manual/R-admin.texi --- r-base-3.1.0/doc/manual/R-admin.texi 2014-04-04 22:15:04.000000000 +0000 +++ r-base-3.1.1/doc/manual/R-admin.texi 2014-06-26 22:15:04.000000000 +0000 @@ -479,12 +479,19 @@ by @command{configure}) or @code{beramono}, which replace the Courier monospaced font by Inconsolata or Bera Sans mono respectively. (You will need a recent version of the appropriate @LaTeX{} package -@pkg{inconsolata} or @pkg{bera} installed.) +@pkg{inconsolata}@footnote{Instructions on how to install the latest +version are at +@uref{http://www.ctan.org/tex-archive/fonts/inconsolata/}.} or +@pkg{bera} installed: @pkg{inconsolata} is likely to require +@pkg{upquote}.) Note that in most @LaTeX{} installations this will not actually use the standard fonts for PDF, but rather embed the URW clones NimbusRom, NimbusSans and (for Courier, if used) NimbusMon. +This needs @LaTeX{} packages @pkg{times}, @pkg{helvetic} and (if used) +@pkg{courier} installed. + @item lm Using the @emph{Latin Modern} fonts. These are not often installed as part of a @TeX{} distribution, but can obtained from @@ -645,12 +652,10 @@ The @command{configure} or @command{make} variables @code{rdocdir} and @code{rsharedir} can be used to install the system-independent -@file{doc} and @file{share}@footnote{do not use this if -@command{configure} option @option{--with-internal-tzcode} was used.} -directories to somewhere other than @code{libdir}. The C header files -can be installed to the value of @code{rincludedir}: note that as the -headers are not installed into a subdirectory you probably want -something like +@file{doc} and @file{share} directories to somewhere other than +@code{libdir}. The C header files can be installed to the value of +@code{rincludedir}: note that as the headers are not installed into a +subdirectory you probably want something like @code{rincludedir=/usr/local/include/R-@value{VERSIONno}}. If you want the @R{} home to be something other than @@ -664,7 +669,7 @@ will use a version-specific @R{} home on a non-Debian Linux 64-bit system. -If you have made @R{} as a shared/dynamic library you can install it in +If you have made @R{} as a shared/static library you can install it in your system's library directory by @example @@ -673,7 +678,12 @@ @noindent where @code{prefix} is optional, and @code{libdir} will give more -precise control. +precise control.@footnote{This will be needed if more than one +sub-architecture is to be installed.} However, you should not install +to a directory mentioned in @env{LDPATHS} (e.g.@: +@file{/usr/local/lib64}) if you intend to work with multiple versions of +@R{}, since that directory may be given precedence over the @file{lib} +directory of other @R{} installations. @example make install-strip @@ -747,6 +757,11 @@ Target @code{uninstall-tests} will uninstall any installed tests, as well as removing the directory @file{tests} containing the test results. +An installed shared/static @code{libR} can be uninstalled by + +@example +make prefix=/path/to/here uninstall-libR +@end example @node Sub-architectures, Other Options, Uninstallation, Installing R under Unix-alikes @@ -902,8 +917,7 @@ to by environment variable @env{TZDIR}: this should contain files such as @file{Europe/London}. On all tested OSes the system timezone was deduced correctly, but if necessary it can be set as the value of -environment variable @env{TZ}. (This option is currently incompatible -with setting @option{rsharedir}.) +environment variable @env{TZ}. @node Testing a Unix-alike Installation, , Other Options, Installing R under Unix-alikes @@ -1140,7 +1154,7 @@ Working in the directory @file{@var{R_HOME}/src/gnuwin32/bitmap}, install the @code{libpng} and @code{jpeg} sources in sub-directories. The @code{jpeg} sub-directory for version 9 is named @file{jpeg-9}; if -you use a different version (e.g.@: @file{jpeg-8d} or +you use a different version (e.g.@: @file{jpeg-9a} or @file{libjpeg-turbo}), copy file @file{src/gnuwin32/MkRules.dist} to @file{src/gnuwin32/MkRules.local} and edit the definition of @code{JPEGDIR}: the names of the @file{libpng} and @file{libtiff} @@ -1149,9 +1163,9 @@ Example: @example -> tar -zxf libpng-1.6.2.tar.gz -> mv libpng-1.6.2 libpng -> tar -zxf jpegsrc.v9.tar.gz +> tar -zxf libpng-1.6.10.tar.gz +> mv libpng-1.6.10 libpng +> tar -zxf jpegsrc.v9a.tar.gz > tar -zxf tiff-4.0.3.tar.gz > mv tiff-4.0.3/libtiff . > rm -rf tiff-4.0.3 @@ -1255,6 +1269,33 @@ tarball unpacks with a top-level directory @file{src/}: @samp{CAIRO_HOME} needs to include that directory in its path.) +@menu +* Using ICU for collation:: +@end menu + +@node Using ICU for collation, , Building the cairo devices files, Building the cairo devices files +@subsubsection Using ICU for collation + +It is possible (and even recommended) to build @R{} to use ICU +(International Components for Unicode, +@uref{http://site.icu-project.org/}) for collation, as is commonly done +on Unix-alikes. + +Two settings are needed in @file{MkRules.local}, +@example +# set to use ICU +# USE_ICU = YES +# path to parent of ICU headers +ICU_PATH = /path/to/ICU +@end example + +@noindent +The first should be uncommented and the second set to the top-level +directory of a suitably packaged binary build of ICU, for example that +at @url{http://www.stats.ox.ac.uk/pub/Rtools/goodies/ICU_531.zip}. +Depending on the build, it may be necessary to edit the macro +@code{ICU_LIBS}. + @node Checking the build, Building the manuals, Building the cairo devices files, Building from source @subsection Checking the build @@ -1540,34 +1581,36 @@ @end macro The front page of a @acronym{CRAN} site has a link `Download R for OS -X'. Click on that, then download the file @file{R-@value{VERSIONno}.pkg} -and install it. This runs on OS X 10.6 and later (Snow Leopard, Lion, -Mountain Lion, Mavericks, @dots{}); it is a 64-bit (@cputype{x86_64}) -build which should run on all Macs from mid-2008 on. For older Intel -Macs and some older versions of the OS you can install @R{} from the -sources. - -There may be a separate installer package for Mavericks users. - -It is important that if you use this binary package that your OS is -fully updated: run `Software Update' from the Apple menu to be sure. -If you update your OS X version, you should re-install @R{}: the -installer tailors the installation to the current version of the OS. +X'. Click on that, then download the file +@file{R-@value{VERSIONno}-snowleopard.pkg} and install it. This runs on +OS X 10.6 and later (Snow Leopard, Lion, Mountain Lion, Mavericks, +@dots{}); it is a 64-bit (@cputype{x86_64}) build which should run on +all Macs from mid-2008 on. For older Intel Macs and some older versions +of the OS you can install @R{} from the sources. + +There is a separate installer package, +@file{R-@value{VERSIONno}-mavericks.pkg}, for use on Mavericks only: the +`Snow Leopard' installer package also works there and may have more +binary packages available (but there are a few packages using C++11 and +only available for the Mavericks build). + +It is important that if you use a binary installer package that your OS +is fully updated: run `Software Update' from the Apple menu to be sure. +(If using XQuartz, check that is current.) To install, just double-click on the icon of the file you downloaded. At the `Installation Type' stage, note the option to `Customize'. This -currently shows three components (`Package Name'). Everyone will need -the `R Framework' component: the `R GUI' and `Tcl/Tk' components are -optional (the latter being needed to use package @pkg{tcltk}). +currently shows three components. Everyone will need the `R Framework' +component: the `R GUI' and `Tcl/Tk' components are optional (the latter +being needed to use package @pkg{tcltk}). This is an Apple Installer package. If you encounter any problem during the installation, please check the Installer log by clicking on the ``Window'' menu and item ``Installer Log''. The full output (select ``Show All Log'') is useful for tracking down problems. -On Mountain Lion and later with `GateKeeper' active you will need to -right/control-click on any unsigned packages and select @samp{Open}: -recent @acronym{CRAN} packages are signed. +If you update your OS X version, you should re-install @R{}: the +installer tailors the installation to the current version of the OS. For building @R{} from source, see @ref{OS X}. @@ -1580,7 +1623,7 @@ @node Running R under OS X, Uninstalling under OS X, Installing R under OS X, Installing R under OS X @section Running R under OS X -There are two ways to run @R{} on OS X from the @acronym{CRAN} binary +There are two ways to run @R{} on OS X from a @acronym{CRAN} binary distribution. There is a GUI console normally installed with the @R{} icon in @@ -2028,7 +2071,9 @@ Installing source packages which do not contain compiled code should work with no additional tools. For others you will need the `Command-line Tools' for @command{Xcode} and compilers which match those -used to build @R{}: see @ref{OS X}. +used to build @R{}: see @ref{OS X}. (Note that the Fortran compilers +differ for the `Snow Leopard' and `Mavericks' binary installations of +@R{}.) Package @CRANpkg{rJava} and those which depend on it need a Java runtime installed and several packages need X11 installed, including those using @@ -2987,10 +3032,20 @@ Building PDF package manuals (including the @R{} reference manual) and vignettes is sensitive to the version of the @LaTeX{} package @pkg{hyperref} and we recommend that the @TeX{} distribution used is -kept up-to-date. A number of @LaTeX{} packages are required (including -@pkg{url.sty}, and @pkg{listings.sty}) and others such as @pkg{hyperref} -and @pkg{inconsolata} are desirable (and without them you may need to change -@R{}'s defaults: @pxref{Making the manuals}). +kept up-to-date. A number of standard @LaTeX{} packages are required +(including @pkg{fancyvrb}, @pkg{url} and some of the font packages such +as @pkg{times}, @pkg{helvetic}, @pkg{ec} and @pkg{cm-super}) and others +such as @pkg{hyperref} and @pkg{inconsolata} are desirable (and without +them you may need to change @R{}'s defaults: @pxref{Making the +manuals}). Note that most versions of @pkg{inconsolata} require package +@pkg{upquote} and that @pkg{hyperref} (currently) requires packages +@pkg{kvoptions}, @pkg{ltxcmds} and @pkg{refcount}. For distributions +based on TeXLive the simplest approach may be to install collections +@pkg{collection-latex}, @pkg{collection-fontsrecommended}, +@pkg{collection-latexrecommended}, @pkg{collection-fontsextra} and +@pkg{collection-latexextra} (assuming they are not installed by +default): Fedora uses names like @pkg{texlive-collection-fontsextra} and +Debian/Ubuntu like @pkg{texlive-fonts-extra}. @cindex Subversion @@ -4566,8 +4621,10 @@ @noindent with @command{clang} and @command{clang++} from Xcode 5, and the Fortran compiler from -@uref{http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2}. -Apple's build of @command{clang} has no OpenMP support. +@uref{http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2}.@footnote{This +is a tarball which needs to be unpacked in the Terminal by e.g.@: +@command{sudo tar -zxf gfortran-4.8.2-darwin13.tar.bz2 -C /}.} Apple's +build of @command{clang} has no OpenMP support. Pre-compiled versions of many of the @ref{Useful libraries and programs} are available from @uref{http://r.research.att.com/libs/}. You will @@ -4607,11 +4664,16 @@ The @TeX{} implementation used by the developers is MacTeX (@uref{http://www.tug.org/mactex/}): the full installation is about 4GB, -but a smaller version (ca 300MB) is available at +but a smaller version is available at @uref{http://www.tug.org/mactex/morepackages.html}: you will need to add -some packages, e.g.@: @pkg{inconsolata}, @pkg{texinfo} and -@pkg{upquote}. @samp{TeX Live Utility} (available @emph{via} the MacTeX -front page) provides a graphical means to manage @TeX{} packages. +some packages, e.g.@: for the 2014 version we needed to add +@pkg{cm-super}, @pkg{ec}, @pkg{helvetic}, @pkg{inconsolata} and +@pkg{texinfo} which brought this to about 380MB (or package +@pkg{texinfo} and the collections @pkg{collection-fontsrecommended}, +@pkg{collection-fontsextra} and @pkg{collection-latexextra} which will +take this up to about 1GB). @samp{TeX Live Utility} (available +@emph{via} the MacTeX front page) provides a graphical means to manage +@TeX{} packages. @menu * Snow Leopard:: @@ -4689,8 +4751,8 @@ after an update to Mavericks, you are advised to re-install them.) They are not available under the @samp{Downloads} preference pane in Xcode. -To use the compilers Xcode 5 provides and the recommended Fortran -compiler, have in @file{config.site} something like +To use the compilers from the command-line tools for Xcode 5 with the +recommended Fortran compiler, have in @file{config.site} something like @example CC=clang @@ -4701,8 +4763,8 @@ @end example @noindent (@code{CC=gcc} and @code{CXX=g++} are slightly different front-ends to -the same compilers.) Some versions of the @acronym{CRAN} binary package -installer for `Snow Leopard' changes the settings in @file{etc/Makeconf} +the same compilers.) Recent versions of the @acronym{CRAN} binary package +installer for `Snow Leopard' change the settings in @file{etc/Makeconf} to @example CC = gcc -arch x86_64 -std=gnu99 @@ -4731,9 +4793,7 @@ --with-tcl-config=/usr/local/lib/tclConfig.sh --with-tk-config=/usr/local/lib/tkConfig.sh @end example -Note that this expects a fully-updated X11 installation: it was built -against the Apple X11 from Snow Leopard, but XQuartz will work if recent -enough (e.g.@: version 2.7.4). +Note that this expects a fully-updated X11 installation. There is also a native (`Aqua') version of Tcl/Tk which produces widgets in the native OS X style: this will not work with @Rapp{} because of @@ -4822,18 +4882,26 @@ ./configure --enable-R-framework @end example -This is only needed if you want to build @R{} for use with the -@Rapp{} console, and implies @option{--enable-R-shlib} to build -@R{} as a dynamic library. This option configures @R{} to be built and -installed as a framework called @file{R.framework}. The default -installation path for @file{R.framework} is @file{/Library/Frameworks} -but this can be changed at configure time by specifying the flag +(This is intended to be used with an Apple toolchain: other compilers may +not support frameworks correctly.) + +It is only needed if you want to build @R{} for use with the @Rapp{} +console, and implies @option{--enable-R-shlib} to build @R{} as a +dynamic library. This option configures @R{} to be built and installed +as a framework called @file{R.framework}. The default installation path +for @file{R.framework} is @file{/Library/Frameworks} but this can be +changed at configure time by specifying the flag @option{--enable-R-framework[=@var{DIR}]} or at install time as @example make prefix=/where/you/want/R.framework/to/go install @end example +Note that installation as a framework is non-standard (especially to a +non-standard location) and utilities may not support it (e.g.@: the +@command{pkg-config} file @file{libR.pc} will be put somewhere unknown +to @command{pkg-config}). + @node Building R.app, , Frameworks, OS X @subsection Building R.app @@ -4919,6 +4987,16 @@ Sparc from Oracle.} do @emph{not} specify @option{-fast}, as this disables @acronym{IEEE} arithmetic and @command{make check} will fail. +It has been reported that some Solaris installations need + +@example +INTERNET_LIBS="-lsocket -lnsl" +@end example + +@noindent +on the @command{configure} command line or in file @file{config.site}; +however, there have been many successful installs without this. + A little juggling of paths was needed to ensure @acronym{GNU} @code{libiconv} (in @file{/usr/local}) was used rather than the Solaris @code{iconv}: @@ -4970,11 +5048,11 @@ Currently @cputype{amd64} and @cputype{sparcv9} builds work out-of-the-box with Sun Studio 12u1 but not Solaris Studio 12.2 and -later: @file{libRblas.so} and @file{lapack.so} are generated with code +12.3: @file{libRblas.so} and @file{lapack.so} are generated with code that causes relocation errors (which is being linked in from the Fortran -libraries). This means that building @R{} as a shared library may be -impossible with Solaris Studio >= 12.2. For a standard build the trick -seems to be to manually set @code{FLIBS} to avoid the troublesome +libraries). This means that building 64-bit @R{} as a shared library +may be impossible with Solaris Studio >= 12.2. For a standard build the +trick seems to be to manually set @code{FLIBS} to avoid the troublesome libraries. For example, on @cputype{amd64} set in @file{config.site} something like @@ -5078,7 +5156,7 @@ it can also be set up to use GNU @command{ld}, but that has not been tested. -Compilation for a 32-bit Sparc target with @command{gcc}@tie{}4.8.2 +Compilation for a 32-bit Sparc target with @command{gcc}@tie{}4.9.0 needed @example @@ -5106,7 +5184,7 @@ The compilation can be tuned to a particular cpu: the @acronym{CRAN} check system uses @code{-mtune=niagara2}. -Compilation for an @cputype{x86} target with @command{gcc}@tie{}4.8.2 +Compilation for an @cputype{x86} target with @command{gcc}@tie{}4.9.0 needed @example @@ -5123,7 +5201,7 @@ 32-bit @code{gcc}, and we need @file{/opt/csw/lib} in @code{R_LD_LIBRARY_PATH}.) -For an @cputype{amd64} target with @command{gcc}@tie{}4.8.2 +For an @cputype{amd64} target with @command{gcc}@tie{}4.9.0 we used @example @@ -5504,11 +5582,23 @@ @section @LaTeX{} The @samp{MiKTeX} (@uref{http://www.miktex.org/}) distribution of -@LaTeX{} includes a suitable port of @code{pdftex}. The `basic' version -of @samp{MiKTeX} almost suffices (the @pkg{grid} vignettes need -@file{fancyvrb.sty}), but it will install the 15Mb @samp{lm} package if -allowed to (although that is not actually used). The @file{Rtools*.exe} -installer does @emph{not} include any version of @LaTeX{}. +@LaTeX{} includes a suitable port of @code{pdftex}. This can be set up +to install extra packages `on the fly', which is the simplest way to use +it (and the default). The `basic' version of @samp{MiKTeX} almost +suffices: when last tested packages + +@example +epsf fancyvrb inconsolata listings mptopdf natbib upquote url +@end example + +@noindent +needed to be added (on the fly or @emph{via} the @samp{MiKTeX} Package +Manager) to install @R{}. In any case ensure that the @pkg{inconsolata} +package is installed---you can check with the @samp{MiKTeX} Package +Manager. + +The @file{Rtools*.exe} installer does @emph{not} include any version of +@LaTeX{}. It is also possible to use the TeXLive distribution from @uref{http://www.tug.org/texlive/}. @@ -5517,9 +5607,7 @@ Please read @ref{Making the manuals} about how to make @file{fullrefman.pdf} and set the environment variable @env{R_RD4PDF} suitably; ensure you have the required fonts installed or that @samp{MiKTeX} is set up to -install @LaTeX{} packages on first use. (In any case ensure that the -@pkg{inconsolata} package is installed---you can check with the MiKTeX -Package Manager.) +install @LaTeX{} packages on first use. @node The Inno Setup installer, The command line tools, LaTeX, The Windows toolset @section The Inno Setup installer diff -Nru r-base-3.1.0/doc/manual/R-data.texi r-base-3.1.1/doc/manual/R-data.texi --- r-base-3.1.0/doc/manual/R-data.texi 2013-07-17 22:05:04.000000000 +0000 +++ r-base-3.1.1/doc/manual/R-data.texi 2014-06-25 22:15:06.000000000 +0000 @@ -247,6 +247,10 @@ looking at the file with the command-line utility @command{od} or a hex editor to work out its encoding. +Note that @code{utf8} is not a valid encoding name (@code{UTF-8} is), +and @code{macintosh} is the most portable name for what is sometimes +called `Mac Roman' encoding. + @node Export to text files, XML, Imports, Introduction @section Export to text files @cindex Exporting to a text file diff -Nru r-base-3.1.0/doc/manual/R-exts.texi r-base-3.1.1/doc/manual/R-exts.texi --- r-base-3.1.0/doc/manual/R-exts.texi 2014-04-04 22:15:04.000000000 +0000 +++ r-base-3.1.1/doc/manual/R-exts.texi 2014-07-09 22:15:04.000000000 +0000 @@ -183,9 +183,10 @@ source package which contains C, C++ or Fortran code will involve compiling that code. There is also the possibility of `byte' compiling the @R{} code in a package (using the facilities of package -@pkg{compiler}): already the base and recommended packages are -byte-compiled. At some future time this might be done routinely, so -@emph{compiling} a package may come to mean compiling its @R{} code. +@pkg{compiler}): already base and recommended packages are normally +byte-compiled and this can be specified for other packages. So +@emph{compiling} a package may come to mean byte-compiling its @R{} +code. @item It used to be unambiguous to talk about @emph{loading} an installed @@ -274,7 +275,6 @@ Unix-alikes, see @ref{Configure and cleanup}. The analogues on Windows are @file{configure.win} and @file{cleanup.win}. - For the conventions for files @file{NEWS} and @file{ChangeLog} in the @acronym{GNU} project see @uref{http://www.gnu.org/@/prep/@/standards/@/standards.html#Documentation}. @@ -1056,9 +1056,9 @@ If your code needs to depend on the platform there are certain defines which can used in C or C++. On all Windows builds (even 64-bit ones) -@samp{WIN32} will be defined: on 64-bit Windows builds also -@samp{WIN64}, and on OS X @samp{__APPLE__} is defined.@footnote{There is -also @samp{__APPLE_CC__}, but that indicates a compiler with +@samp{_WIN32} will be defined: on 64-bit Windows builds also +@samp{_WIN64}, and on OS X @samp{__APPLE__} is defined.@footnote{There +is also @samp{__APPLE_CC__}, but that indicates a compiler with Apple-specific features, not the OS. It is used in @file{Rinlinedfuns.h}.} @@ -1121,6 +1121,10 @@ @} @end example +@noindent +Note the use of architecture-specific subdirectories if @file{bin} where +needed. + The @file{data} subdirectory is for data files: @xref{Data in packages}. The @file{demo} subdirectory is for @R{} scripts (for running @emph{via} @@ -1200,10 +1204,11 @@ can be helpful to do so in all cases, to avoid occasional failures when tests are run). -If @file{tests} has a subdirectory @file{Examples} containing a file -@code{@var{pkg}-Ex.Rout.save}, this is compared to the output file for -running the examples when the latter are checked. Reference output -should be produced without having the @option{--timings} option set. +If directory @file{tests} has a subdirectory @file{Examples} containing +a file @code{@var{pkg}-Ex.Rout.save}, this is compared to the output +file for running the examples when the latter are checked. Reference +output should be produced without having the @option{--timings} option +set (and note that @option{--as-cran} sets it). Subdirectory @file{exec} could contain additional executable scripts the package needs, typically scripts for interpreters such as the shell, @@ -1212,14 +1217,17 @@ installed (and those with names starting with a dot are ignored), and they are all marked as executable (mode @code{755}, moderated by @samp{umask}) on POSIX platforms. Note too that this is not suitable -for executable @emph{programs} since some platforms (including OS X and -Windows) support multiple architectures using the same installed package -directory. The suggestion is that programs are installed under -@file{bin} in a sub-directory which depends on the architecture. +for executable @emph{programs} since some platforms (including Windows) +support multiple architectures using the same installed package +directory. Subdirectory @file{po} is used for files related to @emph{localization}: @pxref{Internationalization}. +Subdirectory @file{tools} is the preferred place for auxiliary files +needed during configuration, and also for sources need to re-create +scripts (e.g.@: M4 files for @command{autoconf}). + @node Data in packages, Non-R scripts in packages, Package subdirectories, Package structure @subsection Data in packages @@ -1904,11 +1912,11 @@ There is nothing to say what version of OpenMP is supported: version 3.0 (May 2008) is supported by recent versions of the Linux, Windows and Solaris platforms, but portable packages cannot assume that end users -have recent versions. The compilers currently used on OS X have partial -support for OpenMP 2.5, but this is not enabled in the @acronym{CRAN} -build. (Apple have discontinued support for those compilers, and their -preferred alternative, @command{clang}, currently has no OpenMP -support. A project to add it has been announced at +have recent versions. The compilers used on OS X 10.6 (`Snow Leopard') +had partial support for OpenMP 2.5, but this is not enabled in the +@acronym{CRAN} build of @R{}. (Apple have discontinued support for those +compilers, and their alternative as from OS X 10.9, @command{clang}, has +no OpenMP support. A project to add it has been announced at @uref{http://clang-omp.github.io/}, but it is unknown when or even if the Apple builds will incorporate it.) @@ -1932,8 +1940,8 @@ first level. The correctness of the detected number of `CPUs' and the assumption that the @R{} process is entitled to use them all are both dubious assumptions. The best way to limit resources is to limit the -overall number of threads available to OpenMP in the R process: this can -be done via environment variable @env{OMP_THREAD_LIMIT}, where +overall number of threads available to OpenMP in the @R{} process: this +can be done via environment variable @env{OMP_THREAD_LIMIT}, where implemented.@footnote{Which it was at the time of writing with GCC, Solaris Studio and Intel compilers.} Alternatively, the number of threads per region can be limited by the environment variable @@ -2227,8 +2235,9 @@ @option{-std=f2008} in @code{PKG_FCFLAGS}: the default is `GNU Fortran', Fortran 95 with non-standard extensions. The Solaris @command{f95} compiler `accepts some Fortran 2003 features'. Note that the compiler -used for OS X is @command{gfortran 4.2.3} which has limited Fortran 2003 -support (@uref{http://gcc.gnu.org/onlinedocs/gcc-4.2.3/gfortran/}). +used for OS X <= 10.8 is @command{gfortran 4.2.3} which has limited +Fortran 2003 support +(@uref{http://gcc.gnu.org/onlinedocs/gcc-4.2.3/gfortran/}). Modern versions of Fortran support modules, whereby compiling one source file creates a module file which is then included in others. (Module @@ -2263,7 +2272,7 @@ C++98. From version 3.1.0, @R{} provides support for C++11 in packages, in -addition to C++98. This support is not consistent across platforms as +addition to C++98. This support is not uniform across platforms as it depends on the capabilities of the compiler (see below). When @R{} is configured, it will determine whether the C++ compiler supports C++11 and which compiler flags, if any, are required to enable C++11 support. @@ -2281,8 +2290,8 @@ Compilation and linking will then be done with the C++11 compiler. If any other value is given to the @samp{CXX_STD} macro it will be ignored. -(Further options may become available in the future depending on the -evolution of the C++ standard.) +(Further options may become available in the future as the C++ standard +evolves.) Packages without a @file{Makevars} file may specify that they require C++11 by including @samp{C++11} in the @samp{SystemRequirements} field @@ -2314,15 +2323,15 @@ If C++11 support is not available then these macros are both empty. Otherwise, @samp{CXX1X} defaults to the same value as the C++ compiler @samp{CXX} and the flag @samp{CXX1XSTD} defaults to -@option{-std=c++11} or @option{-std=c++0x} (the latter on Windows). -It is possible to specify @samp{CXX1X} to be a distinct compiler just -for C++11--using packages, e.g.@: @command{g++ 4.8.x} on Solaris. -Note however that different C++ compilers (and even different versions -of the same compiler) often differ in their ABI so their outputs can -rarely be mixed. By setting @samp{CXX1XSTD} it is also possible to -choose a different dialect of the standard, such as -@option{-std=gnu++11}, or enable experimental support for the next -revision (tentatively planned for 2017) @option{-std=c++1y}. +@option{-std=c++11} or @option{-std=c++0x} (the latter on Windows). It +is possible to specify @samp{CXX1X} to be a distinct compiler just for +C++11--using packages, e.g.@: @command{g++ 4.8.x} on Solaris. Note +however that different C++ compilers (and even different versions of the +same compiler) often differ in their ABI so their outputs can rarely be +mixed. By setting @samp{CXX1XSTD} it is also possible to choose a +different dialect of the standard, such as @option{-std=gnu++11}, or +enable experimental support for the next revision (tentatively planned +for 2017) using something like @option{-std=c++1y}. As noted above, support for C++11 varies across platforms. The default compiler@footnote{OS X 10.7 and later have @command{clang++} but for @@ -2417,8 +2426,9 @@ of @command{file} if available@footnote{A suitable @command{file.exe} is part of the Windows toolset: it checks for @command{gfile} if a suitable @command{file} is not found: the latter is available in the OpenCSW -collection for Solaris at @uref{http://www.opencsw.org}.}. (There may -be rare false positives.) +collection for Solaris at @uref{http://www.opencsw.org}. The source +repository is @uref{ftp://ftp.astron.com/pub/file/}.}. (There may be +rare false positives.) @item The @file{DESCRIPTION} file is checked for completeness, and some of its @@ -2622,7 +2632,10 @@ 2014 @CRANpkg{gdata} declared @samp{Imports: gtools} and @CRANpkg{gtools} declared @samp{Imports: gdata}.}in @file{DESCRIPTION} files needs repositories (including @acronym{CRAN}) set: do this in -@file{~/.Rprofile}. +@file{~/.Rprofile}, by e.g@: +@example +options(repos = c(CRAN="http://cran.r-project.org")) +@end example You do need to ensure that the package is checked in a suitable locale if it contains non-@acronym{ASCII} characters. Such packages are likely @@ -3106,7 +3119,7 @@ Note that a package with non-Sweave vignettes should always have a @samp{VignetteBuilder} field in the @file{DESCRIPTION} file, since this is how @command{R CMD check} recognizes that there are vignettes to be -checked. +checked: packages listed there are required when the package is checked. The vignette engine can produce @file{.tex}, @file{.pdf}, or @file{.html} files as output. If it produces @file{.tex} files, @R{} will @@ -3728,6 +3741,7 @@ * PDF size:: * Check timing:: * Encoding issues:: +* Portable C and C++ code:: * Binary distribution:: @end menu @@ -3739,7 +3753,9 @@ (aka @code{x11()}) which although emulated on Windows may not be available on a Unix-alike (and is not the preferred screen device on OS X). It is rarely necessary for package code or examples to open a new -device, but if essential, use @code{dev.new()}. +device, but if essential,@footnote{People use @code{dev.new()} to open a +device at a particular size: that is not portable but using +@code{dev.new(noRStudioGD = TRUE)} helps.} use @code{dev.new()}. Use @command{R CMD build} to make the release @file{.tar.gz} file. @@ -3789,7 +3805,7 @@ use GNU extensions in files @file{Makevars.win} or @file{Makefile.win}. Moreover, Bash extensions also need to be avoided in shell scripts, -including expression in Makefiles (which are passed to the shell for +including expressions in Makefiles (which are passed to the shell for processing). Some @R{} platforms use strictly POSIX-conformant Bourne shells, and Windows and some Unix-alike OSes use @command{ash} (@uref{http://en.wikipedia.org/wiki/Almquist_shell}), a rather minimal @@ -3804,7 +3820,7 @@ behaviours are allowed (@uref{http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html}) and both occur as defaults on @R{} platforms: portable applications -should not use @option{-n} (as the first argument) or escape sequences. +should not use @option{-n} (as the first argument) nor escape sequences. @item Make use of the abilities of your compilers to check the @@ -3876,7 +3892,7 @@ @item Errors in memory allocation and reading/writing outside arrays are very common causes of crashes (e.g., segfaults) on some machines. -See @ref{Using valgrind} for a tool which can be used to look for this. +See @ref{Checking memory access} for tools which can be used to look for this. @item Many platforms will allow unsatisfied entry points in compiled code, but @@ -3884,7 +3900,7 @@ (notably Windows) will not. Looking at the output of @example -nm -pg mypkg.so # @r{or other extension such as @file{.sl}} +nm -pg mypkg.so @end example @noindent @@ -3948,7 +3964,8 @@ default on Windows, overridden for the @R{} executables. It is also the default on some Solaris compilers.} which use them configure them to allow the use of extended precision. In particular, ARM CPUs do not -(currently) have extended precision nor long doubles. +(currently) have extended precision nor long doubles, and long double +was 64-bit on HP/PA Linux. If you must try to establish a tolerance empirically, configure and build @R{} with @option{--disable-long-double} and use appropriate @@ -3968,16 +3985,16 @@ @command{qpdf} (@uref{http://qpdf.sourceforge.net/}) can compress losslessly. It is fairly readily available (e.g.@: it has binaries for -Windows and packages in Debian/Ubuntu/Fedora 17, and is installed as -part of the @acronym{CRAN} OS X distribution of @R{}). @command{R CMD -build} has an option to run @command{qpdf} over PDF files under -@file{inst/doc} and replace them if at least 10Kb and 10% is saved. The -full path to the @command{qpdf} command can be supplied as environment -variable @env{R_QPDF} (and is on the CRAN binary of @R{} for OS X). It -seems MiKTeX does not use PDF object compression and so @command{qpdf} -can reduce considerably the files it outputs: MiKTeX can be overridden by -code in the preamble of an Sweave or @LaTeX{} file --- see how this is done -for the @R{} reference manual at +Windows and packages in Debian/Ubuntu/Fedora, and is installed as part +of the @acronym{CRAN} OS X distribution of @R{}). @command{R CMD build} +has an option to run @command{qpdf} over PDF files under @file{inst/doc} +and replace them if at least 10Kb and 10% is saved. The full path to +the @command{qpdf} command can be supplied as environment variable +@env{R_QPDF} (and is on the CRAN binary of @R{} for OS X). It seems +MiKTeX does not use PDF object compression and so @command{qpdf} can +reduce considerably the files it outputs: MiKTeX can be overridden by +code in the preamble of an Sweave or @LaTeX{} file --- see how this is +done for the @R{} reference manual at @uref{https://svn.r-project.org/R/trunk/doc/manual/refman.top}. Other tools can reduce the size of PDFs containing bitmap images at @@ -4002,10 +4019,10 @@ @end example @noindent -; see @uref{http://www.ghostscript.com/@/doc/@/9.07/@/Ps2pdf.htm} for +; see @uref{http://www.ghostscript.com/@/doc/@/current/@/Ps2pdf.htm} for more such and consider all the options for image downsampling). There have been examples in @acronym{CRAN} packages for which Ghostscript 9.06 -and later produced dramatically better reductions than 9.05 or earlier. +and later produced much better reductions than 9.05 or earlier. We come across occasionally large PDF files containing excessively complicated figures using PDF vector graphics: such figures are often @@ -4045,7 +4062,7 @@ @env{_R_CHECK_ALWAYS_LOG_VIGNETTE_OUTPUT_} is set to a true value. -@node Encoding issues, Binary distribution, Check timing, Writing portable packages +@node Encoding issues, Portable C and C++ code, Check timing, Writing portable packages @subsection Encoding issues Care is needed if your package contains non-@acronym{ASCII} text, and in @@ -4110,7 +4127,68 @@ the current locale is UTF-8 then the package code is translated to UTF-8 for syntax checking. -@node Binary distribution, , Encoding issues, Writing portable packages +@node Portable C and C++ code, Binary distribution, Encoding issues, Writing portable packages +@subsection Portable C and C++ code + +Writing portable C and C++ code is mainly a matter of observing the +standards (C99, C++98 or where declared C++11) and testing that +extensions (such as POSIX functions) are supported. However, some +common errors are worth pointing out here. It can be helpful to look up +functions at @uref{http://www.cplusplus.com/reference/} or +@uref{http://en.cppreference.com/w/} and compare what is defined in the +various standards. + +@itemize +@item +Mathematical functions such as @code{sqrt} are defined in C++ for +floating-point arguments. It is legitimate in C++ to overload these +with versions for types @code{float}, @code{double}, @code{long double} +and possibly more. This means that calling @code{sqrt} on an integer +type may have `overloading ambiguity' as it could be promoted to any of the +supported floating-point types: this is commonly seen on Solaris. +(C++11 requires additional overloads for integer types.) + +@item +Function @code{fabs} is defined for only for floating-point types, +except in C++11 which has overloads in @file{} for integer types. +Function @code{abs} is defined in C99's @file{} for @code{int} +and in C++98's @file{} for integer types, overloaded in +@file{} for floating-point types. C++11 has additional overloads +for @code{abs} in @file{} for integer types. + +@item +Functions/macros such as @code{isnan}, @code{isinf} and @code{isfinite} +are not required by C++98: where compilers support them they may be only +in the @code{std} namespace or only in the main namespace. There is no +way to make use of these functions which works with all C++ compilers +currently in use on @R{} platforms: use @R{}'s versions such as +@code{ISNAN} and @code{R_FINITE} instead. + +It is an error (and make little sense, although has been seen) to call +these functions for integer arguments. + +@item +Variable-length arrays are C99, not supported by C++98 nor by the C++ +compilers in use with @R{} on some platforms. + +@item +Macros defined by the compiler/OS can cause problems. Macros starting +with an underscore followed by an upper-case letter or another +underscore are reserved and should not be used in portable code. Other +macros, typically upper-case, may be defined by the compiler or system +headers and can cause problems. +@c http://lists.x.org/archives/xorg-devel/2013-November/038808.html +The most common issue involves the names of the Intel CPU registers such +as @code{CS}, @code{DS} and @code{SS} defined on i586/x64 Solaris in +@file{} and often included indirectly by @file{} +and other core headers. +@end itemize + +Some additional information for C++ is available at +@uref{http://journal.r-project.org/archive/2011-2/RJournal_2011-2_Plummer.pdf} +by Martyn Plummer. + +@node Binary distribution, , Portable C and C++ code, Writing portable packages @subsection Binary distribution If you want to distribute a binary version of a package on Windows or OS @@ -7024,6 +7102,7 @@ * Using valgrind:: * Using Address Sanitizer:: * Using Undefined Behaviour Sanitizer:: +* Other analyses with `clang':: * Using `Dr. Memory':: * Fortran array bounds checking:: @end menu @@ -7089,7 +7168,7 @@ @end itemize @code{R CMD check --use-gct} can be set to use -@code{gctorture2(@var{n})} rather than @code{gctorture(TRUE)} by +@code{gctorture2(@var{n})} rather than @code{gctorture(TRUE)} by setting environment variable @env{_R_CHECK_GCT_N_} to a positive integer value to be used as @code{@var{n}}. @@ -7100,12 +7179,12 @@ @node Using valgrind, Using Address Sanitizer, Using gctorture, Checking memory access @subsection Using valgrind -If you have access to Linux on a common CPU type or OS X@footnote{at the -time of writing mainly for 10.7 with some support for 10.8, none for the -current 10.9.} you can use @code{valgrind} -(@uref{http://www.valgrind.org/}, pronounced to rhyme with `tinned') to -check for possible problems. To run some examples under @code{valgrind} -use something like +If you have access to Linux on a common CPU type or supported versions +of OS X@footnote{at the time of writing mainly for 10.7 with some +support for 10.8, none for the current 10.9.} you can use +@code{valgrind} (@uref{http://www.valgrind.org/}, pronounced to rhyme +with `tinned') to check for possible problems. To run some examples +under @code{valgrind} use something like @example R -d valgrind --vanilla < mypkg-Ex.R @@ -7160,7 +7239,7 @@ @end smallexample @noindent This example is from an instrumented version of @R{}, while tracking -down a bug in the @CRANpkg{Matrix} package in January, 2006. The first line +down a bug in the @CRANpkg{Matrix} package in 2006. The first line indicates that @R{} has tried to read 4 bytes from a memory address that it does not have access to. This is followed by a C stack trace showing where the error occurred. Next is a description of the memory that was @@ -7215,37 +7294,50 @@ builds@footnote{not including the versions distributed by Apple in @code{Xcode} 4.6 or 5, nor of @command{clang} in Fedora prior to an update in Fedora 19. On some platforms, e.g.@: Fedora, the runtime -library, @pkg{libasan}, needs to be installed separately.} of -@command{gcc} 4.8.0 or @command{clang} 3.1 and later on common Linux and -OS X platforms. See +library, @pkg{libasan}, needs to be installed separately. OS X users can +install a suitable @command{clang} from the sources or possibly +distributions such as MacPorts or Homebrew.} of @command{gcc} 4.8.0 or +@command{clang} 3.1 and later on common Linux and OS X platforms. See @uref{http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation}, @uref{http://clang.llvm.org/docs/AddressSanitizer.html} and @uref{https://code.google.com/p/address-sanitizer/}. It requires code to have been compiled @emph{and linked} with @option{-fsanitize=address}@footnote{@option{-faddress-sanitizer} in -@command{clang} 3.1}, and using @code{-fno-omit-frame-pointer} will give -more legible reports. It has a runtime penalty of 2--3x, extended -compilation times and uses substantially more memory, often 1--2GB, at -run time. By comparison with @command{valgrind}, it can detect misuse -of stack and global variables but not the use of uninitialized memory. - -Most versions@footnote{@command{gcc} will from version 4.9.0.} do not -return symbolic addresses for the location of the error. One -possibility is to use an external symbolizer such as +@command{clang} 3.1}, and compiling with @code{-fno-omit-frame-pointer} +will give more legible reports. It has a runtime penalty of 2--3x, +extended compilation times and uses substantially more memory, often +1--2GB, at run time. On 64-bit platforms it reserves (but does not +allocate) 16--20TB of virtual memory: restrictive shell settings can +cause problems. + +By comparison with @command{valgrind}, ASan can +detect misuse of stack and global variables but not the use of +uninitialized memory. + +@command{gcc} as from version 4.9.0 returns symbolic addresses for the +location of the error, but most other versions do not. For the latter, +one possibility is to use an external symbolizer. Depending on the +version, this can be done @emph{via} an environment variable, e.g.@: + +@example +ASAN_SYMBOLIZER_PATH=/path/to/llvm-symbolizer +@end example + +@noindent +or by piping the output through @command{asan_symbolize.py}@footnote{installed on some Linux systems as @command{asan_symbolize}, and obtainable from @uref{https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py}: -it makes use of @command{llvm-symbolizer} if available.}. For example, -the check output can be piped through @command{asan_symbolize.py} and +it makes use of @command{llvm-symbolizer} if available.} and perhaps then (for compiled C++ code) @command{c++filt}. The simplest way to make use of this is to build a version of @R{} with something like @example -CC="gcc-4.8 -std=gnu99 -fsanitize=address" -CFLAGS="-fno-omit-frame-pointer -O2 -Wall -pedantic -mtune=native" +CC="gcc-4.9 -std=gnu99 -fsanitize=address" +CFLAGS="-fno-omit-frame-pointer -g -O2 -Wall -pedantic -mtune=native" @end example @noindent @@ -7253,25 +7345,38 @@ into the @R{} executable. However this check can be enabled on a per-package basis by using a @file{~/.R/Makevars} file like @example -CC = gcc-4.8 -std=gnu99 -fsanitize=address -fno-omit-frame-pointer -CXX = g++-4.8 -fsanitize=address -fno-omit-frame-pointer -F77 = gfortran-4.8 -fsanitize=address -FC = gfortran-4.8 -fsanitize=address +CC = gcc-4.9 -std=gnu99 -fsanitize=address -fno-omit-frame-pointer +CXX = g++-4.9 -fsanitize=address -fno-omit-frame-pointer +F77 = gfortran-4.9 -fsanitize=address +FC = gfortran-4.9 -fsanitize=address @end example (Note that @code{-fsanitize=address} has to be part of the compiler specification to ensure it is used for linking. These settings will not be honoured by packages which ignore @file{~/.R/Makevars}.) It will -likely be necessary to build @R{} with +be necessary to build @R{} with @example MAIN_LDFLAGS = -fsanitize=address @end example @noindent -to link the required libraries into the @R{} executable. +to link the runtime libraries into the @R{} executable if it was not +specified as part of @samp{CC} when @R{} was built. -For options available @emph{via} an environment variable see +For options available @emph{via} the environment variable +@env{ASAN_OPTIONS} see @uref{https://code.google.com/p/address-sanitizer/wiki/Flags#Run-time_flags}. +With @command{gcc} additional control is available @emph{via} the +@option{--params} flag: see its @command{man} page. For some builds on +@code{x86_64} Linux this includes enabling the leak sanitizer +(@uref{https://code.google.com/p/address-sanitizer/wiki/LeakSanitizer}), +which might even be enabled by default: this means any leaks give the +process a failure error status (by default @code{23}). To disable this +and some strict checking use + +@example +setenv ASAN_OPTIONS 'alloc_dealloc_mismatch=0:detect_leaks=0' +@end example For more detailed information @R{} can be run under a debugger with a breakpoint set before the address sanitizer report is produced: for @@ -7282,24 +7387,12 @@ (See @uref{http://code.google.com/p/address-sanitizer/wiki/AddressSanitizer#gdb}.) -Some versions of @command{clang} also have a (currently experimental) -memory sanitizer invoked by @option{-fsanitize=memory} which detects -uses of uninitialized memory. See -@uref{http://clang.llvm.org/docs/MemorySanitizer.html}. And some have -an experimental leak sanitizer for @code{x86_64} Linux: see -@uref{https://code.google.com/p/address-sanitizer/wiki/LeakSanitizer}. - -Clang also has a Static Analyser run on the source files during -compilation: see @uref{http://clang-analyzer.llvm.org/}. - -@node Using Undefined Behaviour Sanitizer, Using `Dr. Memory', Using Address Sanitizer, Checking memory access +@node Using Undefined Behaviour Sanitizer, Other analyses with `clang', Using Address Sanitizer, Checking memory access @subsection Using the Undefined Behaviour Sanitizer `UBSanitizer' is a tool for C/C++ source code selected by -@samp{-fsanitize=undefined} (or with the address sanitizer by -@samp{-fsanitize=undefined,address} where supported) in suitable builds -of @command{clang}, and will appear in GCC 4.9.0. (It can be enabled in -a similar way to the address sanitizer: see the previous subsection.) +@option{-fsanitize=undefined} in suitable builds +of @command{clang}, and GCC as from 4.9.0. `Undefined behaviour' is where the language standard does not require particular behaviour from the compiler. Examples include division by @@ -7313,6 +7406,11 @@ common is @code{y[x - 1]} forgetting that @code{x} might be @code{NA_INTEGER}. +This sanitizer can be combined with the Address Sanitizer by +@option{-fsanitize=undefined,address}. Its runtime library is linked +into each package's DLL, so it is less often needed to be included in +@env{MAIN_LDFLAGS}. + Finer control of what is checked can be achieved by other options: for @command{clang} see @uref{http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation}. @@ -7331,16 +7429,71 @@ -fsanitize=undefined -fno-sanitize=float-divide-by-zero @end example -There is also the compiler flag @option{-fcatch-undefined-behavior}, -said to be more reliable in @command{clang} than @command{gcc}. +@noindent +In addition, +@example +-fsanitize=unsigned-integer-overflow +@end example +is available as a separate option in some versions of @command{clang} +(not enabled by @option{-fsanitize=undefined}). + +A smaller selection is available for GCC, currently defaulting to +@example +-fsanitize=integer-divide-by-zero,null,return,shift,signed-integer-overflow,unreachable,vla-bound +@end example + +@noindent +with +@example +-fsanitize=float-divide-by-zero +@end example + +@noindent +as a separate option not enabled by @code{-fsanitize=undefined}. + +Other useful flags include +@example +-no-fsanitize=recover +@end example + +@noindent +which causes the first report to be fatal (it always is for the +@code{unreachable} and @code{return} suboptions). + + +There are also the compiler flags @option{-fcatch-undefined-behavior} +and @option{-ftrapv}, said to be more reliable in @command{clang} than +@command{gcc}. For more details on the topic see @uref{http://blog.regehr.org/archives/213} and -@uref{http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html}. +@uref{http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html} +(which has 3 parts). This option does not currently compile OpenMP code. -@node Using `Dr. Memory', Fortran array bounds checking, Using Undefined Behaviour Sanitizer, Checking memory access +@node Other analyses with `clang', Using `Dr. Memory', Using Undefined Behaviour Sanitizer, Checking memory access +@subsection Other analyses with `clang' + + +@command{clang} has a `Static Analyser' run on the source files during +compilation: see @uref{http://clang-analyzer.llvm.org/}. + +Some versions of @command{clang} have a (currently experimental) memory +sanitizer invoked by @option{-fsanitize=memory} which detects uses of +uninitialized memory. See +@uref{http://clang.llvm.org/docs/MemorySanitizer.html}. + +For @code{x86_64} Linux there is a leak sanitizer: see +@uref{https://code.google.com/p/address-sanitizer/wiki/LeakSanitizer}: +one way to invoke this from an ASAN-enabled build is by the environment +variable + +@example +ASAN_OPTIONS='detect_leaks=1' +@end example + +@node Using `Dr. Memory', Fortran array bounds checking, Other analyses with `clang', Checking memory access @subsection Using `Dr. Memory' `Dr. Memory' from @uref{http://www.drmemory.org/} is a memory checker @@ -7679,7 +7832,7 @@ @end smallexample For a more fine-grained control over the the depth of the recursion -and the output of vectors @code{R_inspect3} takes additional two integer +and the output of vectors @code{R_inspect3} takes additional two character() parameters: maximum depth and the maximal number of elements that will be printed for scalar vectors. The defaults in @code{R_inspect} are currently -1 (no limit) and 5 respectively. @@ -8435,10 +8588,10 @@ mechanisms, please resist. Far too much developer time has been wasted in chasing down errors caused by failures to follow this documentation, and even more by package authors demanding explanations as to why their -packages not longer work. +packages no longer work. @c Jasjeet Singh Sekhon: this is your moment of infamy. -In particular, undocumented environment or make variables are not for -use by package writers and are subject to change without notice. +In particular, undocumented environment or @command{make} variables are +not for use by package writers and are subject to change without notice. @node Interfacing C++ code, Fortran I/O, Creating shared objects, System and foreign language interfaces @section Interfacing C++ code @@ -8600,6 +8753,9 @@ desirable that the API provided by package @pkg{packB} remains backwards-compatible. +Shipping a static library in package @pkg{packB} for other packages to +link to avoids most of the difficulties. + @menu * Unix-alikes:: * Windows:: @@ -8614,48 +8770,53 @@ recommended for a distributed package. This is easiest if @pkg{packB} provides a static library -@file{packB/libs/libpackB.a}. (This will need to be compiled with +@file{packB/lib/libpackB.a}. (Note using directory @file{lib} rather +than @file{libs} is conventional, and architecture-specific +sub-directories may be needed and are assumed in the sample code +below. The code in the static library will need to be compiled with @code{PIC} flags on platforms where it matters.) Then as the code from package @pkg{packB} is incorporated when package @pkg{packA} is installed, we only need to find the static library at install time for -package @pkg{packB}. The only issue is to find package @pkg{packB}, and -for that we can ask @R{} by something like (long lines broken for display here) +package @pkg{packA}. The only issue is to find package @pkg{packB}, and +for that we can ask @R{} by something like (long lines broken for +display here) @example PKGB_PATH=`echo 'library(packB); - cat(system.file("libs", package="packB", mustWork=TRUE))' \ + cat(system.file("lib", package="packB", mustWork=TRUE))' \ | "$@{R_HOME@}/bin/R" --vanilla --slave` PKG_LIBS="$(PKGB_PATH)$(R_ARCH)/libpackB.a" @end example -For a dynamic library @file{packB/libs/libpackB.so} -(@file{packB/libs/libpackB.dylib} on OS X: note that you cannot link to -a shared object, @file{.so} on that platform) we could use +For a dynamic library @file{packB/lib/libpackB.so} +(@file{packB/lib/libpackB.dylib} on OS X: note that you cannot link to +a shared object, @file{.so}, on that platform) we could use @example PKGB_PATH=`echo 'library(packB); - cat(system.file("libs", package="packB", mustWork=TRUE))' \ + cat(system.file("lib", package="packB", mustWork=TRUE))' \ | "$@{R_HOME@}/bin/R" --vanilla --slave` PKG_LIBS=-L"$(PKGB_PATH)$(R_ARCH)" -lpackB @end example @noindent This will work for installation, but very likely not when package -@code{packB} is loaded, as the path to package @pkg{packB}'s @file{libs} +@code{packB} is loaded, as the path to package @pkg{packB}'s @file{lib} directory is not in the @command{ld.so}@footnote{@command{dyld} on OS X, and @env{DYLD_LIBRARY_PATHS} below.} search path. You can arrange to put it there @strong{before} @R{} is launched by setting (on some platforms) @env{LD_RUN_PATH} or @env{LD_LIBRARY_PATH} or adding to the @command{ld.so} cache (see @command{man ldconfig}). On platforms that -support it, the path to the dynamic library can be hardcoded at install -time (which assumes that the location of package @pkg{packB} will not be -changed) nor the package updated to a changed API). On systems with the -@command{gcc} or @command{clang} and the @acronym{GNU} linker (e.g.@: -Linux) and some others (e.g.@: OS X) this can be done by e.g.@: +support it, the path to the directory containing the dynamic library can +be hardcoded at install time (which assumes that the location of package +@pkg{packB} will not be changed nor the package updated to a changed +API). On systems with the @command{gcc} or @command{clang} and the +@acronym{GNU} linker (e.g.@: Linux) and some others (e.g.@: OS X) this +can be done by e.g.@: @example PKGB_PATH=`echo 'library(packB); - cat(system.file("libs", package="packB", mustWork=TRUE)))' \ + cat(system.file("lib", package="packB", mustWork=TRUE)))' \ | "$@{R_HOME@}/bin/R" --vanilla --slave` PKG_LIBS=-L"$(PKGB_PATH)$(R_ARCH)" -Wl,-rpath,"$(PKGB_PATH)$(R_ARCH)" -lpackB @end example @@ -8668,7 +8829,8 @@ It may be possible to figure out what is required semi-automatically from the result of @command{R CMD libtool --config} (look for @samp{hardcode}), although that does not currently know the spell for OS -X (as given in the example above). +X (as given in the example above, as @option{-rpath} is only supported for +shared objects and not for executables). Making headers provided by package @pkg{packB} available to the code to be compiled in package @pkg{packA} can be done by the @code{LinkingTo} @@ -12506,9 +12668,12 @@ R CMD config --ldflags @end example -If @R{} is installed, @code{pkg-config} is available and -sub-architectures have not been used, alternatives for a shared @R{} -library are +@noindent +(These apply only to an uninstalled copy or a standard install.) + +If @R{} is installed, @code{pkg-config} is available and neither +sub-architectures nor an OS X framework have been used, alternatives for +a shared @R{} library are @example pkg-config --cflags libR @@ -12523,6 +12688,11 @@ pkg-config --libs --static libR @end example +@noindent +(This may work for an installed OS framework if @code{pkg-config} is +taught where to look for @file{libR.pc}: it is installed inside the +framework.) + However, a more comprehensive way is to set up a @file{Makefile} to compile the front-end. Suppose file @file{myfe.c} is to be compiled to @file{myfe}. A suitable @file{Makefile} might be diff -Nru r-base-3.1.0/doc/manual/R-FAQ.texi r-base-3.1.1/doc/manual/R-FAQ.texi --- r-base-3.1.0/doc/manual/R-FAQ.texi 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/doc/manual/R-FAQ.texi 2014-07-03 22:15:10.000000000 +0000 @@ -5,11 +5,11 @@ @settitle R FAQ @setchapternewpage on @set FAQ_YEAR 2014 -@set FAQ_DATE @value{FAQ_YEAR}-04-05 +@set FAQ_DATE @value{FAQ_YEAR}-07-03 @set REL_YEAR 2014 @set REL_MAJOR 3 @set REL_MINOR 1 -@set REL_PATCHLEVEL 0 +@set REL_PATCHLEVEL 1 @set REL_VERSION @value{REL_MAJOR}.@value{REL_MINOR}.@value{REL_PATCHLEVEL} @set FAQ_VERSION @value{REL_MAJOR}.@value{REL_MINOR}.@value{FAQ_DATE} @documentlanguage en diff -Nru r-base-3.1.0/doc/manual/R-intro.texi r-base-3.1.1/doc/manual/R-intro.texi --- r-base-3.1.0/doc/manual/R-intro.texi 2014-03-29 23:15:05.000000000 +0000 +++ r-base-3.1.1/doc/manual/R-intro.texi 2014-05-19 22:15:04.000000000 +0000 @@ -804,12 +804,12 @@ arguments given the result is the same as the colon operator. That is @code{seq(2,10)} is the same vector as @code{2:10}. -Parameters to @code{seq()}, and to many other @R{} functions, can also +Arguments to @code{seq()}, and to many other @R{} functions, can also be given in named form, in which case the order in which they appear is -irrelevant. The first two parameters may be named +irrelevant. The first two arguments may be named @code{from=@var{value}} and @code{to=@var{value}}; thus @code{seq(1,30)}, @code{seq(from=1, to=30)} and @code{seq(to=30, -from=1)} are all the same as @code{1:30}. The next two parameters to +from=1)} are all the same as @code{1:30}. The next two arguments to @code{seq()} may be named @code{by=@var{value}} and @code{length=@var{value}}, which specify a step size and a length for the sequence respectively. If neither of these is given, the default @@ -832,8 +832,8 @@ @noindent generates the same vector in @code{s4}. -The fifth parameter may be named @code{along=@var{vector}}, which is -normally used as the only parameter to create the sequence @code{1, 2, +The fifth argument may be named @code{along=@var{vector}}, which is +normally used as the only argument to create the sequence @code{1, 2, @dots{}, length(@var{vector})}, or the empty sequence if the vector is empty (as it can be). @@ -991,7 +991,7 @@ among the arguments are coerced into character strings in the evident way, that is, in the same way they would be if they were printed. The arguments are by default separated in the result by a single blank -character, but this can be changed by the named parameter, +character, but this can be changed by the named argument, @code{sep=@var{string}}, which changes it to @code{@var{string}}, possibly empty. @@ -1012,8 +1012,8 @@ thus @code{c("X", "Y")} is repeated 5 times to match the sequence @code{1:10}. @footnote{@code{paste(..., collapse=@var{ss})} joins the -arguments into a single character string putting @var{ss} in between. -There are more tools for character manipulation, see the help +arguments into a single character string putting @var{ss} in between, e.g., +@code{ss <- "|"}. There are more tools for character manipulation, see the help for @code{sub} and @code{substring}.} @node Index vectors, Other types of objects, Character vectors, Simple manipulations numbers and vectors @@ -1035,7 +1035,7 @@ @enumerate @item -@strong{A logical vector}. In this case the index vector must be of the +@strong{A logical vector}. In this case the index vector is recycled to the same length as the vector from which elements are to be selected. Values corresponding to @code{TRUE} in the index vector are selected and those corresponding to @code{FALSE} are omitted. For example diff -Nru r-base-3.1.0/doc/manual/rw-FAQ.texi r-base-3.1.1/doc/manual/rw-FAQ.texi --- r-base-3.1.0/doc/manual/rw-FAQ.texi 2014-01-17 23:05:04.000000000 +0000 +++ r-base-3.1.1/doc/manual/rw-FAQ.texi 2014-06-26 22:15:04.000000000 +0000 @@ -146,11 +146,10 @@ 95/98/ME/NT4 was 2.6.1. @c 2000 went end-of-life 2010-07-13 -@c XP SP3 goes end of life 2014-04-08 +@c XP SP3 went end of life 2014-04-08 We only test on versions of Windows currently supported by Microsoft, -mainly 64-bit Windows 7 and Server 2008, but to a limited extent on -32-bit XP SP3. +mainly 64-bit Windows 7 and Server 2008. Your file system must allow case-honouring long file names (as is likely except perhaps for some network-mounted systems). A installation takes @@ -462,9 +461,7 @@ @item For all applications via Windows. How you set an environment variable -is system specific: under Windows XP/Server 2003 you can use `System' in -the control panel or the properties of `My Computer' (under the -`Advanced' tab). Under recent versions of Windows, go to `User +is system specific: under recent versions of Windows, go to `User Accounts' in the Control Panel, and select your account and then `Change my environment variables'. @end enumerate @@ -796,8 +793,7 @@ some keyboards the uses of AltGr are at @url{http://office.microsoft.com/@/en-us/@/word/@/HP052590631033.aspx}: you can explore those for your keyboard via the `On-Screen Keyboard' -(under Accessories, Accessibility on XP, Accessories, Ease of access on -Windows 7). +(under Ease of access on Windows 7). On all Windows versions you should be able to get tilde by holding the down the left Alt key and typing 0126 on the numeric keypad (if you have @@ -1001,11 +997,7 @@ @uref{http://msdn.microsoft.com/@/library/@/default.asp?url=/@/library/@/en-us/@/vccore98/@/html/@/_crt_language_and_country_strings.asp}: beware that @code{"Chinese"} is Traditional Chinese (code page 950, Big5) and @code{"chs"} is needed for Simplified Chinese (code page 936, -GB2312). Note that this can be rather tricky: for example, on -International versions of Windows XP there are several places to select -the language under the `Regional and Language Options' part of the -control panel, and the appropriate language has to be set under -@emph{both} the `Regional Options' and `Advanced' tabs. +GB2312). When using @command{Rterm} the window in which it is run has to be set up to use a suitable font (e.g. @code{Lucida Console} or @@ -1067,13 +1059,9 @@ In most cases they actually are, but by Windows. Setting the locale or the @code{LANGUAGE} environment variable does not change the Windows -setting of its `UI language'. Under (international) Windows XP there -are three tabs on the @emph{Regional and Language Options} applet in the -Control Panel. The first tab controls the locale, the second the UI and -the third the fonts used for `non-Unicode' programs (but apparently also -for Unicode ones in many cases): see Q3.3. Vista and later talk about -the 'UI language' and the 'system locale' for setting the language used -for `non-Unicode' programs (on the 'Administrative' tab in Windows 7). +setting of its `UI language'. Vista and later talk about the 'UI +language' and the 'system locale' for setting the language used for +`non-Unicode' programs (on the 'Administrative' tab in Windows 7). If you have Windows running completely in say French or Chinese these settings are likely to be consistent. However, if you try to run @@ -1680,13 +1668,10 @@ speed up numerical linear algebra. There is support in the R sources for the `tuned' BLAS called ATLAS (@uref{http://math-atlas.sourceforge.net}). The savings can be -appreciable: on a 2.6GHz P4 and a 1000 x 1000 matrix @code{svd} took -16.2 sec with the standard BLAS and 7.8 sec with ATLAS. Because ATLAS -is tuned to a particular chip we can't use it generally: the optimal -routines for a P4 or an Athlon XP are quite different and neither will -run at all on a PII. However, linear algebra on large matrices is not -often an important part of R computations, and more typical calculations -on small matrices may run slower. +appreciable but because ATLAS is tuned to a particular chip we can't use +it generally. However, linear algebra on large matrices is not often an +important part of R computations, and more typical calculations on small +matrices may run slower. BLAS support is supplied by the single DLL @file{R_HOME\bin\x64\Rblas.dll}, and you can add a fast BLAS just by diff -Nru r-base-3.1.0/doc/NEWS r-base-3.1.1/doc/NEWS --- r-base-3.1.0/doc/NEWS 2014-04-10 07:05:07.000000000 +0000 +++ r-base-3.1.1/doc/NEWS 2014-07-10 07:05:12.000000000 +0000 @@ -1,5 +1,243 @@ R News +CHANGES IN R 3.1.1: + + NEW FEATURES: + + * When attach() reports conflicts, it does so compatibly with + library() by using message(). + + * R CMD Sweave no longer cleans any files by default, compatibly + with versions of R prior to 3.1.0. There are new options + --clean, --clean=default and --clean=keepOuts. + + * tools::buildVignette() and tools::buildVignettes() with clean = + FALSE no longer remove any created files. buildvignette() gains + a keep argument for more cleaning customization. + + * The Bioconductor 'version' used by setRepositories() can now be + set by environment variable R_BIOC_VERSION at runtime, not just + when R is installed. (It has been stated that Bioconductor will + switch from 'version' 2.14 to 'version' 3.0 during the lifetime + of the R 3.1 series.) + + * Error messages from bugs in embedded Sexpr code in Sweave + documents now report the source location. + + * type.convert(), read.table() and similar read.*() functions get a + new numerals argument, specifying how numeric input is converted + when its conversion to double precision loses accuracy. The + default value, "allow.loss" allows accuracy loss, as in R + versions before 3.1.0. + + * For some compilers, integer addition could overflow without a + warning. R's internal code for both integer addition and + subtraction is more robust now. (PR#15774) + + * The function determining the default number of knots for + smooth.spline() is now exported, as .nknots.smspl(). + + * dbeta(, a,b), pbeta(), qbeta() and rbeta() are now defined also + for a = 0, b = 0, or infinite a and b (where they typically + returned NaN before). + + * Many package authors report that the RStudio graphics device does + not work correctly with their package's use of dev.new(). The + new option dev.new(noRStudioGD = TRUE) replaces the RStudio + override by the default device as selected by R itself, still + respecting environment variables R_INTERACTIVE_DEVICE and + R_DEFAULT_DEVICE. + + * readRDS() now returns visibly. + + * Modifying internal logical scalar constants now results in an + error instead of a warning. + + * install.packages(repos = NULL) now accepts http:// or ftp:// URLs + of package archives as well as file paths, and will download as + required. In most cases repos = NULL can be deduced from the + extension of the URL. + + * The warning when using partial matching with the $ operator on + data frames is now only given when + options("warnPartialMatchDollar") is TRUE. + + * Package help requests like package?foo now try the package foo + whether loaded or not. + + * General help requests now default to trying all loaded packages, + not just those on the search path. + + * Added a new function promptImport(), to generate a help page for + a function that was imported from another package (and presumably + re-exported, or help would not be needed). + + INSTALLATION and INCLUDED SOFTWARE: + + * configure option --with-internal-tzcode can now be used with + variable rsharedir. + + * The included version of PCRE has been updated to 8.35. + + * There is a new target make uninstall-libR to remove an installed + shared/static libR. + + make install-libR now works if a sub-architecture is used, + although the user will need to specify libdir differently for + different sub-architectures. + + * There is more extensive advice on which LaTeX packages are + required to install R or to make package manuals (as done by R + CMD check) in the 'Writing R Extensions' manual. + + * Compilers/linkers were handling the visibility controls in + src/extra/xz inconsistently (and apparently in some cases + incorrectly), so it has been simplified. (PR#15327) + + * (Windows) There is updated support for the use of ICU for + collation: see the 'R Installation and Administration Manual'. + + BUG FIXES: + + * dbinom(x, n), pbinom(), dpois(), etc, are slightly less + restrictive in checking if n is integer-valued. (Wish of + PR#15734.) + + * pchisq(x, df, ncp, log.p = TRUE) is more accurate and no longer + underflows for small x and ncp < 80, e.g, for pchisq(1e-5, df = + 100, ncp = 1, log = TRUE). (Based on PR#15635 and a suggestion + by Roby Joehanes.) + + * The s ("step into") command in the debugger would cause R to step + into expressions evaluated there, not just into functions being + debugged. (PR#15770) + + * The C code used by strptime() rejected time-zone offsets of more + than +1200 (+1245, +1300 and +1400 can occur). (PR#15768) + + * (Windows only.) png(type = "cairo", antialias = "gray") was not + accepted. (PR#15760) + + * Use of save(..., envir=) with named objects could fail. + (PR#15758) + + * Sweave() mis-parsed Sexpr expressions that contained backslashes. + (PR#15779) + + * The return value from options(foo = NULL) was not the previous + value of the option. (PR#15781) + + * enc2utf8() and enc2native() did not always mark the encoding of + the return values when it was known. + + * dnbinom(x, size = , mu, log = TRUE) no longer underflows + to -Inf for large mu, thanks to a suggestion from Alessandro + Mammana (MPI MolGen, Berlin). + + * pbeta(x, a, b, log = TRUE) no longer behaves discontinuously (in + a small x-region) because of denormalized numbers. Also, + pbeta(1-1e-12, 1e30, 1.001, log=TRUE) now terminates "in real + time". + + * The "CRAN" filter (see available.packages()) no longer removes + duplicates other than of packages on CRAN, and does not fail if + there is no CRAN repository in getOption("repos"). + + * The device listing from dev2bitmap() and bitmap() was truncated + to 1000 characters: modern versions of GhostScript on most + platforms have many more devices. + + * (Windows.) Commands such as Sys.which() and pipe() which needed + to find the full path to a command could segfault if the 'long' + path name was much longer than the 'short' path name (which + Sys.which() returns), as the behaviour of the Windows API call + had changed. + + * R CMD build will fail with an error if one of the packages + specified in the VignetteBuilder field is not installed. + (Without loading those packages it cannot be ascertained which + files are intended to be vignettes. This means that the + VignetteBuilder packages have to be installed for package + checking too.) (Wish of PR#15775.) + + * Misguided attempts to use chull() with non-finite points now give + an error (related to PR#15777). + + * For a formula with exactly 32 variables the 32nd variable was + aliased to the intercept in some C-level computations of terms, + so that for example attempting to remove it would remove the + intercept instead (and leave a corrupt internal structure). + (PR#15735) + + * anyDuplicated() silently returned wrong values when the first + duplicate was at an index which was too large to be stored in an + integer vector (although a lot of RAM and patience would have + been needed to encounter this). + + * tools::Rd2ex(commentDontrun = FALSE) failed if the block had only + one line. + + * Hexadecimal constants such as 0x110p-5L which were incorrectly + qualified by L were parsed incorrectly since R 3.0.0, with a + slightly garbled warning. (PR#15753) + + * system() returned success on some platforms even if the system + was unable to launch a process. (PR#15796) + + * (Windows Rgui console.) Unbuffered output was sometimes not + output immediately if the prompt was not on the last line of the + console. + + * The built-in help server did not declare the encoding for the + DESCRIPTION or other text files to be the package encoding, so + non-ASCII characters could be displayed incorrectly. + + * R is now trying harder to not cleanup child processes that were + not spawned by mcparallel() on platforms that provide information + about the source process of the SIGCHLD signal. This allows 3rd + party libraries to manage the exit status of children that they + spawn without R interfering. + + * mcmapply() was only parallelizing if the number of jobs was + bigger than the number of cores. It now parallelizes if the + number of jobs is more than one. + + * Auto-printing would re-evaluate its argument when trying to + dispatch to a print method. This is now avoided when possible. + + * Unserializing (including load() and readRDS()) could silently + return incorrect numeric values from ASCII saves if there was a + read error. + + * getParseData() could return incorrect values for the parents of + some elements. (Reported by Andrew Redd.) + + * Attempting to use data frames of 2^31 or more rows with merge() + or to create a merged data frame of that size now gives a clearer + error message. + + * parse() did not check its file argument was a connection if it + was not a character string, so e.g. parse(FALSE) attempted to + read from stdin. + + Nor did dump() and dput(). + + * The "help.try.all.packages" option was ignored when the shortcut + syntax for help was used, e.g. ?foo. + + * A potential segfault in string allocation has been fixed. (Found + by Radford Neal.) + + * Potential memory protection errors in sort() and D() have been + fixed. (Found by Radford Neal.) + + * Fixed a lack of error checking in graphics event functions. + (Found by Radford Neal; a different patch used here than the one + in pqR.) + + * numericDeriv() sometimes miscalculated the gradient. (PR#15849, + reported originally by Radford Neal) + CHANGES IN R 3.1.0: NEW FEATURES: @@ -99,9 +337,9 @@ X.) Currently time_t is usually long and hence 64-bit on Unix-alike - 64-bit platforms: however it several cases the time-zone database - is 32-bit. On R for Windows it is 64-bit (for both architectures - as from this version). + 64-bit platforms: however in several cases the time-zone database + is 32-bit. For R for Windows it is 64-bit (for both + architectures as from this version). * The "save.defaults" option can include a value for compression_level. (Wish of PR#15579.) @@ -1084,7 +1322,7 @@ * The default 'version' of Bioconductor for its packages has been changed to the upcoming 2.13, but this can be set by the - environment variable R_BIOC_VERSION, e.g. in file Renviron.site. + environment variable R_BIOC_VERSION when R is installed. C-LEVEL FACILITIES: Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/doc/NEWS.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/doc/NEWS.pdf differ diff -Nru r-base-3.1.0/doc/NEWS.Rd r-base-3.1.1/doc/NEWS.Rd --- r-base-3.1.0/doc/NEWS.Rd 2014-04-03 22:15:04.000000000 +0000 +++ r-base-3.1.1/doc/NEWS.Rd 2014-07-08 22:15:04.000000000 +0000 @@ -7,6 +7,260 @@ \title{R News} \encoding{UTF-8} +\section{\Rlogo CHANGES IN R 3.1.1}{ + \subsection{NEW FEATURES}{ + \itemize{ + \item When \code{attach()} reports conflicts, it does so + compatibly with \code{library()} by using \code{message()}. + + \item \command{R CMD Sweave} no longer cleans any files by + default, compatibly with versions of \R prior to 3.1.0. There are + new options \option{--clean}, \option{--clean=default} and + \option{--clean=keepOuts}. + + \item \code{tools::buildVignette()} and \code{tools::buildVignettes()} + with \code{clean = FALSE} no longer remove any created files. + \code{buildvignette()} gains a \code{keep} argument for more + cleaning customization. + + \item The Bioconductor \sQuote{version} used by + \code{setRepositories()} can now be set by environment variable + \env{R_BIOC_VERSION} at runtime, not just when \R is installed. + (It has been stated that Bioconductor will switch from + \sQuote{version} 2.14 to \sQuote{version} 3.0 during the lifetime + of the \R 3.1 series.) + + \item Error messages from bugs in embedded \samp{Sexpr} code + in Sweave documents now report the source location. + + \item \code{type.convert()}, \code{read.table()} and similar + \code{read.*()} functions get a new \code{numerals} argument, + specifying how numeric input is converted when its conversion to + double precision loses accuracy. The default value, + \code{"allow.loss"} allows accuracy loss, as in \R versions before + 3.1.0. + + \item For some compilers, integer addition could overflow without + a warning. \R's internal code for both integer addition and + subtraction is more robust now. (\PR{15774}) + + \item The function determining the default number of knots for + \code{smooth.spline()} is now exported, as \code{.nknots.smspl()}. + + \item \code{dbeta(, a,b)}, \code{pbeta()}, \code{qbeta()} and + \code{rbeta()} are now defined also for \eqn{a = 0}, \eqn{b = 0}, + or infinite \eqn{a} and \eqn{b} (where they typically returned + \code{NaN} before). + + \item Many package authors report that the RStudio graphics device + does not work correctly with their package's use of + \code{dev.new()}. The new option \code{dev.new(noRStudioGD = + TRUE)} replaces the RStudio override by the default device as + selected by \R itself, still respecting environment variables + \env{R_INTERACTIVE_DEVICE} and \env{R_DEFAULT_DEVICE}. + + \item \code{readRDS()} now returns visibly. + + \item Modifying internal logical scalar constants now results in + an error instead of a warning. + + \item \code{install.packages(repos = NULL)} now accepts + \code{http://} or \code{ftp://} URLs of package archives as well + as file paths, and will download as required. In most cases + \code{repos = NULL} can be deduced from the extension of the URL. + + \item The warning when using partial matching with the \code{$} + operator on data frames is now only given when + \code{options("warnPartialMatchDollar")} is \code{TRUE}. + + \item Package help requests like \code{package?foo} now + try the package \code{foo} whether loaded or not. + + \item General help requests now default to trying all loaded + packages, not just those on the search path. + + \item Added a new function \code{promptImport()}, to generate a + help page for a function that was imported from another package + (and presumably re-exported, or help would not be needed). + } + } + + \subsection{INSTALLATION and INCLUDED SOFTWARE}{ + \itemize{ + \item \command{configure} option \option{--with-internal-tzcode} + can now be used with variable \code{rsharedir}. + + \item The included version of PCRE has been updated to 8.35. + + \item There is a new target \command{make uninstall-libR} to + remove an installed shared/static \file{libR}. + + \command{make install-libR} now works if a sub-architecture is + used, although the user will need to specify \code{libdir} + differently for different sub-architectures. + + \item There is more extensive advice on which LaTeX packages are + required to install \R or to make package manuals (as done by + \command{R CMD check}) in the \sQuote{Writing R Extensions} + manual. + + \item Compilers/linkers were handling the visibility controls in + \file{src/extra/xz} inconsistently (and apparently in some cases + incorrectly), so it has been simplified. (\PR{15327}) + + \item (Windows) There is updated support for the use of ICU for + collation: see the \sQuote{R Installation and Administration Manual}. + } + } + + \subsection{BUG FIXES}{ + \itemize{ + \item \code{dbinom(x, n)}, \code{pbinom()}, \code{dpois()}, etc, + are slightly less restrictive in checking if \code{n} is + integer-valued. (Wish of \PR{15734}.) + + \item \code{pchisq(x, df, ncp, log.p = TRUE)} is more accurate and + no longer underflows for small \code{x} and \code{ncp < 80}, e.g, + for \code{pchisq(1e-5, df = 100, ncp = 1, log = TRUE)}. + (Based on \PR{15635} and a suggestion by Roby Joehanes.) + + \item The \code{s} (\dQuote{step into}) command in the debugger + would cause \R to step into expressions evaluated there, + not just into functions being debugged. (\PR{15770}) + + \item The C code used by \code{strptime()} rejected time-zone + offsets of more than \code{+1200} (\code{+1245}, \code{+1300} and + \code{+1400} can occur). (\PR{15768}) + + \item (Windows only.) + \code{png(type = "cairo", antialias = "gray")} + was not accepted. (\PR{15760}) + + \item Use of \code{save(..., envir=)} with named objects could + fail. (\PR{15758}) + + \item \code{Sweave()} mis-parsed \samp{Sexpr} expressions that + contained backslashes. (\PR{15779}) + + \item The return value from \code{options(foo = NULL)} was not + the previous value of the option. (\PR{15781}) + + \item \code{enc2utf8()} and \code{enc2native()} did not always + mark the encoding of the return values when it was known. + + \item \code{dnbinom(x, size = , mu, log = TRUE)} no longer + underflows to -Inf for large \code{mu}, thanks to a suggestion + from Alessandro Mammana (MPI MolGen, Berlin). + + \item \code{pbeta(x, a, b, log = TRUE)} no longer behaves + discontinuously (in a small x-region) because of denormalized + numbers. Also, \code{pbeta(1-1e-12, 1e30, 1.001, log=TRUE)} now + terminates \dQuote{in real time}. + + \item The \code{"CRAN"} filter (see \code{available.packages()}) + no longer removes duplicates other than of packages on CRAN, and + does not fail if there is no CRAN repository in + \code{getOption("repos")}. + + \item The device listing from \code{dev2bitmap()} and + \code{bitmap()} was truncated to 1000 characters: modern versions + of GhostScript on most platforms have many more devices. + + \item (Windows.) Commands such as \code{Sys.which()} and + \code{pipe()} which needed to find the full path to a command + could segfault if the \sQuote{long} path name was much longer than + the \sQuote{short} path name (which \code{Sys.which()} returns), + as the behaviour of the Windows API call had changed. + + \item \command{R CMD build} will fail with an error if one of the + packages specified in the \samp{VignetteBuilder} field is not + installed. (Without loading those packages it cannot be + ascertained which files are intended to be vignettes. This means + that the \samp{VignetteBuilder} packages have to be installed for + package checking too.) + (Wish of \PR{15775}.) + + \item Misguided attempts to use \code{chull()} with non-finite + points now give an error (related to \PR{15777}). + + \item For a formula with exactly 32 variables the 32nd variable + was aliased to the intercept in some C-level computations of + terms, so that for example attempting to remove it would remove + the intercept instead (and leave a corrupt internal structure). + (\PR{15735}) + + \item \code{anyDuplicated()} silently returned wrong values when + the first duplicate was at an index which was too large to be + stored in an integer vector (although a lot of RAM and patience + would have been needed to encounter this). + + \item \code{tools::Rd2ex(commentDontrun = FALSE)} failed if the + block had only one line. + + \item Hexadecimal constants such as \code{0x110p-5L} which were + incorrectly qualified by \code{L} were parsed incorrectly since \R + 3.0.0, with a slightly garbled warning. (\PR{15753}) + + \item \code{system()} returned success on some platforms even if + the system was unable to launch a process. (\PR{15796}) + + \item (Windows \command{Rgui} console.) Unbuffered output was + sometimes not output immediately if the prompt was not on the last + line of the console. + + \item The built-in help server did not declare the encoding for + the \file{DESCRIPTION} or other text files to be the package + encoding, so non-ASCII characters could be displayed incorrectly. + + \item \R{} is now trying harder to not cleanup child processes + that were not spawned by \code{mcparallel()} on platforms that + provide information about the source process of the \code{SIGCHLD} + signal. This allows 3rd party libraries to manage the exit status + of children that they spawn without \R{} interfering. + + \item \code{mcmapply()} was only parallelizing if the number of + jobs was bigger than the number of cores. It now parallelizes if + the number of jobs is more than one. + + \item Auto-printing would re-evaluate its argument when trying to + dispatch to a print method. This is now avoided when possible. + + \item Unserializing (including \code{load()} and \code{readRDS()}) + could silently return incorrect numeric values from ASCII saves if + there was a read error. + + \item \code{getParseData()} could return incorrect values for + the parents of some elements. (Reported by Andrew Redd.) + + \item Attempting to use data frames of 2^31 or more rows with + \code{merge()} or to create a merged data frame of that size now + gives a clearer error message. + + \item \code{parse()} did not check its \code{file} argument was a + connection if it was not a character string, so + e.g. \code{parse(FALSE)} attempted to read from \code{stdin}. + + Nor did \code{dump()} and \code{dput()}. + + \item The \code{"help.try.all.packages"} option was ignored when + the shortcut syntax for help was used, e.g. \code{?foo}. + + \item A potential segfault in string allocation has been fixed. + (Found by Radford Neal.) + + \item Potential memory protection errors in \code{sort()} and + \code{D()} have been fixed. (Found by Radford Neal.) + + \item Fixed a lack of error checking in graphics event functions. + (Found by Radford Neal; a different patch used here than the + one in pqR.) + + \item \code{numericDeriv()} sometimes miscalculated the gradient. + (\PR{15849}, reported originally by Radford Neal) + } + } +} + \section{\Rlogo CHANGES IN R 3.1.0}{ \subsection{NEW FEATURES}{ \itemize{ @@ -117,9 +371,9 @@ errors and so not used on OS X.) Currently \code{time_t} is usually \code{long} and hence 64-bit on - Unix-alike 64-bit platforms: however it several cases the - time-zone database is 32-bit. On \R for Windows it is 64-bit (for - both architectures as from this version). + Unix-alike 64-bit platforms: however in several cases the + time-zone database is 32-bit. For \R for Windows it is 64-bit + (for both architectures as from this version). \item The \code{"save.defaults"} option can include a value for \code{compression_level}. (Wish of \PR{15579}.) @@ -174,7 +428,7 @@ values in expressions such as \code{Z$a <- a0} and \code{ans[[i]] <- tmp}: some package code has relied on there being copies. - + Also, a number of other changes to reduce copying of objects; all contributed by or based on suggestions by Michael Lawrence. @@ -267,7 +521,7 @@ updated from the official source, whereas the \code{sunspots} and \code{sunspot.year} datasets will remain immutable. The documentation and source links have been updated correspondingly. - + \item The \code{summary()} method for \code{"lm"} fits warns if the fit is essentially perfect, as most of the summary may be computed inaccurately (and with platform-dependent values). @@ -622,7 +876,7 @@ methods now obeys small \code{getOption("width")} settings, line wrapping the \samp{"signif. codes"} legend appropriately. (\PR{15708}) - + \item \code{model.matrix()} assumed that the stored dimnames for a matrix was \code{NULL} or length 2, but length 1 occurred. @@ -1182,8 +1436,8 @@ \item The default \sQuote{version} of Bioconductor for its packages has been changed to the upcoming \samp{2.13}, but this - can be set by the environment variable \env{R_BIOC_VERSION}, e.g. - in file \file{Renviron.site}. + can be set by the environment variable \env{R_BIOC_VERSION} when + \R is installed. } } @@ -2635,13 +2889,13 @@ } \section{CHANGES in previous versions}{ - \itemize{ - \item - Older news can be found in text format in files - \ifelse{html}{\href{../NEWS.0}{NEWS.0}, \href{../NEWS.1}{NEWS.1} - and \href{../NEWS.2}{NEWS.2}}{\file{NEWS.0}, \file{NEWS.1} and - \file{NEWS.2}} in the \file{doc} directory. News in HTML format for - \R versions from 2.10.0 to 2.15.3 is in - \ifelse{html}{\url{NEWS.2.html}}{\file{doc/html/NEWS.2.html}}. - } - } + \itemize{ + \item Older news can be found in text format in files + \ifelse{html}{\href{../NEWS.0}{NEWS.0}, \href{../NEWS.1}{NEWS.1} + and \href{../NEWS.2}{NEWS.2}}{\file{NEWS.0}, \file{NEWS.1} and + \file{NEWS.2}} + in the \file{doc} directory. News in HTML format for + \R versions from 2.10.0 to 2.15.3 is in + \ifelse{html}{\url{NEWS.2.html}}{\file{doc/html/NEWS.2.html}}. + } +} diff -Nru r-base-3.1.0/m4/cairo.m4 r-base-3.1.1/m4/cairo.m4 --- r-base-3.1.0/m4/cairo.m4 2011-10-02 22:02:09.000000000 +0000 +++ r-base-3.1.1/m4/cairo.m4 2014-06-13 22:15:06.000000000 +0000 @@ -125,7 +125,7 @@ CAIROX11_CPPFLAGS=`"${PKGCONF}" --cflags ${xmodlist}` case "${host_os}" in darwin*) - ## This is for static MacOS build + ## This is for static OS X build CAIRO_LIBS=`"${PKGCONF}" --static --libs ${modlist}` CAIROX11_LIBS=`"${PKGCONF}" --static --libs ${xmodlist}` ;; diff -Nru r-base-3.1.0/m4/gettext.m4 r-base-3.1.1/m4/gettext.m4 --- r-base-3.1.0/m4/gettext.m4 2013-03-05 23:02:15.000000000 +0000 +++ r-base-3.1.1/m4/gettext.m4 2014-06-13 22:15:06.000000000 +0000 @@ -104,7 +104,7 @@ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) ]) - dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. + dnl Sometimes, on OS X, libintl requires linking with CoreFoundation. gt_INTL_MACOSX dnl Set USE_NLS. @@ -373,11 +373,11 @@ ]) -dnl Checks for special options needed on MacOS X. +dnl Checks for special options needed on OS X. dnl Defines INTL_MACOSX_LIBS. AC_DEFUN([gt_INTL_MACOSX], [ - dnl Check for API introduced in MacOS X 10.2. + dnl Check for API introduced in OS X 10.2. AC_CACHE_CHECK([for CFPreferencesCopyAppValue], gt_cv_func_CFPreferencesCopyAppValue, [gt_save_LIBS="$LIBS" @@ -389,9 +389,9 @@ LIBS="$gt_save_LIBS"]) if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1, - [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework. (For intl)]) + [Define to 1 if you have the OS X function CFPreferencesCopyAppValue in the CoreFoundation framework. (For intl)]) fi - dnl Check for API introduced in MacOS X 10.3. + dnl Check for API introduced in OS X 10.3. AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent, [gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" @@ -401,7 +401,7 @@ LIBS="$gt_save_LIBS"]) if test $gt_cv_func_CFLocaleCopyCurrent = yes; then AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1, - [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework. (For intl)]) + [Define to 1 if you have the OS X function CFLocaleCopyCurrent in the CoreFoundation framework. (For intl)]) fi INTL_MACOSX_LIBS= if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then @@ -1194,7 +1194,7 @@ LTLIBTHREAD= fi fi - # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the + # OSF/1 4.0 and OS X 10.1 lack the pthread_rwlock_t type and the # pthread_rwlock_* functions. AC_CHECK_TYPE([pthread_rwlock_t], [AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1, diff -Nru r-base-3.1.0/m4/R.m4 r-base-3.1.1/m4/R.m4 --- r-base-3.1.0/m4/R.m4 2014-03-12 23:02:05.000000000 +0000 +++ r-base-3.1.1/m4/R.m4 2014-06-13 22:15:06.000000000 +0000 @@ -3323,7 +3323,7 @@ ## ------- ## Look for iconv, possibly in libiconv. ## Need to include as this may define iconv as a macro. -## libiconv, e.g. on MacOS X, has iconv as a macro and needs -liconv. +## libiconv, e.g. on OS X, has iconv as a macro and needs -liconv. AC_DEFUN([R_ICONV], [AC_CHECK_HEADERS(iconv.h) ## need to ignore cache for this as it may set LIBS diff -Nru r-base-3.1.0/Makefile.in r-base-3.1.1/Makefile.in --- r-base-3.1.0/Makefile.in 2014-03-12 23:02:06.000000000 +0000 +++ r-base-3.1.1/Makefile.in 2014-05-20 22:15:03.000000000 +0000 @@ -121,12 +121,15 @@ fi \ fi -libR_la = lib/libR$(DYLIB_EXT) +@WANT_R_STATIC_FALSE@libR_la = libR$(DYLIB_EXT) +@WANT_R_STATIC_TRUE@libR_la = libR.a install-libR: - @if test -f $(libR_la); then $(MAKE) install-libR-exists; fi + @if test -f lib$(R_ARCH)/$(libR_la); then $(MAKE) install-libR-exists; fi install-libR-exists: @$(MKINSTALLDIRS) "$(DESTDIR)${libdir}" - @$(INSTALL_DATA) -m755 $(libR_la) "$(DESTDIR)${libdir}" + @$(INSTALL_DATA) -m755 lib$(R_ARCH)/$(libR_la) "$(DESTDIR)${libdir}" +uninstall-libR: + @rm -f "$(DESTDIR)${libdir}/$(libR_la)" installdirs: @$(MKINSTALLDIRS) "$(DESTDIR)$(rhome)" diff -Nru r-base-3.1.0/README r-base-3.1.1/README --- r-base-3.1.0/README 2013-03-05 23:02:46.000000000 +0000 +++ r-base-3.1.1/README 2014-07-07 22:15:07.000000000 +0000 @@ -50,7 +50,7 @@ code archive, listed in file doc/AUTHORS. R 1.0.0 was released on 29 February 2000 and 2.0.0 on 4 October 2004. -R 3.0.0 is planned for Spring 2013. +R 3.0.0 came out on 3 April 2013. This file has been minimally revised since the release of R 1.0.0. diff -Nru r-base-3.1.0/share/licenses/license.db r-base-3.1.1/share/licenses/license.db --- r-base-3.1.0/share/licenses/license.db 2014-03-12 23:03:31.000000000 +0000 +++ r-base-3.1.1/share/licenses/license.db 2014-06-15 22:15:03.000000000 +0000 @@ -213,6 +213,13 @@ FOSS: yes Extensible: yes +Name: Creative Commons Attribution-ShareAlike 3.0 Unported License +Abbrev: CC BY-SA 3.0 +FSF: free_and_GPLv3_incompatible +URL: http://creativecommons.org/licenses/by-sa/3.0 +FOSS: yes +Extensible: yes + Name: Creative Commons Attribution-NonCommercial 3.0 Unported License Abbrev: CC BY-NC 3.0 URL: http://creativecommons.org/licenses/by-nc/3.0 @@ -241,6 +248,41 @@ FOSS: yes Extensible: yes +Name: Creative Commons Attribution 4.0 International License +Abbrev: CC BY 4.0 +FSF: free_and_GPLv3_incompatible +URL: http://creativecommons.org/licenses/by/4.0 +FOSS: yes +Extensible: yes + +Name: Creative Commons Attribution-ShareAlike 4.0 International License +Abbrev: CC BY-SA 4.0 +FSF: free_and_GPLv3_incompatible +URL: http://creativecommons.org/licenses/by-sa/4.0 +FOSS: yes +Extensible: yes + +Name: Creative Commons Attribution-NonCommercial 4.0 International License +Abbrev: CC BY-NC 4.0 +URL: http://creativecommons.org/licenses/by-nc/4.0 +FOSS: no +Extensible: yes +Restricts_use: yes + +Name: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License +Abbrev: CC BY-NC-SA 4.0 +URL: http://creativecommons.org/licenses/by-nc-sa/4.0 +FOSS: no +Extensible: yes +Restricts_use: yes + +Name: Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International License +Abbrev: CC BY-NC-ND 4.0 +URL: http://creativecommons.org/licenses/by-nc-nd/4.0 +FOSS: no +Extensible: yes +Restricts_use: yes + Name: CC0 FSF: free_and_GPLv3_compatible (http://www.gnu.org/licenses/license-list.html#CC0) OSI: NA (http://opensource.org/faq#cc-zero) diff -Nru r-base-3.1.0/share/texmf/bibtex/bib/RJournal.bib r-base-3.1.1/share/texmf/bibtex/bib/RJournal.bib --- r-base-3.1.0/share/texmf/bibtex/bib/RJournal.bib 2014-04-09 22:15:09.000000000 +0000 +++ r-base-3.1.1/share/texmf/bibtex/bib/RJournal.bib 2014-07-09 22:15:08.000000000 +0000 @@ -30,6 +30,71 @@ +@Article{ muschelli-sweeney-crainiceanu:, + author = { John Muschelli and Elizabeth Sweeney and Ciprian Crainiceanu }, + title = { brainR: Interactive 3 and 4d Images of High Resolution Neuroimage Data }, + journal = { The R Journal }, + year = { }, + volume = { }, + number = { }, + pages = { }, + month = , + url = { http://journal.r-project.org/archive/-/muschelli-sweeney-crainiceanu.pdf } + + + +@Article{ vandekerckhove-wabersich:, + author = { Joachim Vandekerckhove and Dominik Wabersich }, + title = { The RWiener package: an R package providing distribution functions for the Wiener diffusion model }, + journal = { The R Journal }, + year = { }, + volume = { }, + number = { }, + pages = { }, + month = , + url = { http://journal.r-project.org/archive/-/vandekerckhove-wabersich.pdf } + + + +@Article{ qian:, + author = { Hai Qian }, + title = { PivotalR: A Package for Machine Learning on Big Data }, + journal = { The R Journal }, + year = { }, + volume = { }, + number = { }, + pages = { }, + month = , + url = { http://journal.r-project.org/archive/-/qian.pdf } + + + +@Article{ stanfill-hofmann-genschel:, + author = { Bryan Stanfill and Heike Hofmann and Ulrike Genschel }, + title = { rotations: An R Package for SO(3) Data }, + journal = { The R Journal }, + year = { }, + volume = { }, + number = { }, + pages = { }, + month = , + url = { http://journal.r-project.org/archive/-/stanfill-hofmann-genschel.pdf } + + + +@Article{ greenwell-kabban:, + author = { Brandon Greenwell and Christine Schubert Kabban }, + title = { investr: An R Package for Inverse Estimation }, + journal = { The R Journal }, + year = { }, + volume = { }, + number = { }, + pages = { }, + month = , + url = { http://journal.r-project.org/archive/-/greenwell-kabban.pdf } + + + @Article{ jacques-grimonprez-biernacki:, author = { Julien Jacques and Quentin Grimonprez and Christophe Biernacki }, title = { Rankcluster: An R Package For Clustering Multivariate Partial Rankings }, @@ -69,6 +134,32 @@ +@Article{ murrell-potter:, + author = { Paul Murrell and Simon Potter }, + title = { The gridSVG package }, + journal = { The R Journal }, + year = { }, + volume = { }, + number = { }, + pages = { }, + month = , + url = { http://journal.r-project.org/archive/-/murrell-potter.pdf } + + + +@Article{ koziol-bilder:, + author = { Natalie Koziol and Christopher Bilder }, + title = { MRCV: A Package for Analyzing Categorical Variables with Multiple Response Options }, + journal = { The R Journal }, + year = { }, + volume = { }, + number = { }, + pages = { }, + month = , + url = { http://journal.r-project.org/archive/-/koziol-bilder.pdf } + + + @Article{ leeper:, author = { Thomas J. Leeper }, title = { Archiving Reproducible Research with R and Dataverse }, @@ -95,6 +186,32 @@ +@Article{ bottomly-wilmot-mcweeney:, + author = { Daniel Bottomly and Beth Wilmot and Shannon McWeeney }, + title = { oligoMask: A framework for assessing and removing the effect of genetic variants on microarray probes }, + journal = { The R Journal }, + year = { }, + volume = { }, + number = { }, + pages = { }, + month = , + url = { http://journal.r-project.org/archive/-/bottomly-wilmot-mcweeney.pdf } + + + +@Article{ lombardi-pastore:, + author = { Luigi Lombardi and Massimiliano Pastore }, + title = { sgr: A Package for Simulating Conditional Fake Ordinal Data }, + journal = { The R Journal }, + year = { }, + volume = { }, + number = { }, + pages = { }, + month = , + url = { http://journal.r-project.org/archive/-/lombardi-pastore.pdf } + + + @Article{ RJournal:2009-1:Chambers, author = {John M. Chambers}, title = {{Facets of R}}, @@ -1584,7 +1701,7 @@ @Article{ RJournal:2013-1:r-changes, - author = {Kurt Hornik and Achim Zeileis}, + author = {The R Core Team}, title = {{Changes in R}}, journal = {The R Journal}, year = 2013, @@ -1877,14 +1994,28 @@ -@Article{ RJournal:2013-2:r-changes, +@Article{ RJournal:2013-2:cran, author = {Kurt Hornik and Achim Zeileis}, + title = {{Changes on CRAN}}, + journal = {The R Journal}, + year = 2013, + volume = 5, + number = 2, + pages = {166--192}, + month = Dec, + url = {http://journal.r-project.org/archive/2013-2/RJournal_2013-2_cran.pdf} +} + + + +@Article{ RJournal:2013-2:r-changes, + author = {The R Core Team}, title = {{Changes in R}}, journal = {The R Journal}, year = 2013, volume = 5, number = 2, - pages = {166--172}, + pages = {192--198}, month = Dec, url = {http://journal.r-project.org/archive/2013-2/RJournal_2013-2_r-changes.pdf} } diff -Nru r-base-3.1.0/src/appl/lbfgsb.c r-base-3.1.1/src/appl/lbfgsb.c --- r-base-3.1.0/src/appl/lbfgsb.c 2014-02-21 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/appl/lbfgsb.c 2014-05-22 22:15:04.000000000 +0000 @@ -39,11 +39,6 @@ #include #include /* Rprintf */ -static void timer(double * ttime) -{ - *ttime = 0.0; -} - #define FALSE_ 0 #define TRUE_ 1 #ifndef max @@ -57,15 +52,6 @@ static int c__1 = 1; static int c__11 = 11; -/* -extern double F77_NAME(ddot)(int *, double *, int *, double *, int *); -extern void F77_NAME(dscal)(int *, double *, double *, int *); -extern void F77_NAME(dcopy)(int *, double *, int *, double *, int *); -extern void F77_NAME(daxpy)(int *, double *, double *, int *, double *, int *); -extern void F77_NAME(dpofa)(double *, int *, int *, int *); -extern void F77_NAME(dtrsl)(double *, int *, int *, double *, int *, int *); -*/ - static void active(int, double *, double *, int *, double *, int *, int, int *, int *, int *); static void bmv(int, double *, double *, int *, double *, double *, int *); @@ -82,15 +68,11 @@ int *); static void dcsrch(double *, double *, double *, double, double, double, - double, double, - char *, int *, double *); + double, double, char *); static void dcstep(double *, double *, double *, double *, double *, double *, double *, double *, double *, int *, double *, double *); -#ifdef NOT_USING_DBL_EPSILON - static double dpmeps(void); -#endif static void errclb(int, int, double, double *, double *, int *, char *, int *, int *); static void formk(int, int *, int *, int *, int *, int *, int *, @@ -108,14 +90,14 @@ double *, double *, double *, double *, double *, double *, double *, int *, int *, int *, int *, int *, char *, int *, int *, - char *, int *, double *); + char *); static void mainlb(int, int, double *, double *, double *, int *, double *, double *, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, int *, int *, int *, char *, - int, char *, int *, int *, double *); + int, char *, int *); static void matupd(int, int, double *, double *, double *, double *, double *, double *, int *, int *, int *, int *, double *, double *, double *, @@ -144,8 +126,7 @@ static void setulb(int n, int m, double *x, double *l, double *u, int *nbd, double *f, double *g, double factr, double *pgtol, - double *wa, int * iwa, char *task, int iprint, - int *lsave, int *isave, double *dsave) + double *wa, int * iwa, char *task, int iprint, int *isave) { /* ************ @@ -236,6 +217,8 @@ csave is a working string of characters of length 60. + *** These are all Fortan 1-based indices. + *** now only used local to mainlb. lsave is a logical working array of dimension 4. On exit with 'task' = NEW_X, the following information is available: @@ -245,6 +228,7 @@ If lsave(3) = .true. then each variable has upper and lower bounds; + *** re-arranged to be of size 21, reduce indices by 21. isave is an integer working array of dimension 44. On exit with 'task' = NEW_X, the following information is available: @@ -272,6 +256,7 @@ isave(41) = the number of variables entering the set of active constraints in the current iteration. + *** re-arranged to be of size 16, no longer exported. dsave is a double precision working array of dimension 29. On exit with 'task' = NEW_X, the following information is available: @@ -332,52 +317,34 @@ char csave[60]; /* Local variables */ - int lsnd, ld, lr, lt; - int lz, lwa, lwn, lss, lws, lwt, lsy, lwy; + static int lsnd, ld, lr, lt, lz, lwa, lwn, lss, lws, lwt, lsy, lwy; /* make sure csave is initialized */ csave[0] = '\0'; /* Parameter adjustments */ --wa; - --isave; - /* Function Body */ if (strncmp(task, "START", 5) == 0) { - isave[1] = m * n; - isave[2] = m * m; - isave[3] = m * m << 2; - isave[4] = 1; - isave[5] = isave[4] + isave[1]; - isave[6] = isave[5] + isave[1]; - isave[7] = isave[6] + isave[2]; - isave[8] = isave[7] + isave[2]; - isave[9] = isave[8]; - isave[10] = isave[9] + isave[2]; - isave[11] = isave[10] + isave[3]; - isave[12] = isave[11] + isave[3]; - isave[13] = isave[12] + n; - isave[14] = isave[13] + n; - isave[15] = isave[14] + n; - isave[16] = isave[15] + n; - } - lws = isave[4]; - lwy = isave[5]; - lsy = isave[6]; - lss = isave[7]; - lwt = isave[9]; - lwn = isave[10]; - lsnd = isave[11]; - lz = isave[12]; - lr = isave[13]; - ld = isave[14]; - lt = isave[15]; - lwa = isave[16]; + lws = 1; + lwy = lws + m * n; + lsy = lwy + m * n; + lss = lsy + m * m; + lwt = lss + m * m; + lwn = lwt + m * m; + lsnd = lwn + (m * m << 2); + lz = lsnd + (m * m << 2); + lr = lz + n; + ld = lr + n; + lt = ld + n; + lwa = lt + n; + } + mainlb(n, m, x, l, u, nbd, f, g, factr, pgtol, &wa[lws], &wa[lwy], &wa[lsy],&wa[lss], &wa[lwt],&wa[lwn], &wa[lsnd], &wa[lz], &wa[lr], &wa[ld], &wa[lt], &wa[lwa], iwa, &iwa[n], &iwa[n << 1], task, iprint, - csave, lsave, &isave[22], dsave); + csave, isave); return; } /* setulb */ /* ======================= The end of setulb ============================= */ @@ -389,7 +356,7 @@ double *snd, double *z, double *r, double *d, double *t, double *wa, int *indx, int *iwhere, int *indx2, char *task, int iprint, - char *csave, int *lsave, int *isave, double *dsave) + char *csave, int *isave) { /* ************ Subroutine mainlb @@ -517,12 +484,7 @@ csave is a working string of characters of length 60. - lsave is a logical working array of dimension 4. - - isave is an integer working array of dimension 23. - - dsave is a double precision working array of dimension 29. - + isave is an integer working array of dimension 21. Subprograms called @@ -571,44 +533,17 @@ /* System generated locals */ int ws_offset=0, wy_offset=0, sy_offset=0, ss_offset=0, wt_offset=0, - wn_offset=0, snd_offset=0, i__1; + wn_offset=0, snd_offset=0; double d__1, d__2; /* Local variables */ - int head; - double fold; - int nact; double ddum; - int info; - int nfgv, ifun, iter, nint; char word[4]; /* allow for terminator */ - int i, iback, k = 0; /* -Wall */ - double gdold; - int nfree; - int boxed; - int itail; - double theta; - double dnorm; - int nskip, iword; - double xstep = 0.0, stpmx; /* xstep is printed before being used */ - double gd, dr, rr; - int ileave; - int itfile; - double cachyt, epsmch; - int updatd; - double sbtime; - int prjctd; - int iupdat; - int cnstnd; - double sbgnrm; - int nenter; - double lnscht; - int nintol; - double dtd; - int col; - double tol; + int k = 0; /* -Wall */ + double xstep = 0.0; /* printed before being used */ + double dr, rr; int wrk; - double stp, cpu1, cpu2; + /* Parameter adjustments */ --indx2; @@ -624,21 +559,21 @@ --l; --x; --wa; - --lsave; - --isave; - --dsave; + // formerly lsave + static int prjctd, cnstnd, boxed, updatd; + // in isave + static int nintol, iback, nskip, head, col, itail, iter, iupdat, + nint, nfgv, info, ifun, iword, nfree, nact, ileave, nenter; + // formerly dsave + static double theta, fold, tol, dnorm, epsmch, gd, stpmx, sbgnrm, + stp, gdold, dtd; /* Function Body */ if (strncmp(task, "START", 5) == 0) { /* Generate the current machine precision. */ -#ifdef NOT_USING_DBL_EPSILON - epsmch = dpmeps(); -#else epsmch = DBL_EPSILON; -#endif fold = 0.; dnorm = 0.; - cpu1 = 0.; gd = 0.; sbgnrm = 0.; stp = 0.; @@ -669,21 +604,15 @@ nfree = n; /* for stopping tolerance: */ tol = factr * epsmch; -/* for measuring running time: */ - cachyt = 0.; - sbtime = 0.; - lnscht = 0.; /* 'word' records the status of subspace solutions. */ strcpy(word, "---"); /* 'info' records the termination information. */ info = 0; - itfile = 0; /* Check the input arguments for errors. */ errclb(n, m, factr, &l[1], &u[1], &nbd[1], task, &info, &k); if (strncmp(task, "ERROR", 5) == 0) { - prn3lb(n, x+1, f, task, iprint, info, - iter, nfgv, nintol, nskip, nact, sbgnrm, - nint, word, iback, stp, xstep, k); + prn3lb(n, x+1, f, task, iprint, info, iter, nfgv, nintol, nskip, + nact, sbgnrm, nint, word, iback, stp, xstep, k); return; } @@ -694,46 +623,6 @@ &cnstnd, &boxed); /* The end of the initialization. */ } else { -/* restore local variables. */ - prjctd = lsave[1]; - cnstnd = lsave[2]; - boxed = lsave[3]; - updatd = lsave[4]; - - nintol = isave[1]; - itfile = isave[3]; - iback = isave[4]; - nskip = isave[5]; - head = isave[6]; - col = isave[7]; - itail = isave[8]; - iter = isave[9]; - iupdat = isave[10]; - nint = isave[12]; - nfgv = isave[13]; - info = isave[14]; - ifun = isave[15]; - iword = isave[16]; - nfree = isave[17]; - nact = isave[18]; - ileave = isave[19]; - nenter = isave[20]; - - theta = dsave[1]; - fold = dsave[2]; - tol = dsave[3]; - dnorm = dsave[4]; - epsmch = dsave[5]; - cpu1 = dsave[6]; - cachyt = dsave[7]; - sbtime = dsave[8]; - lnscht = dsave[9]; - gd = dsave[11]; - stpmx = dsave[12]; - sbgnrm = dsave[13]; - stp = dsave[14]; - gdold = dsave[15]; - dtd = dsave[16]; /* After returning from the driver go to the point where execution */ /* is to resume. */ if (strncmp(task, "FG_LN", 5) == 0) goto L666; @@ -785,7 +674,6 @@ /* Compute the Generalized Cauchy Point (GCP). */ /* ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */ - timer(&cpu1); cauchy(n, &x[1], &l[1], &u[1], &nbd[1], &g[1], &indx2[1], &iwhere[1], &t[ 1], &d[1], &z[1], m, &wy[wy_offset], &ws[ws_offset], &sy[ sy_offset], &wt[wt_offset], &theta, &col, &head, &wa[1], &wa[(m @@ -802,12 +690,8 @@ theta = 1.; iupdat = 0; updatd = FALSE_; - timer(&cpu2); - cachyt = cachyt + cpu2 - cpu1; goto L222; } - timer(&cpu2); - cachyt = cachyt + cpu2 - cpu1; nintol += nint; /* Count the entering and leaving variables for iter > 0; */ /* find the index set of free and active variables at the GCP. */ @@ -825,17 +709,15 @@ /* Subspace minimization. */ /* ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */ - timer(&cpu1); /* Form the LEL^T factorization of the indefinite */ /* matrix K = [-D -Y'ZZ'Y/theta L_a'-R_z' ] */ /* [L_a -R_z theta*S'AA'S ] */ /* where E = [-I 0] */ /* [ 0 I] */ - if (wrk) { + if (wrk) formk(n, &nfree, &indx[1], &nenter, &ileave, &indx2[1], &iupdat, & updatd, &wn[wn_offset], &snd[snd_offset], m, &ws[ws_offset], & wy[wy_offset], &sy[sy_offset], &theta, &col, &head, &info); - } if (info != 0) { /* nonpositive definiteness in Cholesky factorization; */ /* refresh the lbfgs memory and restart the iteration. */ @@ -849,18 +731,15 @@ theta = 1.; iupdat = 0; updatd = FALSE_; - timer(&cpu2); - sbtime = sbtime + cpu2 - cpu1; goto L222; } /* compute r=-Z'B(xcp-xk)-Z'g (using wa(2m+1)=W'(xcp-x) */ /* from 'cauchy'). */ - cmprlb(n, m, &x[1], &g[1], &ws[ws_offset], &wy[wy_offset], &sy[sy_offset] - , &wt[wt_offset], &z[1], &r[1], &wa[1], &indx[1], &theta, & - col, &head, &nfree, &cnstnd, &info); - if (info != 0) { + cmprlb(n, m, &x[1], &g[1], &ws[ws_offset], &wy[wy_offset], + &sy[sy_offset], &wt[wt_offset], &z[1], &r[1], &wa[1], &indx[1], + &theta, &col, &head, &nfree, &cnstnd, &info); + if (info != 0) goto L444; - } /* call the direct method. */ subsm(n, m, &nfree, &indx[1], &l[1], &u[1], &nbd[1], &z[1], &r[1], & ws[ws_offset], &wy[wy_offset], &theta, &col, &head, &iword, &wa[1] @@ -878,12 +757,8 @@ theta = 1.; iupdat = 0; updatd = FALSE_; - timer(&cpu2); - sbtime = sbtime + cpu2 - cpu1; goto L222; } - timer(&cpu2); - sbtime = sbtime + cpu2 - cpu1; L555: /* ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */ @@ -891,17 +766,13 @@ /* ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc */ /* Generate the search direction d:=z-x. */ - i__1 = n; - for (i = 1; i <= i__1; ++i) { + for (int i = 1; i <= n; ++i) d[i] = z[i] - x[i]; -/* L40: */ - } - timer(&cpu1); L666: lnsrlb(n, &l[1], &u[1], &nbd[1], &x[1], f, &fold, &gd, &gdold, &g[1], & d[1], &r[1], &t[1], &z[1], &stp, &dnorm, &dtd, &xstep, & stpmx, &iter, &ifun, &iback, &nfgv, &info, task, &boxed, &cnstnd, - csave, &isave[22], &dsave[17]); + csave); if (info != 0 || iback >= 20) { /* restore the previous iterate. */ F77_CALL(dcopy)(&n, &t[1], &c__1, &x[1], &c__1); @@ -924,9 +795,8 @@ if (iprint >= 1) Rprintf("%s\n%s\n", "Bad direction in the line search;", " refresh the lbfgs memory and restart the iteration."); - if (info == 0) { + if (info == 0) --nfgv; - } info = 0; col = 0; head = 1; @@ -934,8 +804,6 @@ iupdat = 0; updatd = FALSE_; strcpy(task, "RESTART_FROM_LNSRCH"); - timer(&cpu2); - lnscht = lnscht + cpu2 - cpu1; goto L222; } } else if (strncmp(task, "FG_LN", 5) == 0) { @@ -943,8 +811,6 @@ goto L1000; } else { /* calculate and print out the quantities related to the new X. */ - timer(&cpu2); - lnscht = lnscht + cpu2 - cpu1; ++iter; /* Compute the infinity norm of the projected (-)gradient. */ projgr(n, &l[1], &u[1], &nbd[1], &x[1], &g[1], &sbgnrm); @@ -961,8 +827,8 @@ goto L999; } /* Computing MAX */ - d__1 = fabs(fold), d__2 = fabs(*f), d__1 = max(d__1,d__2); - ddum = max(d__1,1.); + d__1 = fabs(fold), d__2 = fabs(*f), d__1 = max(d__1, d__2); + ddum = max(d__1, 1.); if (fold - *f <= tol * ddum) { /* terminate the algorithm. */ strcpy(task, "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH"); @@ -971,11 +837,8 @@ goto L999; } /* Compute d=newx-oldx, r=newg-oldg, rr=y'y and dr=y's. */ - i__1 = n; - for (i = 1; i <= i__1; ++i) { + for (int i = 1; i <= n; ++i) r[i] = g[i] - r[i]; -/* L42: */ - } rr = F77_CALL(ddot)(&n, &r[1], &c__1, &r[1], &c__1); if (stp == 1.) { dr = gd - gdold; @@ -1034,46 +897,27 @@ L999: L1000: /* Save local variables. */ - lsave[1] = prjctd; - lsave[2] = cnstnd; - lsave[3] = boxed; - lsave[4] = updatd; - isave[1] = nintol; - isave[3] = itfile; - isave[4] = iback; - isave[5] = nskip; - isave[6] = head; - isave[7] = col; - isave[8] = itail; - isave[9] = iter; - isave[10] = iupdat; - isave[12] = nint; - isave[13] = nfgv; - isave[14] = info; - isave[15] = ifun; - isave[16] = iword; - isave[17] = nfree; - isave[18] = nact; - isave[19] = ileave; - isave[20] = nenter; - dsave[1] = theta; - dsave[2] = fold; - dsave[3] = tol; - dsave[4] = dnorm; - dsave[5] = epsmch; - dsave[6] = cpu1; - dsave[7] = cachyt; - dsave[8] = sbtime; - dsave[9] = lnscht; - dsave[11] = gd; - dsave[12] = stpmx; - dsave[13] = sbgnrm; - dsave[14] = stp; - dsave[15] = gdold; - dsave[16] = dtd; - prn3lb(n, x+1, f, task, iprint, info, - iter, nfgv, nintol, nskip, nact, sbgnrm, - nint, word, iback, stp, xstep, k); +// isave[1-1] = nintol; +// isave[3-1] = itfile; +// isave[4-1] = iback; +// isave[5-1] = nskip; +// isave[6-1] = head; +// isave[7-1] = col; +// isave[8-1] = itail; +// isave[9-1] = iter; +// isave[10-1] = iupdat; +// isave[12-1] = nint; + isave[13-1] = nfgv; +// isave[14-1] = info; +// isave[15-1] = ifun; +// isave[16-1] = iword; +// isave[17-1] = nfree; +// isave[18-1] = nact; +// isave[19-1] = ileave; +// isave[20-1] = nenter; + + prn3lb(n, x+1, f, task, iprint, info, iter, nfgv, nintol, nskip, nact, + sbgnrm, nint, word, iback, stp, xstep, k); return; } /* mainlb */ /* ======================= The end of mainlb ============================= */ @@ -1110,7 +954,7 @@ */ /* Local variables */ - int nbdd, i; + int nbdd; /* Parameter adjustments */ --iwhere; @@ -1127,7 +971,7 @@ *cnstnd = FALSE_; *boxed = TRUE_; /* Project the initial x to the easible set if necessary. */ - for (i = 1; i <= n; ++i) { + for (int i = 1; i <= n; ++i) { if (nbd[i] > 0) { if (nbd[i] <= 2 && x[i] <= l[i]) { if (x[i] < l[i]) { @@ -1146,10 +990,9 @@ } /* Initialize iwhere and assign values to cnstnd and boxed. */ - for (i = 1; i <= n; ++i) { - if (nbd[i] != 2) { + for (int i = 1; i <= n; ++i) { + if (nbd[i] != 2) *boxed = FALSE_; - } if (nbd[i] == 0) { /* this variable is always free */ iwhere[i] = -1; @@ -1159,9 +1002,8 @@ if (nbd[i] == 2 && u[i] - l[i] <= 0.) { /* this variable is always fixed */ iwhere[i] = 3; - } else { + } else iwhere[i] = 0; - } } } if (iprint >= 0) { @@ -1242,8 +1084,7 @@ /* Local variables */ - int i, k; - int i2; + int i2, k; double sum; /* Parameter adjustments */ @@ -1266,14 +1107,12 @@ */ Col = *col; p[*col + 1] = v[*col + 1]; - for (i = 2; i <= Col; ++i) { + for (int i = 2; i <= Col; ++i) { i2 = *col + i; sum = 0.; - for (k = 1; k <= i - 1; ++k) { + for (int k = 1; k <= i - 1; ++k) sum += sy[i + k * sy_dim1] * v[k] / sy[k + k * sy_dim1]; - } p[i2] = v[i2] + sum; -/* L20: */ } /* Solve the triangular system */ F77_CALL(dtrsl)(&wt[wt_offset], &m, col, &p[*col + 1], &c__11, info); @@ -1281,30 +1120,28 @@ return; } /* solve D^(1/2)p1=v1. */ - for (i = 1; i <= Col; ++i) { + for (int i = 1; i <= Col; ++i) p[i] = v[i] / sqrt(sy[i + i * sy_dim1]); - } /* PART II: solve [ -D^(1/2) D^(-1/2)*L' ] [ p1 ] = [ p1 ] * [ 0 J' ] [ p2 ] [ p2 ]. * solve J^Tp2=p2. */ F77_CALL(dtrsl)(&wt[wt_offset], &m, col, &p[*col + 1], &c__1, info); - if (*info != 0) { + if (*info != 0) return; - } + /* compute p1=-D^(-1/2)(p1-D^(-1/2)L'p2) */ /* =-D^(-1/2)p1 + D^(-1)L'p2. */ - for (i = 1; i <= Col; ++i) { + for (int i = 1; i <= Col; ++i) { p[i] = -p[i] / sqrt(sy[i + i * sy_dim1]); } - for (i = 1; i <= Col; ++i) { + for (int i = 1; i <= Col; ++i) { sum = 0.; for (k = i + 1; k <= Col; ++k) { sum += sy[k + i * sy_dim1] * p[*col + k] / sy[i + i * sy_dim1]; } p[i] += sum; -/* L60: */ } return; } /* bmv */ @@ -1498,7 +1335,7 @@ double bkmin, dibp, dibp2, zibp, neggi, tsum; double f1, f2, f2_org__, dt, tj, tj0, tl= 0.0, tu=0.0, dtm, wmc, wmp, wmw; - int i, j, ibp, iter, bnded, nfree, nleft, nbreak, ibkmin, pointr; + int ibp, iter, bnded, nfree, nleft, nbreak, ibkmin, pointr; int xlower, xupper, col2; /* Parameter adjustments */ @@ -1544,14 +1381,14 @@ Rprintf("\n---------------- CAUCHY entered-------------------\n\n"); /* We set p to zero and build it up as we determine d. */ - for (i = 1; i <= col2; ++i) + for (int i = 1; i <= col2; ++i) p[i] = 0.; /* In the following loop we determine for each variable its bound */ /* status and its breakpoint, and update p accordingly. */ /* Smallest breakpoint is identified. */ - for (i = 1; i <= n; ++i) { + for (int i = 1; i <= n; ++i) { neggi = -g[i]; if (iwhere[i] != 3 && iwhere[i] != -1) { /* if x(i) is not a constant and has bounds, */ @@ -1590,7 +1427,7 @@ f1 -= neggi * neggi; /* calculate p := p - W'e_i* (g_i). */ i__2 = *col; - for (j = 1; j <= i__2; ++j) { + for (int j = 1; j <= i__2; ++j) { p[j] += wy[i + pointr * wy_dim1] * neggi; p[*col + j] += ws[i + pointr * ws_dim1] * neggi; pointr = pointr % m + 1; @@ -1620,7 +1457,6 @@ bnded = FALSE_; } } -/* L50: */ } /* for(i = 1:n) */ /* The indices of the nonzero components of d are now stored */ @@ -1636,13 +1472,13 @@ /* is a zero vector, return with the initial xcp as GCP. */ if (iprint > 100) { Rprintf("Cauchy X = "); - for(i = 1; i <= n; i++) Rprintf("%g ", xcp[i]); + for (int i = 1; i <= n; i++) Rprintf("%g ", xcp[i]); Rprintf("\n"); } return; } /* Initialize c = W'(xcp - x) = 0. */ - for (j = 1; j <= col2; ++j) + for (int j = 1; j <= col2; ++j) c[j] = 0.; /* Initialize derivative f2. */ @@ -1743,7 +1579,7 @@ /* choose wbp, */ /* the row of W corresponding to the breakpoint encountered. */ pointr = *head; - for (j = 1; j <= *col; ++j) { + for (int j = 1; j <= *col; ++j) { wbp[j] = wy[ibp + pointr * wy_dim1]; wbp[*col + j] = *theta * ws[ibp + pointr * ws_dim1]; pointr = pointr % m + 1; @@ -1799,7 +1635,7 @@ } if (iprint >= 100) { Rprintf("Cauchy X = "); - for(i = 1; i <= n; i++) Rprintf("%g ", xcp[i]); + for (int i = 1; i <= n; i++) Rprintf("%g ", xcp[i]); Rprintf("\n"); } @@ -1844,7 +1680,7 @@ wt_dim1, wt_offset, Col, n_f; /* Local variables */ - int i, j, k; + int k; double a1, a2; int pointr; @@ -1871,12 +1707,12 @@ /* Function Body */ Col = *col; if (! (*cnstnd) && Col > 0) { - for (i = 1; i <= n; ++i) + for (int i = 1; i <= n; ++i) r[i] = -g[i]; } else { n_f = *nfree; - for (i = 1; i <= n_f; ++i) { + for (int i = 1; i <= n_f; ++i) { k = indx[i]; r[i] = -(*theta) * (z[k] - x[k]) - g[k]; } @@ -1887,10 +1723,10 @@ return; } pointr = *head; - for (j = 1; j <= Col; ++j) { + for (int j = 1; j <= Col; ++j) { a1 = wa[j]; a2 = *theta * wa[Col + j]; - for (i = 1; i <= n_f; ++i) { + for (int i = 1; i <= n_f; ++i) { k = indx[i]; r[i] += wy[k + pointr * wy_dim1] * a1 + ws[k + pointr * ws_dim1] * a2; @@ -1922,9 +1758,6 @@ ************ */ - /* Local variables */ - int i; - /* Parameter adjustments */ --nbd; --u; @@ -1940,7 +1773,7 @@ strcpy(task, "ERROR: FACTR .LT. 0"); /* Check the validity of the arrays nbd(i), u(i), and l(i). */ - for (i = 1; i <= n; ++i) { + for (int i = 1; i <= n; ++i) { if (nbd[i] < 0 || nbd[i] > 3) { /* return */ strcpy(task, "ERROR: INVALID NBD"); @@ -2090,14 +1923,14 @@ /* System generated locals */ int wn_dim1, wn_offset, wn1_dim1, wn1_offset, ws_dim1, ws_offset, - wy_dim1, wy_offset, sy_dim1, sy_offset, i__1, i__2; + wy_dim1, wy_offset, sy_dim1, sy_offset; /* Local variables */ int dend, pend; int upcl; double temp1, temp2, temp3, temp4; - int i, k; - int ipntr, jpntr, k1, m2, dbegin, is, js, iy, jy, pbegin, is1, js1, +// int i, k; + int ipntr, jpntr, k1, m2, dbegin, is, js, iy, pbegin, is1, js1, col2; /* Parameter adjustments */ @@ -2129,10 +1962,9 @@ if (*updatd) { if (*iupdat > m) {/* shift old part of WN1. */ - i__1 = m - 1; - for (jy = 1; jy <= i__1; ++jy) { + for (int jy = 1; jy <= m - 1; ++jy) { js = m + jy; - i__2 = m - jy; + int i__2 = m - jy; F77_CALL(dcopy)(&i__2, &wn1[jy + 1 + (jy + 1)* wn1_dim1], &c__1, &wn1[jy + jy * wn1_dim1], &c__1); F77_CALL(dcopy)(&i__2, &wn1[js + 1 + (js + 1)* wn1_dim1], &c__1, @@ -2140,7 +1972,6 @@ i__2 = m - 1; F77_CALL(dcopy)(&i__2, &wn1[m + 2 + (jy + 1) * wn1_dim1], &c__1, &wn1[m + 1 + jy * wn1_dim1], &c__1); -/* L10: */ } } /* put new rows in blocks (1,1), (2,1) and (2,2). */ @@ -2155,19 +1986,18 @@ ipntr -= m; } jpntr = *head; - i__1 = *col; - for (jy = 1; jy <= i__1; ++jy) { + for (int jy = 1; jy <= *col; ++jy) { js = m + jy; temp1 = 0.; temp2 = 0.; temp3 = 0.; /* compute element jy of row 'col' of Y'ZZ'Y */ - for (k = pbegin; k <= pend; ++k) { + for (int k = pbegin; k <= pend; ++k) { k1 = ind[k]; temp1 += wy[k1 + ipntr * wy_dim1] * wy[k1 + jpntr * wy_dim1]; } /* compute elements jy of row 'col' of L_a and S'AA'S */ - for (k = dbegin; k <= dend; ++k) { + for (int k = dbegin; k <= dend; ++k) { k1 = ind[k]; temp2 += ws[k1 + ipntr * ws_dim1] * ws[k1 + jpntr * ws_dim1]; temp3 += ws[k1 + ipntr * ws_dim1] * wy[k1 + jpntr * wy_dim1]; @@ -2176,27 +2006,24 @@ wn1[is + js * wn1_dim1] = temp2; wn1[is + jy * wn1_dim1] = temp3; jpntr = jpntr % m + 1; -/* L20: */ } /* put new column in block (2,1). */ - jy = *col; + int jy = *col; jpntr = *head + *col - 1; if (jpntr > m) { jpntr -= m; } ipntr = *head; - i__1 = *col; - for (i = 1; i <= i__1; ++i) { + for (int i = 1; i <= *col; ++i) { is = m + i; temp3 = 0.; /* compute element i of column 'col' of R_z */ - for (k = pbegin; k <= pend; ++k) { + for (int k = pbegin; k <= pend; ++k) { k1 = ind[k]; temp3 += ws[k1 + ipntr * ws_dim1] * wy[k1 + jpntr * wy_dim1]; } ipntr = ipntr % m + 1; wn1[is + jy * wn1_dim1] = temp3; -/* L30: */ } upcl = *col - 1; } else { @@ -2205,21 +2032,21 @@ /* modify the old parts in blocks (1,1) and (2,2) due to changes */ /* in the set of free variables. */ ipntr = *head; - for (iy = 1; iy <= upcl; ++iy) { + for (int iy = 1; iy <= upcl; ++iy) { is = m + iy; jpntr = *head; - for (jy = 1; jy <= iy; ++jy) { + for (int jy = 1; jy <= iy; ++jy) { js = m + jy; temp1 = 0.; temp2 = 0.; temp3 = 0.; temp4 = 0.; - for (k = 1; k <= *nenter; ++k) { + for (int k = 1; k <= *nenter; ++k) { k1 = indx2[k]; temp1 += wy[k1 + ipntr * wy_dim1] * wy[k1 + jpntr * wy_dim1]; temp2 += ws[k1 + ipntr * ws_dim1] * ws[k1 + jpntr * ws_dim1]; } - for (k = *ileave; k <= n; ++k) { + for (int k = *ileave; k <= n; ++k) { k1 = indx2[k]; temp3 += wy[k1 + ipntr * wy_dim1] * wy[k1 + jpntr * wy_dim1]; temp4 += ws[k1 + ipntr * ws_dim1] * ws[k1 + jpntr * ws_dim1]; @@ -2227,23 +2054,21 @@ wn1[iy + jy * wn1_dim1] = wn1[iy + jy * wn1_dim1] + temp1 - temp3; wn1[is + js * wn1_dim1] = wn1[is + js * wn1_dim1] - temp2 + temp4; jpntr = jpntr % m + 1; -/* L40: */ } ipntr = ipntr % m + 1; -/* L45: */ } /* modify the old parts in block (2,1). */ ipntr = *head; - for (is = m + 1; is <= m + upcl; ++is) { + for (int is = m + 1; is <= m + upcl; ++is) { jpntr = *head; - for (jy = 1; jy <= upcl; ++jy) { + for (int jy = 1; jy <= upcl; ++jy) { temp1 = 0.; temp3 = 0.; - for (k = 1; k <= *nenter; ++k) { + for (int k = 1; k <= *nenter; ++k) { k1 = indx2[k]; temp1 += ws[k1 + ipntr * ws_dim1] * wy[k1 + jpntr * wy_dim1]; } - for (k = *ileave; k <= n; ++k) { + for (int k = *ileave; k <= n; ++k) { k1 = indx2[k]; temp3 += ws[k1 + ipntr * ws_dim1] * wy[k1 + jpntr * wy_dim1]; } @@ -2253,36 +2078,28 @@ wn1[is + jy * wn1_dim1] += -temp1 + temp3; } jpntr = jpntr % m + 1; -/* L55: */ } ipntr = ipntr % m + 1; -/* L60: */ } /* Form the upper triangle of WN = [D+Y' ZZ'Y/theta -L_a'+R_z' ] */ /* [-L_a +R_z S'AA'S*theta] */ m2 = m << 1; - i__1 = *col; - for (iy = 1; iy <= i__1; ++iy) { + for (int iy = 1; iy <= *col; ++iy) { is = *col + iy; is1 = m + iy; - i__2 = iy; - for (jy = 1; jy <= i__2; ++jy) { + for (int jy = 1; jy <= iy; ++jy) { js = *col + jy; js1 = m + jy; wn[jy + iy * wn_dim1] = wn1[iy + jy * wn1_dim1] / *theta; wn[js + is * wn_dim1] = wn1[is1 + js1 * wn1_dim1] * *theta; -/* L65: */ } - i__2 = iy - 1; - for (jy = 1; jy <= i__2; ++jy) { + for (int jy = 1; jy <= iy - 1; ++jy) { wn[jy + is * wn_dim1] = -wn1[is1 + jy * wn1_dim1]; } - i__2 = *col; - for (jy = iy; jy <= i__2; ++jy) { + for (int jy = iy; jy <= *col; ++jy) { wn[jy + is * wn_dim1] = wn1[is1 + jy * wn1_dim1]; } wn[iy + iy * wn_dim1] += sy[iy + iy * sy_dim1]; -/* L70: */ } /* Form the upper triangle of */ /* WN= [ LL' L^-1(-L_a'+R_z')] */ @@ -2296,19 +2113,18 @@ } /* then form L^-1(-L_a'+R_z') in the (1,2) block. */ col2 = *col << 1; - for (js = *col + 1; js <= col2; ++js) { + for (int js = *col + 1; js <= col2; ++js) { F77_CALL(dtrsl)(&wn[wn_offset], &m2, col, &wn[js * wn_dim1 + 1], &c__11, info); } /* Form S'AA'S*theta + (L^-1(-L_a'+R_z'))'L^-1(-L_a'+R_z') in the */ /* upper triangle of (2,2) block of wn. */ - for (is = *col + 1; is <= col2; ++is) { - for (js = is; js <= col2; ++js) { + for (int is = *col + 1; is <= col2; ++is) { + for (int js = is; js <= col2; ++js) { wn[is + js * wn_dim1] += F77_CALL(ddot)(col, &wn[is * wn_dim1 + 1], &c__1, &wn[js * wn_dim1 + 1], &c__1); } -/* L72: */ } /* Cholesky factorization of (2,2) block of wn. */ F77_CALL(dpofa)(&wn[*col + 1 + (*col + 1) * wn_dim1], &m2, col, info); @@ -2350,12 +2166,11 @@ */ /* System generated locals */ - int wt_dim1, wt_offset, sy_dim1, sy_offset, ss_dim1, ss_offset, i__1; + int wt_dim1, wt_offset, sy_dim1, sy_offset, ss_dim1, ss_offset; /* Local variables */ double ddum; - int i, j, k; - int k1; + int k, k1; /* Parameter adjustments */ ss_dim1 = m; @@ -2372,12 +2187,10 @@ /* Form the upper half of T = theta*SS + L*D^(-1)*L', */ /* store T in the upper triangle of the array wt. */ - i__1 = *col; - for (j = 1; j <= i__1; ++j) { + for (int j = 1; j <= *col; ++j) wt[j * wt_dim1 + 1] = *theta * ss[j * ss_dim1 + 1]; - } - for (i = 2; i <= i__1; ++i) { - for (j = i; j <= i__1; ++j) { + for (int i = 2; i <= *col; ++i) { + for (int j = i; j <= *col; ++j) { k1 = min(i,j) - 1; ddum = 0.; for (k = 1; k <= k1; ++k) { @@ -2386,7 +2199,6 @@ } wt[i + j * wt_dim1] = ddum + *theta * ss[i + j * ss_dim1]; } -/* L55: */ } /* Cholesky factorize T to J*J' with */ /* J' stored in the upper triangle of wt. */ @@ -2441,11 +2253,8 @@ ************ */ - /* System generated locals */ - int i__1; - /* Local variables */ - int iact, i, k; + int iact, k; /* Parameter adjustments */ --iwhere; @@ -2456,8 +2265,7 @@ *nenter = 0; *ileave = n + 1; if (*iter > 0 && *cnstnd) {/* count the entering and leaving variables. */ - i__1 = *nfree; - for (i = 1; i <= i__1; ++i) { + for (int i = 1; i <= *nfree; ++i) { k = indx[i]; if (iwhere[k] > 0) { --(*ileave); @@ -2466,9 +2274,8 @@ Rprintf("Variable %d leaves the set of free variables\n", k); } -/* L20: */ } - for (i = *nfree + 1; i <= n; ++i) { + for (int i = *nfree + 1; i <= n; ++i) { k = indx[i]; if (iwhere[k] <= 0) { ++(*nenter); @@ -2477,7 +2284,6 @@ Rprintf("Variable %d enters the set of free variables\n", k); } -/* L22: */ if (iprint >= 100) Rprintf("%d variables leave; %d variables enter\n", n + 1 - *ileave, *nenter); @@ -2487,7 +2293,7 @@ /* Find the index set of free and active variables at the GCP. */ *nfree = 0; iact = n + 1; - for (i = 1; i <= n; ++i) { + for (int i = 1; i <= n; ++i) { if (iwhere[i] <= 0) { ++(*nfree); indx[*nfree] = i; @@ -2550,7 +2356,7 @@ /* Local variables */ double ddum; - int i, j, k, indxin, indxou; + int i, j, indxin, indxou; double out; /* Parameter adjustments */ @@ -2560,7 +2366,7 @@ /* Function Body */ if (iheap == 0) { /* Rearrange the elements t(1) to t(n) to form a heap. */ - for (k = 2; k <= n; ++k) { + for (int k = 2; k <= n; ++k) { ddum = t[k]; indxin = iorder[k]; /* Add ddum to the heap. */ @@ -2577,7 +2383,6 @@ } t[i] = ddum; iorder[i] = indxin; -/* L20: */ } } /* Assign to 'out' the value of t(1), the least member of the heap, */ @@ -2620,7 +2425,7 @@ double *dnorm, double *dtd, double *xstep, double *stpmx, int *iter, int *ifun, int *iback, int *nfgv, int *info, char *task, int *boxed, int *cnstnd, - char *csave, int *isave, double *dsave) + char *csave) { /* ********** @@ -2659,7 +2464,6 @@ double d1; /* Local variables */ - int i; double a1, a2; /* Parameter adjustments */ @@ -2685,7 +2489,7 @@ if (*iter == 0) { *stpmx = 1.; } else { - for (i = 1; i <= n; ++i) { + for (int i = 1; i <= n; ++i) { a1 = d[i]; if (nbd[i] != 0) { if (a1 < 0. && nbd[i] <= 2) { @@ -2704,7 +2508,6 @@ } } } -/* L43: */ } } } @@ -2731,10 +2534,7 @@ return; } } - dcsrch(f, gd, stp, - ftol, gtol, xtol, - stpmin, *stpmx, - csave, isave, dsave); + dcsrch(f, gd, stp, ftol, gtol, xtol, stpmin, *stpmx, csave); *xstep = *stp * *dnorm; if (strncmp(csave, "CONV", 4) != 0 && strncmp(csave, "WARN", 4) != 0) { strcpy(task, "FG_LNSRCH"); @@ -2744,7 +2544,7 @@ if (*stp == 1.) { F77_CALL(dcopy)(&n, &z[1], &c__1, &x[1], &c__1); } else { - for (i = 1; i <= n; ++i) { + for (int i = 1; i <= n; ++i) { x[i] = *stp * d[i] + t[i]; } } @@ -2787,10 +2587,9 @@ /* System generated locals */ int ws_dim1, ws_offset, wy_dim1, wy_offset, sy_dim1, sy_offset, - ss_dim1, ss_offset, i__1, i__2; + ss_dim1, ss_offset; /* Local variables */ - int j; int pointr; /* Parameter adjustments */ @@ -2829,27 +2628,23 @@ /* and the lower triangle of SY: */ if (*iupdat > m) { /* move old information */ - i__1 = *col - 1; - for (j = 1; j <= i__1; ++j) { + for (int j = 1; j <= *col - 1; ++j) { F77_CALL(dcopy)(&j, &ss[(j + 1) * ss_dim1 + 2], &c__1, &ss[j * ss_dim1 + 1], &c__1); - i__2 = *col - j; + int i__2 = *col - j; F77_CALL(dcopy)(&i__2, &sy[j + 1 + (j + 1) * sy_dim1], &c__1, &sy[j + j * sy_dim1], &c__1); -/* L50: */ } } /* add new information: the last row of SY */ /* and the last column of SS: */ pointr = *head; - i__1 = *col - 1; - for (j = 1; j <= i__1; ++j) { + for (int j = 1; j <= *col - 1; ++j) { sy[*col + j * sy_dim1] = F77_CALL(ddot)(&n, &d[1], &c__1, &wy[pointr * wy_dim1 + 1], &c__1); ss[j + *col * ss_dim1] = F77_CALL(ddot)(&n, &ws[pointr * ws_dim1 + 1], &c__1, &d[1], &c__1); pointr = pointr % m + 1; -/* L51: */ } if (*stp == 1.) { ss[*col + *col * ss_dim1] = *dtd; @@ -2882,11 +2677,10 @@ ************ */ - int i; double gi, d__1; *sbgnrm = 0.; - for (i = 0; i < n; ++i) { + for (int i = 0; i < n; ++i) { gi = g[i]; if (nbd[i] != 0) { if (gi < 0.) { @@ -3066,7 +2860,7 @@ /* Local variables */ double alpha, dk, temp1, temp2; - int i, j, k, m2, js, jy, pointr, ibd = 0, col2, ns; + int k, m2, js, pointr, ibd = 0, col2, ns; /* Parameter adjustments */ --d; @@ -3090,10 +2884,10 @@ /* Compute wv = W'Zd. */ pointr = *head; - for (i = 1; i <= *col; ++i) { + for (int i = 1; i <= *col; ++i) { temp1 = 0.; temp2 = 0.; - for (j = 1; j <= ns; ++j) { + for (int j = 1; j <= ns; ++j) { k = ind[j]; temp1 += wy[k + pointr * n] * d[j]; temp2 += ws[k + pointr * n] * d[j]; @@ -3101,7 +2895,6 @@ wv[i] = temp1; wv[*col + i] = *theta * temp2; pointr = pointr % m + 1; -/* L20: */ } /* Compute wv:=K^(-1)wv. */ m2 = m << 1; @@ -3110,7 +2903,7 @@ if (*info != 0) { return; } - for (i = 1; i <= *col; ++i) + for (int i = 1; i <= *col; ++i) wv[i] = -wv[i]; F77_CALL(dtrsl)(&wn[wn_offset], &m2, &col2, &wv[1], &c__1, info); @@ -3119,24 +2912,23 @@ } /* Compute d = (1/theta)d + (1/theta**2)Z'W wv. */ pointr = *head; - for (jy = 1; jy <= *col; ++jy) { + for (int jy = 1; jy <= *col; ++jy) { js = *col + jy; - for (i = 1; i <= ns; ++i) { + for (int i = 1; i <= ns; ++i) { k = ind[i]; d[i] += (wy[k + pointr * n] * wv[jy] / *theta + ws[k + pointr * n] * wv[js]); } pointr = pointr % m + 1; -/* L40: */ } - for (i = 1; i <= ns; ++i) + for (int i = 1; i <= ns; ++i) d[i] /= *theta; /* Backtrack to the feasible region. */ alpha = 1.; temp1 = alpha; - for (i = 1; i <= ns; ++i) { + for (int i = 1; i <= ns; ++i) { k = ind[i]; dk = d[i]; if (nbd[k] != 0) { @@ -3160,7 +2952,6 @@ ibd = i; } } -/* L60: */ } if (alpha < 1.) { dk = d[ibd]; @@ -3173,7 +2964,7 @@ d[ibd] = 0.; } } - for (i = 1; i <= ns; ++i) + for (int i = 1; i <= ns; ++i) x[ind[i]] += alpha * d[i]; *iword = (alpha < 1.) ? 1 : 0; @@ -3185,8 +2976,7 @@ static void dcsrch(double *f, double *g, double *stp, /*Chgd: the next five are no longer pointers:*/ double ftol, double gtol, double xtol, - double stpmin, double stpmax, - char *task, int *isave, double *dsave) + double stpmin, double stpmax, char *task) { /* ********** @@ -3235,8 +3025,7 @@ The subroutine statement is - subroutine dcsrch(f,g,stp,ftol,gtol,xtol,stpmin,stpmax, - task,isave,dsave) + subroutine dcsrch(f,g,stp,ftol,gtol,xtol,stpmin,stpmax task) where f is a double precision variable. @@ -3303,10 +3092,6 @@ On exit with convergence, a warning or an error, the variable task contains additional information. - isave is an integer work array of dimension 2. - - dsave is a double precision work array of dimension 13. - Subprograms called MINPACK-2 ... dcstep @@ -3324,15 +3109,10 @@ */ /* Local variables */ - int stage; - double finit, ginit, width, ftest, gtest, stmin, stmax, width1, fm, - gm, fx, fy, gx, gy; - int brackt; - double fxm, fym, gxm, gym, stx, sty; - - /* Parameter adjustments */ - --dsave; - --isave; + static int stage, brackt; + static double ginit, gtest, gx, gy, finit, fx, fy, stx, sty, + stmin, stmax, width, width1; + double ftest, fm, gm, fxm, fym, gxm, gym; /* Function Body */ @@ -3371,35 +3151,13 @@ stmin = 0.; stmax = *stp + *stp * 4.; strcpy(task, "FG"); - goto L1000; - } else { -/* Restore local variables. */ - if (isave[1] == 1) { - brackt = TRUE_; - } else { - brackt = FALSE_; - } - stage = isave[2]; - ginit = dsave[1]; - gtest = dsave[2]; - gx = dsave[3]; - gy = dsave[4]; - finit = dsave[5]; - fx = dsave[6]; - fy = dsave[7]; - stx = dsave[8]; - sty = dsave[9]; - stmin = dsave[10]; - stmax = dsave[11]; - width = dsave[12]; - width1 = dsave[13]; + return; } /* If psi(stp) <= 0 and f'(stp) >= 0 for some step, then the */ /* algorithm enters the second stage. */ ftest = finit + *stp * gtest; - if (stage == 1 && *f <= ftest && *g >= 0.) { + if (stage == 1 && *f <= ftest && *g >= 0.) stage = 2; - } /* Test for warnings. */ if (brackt && (*stp <= stmin || *stp >= stmax)) strcpy(task, "WARNING: ROUNDING ERRORS PREVENT PROGRESS"); @@ -3414,7 +3172,7 @@ strcpy(task, "CONVERGENCE"); /* Test for termination. */ if (strncmp(task, "WARN", 4) == 0 || strncmp(task, "CONV", 4) == 0) - goto L1000; + return; /* A modified function is used to predict the step during the */ /* first stage if a lower function value has been obtained but */ @@ -3468,27 +3226,6 @@ } /* Obtain another function and derivative. */ strcpy(task, "FG"); -L1000: -/* Save local variables. */ - if (brackt) { - isave[1] = 1; - } else { - isave[1] = 0; - } - isave[2] = stage; - dsave[1] = ginit; - dsave[2] = gtest; - dsave[3] = gx; - dsave[4] = gy; - dsave[5] = finit; - dsave[6] = fx; - dsave[7] = fy; - dsave[8] = stx; - dsave[9] = sty; - dsave[10] = stmin; - dsave[11] = stmax; - dsave[12] = width; - dsave[13] = width1; return; } /* dcsrch */ /* ====================== The end of dcsrch ============================== */ @@ -3765,9 +3502,8 @@ static void pvector(char *title, double *x, int n) { - int i; Rprintf("%s ", title); - for (i = 0; i < n; i++) Rprintf("%g ", x[i]); + for (int i = 0; i < n; i++) Rprintf("%g ", x[i]); Rprintf("\n"); } @@ -3832,132 +3568,3 @@ } } - - - -#ifdef NOT_USING_DBL_EPSILON - -static double dpmeps(void) -{ -/* ********** - - Subroutine dpeps - - This subroutine computes the machine precision parameter - dpmeps as the smallest floating point number such that - 1 + dpmeps differs from 1. - - This subroutine is based on the subroutine machar described in - - W. J. Cody, - MACHAR: A subroutine to dynamically determine machine parameters, - ACM Trans. Math. Soft., 14, 1988, pages 303-311. - - The subroutine statement is: - - subroutine dpeps(dpmeps) - - where - - dpmeps is a double precision variable. - On entry dpmeps need not be specified. - On exit dpmeps is the machine precision. - - MINPACK-2 Project. February 1991. - Argonne National Laboratory and University of Minnesota. - Brett M. Averick. - - ******* */ - - /* Initialized data */ - - static double zero = 0.; - static double one = 1.; - static double two = 2.; - - /* System generated locals */ - int i__1; - double ret_val; - - /* Local variables */ - double beta; - int irnd; - double temp, temp1, a, b; - int i; - double betah; - int ibeta, negep; - double tempa; - int itemp, it; - double betain; - -/* determine ibeta, beta ala malcolm. */ - a = one; - b = one; -L10: - a += a; - temp = a + one; - temp1 = temp - a; - if (temp1 - one == zero) { - goto L10; - } -L20: - b += b; - temp = a + b; - itemp = (int) (temp - a); - if (itemp == 0) { - goto L20; - } - ibeta = itemp; - beta = (double) ibeta; -/* determine it, irnd. */ - it = 0; - b = one; -L30: - ++it; - b *= beta; - temp = b + one; - temp1 = temp - b; - if (temp1 - one == zero) { - goto L30; - } - irnd = 0; - betah = beta / two; - temp = a + betah; - if (temp - a != zero) { - irnd = 1; - } - tempa = a + beta; - temp = tempa + betah; - if (irnd == 0 && temp - tempa != zero) { - irnd = 2; - } -/* determine dpmeps. */ - negep = it + 3; - betain = one / beta; - a = one; - i__1 = negep; - for (i = 1; i <= i__1; ++i) { - a *= betain; - } -L50: - temp = one + a; - if (temp - one != zero) { - goto L60; - } - a *= beta; - goto L50; -L60: - ret_val = a; - if (ibeta == 2 || irnd == 0) { - goto L70; - } - a = a * (one + a) / two; - temp = one + a; - if (temp - one != zero) { - ret_val = a; - } -L70: - return ret_val; -} /* dpmeps */ - -#endif diff -Nru r-base-3.1.0/src/appl/optim.c r-base-3.1.1/src/appl/optim.c --- r-base-3.1.0/src/appl/optim.c 2014-02-21 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/appl/optim.c 2014-05-22 22:15:04.000000000 +0000 @@ -646,12 +646,9 @@ int trace, int nREPORT) { char task[60]; - double f, *g, dsave[29], *wa; - int tr = -1, iter = 0, *iwa, isave[44], lsave[4]; - - /* shut up gcc -Wall in 4.6.x */ - - for(int i = 0; i < 4; i++) lsave[i] = 0; + double f, *g, *wa; + int tr = -1, iter = 0, *iwa, isave[21]; + isave[12] = 0; // -Wall if(n == 0) { /* not handled in setulb */ *fncount = 1; @@ -680,7 +677,7 @@ strcpy(task, "START"); while(1) { setulb(n, m, x, l, u, nbd, &f, g, factr, &pgtol, wa, iwa, task, - tr, lsave, isave, dsave); + tr, isave); /* Rprintf("in lbfgsb - %s\n", task);*/ if (strncmp(task, "FG", 2) == 0) { f = fminfn(n, x, ex); @@ -710,7 +707,7 @@ } } *Fmin = f; - *fncount = *grcount = isave[33]; + *fncount = *grcount = isave[12]; if (trace) { Rprintf("final value %f \n", *Fmin); if (iter < maxit && *fail == 0) Rprintf("converged\n"); diff -Nru r-base-3.1.0/src/extra/graphapp/buttons.c r-base-3.1.1/src/extra/graphapp/buttons.c --- r-base-3.1.0/src/extra/graphapp/buttons.c 2010-03-17 14:43:05.000000000 +0000 +++ r-base-3.1.1/src/extra/graphapp/buttons.c 2014-06-13 22:15:07.000000000 +0000 @@ -73,7 +73,7 @@ { HWND hwnd; hwnd = obj->handle; -#ifdef WIN64 +#ifdef _WIN64 obj->winproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC); SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) app_control_proc); #else diff -Nru r-base-3.1.0/src/extra/intl/dcigettext.c r-base-3.1.1/src/extra/intl/dcigettext.c --- r-base-3.1.0/src/extra/intl/dcigettext.c 2013-11-25 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/intl/dcigettext.c 2014-06-13 22:15:07.000000000 +0000 @@ -154,7 +154,7 @@ # define getcwd(buf, max) (getcwd) (buf, max, 0) # else /* This is naughty if already declared, but harmful on Win64 */ -# ifndef WIN64 +# ifndef _WIN64 char *getcwd (); # endif # endif @@ -1544,7 +1544,7 @@ locale_defaulted = 1; } } -# ifdef WIN32 +# ifdef _WIN32 /* Need to translate some Windows locale names */ const static struct { const char * const win; diff -Nru r-base-3.1.0/src/extra/intl/R_changes r-base-3.1.1/src/extra/intl/R_changes --- r-base-3.1.0/src/extra/intl/R_changes 2012-08-07 22:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/intl/R_changes 2014-06-13 22:15:07.000000000 +0000 @@ -32,7 +32,7 @@ # define getcwd(buf, max) (getcwd) (buf, max, 0) # else +/* This is naughty if already declared, but harmful on Win64 */ -+# ifndef WIN64 ++# ifndef _WIN64 char *getcwd (); +# endif # endif @@ -52,7 +52,7 @@ locale_defaulted = 1; } } -+# ifdef WIN32 ++# ifdef _WIN32 + /* Need to translate some Windows locale names */ + if(strcmp(locale, "chs") == 0) locale = "zh_CN"; + if(strcmp(locale, "chinese") == 0) locale = "zh_TW"; diff -Nru r-base-3.1.0/src/extra/pcre/LICENCE r-base-3.1.1/src/extra/pcre/LICENCE --- r-base-3.1.0/src/extra/pcre/LICENCE 2013-06-05 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/LICENCE 2014-04-20 22:15:04.000000000 +0000 @@ -24,7 +24,7 @@ University of Cambridge Computing Service, Cambridge, England. -Copyright (c) 1997-2013 University of Cambridge +Copyright (c) 1997-2014 University of Cambridge All rights reserved. @@ -35,7 +35,7 @@ Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2010-2013 Zoltan Herczeg +Copyright(c) 2010-2014 Zoltan Herczeg All rights reserved. @@ -46,7 +46,7 @@ Email local part: hzmester Emain domain: freemail.hu -Copyright(c) 2009-2013 Zoltan Herczeg +Copyright(c) 2009-2014 Zoltan Herczeg All rights reserved. diff -Nru r-base-3.1.0/src/extra/pcre/pcre_compile.c r-base-3.1.1/src/extra/pcre/pcre_compile.c --- r-base-3.1.0/src/extra/pcre/pcre_compile.c 2014-01-10 23:05:02.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/pcre_compile.c 2014-04-20 22:15:03.000000000 +0000 @@ -6,7 +6,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2013 University of Cambridge + Copyright (c) 1997-2014 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -547,6 +547,8 @@ "parentheses are too deeply nested\0" "invalid range in character class\0" "group name must start with a non-digit\0" + /* 85 */ + "parentheses are too deeply nested (stack check)\0" ; /* Table to identify digits and hex digits. This is used when compiling @@ -3070,6 +3072,9 @@ const pcre_uint32 *ochr_ptr; const pcre_uint32 *list_ptr; const pcre_uchar *next_code; +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 +const pcre_uchar *xclass_flags; +#endif const pcre_uint8 *class_bitset; const pcre_uint8 *set1, *set2, *set_end; pcre_uint32 chr; @@ -3220,30 +3225,41 @@ ((list_ptr == list ? code : base_end) - list_ptr[2]); break; - /* OP_XCLASS cannot be supported here, because its bitset - is not necessarily complete. E.g: [a-\0x{200}] is stored - as a character range, and the appropriate bits are not set. */ +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 + case OP_XCLASS: + xclass_flags = (list_ptr == list ? code : base_end) - list_ptr[2] + LINK_SIZE; + if ((*xclass_flags & XCL_HASPROP) != 0) return FALSE; + if ((*xclass_flags & XCL_MAP) == 0) + { + /* No bits are set for characters < 256. */ + if (list[1] == 0) return TRUE; + /* Might be an empty repeat. */ + continue; + } + set2 = (pcre_uint8 *)(xclass_flags + 1); + break; +#endif case OP_NOT_DIGIT: - invert_bits = TRUE; - /* Fall through */ + invert_bits = TRUE; + /* Fall through */ case OP_DIGIT: - set2 = (pcre_uint8 *)(cd->cbits + cbit_digit); - break; + set2 = (pcre_uint8 *)(cd->cbits + cbit_digit); + break; case OP_NOT_WHITESPACE: - invert_bits = TRUE; - /* Fall through */ + invert_bits = TRUE; + /* Fall through */ case OP_WHITESPACE: - set2 = (pcre_uint8 *)(cd->cbits + cbit_space); - break; + set2 = (pcre_uint8 *)(cd->cbits + cbit_space); + break; case OP_NOT_WORDCHAR: - invert_bits = TRUE; - /* Fall through */ + invert_bits = TRUE; + /* Fall through */ case OP_WORDCHAR: - set2 = (pcre_uint8 *)(cd->cbits + cbit_word); - break; + set2 = (pcre_uint8 *)(cd->cbits + cbit_word); + break; default: return FALSE; @@ -3552,7 +3568,9 @@ if (list[1] == 0) return TRUE; } -return FALSE; +/* Control never reaches here. There used to be a fail-save return FALSE; here, +but some compilers complain about an unreachable statement. */ + } @@ -3624,7 +3642,7 @@ break; case OP_MINUPTO: - *code += OP_MINUPTO - OP_UPTO; + *code += OP_POSUPTO - OP_MINUPTO; break; } } @@ -4063,12 +4081,16 @@ if (c > d) return -1; /* Reached end of range */ +/* Found a character that has a single other case. Search for the end of the +range, which is either the end of the input range, or a character that has zero +or more than one other cases. */ + *ocptr = othercase; next = othercase + 1; for (++c; c <= d; c++) { - if (UCD_OTHERCASE(c) != next) break; + if ((co = UCD_CASESET(c)) != 0 || UCD_OTHERCASE(c) != next) break; next++; } @@ -4106,6 +4128,7 @@ compile_data *cd, pcre_uint32 start, pcre_uint32 end) { pcre_uint32 c; +pcre_uint32 classbits_end = (end <= 0xff ? end : 0xff); int n8 = 0; /* If caseless matching is required, scan the range and process alternate @@ -4149,7 +4172,7 @@ /* Not UTF-mode, or no UCP */ - for (c = start; c <= end && c < 256; c++) + for (c = start; c <= classbits_end; c++) { SETBIT(classbits, cd->fcc[c]); n8++; @@ -4174,22 +4197,21 @@ #endif /* COMPILE_PCRE[8|16] */ -/* If all characters are less than 256, use the bit map. Otherwise use extra -data. */ +/* Use the bitmap for characters < 256. Otherwise use extra data.*/ -if (end < 0x100) +for (c = start; c <= classbits_end; c++) { - for (c = start; c <= end; c++) - { - n8++; - SETBIT(classbits, c); - } + /* Regardless of start, c will always be <= 255. */ + SETBIT(classbits, c); + n8++; } -else +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 +if (start <= 0xff) start = 0xff + 1; + +if (end >= start) { pcre_uchar *uchardata = *uchardptr; - #ifdef SUPPORT_UTF if ((options & PCRE_UTF8) != 0) /* All UTFs use the same flag bit */ { @@ -4229,6 +4251,7 @@ *uchardptr = uchardata; /* Updata extra data pointer */ } +#endif /* SUPPORT_UTF || !COMPILE_PCRE8 */ return n8; /* Number of 8-bit characters */ } @@ -4450,8 +4473,11 @@ BOOL reset_bracount; int class_has_8bitchar; int class_one_char; +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 + BOOL xclass_has_prop; +#endif int newoptions; - int recno = 0; + int recno; int refsign; int skipbytes; pcre_uint32 subreqchar, subfirstchar; @@ -4784,13 +4810,26 @@ should_flip_negation = FALSE; + /* Extended class (xclass) will be used when characters > 255 + might match. */ + +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 + xclass = FALSE; + class_uchardata = code + LINK_SIZE + 2; /* For XCLASS items */ + class_uchardata_base = class_uchardata; /* Save the start */ +#endif + /* For optimization purposes, we track some properties of the class: class_has_8bitchar will be non-zero if the class contains at least one < 256 character; class_one_char will be 1 if the class contains just one - character. */ + character; xclass_has_prop will be TRUE if unicode property checks + are present in the class. */ class_has_8bitchar = 0; class_one_char = 0; +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 + xclass_has_prop = FALSE; +#endif /* Initialize the 32-char bit map to all zeros. We build the map in a temporary bit of memory, in case the class contains fewer than two @@ -4799,12 +4838,6 @@ memset(classbits, 0, 32 * sizeof(pcre_uint8)); -#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 - xclass = FALSE; - class_uchardata = code + LINK_SIZE + 2; /* For XCLASS items */ - class_uchardata_base = class_uchardata; /* Save the start */ -#endif - /* Process characters until ] is reached. By writing this as a "do" it means that an initial ] is taken as a data character. At the start of the loop, c contains the first byte of the character. */ @@ -4928,6 +4961,7 @@ *class_uchardata++ = local_negate? XCL_NOTPROP : XCL_PROP; *class_uchardata++ = ptype; *class_uchardata++ = 0; + xclass_has_prop = TRUE; ptr = tempptr + 1; continue; @@ -5110,6 +5144,7 @@ XCL_PROP : XCL_NOTPROP; *class_uchardata++ = ptype; *class_uchardata++ = pdata; + xclass_has_prop = TRUE; class_has_8bitchar--; /* Undo! */ continue; } @@ -5404,6 +5439,7 @@ *code++ = OP_XCLASS; code += LINK_SIZE; *code = negate_class? XCL_NOT:0; + if (xclass_has_prop) *code |= XCL_HASPROP; /* If the map is required, move up the extra data to make room for it; otherwise just move the code pointer to the end of the extra data. */ @@ -5413,6 +5449,8 @@ *code++ |= XCL_MAP; memmove(code + (32 / sizeof(pcre_uchar)), code, IN_UCHARS(class_uchardata - code)); + if (negate_class && !xclass_has_prop) + for (c = 0; c < 32; c++) classbits[c] = ~classbits[c]; memcpy(code, classbits, 32); code = class_uchardata + (32 / sizeof(pcre_uchar)); } @@ -6507,9 +6545,9 @@ else if (*ptr == CHAR_QUESTION_MARK) { - int i, set, unset, namelen = 0; // -Wall + int i, set, unset, namelen; int *optset; - const pcre_uchar *name = NULL; // -Wall + const pcre_uchar *name; pcre_uchar *slot; switch (*(++ptr)) @@ -6581,7 +6619,10 @@ code[1+LINK_SIZE] = OP_CREF; skipbytes = 1+IMM2_SIZE; - refsign = -1; + refsign = -1; /* => not a number */ + namelen = -1; /* => not a name; must set to avoid warning */ + name = NULL; /* Always set to avoid warning */ + recno = 0; /* Always set to avoid warning */ /* Check for a test for recursion in a named group. */ @@ -6618,7 +6659,6 @@ if (refsign >= 0) { - recno = 0; while (IS_DIGIT(*ptr)) { recno = recno * 10 + (int)(*ptr - CHAR_0); @@ -7995,6 +8035,16 @@ unsigned int max_bracount; branch_chain bc; +/* If set, call the external function that checks for stack availability. */ + +if (PUBL(stack_guard) != NULL && PUBL(stack_guard)()) + { + *errorcodeptr= ERR85; + return FALSE; + } + +/* Miscellaneous initialization */ + bc.outer = bcptr; bc.current_branch = code; diff -Nru r-base-3.1.0/src/extra/pcre/pcre_exec.c r-base-3.1.1/src/extra/pcre/pcre_exec.c --- r-base-3.1.0/src/extra/pcre/pcre_exec.c 2014-01-06 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/pcre_exec.c 2014-04-20 22:15:04.000000000 +0000 @@ -6,7 +6,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2013 University of Cambridge + Copyright (c) 1997-2014 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -134,7 +134,7 @@ BOOL utf = md->utf; if (is_subject && length > md->end_subject - p) length = md->end_subject - p; while (length-- > 0) - if (isprint(c = RAWUCHARINCTEST(p))) printf("%c", (char)c); else printf("\\x{%02x}", c); + if (isprint(c = UCHAR21INCTEST(p))) printf("%c", (char)c); else printf("\\x{%02x}", c); } #endif @@ -237,8 +237,8 @@ { pcre_uint32 cc, cp; if (eptr >= md->end_subject) return -2; /* Partial match */ - cc = RAWUCHARTEST(eptr); - cp = RAWUCHARTEST(p); + cc = UCHAR21TEST(eptr); + cp = UCHAR21TEST(p); if (TABLE_GET(cp, md->lcc, cp) != TABLE_GET(cc, md->lcc, cc)) return -1; p++; eptr++; @@ -254,7 +254,7 @@ while (length-- > 0) { if (eptr >= md->end_subject) return -2; /* Partial match */ - if (RAWUCHARINCTEST(p) != RAWUCHARINCTEST(eptr)) return -1; + if (UCHAR21INCTEST(p) != UCHAR21INCTEST(eptr)) return -1; } } @@ -2103,7 +2103,7 @@ eptr + 1 >= md->end_subject && NLBLOCK->nltype == NLTYPE_FIXED && NLBLOCK->nllen == 2 && - RAWUCHARTEST(eptr) == NLBLOCK->nl[0]) + UCHAR21TEST(eptr) == NLBLOCK->nl[0]) { md->hitend = TRUE; if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); @@ -2147,7 +2147,7 @@ eptr + 1 >= md->end_subject && NLBLOCK->nltype == NLTYPE_FIXED && NLBLOCK->nllen == 2 && - RAWUCHARTEST(eptr) == NLBLOCK->nl[0]) + UCHAR21TEST(eptr) == NLBLOCK->nl[0]) { md->hitend = TRUE; if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); @@ -2290,7 +2290,7 @@ eptr + 1 >= md->end_subject && NLBLOCK->nltype == NLTYPE_FIXED && NLBLOCK->nllen == 2 && - RAWUCHARTEST(eptr) == NLBLOCK->nl[0]) + UCHAR21TEST(eptr) == NLBLOCK->nl[0]) { md->hitend = TRUE; if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); @@ -2444,7 +2444,7 @@ { SCHECK_PARTIAL(); } - else if (RAWUCHARTEST(eptr) == CHAR_LF) eptr++; + else if (UCHAR21TEST(eptr) == CHAR_LF) eptr++; break; case CHAR_LF: @@ -2700,11 +2700,11 @@ while (count-- > 0) { offset = GET2(slot, 0) << 1; - if (offset < offset_top && md->offset_vector[offset] >= 0) + if (offset < offset_top && md->offset_vector[offset] >= 0) { length = md->offset_vector[offset+1] - md->offset_vector[offset]; break; - } + } slot += md->name_entry_size; } } @@ -3218,7 +3218,7 @@ CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */ RRETURN(MATCH_NOMATCH); } - while (length-- > 0) if (*ecode++ != RAWUCHARINC(eptr)) RRETURN(MATCH_NOMATCH); + while (length-- > 0) if (*ecode++ != UCHAR21INC(eptr)) RRETURN(MATCH_NOMATCH); } else #endif @@ -3258,7 +3258,7 @@ if (fc < 128) { - pcre_uint32 cc = RAWUCHAR(eptr); + pcre_uint32 cc = UCHAR21(eptr); if (md->lcc[fc] != TABLE_GET(cc, md->lcc, cc)) RRETURN(MATCH_NOMATCH); ecode++; eptr++; @@ -3527,7 +3527,7 @@ SCHECK_PARTIAL(); RRETURN(MATCH_NOMATCH); } - cc = RAWUCHARTEST(eptr); + cc = UCHAR21TEST(eptr); if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH); eptr++; } @@ -3545,7 +3545,7 @@ SCHECK_PARTIAL(); RRETURN(MATCH_NOMATCH); } - cc = RAWUCHARTEST(eptr); + cc = UCHAR21TEST(eptr); if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH); eptr++; } @@ -3562,7 +3562,7 @@ SCHECK_PARTIAL(); break; } - cc = RAWUCHARTEST(eptr); + cc = UCHAR21TEST(eptr); if (fc != cc && foc != cc) break; eptr++; } @@ -3589,7 +3589,7 @@ SCHECK_PARTIAL(); RRETURN(MATCH_NOMATCH); } - if (fc != RAWUCHARINCTEST(eptr)) RRETURN(MATCH_NOMATCH); + if (fc != UCHAR21INCTEST(eptr)) RRETURN(MATCH_NOMATCH); } if (min == max) continue; @@ -3606,7 +3606,7 @@ SCHECK_PARTIAL(); RRETURN(MATCH_NOMATCH); } - if (fc != RAWUCHARINCTEST(eptr)) RRETURN(MATCH_NOMATCH); + if (fc != UCHAR21INCTEST(eptr)) RRETURN(MATCH_NOMATCH); } /* Control never gets here */ } @@ -3620,7 +3620,7 @@ SCHECK_PARTIAL(); break; } - if (fc != RAWUCHARTEST(eptr)) break; + if (fc != UCHAR21TEST(eptr)) break; eptr++; } if (possessive) continue; /* No backtracking */ @@ -4375,7 +4375,7 @@ eptr + 1 >= md->end_subject && NLBLOCK->nltype == NLTYPE_FIXED && NLBLOCK->nllen == 2 && - RAWUCHAR(eptr) == NLBLOCK->nl[0]) + UCHAR21(eptr) == NLBLOCK->nl[0]) { md->hitend = TRUE; if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); @@ -4417,7 +4417,7 @@ default: RRETURN(MATCH_NOMATCH); case CHAR_CR: - if (eptr < md->end_subject && RAWUCHAR(eptr) == CHAR_LF) eptr++; + if (eptr < md->end_subject && UCHAR21(eptr) == CHAR_LF) eptr++; break; case CHAR_LF: @@ -4527,7 +4527,7 @@ SCHECK_PARTIAL(); RRETURN(MATCH_NOMATCH); } - cc = RAWUCHAR(eptr); + cc = UCHAR21(eptr); if (cc >= 128 || (md->ctypes[cc] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH); eptr++; @@ -4544,7 +4544,7 @@ SCHECK_PARTIAL(); RRETURN(MATCH_NOMATCH); } - cc = RAWUCHAR(eptr); + cc = UCHAR21(eptr); if (cc < 128 && (md->ctypes[cc] & ctype_space) != 0) RRETURN(MATCH_NOMATCH); eptr++; @@ -4561,7 +4561,7 @@ SCHECK_PARTIAL(); RRETURN(MATCH_NOMATCH); } - cc = RAWUCHAR(eptr); + cc = UCHAR21(eptr); if (cc >= 128 || (md->ctypes[cc] & ctype_space) == 0) RRETURN(MATCH_NOMATCH); eptr++; @@ -4578,7 +4578,7 @@ SCHECK_PARTIAL(); RRETURN(MATCH_NOMATCH); } - cc = RAWUCHAR(eptr); + cc = UCHAR21(eptr); if (cc < 128 && (md->ctypes[cc] & ctype_word) != 0) RRETURN(MATCH_NOMATCH); eptr++; @@ -4595,7 +4595,7 @@ SCHECK_PARTIAL(); RRETURN(MATCH_NOMATCH); } - cc = RAWUCHAR(eptr); + cc = UCHAR21(eptr); if (cc >= 128 || (md->ctypes[cc] & ctype_word) == 0) RRETURN(MATCH_NOMATCH); eptr++; @@ -5156,7 +5156,7 @@ { default: RRETURN(MATCH_NOMATCH); case CHAR_CR: - if (eptr < md->end_subject && RAWUCHAR(eptr) == CHAR_LF) eptr++; + if (eptr < md->end_subject && UCHAR21(eptr) == CHAR_LF) eptr++; break; case CHAR_LF: @@ -5695,7 +5695,7 @@ eptr + 1 >= md->end_subject && NLBLOCK->nltype == NLTYPE_FIXED && NLBLOCK->nllen == 2 && - RAWUCHAR(eptr) == NLBLOCK->nl[0]) + UCHAR21(eptr) == NLBLOCK->nl[0]) { md->hitend = TRUE; if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); @@ -5721,7 +5721,7 @@ eptr + 1 >= md->end_subject && NLBLOCK->nltype == NLTYPE_FIXED && NLBLOCK->nllen == 2 && - RAWUCHAR(eptr) == NLBLOCK->nl[0]) + UCHAR21(eptr) == NLBLOCK->nl[0]) { md->hitend = TRUE; if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); @@ -5778,7 +5778,7 @@ if (c == CHAR_CR) { if (++eptr >= md->end_subject) break; - if (RAWUCHAR(eptr) == CHAR_LF) eptr++; + if (UCHAR21(eptr) == CHAR_LF) eptr++; } else { @@ -5941,8 +5941,8 @@ if (rrc != MATCH_NOMATCH) RRETURN(rrc); eptr--; BACKCHAR(eptr); - if (ctype == OP_ANYNL && eptr > pp && RAWUCHAR(eptr) == CHAR_NL && - RAWUCHAR(eptr - 1) == CHAR_CR) eptr--; + if (ctype == OP_ANYNL && eptr > pp && UCHAR21(eptr) == CHAR_NL && + UCHAR21(eptr - 1) == CHAR_CR) eptr--; } } else @@ -6789,10 +6789,10 @@ if (first_char != first_char2) while (start_match < end_subject && - (smc = RAWUCHARTEST(start_match)) != first_char && smc != first_char2) + (smc = UCHAR21TEST(start_match)) != first_char && smc != first_char2) start_match++; else - while (start_match < end_subject && RAWUCHARTEST(start_match) != first_char) + while (start_match < end_subject && UCHAR21TEST(start_match) != first_char) start_match++; } @@ -6824,7 +6824,7 @@ if (start_match[-1] == CHAR_CR && (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) && start_match < end_subject && - RAWUCHARTEST(start_match) == CHAR_NL) + UCHAR21TEST(start_match) == CHAR_NL) start_match++; } } @@ -6835,7 +6835,7 @@ { while (start_match < end_subject) { - register pcre_uint32 c = RAWUCHARTEST(start_match); + register pcre_uint32 c = UCHAR21TEST(start_match); #ifndef COMPILE_PCRE8 if (c > 255) c = 255; #endif @@ -6893,7 +6893,7 @@ { while (p < end_subject) { - register pcre_uint32 pp = RAWUCHARINCTEST(p); + register pcre_uint32 pp = UCHAR21INCTEST(p); if (pp == req_char || pp == req_char2) { p--; break; } } } @@ -6901,7 +6901,7 @@ { while (p < end_subject) { - if (RAWUCHARINCTEST(p) == req_char) { p--; break; } + if (UCHAR21INCTEST(p) == req_char) { p--; break; } } } diff -Nru r-base-3.1.0/src/extra/pcre/pcre_globals.c r-base-3.1.1/src/extra/pcre/pcre_globals.c --- r-base-3.1.0/src/extra/pcre/pcre_globals.c 2012-03-01 23:02:09.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/pcre_globals.c 2014-04-20 22:15:04.000000000 +0000 @@ -6,7 +6,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2012 University of Cambridge + Copyright (c) 1997-2014 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -72,6 +72,7 @@ PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = LocalPcreMalloc; PCRE_EXP_DATA_DEFN void (*PUBL(stack_free))(void *) = LocalPcreFree; PCRE_EXP_DATA_DEFN int (*PUBL(callout))(PUBL(callout_block) *) = NULL; +PCRE_EXP_DATA_DEFN int (*PUBL(stack_guard))(void) = NULL; #elif !defined VPCOMPAT PCRE_EXP_DATA_DEFN void *(*PUBL(malloc))(size_t) = malloc; @@ -79,6 +80,7 @@ PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = malloc; PCRE_EXP_DATA_DEFN void (*PUBL(stack_free))(void *) = free; PCRE_EXP_DATA_DEFN int (*PUBL(callout))(PUBL(callout_block) *) = NULL; +PCRE_EXP_DATA_DEFN int (*PUBL(stack_guard))(void) = NULL; #endif /* End of pcre_globals.c */ diff -Nru r-base-3.1.0/src/extra/pcre/pcre.h r-base-3.1.1/src/extra/pcre/pcre.h --- r-base-3.1.0/src/extra/pcre/pcre.h 2013-12-30 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/pcre.h 2014-04-20 22:15:03.000000000 +0000 @@ -5,7 +5,7 @@ /* This is the public header file for the PCRE library, to be #included by applications that call the PCRE functions. - Copyright (c) 1997-2013 University of Cambridge + Copyright (c) 1997-2014 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -42,9 +42,9 @@ /* The current PCRE version information. */ #define PCRE_MAJOR 8 -#define PCRE_MINOR 34 +#define PCRE_MINOR 35 #define PCRE_PRERELEASE -#define PCRE_DATE 2013-12-15 +#define PCRE_DATE 2014-04-04 /* When an application links to a PCRE DLL in Windows, the symbols that are imported have to be identified as such. When building PCRE, the appropriate @@ -491,36 +491,42 @@ PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t); PCRE_EXP_DECL void (*pcre_stack_free)(void *); PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block *); +PCRE_EXP_DECL int (*pcre_stack_guard)(void); PCRE_EXP_DECL void *(*pcre16_malloc)(size_t); PCRE_EXP_DECL void (*pcre16_free)(void *); PCRE_EXP_DECL void *(*pcre16_stack_malloc)(size_t); PCRE_EXP_DECL void (*pcre16_stack_free)(void *); PCRE_EXP_DECL int (*pcre16_callout)(pcre16_callout_block *); +PCRE_EXP_DECL int (*pcre16_stack_guard)(void); PCRE_EXP_DECL void *(*pcre32_malloc)(size_t); PCRE_EXP_DECL void (*pcre32_free)(void *); PCRE_EXP_DECL void *(*pcre32_stack_malloc)(size_t); PCRE_EXP_DECL void (*pcre32_stack_free)(void *); PCRE_EXP_DECL int (*pcre32_callout)(pcre32_callout_block *); +PCRE_EXP_DECL int (*pcre32_stack_guard)(void); #else /* VPCOMPAT */ PCRE_EXP_DECL void *pcre_malloc(size_t); PCRE_EXP_DECL void pcre_free(void *); PCRE_EXP_DECL void *pcre_stack_malloc(size_t); PCRE_EXP_DECL void pcre_stack_free(void *); PCRE_EXP_DECL int pcre_callout(pcre_callout_block *); +PCRE_EXP_DECL int pcre_stack_guard(void); PCRE_EXP_DECL void *pcre16_malloc(size_t); PCRE_EXP_DECL void pcre16_free(void *); PCRE_EXP_DECL void *pcre16_stack_malloc(size_t); PCRE_EXP_DECL void pcre16_stack_free(void *); PCRE_EXP_DECL int pcre16_callout(pcre16_callout_block *); +PCRE_EXP_DECL int pcre16_stack_guard(void); PCRE_EXP_DECL void *pcre32_malloc(size_t); PCRE_EXP_DECL void pcre32_free(void *); PCRE_EXP_DECL void *pcre32_stack_malloc(size_t); PCRE_EXP_DECL void pcre32_stack_free(void *); PCRE_EXP_DECL int pcre32_callout(pcre32_callout_block *); +PCRE_EXP_DECL int pcre32_stack_guard(void); #endif /* VPCOMPAT */ /* User defined callback which provides a stack just before the match starts. */ diff -Nru r-base-3.1.0/src/extra/pcre/pcre_internal.h r-base-3.1.1/src/extra/pcre/pcre_internal.h --- r-base-3.1.0/src/extra/pcre/pcre_internal.h 2013-12-30 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/pcre_internal.h 2014-04-20 22:15:04.000000000 +0000 @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel - Copyright (c) 1997-2013 University of Cambridge + Copyright (c) 1997-2014 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -345,8 +345,8 @@ &(NLBLOCK->nllen), utf)) \ : \ ((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \ - RAWUCHARTEST(p) == NLBLOCK->nl[0] && \ - (NLBLOCK->nllen == 1 || RAWUCHARTEST(p+1) == NLBLOCK->nl[1]) \ + UCHAR21TEST(p) == NLBLOCK->nl[0] && \ + (NLBLOCK->nllen == 1 || UCHAR21TEST(p+1) == NLBLOCK->nl[1]) \ ) \ ) @@ -359,8 +359,8 @@ &(NLBLOCK->nllen), utf)) \ : \ ((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \ - RAWUCHARTEST(p - NLBLOCK->nllen) == NLBLOCK->nl[0] && \ - (NLBLOCK->nllen == 1 || RAWUCHARTEST(p - NLBLOCK->nllen + 1) == NLBLOCK->nl[1]) \ + UCHAR21TEST(p - NLBLOCK->nllen) == NLBLOCK->nl[0] && \ + (NLBLOCK->nllen == 1 || UCHAR21TEST(p - NLBLOCK->nllen + 1) == NLBLOCK->nl[1]) \ ) \ ) @@ -611,12 +611,27 @@ #define MAX_MARK ((1u << 8) - 1) #endif +/* There is a proposed future special "UTF-21" mode, in which only the lowest +21 bits of a 32-bit character are interpreted as UTF, with the remaining 11 +high-order bits available to the application for other uses. In preparation for +the future implementation of this mode, there are macros that load a data item +and, if in this special mode, mask it to 21 bits. These macros all have names +starting with UCHAR21. In all other modes, including the normal 32-bit +library, the macros all have the same simple definitions. When the new mode is +implemented, it is expected that these definitions will be varied appropriately +using #ifdef when compiling the library that supports the special mode. */ + +#define UCHAR21(eptr) (*(eptr)) +#define UCHAR21TEST(eptr) (*(eptr)) +#define UCHAR21INC(eptr) (*(eptr)++) +#define UCHAR21INCTEST(eptr) (*(eptr)++) + /* When UTF encoding is being used, a character is no longer just a single -byte. The macros for character handling generate simple sequences when used in -character-mode, and more complicated ones for UTF characters. GETCHARLENTEST -and other macros are not used when UTF is not supported, so they are not -defined. To make sure they can never even appear when UTF support is omitted, -we don't even define them. */ +byte in 8-bit mode or a single short in 16-bit mode. The macros for character +handling generate simple sequences when used in the basic mode, and more +complicated ones for UTF characters. GETCHARLENTEST and other macros are not +used when UTF is not supported. To make sure they can never even appear when +UTF support is omitted, we don't even define them. */ #ifndef SUPPORT_UTF @@ -629,10 +644,6 @@ #define GETCHARINC(c, eptr) c = *eptr++; #define GETCHARINCTEST(c, eptr) c = *eptr++; #define GETCHARLEN(c, eptr, len) c = *eptr; -#define RAWUCHAR(eptr) (*(eptr)) -#define RAWUCHARINC(eptr) (*(eptr)++) -#define RAWUCHARTEST(eptr) (*(eptr)) -#define RAWUCHARINCTEST(eptr) (*(eptr)++) /* #define GETCHARLENTEST(c, eptr, len) */ /* #define BACKCHAR(eptr) */ /* #define FORWARDCHAR(eptr) */ @@ -805,30 +816,6 @@ c = *eptr; \ if (utf && c >= 0xc0) GETUTF8LEN(c, eptr, len); -/* Returns the next uchar, not advancing the pointer. This is called when -we know we are in UTF mode. */ - -#define RAWUCHAR(eptr) \ - (*(eptr)) - -/* Returns the next uchar, advancing the pointer. This is called when -we know we are in UTF mode. */ - -#define RAWUCHARINC(eptr) \ - (*((eptr)++)) - -/* Returns the next uchar, testing for UTF mode, and not advancing the -pointer. */ - -#define RAWUCHARTEST(eptr) \ - (*(eptr)) - -/* Returns the next uchar, testing for UTF mode, advancing the -pointer. */ - -#define RAWUCHARINCTEST(eptr) \ - (*((eptr)++)) - /* If the pointer is not at the start of a character, move it back until it is. This is called only in UTF-8 mode - we don't put a test within the macro because almost all calls are already within a block of UTF-8 only code. */ @@ -924,30 +911,6 @@ c = *eptr; \ if (utf && (c & 0xfc00) == 0xd800) GETUTF16LEN(c, eptr, len); -/* Returns the next uchar, not advancing the pointer. This is called when -we know we are in UTF mode. */ - -#define RAWUCHAR(eptr) \ - (*(eptr)) - -/* Returns the next uchar, advancing the pointer. This is called when -we know we are in UTF mode. */ - -#define RAWUCHARINC(eptr) \ - (*((eptr)++)) - -/* Returns the next uchar, testing for UTF mode, and not advancing the -pointer. */ - -#define RAWUCHARTEST(eptr) \ - (*(eptr)) - -/* Returns the next uchar, testing for UTF mode, advancing the -pointer. */ - -#define RAWUCHARINCTEST(eptr) \ - (*((eptr)++)) - /* If the pointer is not at the start of a character, move it back until it is. This is called only in UTF-16 mode - we don't put a test within the macro because almost all calls are already within a block of UTF-16 only @@ -1009,30 +972,6 @@ #define GETCHARLENTEST(c, eptr, len) \ GETCHARTEST(c, eptr) -/* Returns the next uchar, not advancing the pointer. This is called when -we know we are in UTF mode. */ - -#define RAWUCHAR(eptr) \ - (*(eptr)) - -/* Returns the next uchar, advancing the pointer. This is called when -we know we are in UTF mode. */ - -#define RAWUCHARINC(eptr) \ - (*((eptr)++)) - -/* Returns the next uchar, testing for UTF mode, and not advancing the -pointer. */ - -#define RAWUCHARTEST(eptr) \ - (*(eptr)) - -/* Returns the next uchar, testing for UTF mode, advancing the -pointer. */ - -#define RAWUCHARINCTEST(eptr) \ - (*((eptr)++)) - /* If the pointer is not at the start of a character, move it back until it is. This is called only in UTF-32 mode - we don't put a test within the macro because almost all calls are already within a block of UTF-32 only @@ -1903,8 +1842,9 @@ /* Flag bits and data types for the extended class (OP_XCLASS) for classes that contain characters with values greater than 255. */ -#define XCL_NOT 0x01 /* Flag: this is a negative class */ -#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */ +#define XCL_NOT 0x01 /* Flag: this is a negative class */ +#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */ +#define XCL_HASPROP 0x04 /* Flag: property checks are present. */ #define XCL_END 0 /* Marks end of individual items */ #define XCL_SINGLE 1 /* Single item (one multibyte char) follows */ @@ -2370,7 +2310,7 @@ ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59, ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69, ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79, - ERR80, ERR81, ERR82, ERR83, ERR84, ERRCOUNT }; + ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERRCOUNT }; /* JIT compiling modes. The function list is indexed by them. */ diff -Nru r-base-3.1.0/src/extra/pcre/pcre_jit_compile.c r-base-3.1.1/src/extra/pcre/pcre_jit_compile.c --- r-base-3.1.0/src/extra/pcre/pcre_jit_compile.c 2013-12-30 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/pcre_jit_compile.c 2014-04-20 22:15:04.000000000 +0000 @@ -179,11 +179,12 @@ typedef struct executable_functions { void *executable_funcs[JIT_NUMBER_OF_COMPILE_MODES]; + sljit_uw *read_only_data[JIT_NUMBER_OF_COMPILE_MODES]; + sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES]; PUBL(jit_callback) callback; void *userdata; pcre_uint32 top_bracket; pcre_uint32 limit_match; - sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES]; } executable_functions; typedef struct jump_list { @@ -197,6 +198,12 @@ struct stub_list *next; } stub_list; +typedef struct label_addr_list { + struct sljit_label *label; + sljit_uw *addr; + struct label_addr_list *next; +} label_addr_list; + enum frame_types { no_frame = -1, no_stack = -2 @@ -306,7 +313,7 @@ int framesize; } then_trap_backtrack; -#define MAX_RANGE_SIZE 6 +#define MAX_RANGE_SIZE 4 typedef struct compiler_common { /* The sljit ceneric compiler. */ @@ -315,6 +322,12 @@ pcre_uchar *start; /* Maps private data offset to each opcode. */ sljit_si *private_data_ptrs; + /* This read-only data is available during runtime. */ + sljit_uw *read_only_data; + /* The total size of the read-only data. */ + sljit_uw read_only_data_size; + /* The next free entry of the read_only_data. */ + sljit_uw *read_only_data_ptr; /* Tells whether the capturing bracket is optimized. */ pcre_uint8 *optimized_cbracket; /* Tells whether the starting offset is a target of then. */ @@ -349,6 +362,8 @@ sljit_sw lcc; /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */ int mode; + /* TRUE, when minlength is greater than 0. */ + BOOL might_be_empty; /* \K is found in the pattern. */ BOOL has_set_som; /* (*SKIP:arg) is found in the pattern. */ @@ -363,13 +378,16 @@ BOOL positive_assert; /* Newline control. */ int nltype; + pcre_uint32 nlmax; + pcre_uint32 nlmin; int newline; int bsr_nltype; + pcre_uint32 bsr_nlmax; + pcre_uint32 bsr_nlmin; /* Dollar endonly. */ int endonly; /* Tables. */ sljit_sw ctypes; - int digits[2 + MAX_RANGE_SIZE]; /* Named capturing brackets. */ pcre_uchar *name_table; sljit_sw name_count; @@ -380,7 +398,9 @@ struct sljit_label *quit_label; struct sljit_label *forced_quit_label; struct sljit_label *accept_label; + struct sljit_label *ff_newline_shortcut; stub_list *stubs; + label_addr_list *label_addrs; recurse_entry *entries; recurse_entry *currententry; jump_list *partialmatch; @@ -404,10 +424,9 @@ #ifdef SUPPORT_UCP BOOL use_ucp; #endif -#ifndef COMPILE_PCRE32 - jump_list *utfreadchar; -#endif #ifdef COMPILE_PCRE8 + jump_list *utfreadchar; + jump_list *utfreadchar16; jump_list *utfreadtype8; #endif #endif /* SUPPORT_UTF */ @@ -524,6 +543,8 @@ #define GET_LOCAL_BASE(dst, dstw, offset) \ sljit_get_local_base(compiler, (dst), (dstw), (offset)) +#define READ_CHAR_MAX 0x7fffffff + static pcre_uchar* bracketend(pcre_uchar* cc) { SLJIT_ASSERT((*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NOT) || (*cc >= OP_ONCE && *cc <= OP_SCOND)); @@ -533,6 +554,25 @@ return cc; } +static int no_alternatives(pcre_uchar* cc) +{ +int count = 0; +SLJIT_ASSERT((*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NOT) || (*cc >= OP_ONCE && *cc <= OP_SCOND)); +do + { + cc += GET(cc, 1); + count++; + } +while (*cc == OP_ALT); +SLJIT_ASSERT(*cc >= OP_KET && *cc <= OP_KETRPOS); +return count; +} + +static int ones_in_half_byte[16] = { + /* 0 */ 0, 1, 1, 2, /* 4 */ 1, 2, 2, 3, + /* 8 */ 1, 2, 2, 3, /* 12 */ 2, 3, 3, 4 +}; + /* Functions whose might need modification for all new supported opcodes: next_opcode check_opcode_types @@ -752,6 +792,7 @@ { case OP_SET_SOM: common->has_set_som = TRUE; + common->might_be_empty = TRUE; cc += 1; break; @@ -761,6 +802,16 @@ cc += 1 + IMM2_SIZE; break; + case OP_BRA: + case OP_CBRA: + case OP_SBRA: + case OP_SCBRA: + count = no_alternatives(cc); + if (count > 4) + common->read_only_data_size += count * sizeof(sljit_uw); + cc += 1 + LINK_SIZE + (*cc == OP_CBRA || *cc == OP_SCBRA ? IMM2_SIZE : 0); + break; + case OP_CBRAPOS: case OP_SCBRAPOS: common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] = 0; @@ -2019,6 +2070,21 @@ common->stubs = NULL; } +static void add_label_addr(compiler_common *common) +{ +DEFINE_COMPILER; +label_addr_list *label_addr; + +label_addr = sljit_alloc_memory(compiler, sizeof(label_addr_list)); +if (label_addr == NULL) + return; +label_addr->label = LABEL(); +label_addr->addr = common->read_only_data_ptr; +label_addr->next = common->label_addrs; +common->label_addrs = label_addr; +common->read_only_data_ptr++; +} + static SLJIT_INLINE void count_match(compiler_common *common) { DEFINE_COMPILER; @@ -2457,107 +2523,290 @@ JUMPHERE(jump); } -static void read_char(compiler_common *common) +static void peek_char(compiler_common *common, pcre_uint32 max) { -/* Reads the character into TMP1, updates STR_PTR. +/* Reads the character into TMP1, keeps STR_PTR. Does not check STR_END. TMP2 Destroyed. */ DEFINE_COMPILER; #if defined SUPPORT_UTF && !defined COMPILE_PCRE32 struct sljit_jump *jump; #endif +SLJIT_UNUSED_ARG(max); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); -#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 if (common->utf) { -#if defined COMPILE_PCRE8 + if (max < 128) return; + jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0); -#elif defined COMPILE_PCRE16 - jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800); -#endif /* COMPILE_PCRE[8|16] */ + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); add_jump(compiler, &common->utfreadchar, JUMP(SLJIT_FAST_CALL)); + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0); JUMPHERE(jump); } #endif /* SUPPORT_UTF && !COMPILE_PCRE32 */ + +#if defined SUPPORT_UTF && defined COMPILE_PCRE16 +if (common->utf) + { + if (max < 0xd800) return; + + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800); + jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1); + /* TMP2 contains the high surrogate. */ + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x40); + OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 10); + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3ff); + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + JUMPHERE(jump); + } +#endif +} + +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + +static BOOL is_char7_bitset(const pcre_uint8 *bitset, BOOL nclass) +{ +/* Tells whether the character codes below 128 are enough +to determine a match. */ +const pcre_uint8 value = nclass ? 0xff : 0; +const pcre_uint8* end = bitset + 32; + +bitset += 16; +do + { + if (*bitset++ != value) + return FALSE; + } +while (bitset < end); +return TRUE; +} + +static void read_char7_type(compiler_common *common, BOOL full_read) +{ +/* Reads the precise character type of a character into TMP1, if the character +is less than 128. Otherwise it returns with zero. Does not check STR_END. The +full_read argument tells whether characters above max are accepted or not. */ +DEFINE_COMPILER; +struct sljit_jump *jump; + +SLJIT_ASSERT(common->utf); + +OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + +OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); + +if (full_read) + { + jump = CMP(SLJIT_C_LESS, TMP2, 0, SLJIT_IMM, 0xc0); + OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); + JUMPHERE(jump); + } } -static void peek_char(compiler_common *common) +#endif /* SUPPORT_UTF && COMPILE_PCRE8 */ + +static void read_char_range(compiler_common *common, pcre_uint32 min, pcre_uint32 max, BOOL update_str_ptr) { -/* Reads the character into TMP1, keeps STR_PTR. -Does not check STR_END. TMP2 Destroyed. */ +/* Reads the precise value of a character into TMP1, if the character is +between min and max (c >= min && c <= max). Otherwise it returns with a value +outside the range. Does not check STR_END. */ DEFINE_COMPILER; #if defined SUPPORT_UTF && !defined COMPILE_PCRE32 struct sljit_jump *jump; #endif +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 +struct sljit_jump *jump2; +#endif -OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0); -#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 +SLJIT_UNUSED_ARG(update_str_ptr); +SLJIT_UNUSED_ARG(min); +SLJIT_UNUSED_ARG(max); +SLJIT_ASSERT(min <= max); + +OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 if (common->utf) { -#if defined COMPILE_PCRE8 + if (max < 128 && !update_str_ptr) return; + jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0); -#elif defined COMPILE_PCRE16 - jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800); -#endif /* COMPILE_PCRE[8|16] */ - add_jump(compiler, &common->utfreadchar, JUMP(SLJIT_FAST_CALL)); - OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0); + if (min >= 0x10000) + { + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xf0); + if (update_str_ptr) + OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + jump2 = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0x7); + OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f); + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); + OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); + OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2)); + if (!update_str_ptr) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(3)); + OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); + OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + JUMPHERE(jump2); + if (update_str_ptr) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0); + } + else if (min >= 0x800 && max <= 0xffff) + { + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xe0); + if (update_str_ptr) + OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + jump2 = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xf); + OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f); + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); + if (!update_str_ptr) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2)); + OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); + OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + JUMPHERE(jump2); + if (update_str_ptr) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0); + } + else if (max >= 0x800) + add_jump(compiler, (max < 0x10000) ? &common->utfreadchar16 : &common->utfreadchar, JUMP(SLJIT_FAST_CALL)); + else if (max < 128) + { + OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); + } + else + { + OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + if (!update_str_ptr) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + else + OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0); + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f); + OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); + OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + if (update_str_ptr) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0); + } JUMPHERE(jump); } -#endif /* SUPPORT_UTF && !COMPILE_PCRE32 */ +#endif + +#if defined SUPPORT_UTF && defined COMPILE_PCRE16 +if (common->utf) + { + if (max >= 0x10000) + { + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800); + jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1); + /* TMP2 contains the high surrogate. */ + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x40); + OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 10); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3ff); + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + JUMPHERE(jump); + return; + } + + if (max < 0xd800 && !update_str_ptr) return; + + /* Skip low surrogate if necessary. */ + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800); + jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1); + if (update_str_ptr) + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + if (max >= 0xd800) + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0x10000); + JUMPHERE(jump); + } +#endif +} + +static SLJIT_INLINE void read_char(compiler_common *common) +{ +read_char_range(common, 0, READ_CHAR_MAX, TRUE); } -static void read_char8_type(compiler_common *common) +static void read_char8_type(compiler_common *common, BOOL update_str_ptr) { /* Reads the character type into TMP1, updates STR_PTR. Does not check STR_END. */ DEFINE_COMPILER; -#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32 +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 struct sljit_jump *jump; #endif +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 +struct sljit_jump *jump2; +#endif -#ifdef SUPPORT_UTF +SLJIT_UNUSED_ARG(update_str_ptr); + +OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0); +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 if (common->utf) { - OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0); - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -#if defined COMPILE_PCRE8 /* This can be an extra read in some situations, but hopefully it is needed in most cases. */ OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); jump = CMP(SLJIT_C_LESS, TMP2, 0, SLJIT_IMM, 0xc0); - add_jump(compiler, &common->utfreadtype8, JUMP(SLJIT_FAST_CALL)); - JUMPHERE(jump); -#elif defined COMPILE_PCRE16 - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); - jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); - JUMPHERE(jump); - /* Skip low surrogate if necessary. */ - OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xfc00); - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0xd800); - OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL); - OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1); - OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); -#elif defined COMPILE_PCRE32 - OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); - jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); + if (!update_str_ptr) + { + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); + OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); + OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f); + OP2(SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); + jump2 = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255); + OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); + JUMPHERE(jump2); + } + else + add_jump(compiler, &common->utfreadtype8, JUMP(SLJIT_FAST_CALL)); JUMPHERE(jump); -#endif /* COMPILE_PCRE[8|16|32] */ return; } -#endif /* SUPPORT_UTF */ -OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32 +#endif /* SUPPORT_UTF && COMPILE_PCRE8 */ + +#if !defined COMPILE_PCRE8 /* The ctypes array contains only 256 values. */ OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255); #endif OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); -#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32 +#if !defined COMPILE_PCRE8 JUMPHERE(jump); #endif + +#if defined SUPPORT_UTF && defined COMPILE_PCRE16 +if (common->utf && update_str_ptr) + { + /* Skip low surrogate if necessary. */ + OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xd800); + jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + JUMPHERE(jump); + } +#endif /* SUPPORT_UTF && COMPILE_PCRE16 */ } static void skip_char_back(compiler_common *common) @@ -2595,28 +2844,35 @@ OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); } -static void check_newlinechar(compiler_common *common, int nltype, jump_list **backtracks, BOOL jumpiftrue) +static void check_newlinechar(compiler_common *common, int nltype, jump_list **backtracks, BOOL jumpifmatch) { /* Character comes in TMP1. Checks if it is a newline. TMP2 may be destroyed. */ DEFINE_COMPILER; +struct sljit_jump *jump; if (nltype == NLTYPE_ANY) { add_jump(compiler, &common->anynewline, JUMP(SLJIT_FAST_CALL)); - add_jump(compiler, backtracks, JUMP(jumpiftrue ? SLJIT_C_NOT_ZERO : SLJIT_C_ZERO)); + add_jump(compiler, backtracks, JUMP(jumpifmatch ? SLJIT_C_NOT_ZERO : SLJIT_C_ZERO)); } else if (nltype == NLTYPE_ANYCRLF) { - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_CR); - OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL); - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_NL); - OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL); - add_jump(compiler, backtracks, JUMP(jumpiftrue ? SLJIT_C_NOT_ZERO : SLJIT_C_ZERO)); + if (jumpifmatch) + { + add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR)); + add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL)); + } + else + { + jump = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR); + add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL)); + JUMPHERE(jump); + } } else { SLJIT_ASSERT(nltype == NLTYPE_FIXED && common->newline < 256); - add_jump(compiler, backtracks, CMP(jumpiftrue ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline)); + add_jump(compiler, backtracks, CMP(jumpifmatch ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline)); } } @@ -2626,58 +2882,84 @@ static void do_utfreadchar(compiler_common *common) { /* Fast decoding a UTF-8 character. TMP1 contains the first byte -of the character (>= 0xc0). Return char value in TMP1, length - 1 in TMP2. */ +of the character (>= 0xc0). Return char value in TMP1, length in TMP2. */ DEFINE_COMPILER; struct sljit_jump *jump; sljit_emit_fast_enter(compiler, RETURN_ADDR, 0); +OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); +OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f); +OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); +OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); +OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); + /* Searching for the first zero. */ -OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x20); +OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x800); jump = JUMP(SLJIT_C_NOT_ZERO); /* Two byte sequence. */ -OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1f); +OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(2)); +sljit_emit_fast_return(compiler, RETURN_ADDR, 0); + +JUMPHERE(jump); +OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); +OP2(SLJIT_XOR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x800); OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); -OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(1)); -sljit_emit_fast_return(compiler, RETURN_ADDR, 0); -JUMPHERE(jump); -OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x10); +OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x10000); jump = JUMP(SLJIT_C_NOT_ZERO); /* Three byte sequence. */ -OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); -OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0f); -OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 12); -OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); -OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); -OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); -OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2)); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2)); -OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); -OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); -OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(2)); +OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(3)); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); -JUMPHERE(jump); /* Four byte sequence. */ -OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); -OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x07); -OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 18); +JUMPHERE(jump); +OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2)); +OP2(SLJIT_XOR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000); +OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(3)); OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); -OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12); OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); -OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2)); +OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(4)); +sljit_emit_fast_return(compiler, RETURN_ADDR, 0); +} + +static void do_utfreadchar16(compiler_common *common) +{ +/* Fast decoding a UTF-8 character. TMP1 contains the first byte +of the character (>= 0xc0). Return value in TMP1. */ +DEFINE_COMPILER; +struct sljit_jump *jump; + +sljit_emit_fast_enter(compiler, RETURN_ADDR, 0); +OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); +OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f); +OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); -OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); -OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(3)); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(3)); + +/* Searching for the first zero. */ +OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x800); +jump = JUMP(SLJIT_C_NOT_ZERO); +/* Two byte sequence. */ +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); +sljit_emit_fast_return(compiler, RETURN_ADDR, 0); + +JUMPHERE(jump); +OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x400); +OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_NOT_ZERO); +/* This code runs only in 8 bit mode. No need to shift the value. */ +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); +OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); +OP2(SLJIT_XOR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x800); +OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6); OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f); OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); -OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(3)); +/* Three byte sequence. */ +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2)); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); } @@ -2697,53 +2979,27 @@ OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x1f); +/* The upper 5 bits are known at this point. */ +compare = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0x3); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f); OP2(SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0); -compare = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255); OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); JUMPHERE(compare); OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); -JUMPHERE(jump); /* We only have types for characters less than 256. */ -OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); -OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); -sljit_emit_fast_return(compiler, RETURN_ADDR, 0); -} - -#elif defined COMPILE_PCRE16 - -static void do_utfreadchar(compiler_common *common) -{ -/* Fast decoding a UTF-16 character. TMP1 contains the first 16 bit char -of the character (>= 0xd800). Return char value in TMP1, length - 1 in TMP2. */ -DEFINE_COMPILER; -struct sljit_jump *jump; - -sljit_emit_fast_enter(compiler, RETURN_ADDR, 0); -jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xdc00); -/* Do nothing, only return. */ -sljit_emit_fast_return(compiler, RETURN_ADDR, 0); - JUMPHERE(jump); -/* Combine two 16 bit characters. */ -OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3ff); -OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 10); -OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3ff); -OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); -OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(1)); -OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000); +OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0); +OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0); +OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0); sljit_emit_fast_return(compiler, RETURN_ADDR, 0); } -#endif /* COMPILE_PCRE[8|16] */ +#endif /* COMPILE_PCRE8 */ #endif /* SUPPORT_UTF */ @@ -2818,7 +3074,7 @@ mainloop = LABEL(); /* Continual stores does not cause data dependency. */ OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, STR_PTR, 0); - read_char(common); + read_char_range(common, common->nlmin, common->nlmax, TRUE); check_newlinechar(common, common->nltype, &newline, TRUE); CMPTO(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0, mainloop); JUMPHERE(end); @@ -2894,37 +3150,66 @@ return mainloop; } -#define MAX_N_CHARS 3 +#define MAX_N_CHARS 16 +#define MAX_N_BYTES 8 -static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common, BOOL firstline) +static SLJIT_INLINE void add_prefix_byte(pcre_uint8 byte, pcre_uint8 *bytes) { -DEFINE_COMPILER; -struct sljit_label *start; -struct sljit_jump *quit; -pcre_uint32 chars[MAX_N_CHARS * 2]; -pcre_uchar *cc = common->start + 1 + LINK_SIZE; -int location = 0; -pcre_int32 len, c, bit, caseless; -int must_stop; +pcre_uint8 len = bytes[0]; +int i; -/* We do not support alternatives now. */ -if (*(common->start + GET(common->start, 1)) == OP_ALT) - return FALSE; +if (len == 255) + return; + +if (len == 0) + { + bytes[0] = 1; + bytes[1] = byte; + return; + } + +for (i = len; i > 0; i--) + if (bytes[i] == byte) + return; + +if (len >= MAX_N_BYTES - 1) + { + bytes[0] = 255; + return; + } +len++; +bytes[len] = byte; +bytes[0] = len; +} + +static int scan_prefix(compiler_common *common, pcre_uchar *cc, pcre_uint32 *chars, pcre_uint8 *bytes, int max_chars) +{ +/* Recursive function, which scans prefix literals. */ +BOOL last, any, caseless; +int len, repeat, len_save, consumed = 0; +pcre_uint32 chr, mask; +pcre_uchar *alternative, *cc_save, *oc; +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 +pcre_uchar othercase[8]; +#elif defined SUPPORT_UTF && defined COMPILE_PCRE16 +pcre_uchar othercase[2]; +#else +pcre_uchar othercase[1]; +#endif + +repeat = 1; while (TRUE) { - caseless = 0; - must_stop = 1; - switch(*cc) + last = TRUE; + any = FALSE; + caseless = FALSE; + switch (*cc) { - case OP_CHAR: - must_stop = 0; - cc++; - break; - case OP_CHARI: - caseless = 1; - must_stop = 0; + caseless = TRUE; + case OP_CHAR: + last = FALSE; cc++; break; @@ -2943,125 +3228,546 @@ cc++; continue; + case OP_ASSERT: + case OP_ASSERT_NOT: + case OP_ASSERTBACK: + case OP_ASSERTBACK_NOT: + cc = bracketend(cc); + continue; + + case OP_PLUSI: + case OP_MINPLUSI: + case OP_POSPLUSI: + caseless = TRUE; case OP_PLUS: case OP_MINPLUS: case OP_POSPLUS: cc++; break; + case OP_EXACTI: + caseless = TRUE; case OP_EXACT: + repeat = GET2(cc, 1); + last = FALSE; cc += 1 + IMM2_SIZE; break; - case OP_PLUSI: - case OP_MINPLUSI: - case OP_POSPLUSI: - caseless = 1; + case OP_QUERYI: + case OP_MINQUERYI: + case OP_POSQUERYI: + caseless = TRUE; + case OP_QUERY: + case OP_MINQUERY: + case OP_POSQUERY: + len = 1; cc++; +#ifdef SUPPORT_UTF + if (common->utf && HAS_EXTRALEN(*cc)) len += GET_EXTRALEN(*cc); +#endif + max_chars = scan_prefix(common, cc + len, chars, bytes, max_chars); + if (max_chars == 0) + return consumed; + last = FALSE; break; - case OP_EXACTI: - caseless = 1; + case OP_KET: + cc += 1 + LINK_SIZE; + continue; + + case OP_ALT: + cc += GET(cc, 1); + continue; + + case OP_ONCE: + case OP_ONCE_NC: + case OP_BRA: + case OP_BRAPOS: + case OP_CBRA: + case OP_CBRAPOS: + alternative = cc + GET(cc, 1); + while (*alternative == OP_ALT) + { + max_chars = scan_prefix(common, alternative + 1 + LINK_SIZE, chars, bytes, max_chars); + if (max_chars == 0) + return consumed; + alternative += GET(alternative, 1); + } + + if (*cc == OP_CBRA || *cc == OP_CBRAPOS) + cc += IMM2_SIZE; + cc += 1 + LINK_SIZE; + continue; + + case OP_CLASS: +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && !is_char7_bitset((const pcre_uint8 *)(cc + 1), FALSE)) return consumed; +#endif + any = TRUE; + cc += 1 + 32 / sizeof(pcre_uchar); + break; + + case OP_NCLASS: +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 + if (common->utf) return consumed; +#endif + any = TRUE; + cc += 1 + 32 / sizeof(pcre_uchar); + break; + +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 + case OP_XCLASS: +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 + if (common->utf) return consumed; +#endif + any = TRUE; + cc += GET(cc, 1); + break; +#endif + + case OP_DIGIT: +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && !is_char7_bitset((const pcre_uint8 *)common->ctypes - cbit_length + cbit_digit, FALSE)) + return consumed; +#endif + any = TRUE; + cc++; + break; + + case OP_WHITESPACE: +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && !is_char7_bitset((const pcre_uint8 *)common->ctypes - cbit_length + cbit_space, FALSE)) + return consumed; +#endif + any = TRUE; + cc++; + break; + + case OP_WORDCHAR: +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && !is_char7_bitset((const pcre_uint8 *)common->ctypes - cbit_length + cbit_word, FALSE)) + return consumed; +#endif + any = TRUE; + cc++; + break; + + case OP_NOT: + case OP_NOTI: + cc++; + /* Fall through. */ + case OP_NOT_DIGIT: + case OP_NOT_WHITESPACE: + case OP_NOT_WORDCHAR: + case OP_ANY: + case OP_ALLANY: +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 + if (common->utf) return consumed; +#endif + any = TRUE; + cc++; + break; + +#ifdef SUPPORT_UCP + case OP_NOTPROP: + case OP_PROP: +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 + if (common->utf) return consumed; +#endif + any = TRUE; + cc += 1 + 2; + break; +#endif + + case OP_TYPEEXACT: + repeat = GET2(cc, 1); cc += 1 + IMM2_SIZE; + continue; + + case OP_NOTEXACT: + case OP_NOTEXACTI: +#if defined SUPPORT_UTF && !defined COMPILE_PCRE32 + if (common->utf) return consumed; +#endif + any = TRUE; + repeat = GET2(cc, 1); + cc += 1 + IMM2_SIZE + 1; break; default: - must_stop = 2; - break; + return consumed; } - if (must_stop == 2) - break; + if (any) + { +#if defined COMPILE_PCRE8 + mask = 0xff; +#elif defined COMPILE_PCRE16 + mask = 0xffff; +#elif defined COMPILE_PCRE32 + mask = 0xffffffff; +#else + SLJIT_ASSERT_STOP(); +#endif + + do + { + chars[0] = mask; + chars[1] = mask; + bytes[0] = 255; + + consumed++; + if (--max_chars == 0) + return consumed; + chars += 2; + bytes += MAX_N_BYTES; + } + while (--repeat > 0); + + repeat = 1; + continue; + } len = 1; #ifdef SUPPORT_UTF - if (common->utf && HAS_EXTRALEN(cc[0])) len += GET_EXTRALEN(cc[0]); + if (common->utf && HAS_EXTRALEN(*cc)) len += GET_EXTRALEN(*cc); #endif if (caseless && char_has_othercase(common, cc)) { - caseless = char_get_othercase_bit(common, cc); - if (caseless == 0) - return FALSE; -#ifdef COMPILE_PCRE8 - caseless = ((caseless & 0xff) << 8) | (len - (caseless >> 8)); -#else - if ((caseless & 0x100) != 0) - caseless = ((caseless & 0xff) << 16) | (len - (caseless >> 9)); +#ifdef SUPPORT_UTF + if (common->utf) + { + GETCHAR(chr, cc); + if ((int)PRIV(ord2utf)(char_othercase(common, chr), othercase) != len) + return consumed; + } else - caseless = ((caseless & 0xff) << 8) | (len - (caseless >> 9)); #endif + { + chr = *cc; + othercase[0] = TABLE_GET(chr, common->fcc, chr); + } } else - caseless = 0; + caseless = FALSE; - while (len > 0 && location < MAX_N_CHARS * 2) + len_save = len; + cc_save = cc; + while (TRUE) { - c = *cc; - bit = 0; - if (len == (caseless & 0xff)) + oc = othercase; + do { - bit = caseless >> 8; - c |= bit; + chr = *cc; +#ifdef COMPILE_PCRE32 + if (SLJIT_UNLIKELY(chr == NOTACHAR)) + return consumed; +#endif + add_prefix_byte((pcre_uint8)chr, bytes); + + mask = 0; + if (caseless) + { + add_prefix_byte((pcre_uint8)*oc, bytes); + mask = *cc ^ *oc; + chr |= mask; + } + +#ifdef COMPILE_PCRE32 + if (chars[0] == NOTACHAR && chars[1] == 0) +#else + if (chars[0] == NOTACHAR) +#endif + { + chars[0] = chr; + chars[1] = mask; + } + else + { + mask |= chars[0] ^ chr; + chr |= mask; + chars[0] = chr; + chars[1] |= mask; + } + + len--; + consumed++; + if (--max_chars == 0) + return consumed; + chars += 2; + bytes += MAX_N_BYTES; + cc++; + oc++; } + while (len > 0); - chars[location] = c; - chars[location + 1] = bit; + if (--repeat == 0) + break; - len--; - location += 2; - cc++; + len = len_save; + cc = cc_save; + } + + repeat = 1; + if (last) + return consumed; + } +} + +static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common, BOOL firstline) +{ +DEFINE_COMPILER; +struct sljit_label *start; +struct sljit_jump *quit; +pcre_uint32 chars[MAX_N_CHARS * 2]; +pcre_uint8 bytes[MAX_N_CHARS * MAX_N_BYTES]; +pcre_uint8 ones[MAX_N_CHARS]; +int offsets[3]; +pcre_uint32 mask; +pcre_uint8 *byte_set, *byte_set_end; +int i, max, from; +int range_right = -1, range_len = 3 - 1; +sljit_ub *update_table = NULL; +BOOL in_range; + +/* This is even TRUE, if both are NULL. */ +SLJIT_ASSERT(common->read_only_data_ptr == common->read_only_data); + +for (i = 0; i < MAX_N_CHARS; i++) + { + chars[i << 1] = NOTACHAR; + chars[(i << 1) + 1] = 0; + bytes[i * MAX_N_BYTES] = 0; + } + +max = scan_prefix(common, common->start, chars, bytes, MAX_N_CHARS); + +if (max <= 1) + return FALSE; + +for (i = 0; i < max; i++) + { + mask = chars[(i << 1) + 1]; + ones[i] = ones_in_half_byte[mask & 0xf]; + mask >>= 4; + while (mask != 0) + { + ones[i] += ones_in_half_byte[mask & 0xf]; + mask >>= 4; + } + } + +in_range = FALSE; +from = 0; /* Prevent compiler "uninitialized" warning */ +for (i = 0; i <= max; i++) + { + if (in_range && (i - from) > range_len && (bytes[(i - 1) * MAX_N_BYTES] <= 4)) + { + range_len = i - from; + range_right = i - 1; + } + + if (i < max && bytes[i * MAX_N_BYTES] < 255) + { + if (!in_range) + { + in_range = TRUE; + from = i; + } + } + else if (in_range) + in_range = FALSE; + } + +if (range_right >= 0) + { + /* Since no data is consumed (see the assert in the beginning + of this function), this space can be reallocated. */ + if (common->read_only_data) + SLJIT_FREE(common->read_only_data); + + common->read_only_data_size += 256; + common->read_only_data = (sljit_uw *)SLJIT_MALLOC(common->read_only_data_size); + if (common->read_only_data == NULL) + return TRUE; + + update_table = (sljit_ub *)common->read_only_data; + common->read_only_data_ptr = (sljit_uw *)(update_table + 256); + memset(update_table, IN_UCHARS(range_len), 256); + + for (i = 0; i < range_len; i++) + { + byte_set = bytes + ((range_right - i) * MAX_N_BYTES); + SLJIT_ASSERT(byte_set[0] > 0 && byte_set[0] < 255); + byte_set_end = byte_set + byte_set[0]; + byte_set++; + while (byte_set <= byte_set_end) + { + if (update_table[*byte_set] > IN_UCHARS(i)) + update_table[*byte_set] = IN_UCHARS(i); + byte_set++; + } } + } - if (location >= MAX_N_CHARS * 2 || must_stop != 0) +offsets[0] = -1; +/* Scan forward. */ +for (i = 0; i < max; i++) + if (ones[i] <= 2) { + offsets[0] = i; break; } -/* At least two characters are required. */ -if (location < 2 * 2) +if (offsets[0] < 0 && range_right < 0) + return FALSE; + +if (offsets[0] >= 0) + { + /* Scan backward. */ + offsets[1] = -1; + for (i = max - 1; i > offsets[0]; i--) + if (ones[i] <= 2 && i != range_right) + { + offsets[1] = i; + break; + } + + /* This case is handled better by fast_forward_first_char. */ + if (offsets[1] == -1 && offsets[0] == 0 && range_right < 0) return FALSE; + offsets[2] = -1; + /* We only search for a middle character if there is no range check. */ + if (offsets[1] >= 0 && range_right == -1) + { + /* Scan from middle. */ + for (i = (offsets[0] + offsets[1]) / 2 + 1; i < offsets[1]; i++) + if (ones[i] <= 2) + { + offsets[2] = i; + break; + } + + if (offsets[2] == -1) + { + for (i = (offsets[0] + offsets[1]) / 2; i > offsets[0]; i--) + if (ones[i] <= 2) + { + offsets[2] = i; + break; + } + } + } + + SLJIT_ASSERT(offsets[1] == -1 || (offsets[0] < offsets[1])); + SLJIT_ASSERT(offsets[2] == -1 || (offsets[0] < offsets[2] && offsets[1] > offsets[2])); + + chars[0] = chars[offsets[0] << 1]; + chars[1] = chars[(offsets[0] << 1) + 1]; + if (offsets[2] >= 0) + { + chars[2] = chars[offsets[2] << 1]; + chars[3] = chars[(offsets[2] << 1) + 1]; + } + if (offsets[1] >= 0) + { + chars[4] = chars[offsets[1] << 1]; + chars[5] = chars[(offsets[1] << 1) + 1]; + } + } + +max -= 1; if (firstline) { SLJIT_ASSERT(common->first_line_end != 0); + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end); OP1(SLJIT_MOV, TMP3, 0, STR_END, 0); - OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, IN_UCHARS((location >> 1) - 1)); + OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max)); + quit = CMP(SLJIT_C_LESS_EQUAL, STR_END, 0, TMP1, 0); + OP1(SLJIT_MOV, STR_END, 0, TMP1, 0); + JUMPHERE(quit); } else - OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1)); + OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max)); + +#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) +if (range_right >= 0) + OP1(SLJIT_MOV, RETURN_ADDR, 0, SLJIT_IMM, (sljit_sw)update_table); +#endif start = LABEL(); quit = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); -OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0)); -OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); -OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); -if (chars[1] != 0) - OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[1]); -CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[0], start); -if (location > 2 * 2) - OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1)); -if (chars[3] != 0) - OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, chars[3]); -CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, chars[2], start); -if (location > 2 * 2) - { - if (chars[5] != 0) - OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[5]); - CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[4], start); +SLJIT_ASSERT(range_right >= 0 || offsets[0] >= 0); + +if (range_right >= 0) + { +#if defined COMPILE_PCRE8 || (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN) + OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right)); +#else + OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right + 1) - 1); +#endif + +#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) + OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(RETURN_ADDR, TMP1), 0); +#else + OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)update_table); +#endif + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0); + CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0, start); + } + +if (offsets[0] >= 0) + { + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[0])); + if (offsets[1] >= 0) + OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[1])); + OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); + + if (chars[1] != 0) + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[1]); + CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[0], start); + if (offsets[2] >= 0) + OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[2] - 1)); + + if (offsets[1] >= 0) + { + if (chars[5] != 0) + OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, chars[5]); + CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, chars[4], start); + } + + if (offsets[2] >= 0) + { + if (chars[3] != 0) + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[3]); + CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[2], start); + } + OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); } -OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1)); JUMPHERE(quit); if (firstline) + { + if (range_right >= 0) + OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end); OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); + if (range_right >= 0) + { + quit = CMP(SLJIT_C_LESS_EQUAL, STR_PTR, 0, TMP1, 0); + OP1(SLJIT_MOV, STR_PTR, 0, TMP1, 0); + JUMPHERE(quit); + } + } else - OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1)); + OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max)); return TRUE; } #undef MAX_N_CHARS +#undef MAX_N_BYTES static SLJIT_INLINE void fast_forward_first_char(compiler_common *common, pcre_uchar first_char, BOOL caseless, BOOL firstline) { @@ -3167,7 +3873,7 @@ JUMPHERE(lastchar); if (firstline) - OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0); + OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); return; } @@ -3177,7 +3883,9 @@ skip_char_back(common); loop = LABEL(); -read_char(common); +common->ff_newline_shortcut = loop; + +read_char_range(common, common->nlmin, common->nlmax, TRUE); lastchar = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0); if (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF) foundcr = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR); @@ -3206,24 +3914,19 @@ OP1(SLJIT_MOV, STR_END, 0, TMP3, 0); } -static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, jump_list **backtracks); +static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks); -static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, sljit_uw start_bits, BOOL firstline) +static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, pcre_uint8 *start_bits, BOOL firstline) { DEFINE_COMPILER; struct sljit_label *start; struct sljit_jump *quit; struct sljit_jump *found = NULL; jump_list *matches = NULL; -pcre_uint8 inverted_start_bits[32]; -int i; #ifndef COMPILE_PCRE8 struct sljit_jump *jump; #endif -for (i = 0; i < 32; ++i) - inverted_start_bits[i] = ~(((pcre_uint8*)start_bits)[i]); - if (firstline) { SLJIT_ASSERT(common->first_line_end != 0); @@ -3239,7 +3942,7 @@ OP1(SLJIT_MOV, TMP3, 0, TMP1, 0); #endif -if (!check_class_ranges(common, inverted_start_bits, (inverted_start_bits[31] & 0x80) != 0, &matches)) +if (!check_class_ranges(common, start_bits, (start_bits[31] & 0x80) != 0, TRUE, &matches)) { #ifndef COMPILE_PCRE8 jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 255); @@ -3248,7 +3951,7 @@ #endif OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), start_bits); + OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)start_bits); OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); found = JUMP(SLJIT_C_NOT_ZERO); @@ -3451,7 +4154,7 @@ OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0); check_str_end(common, &skipread_list); -peek_char(common); +peek_char(common, READ_CHAR_MAX); /* Testing char type. This is a code duplication. */ #ifdef SUPPORT_UCP @@ -3497,143 +4200,153 @@ sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0); } -/* - range format: - - ranges[0] = length of the range (max MAX_RANGE_SIZE, -1 means invalid range). - ranges[1] = first bit (0 or 1) - ranges[2-length] = position of the bit change (when the current bit is not equal to the previous) -*/ - -static BOOL check_ranges(compiler_common *common, int *ranges, jump_list **backtracks, BOOL readch) +static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks) { DEFINE_COMPILER; -struct sljit_jump *jump; +int ranges[MAX_RANGE_SIZE]; +pcre_uint8 bit, cbit, all; +int i, byte, length = 0; -if (ranges[0] < 0) +bit = bits[0] & 0x1; +/* All bits will be zero or one (since bit is zero or one). */ +all = -bit; + +for (i = 0; i < 256; ) + { + byte = i >> 3; + if ((i & 0x7) == 0 && bits[byte] == all) + i += 8; + else + { + cbit = (bits[byte] >> (i & 0x7)) & 0x1; + if (cbit != bit) + { + if (length >= MAX_RANGE_SIZE) + return FALSE; + ranges[length] = i; + length++; + bit = cbit; + all = -cbit; + } + i++; + } + } + +if (((bit == 0) && nclass) || ((bit == 1) && !nclass)) + { + if (length >= MAX_RANGE_SIZE) + return FALSE; + ranges[length] = 256; + length++; + } + +if (length < 0 || length > 4) return FALSE; -switch(ranges[0]) +bit = bits[0] & 0x1; +if (invert) bit ^= 0x1; + +/* No character is accepted. */ +if (length == 0 && bit == 0) + add_jump(compiler, backtracks, JUMP(SLJIT_JUMP)); + +switch(length) { + case 0: + /* When bit != 0, all characters are accepted. */ + return TRUE; + case 1: - if (readch) - read_char(common); - add_jump(compiler, backtracks, CMP(ranges[1] == 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2])); + add_jump(compiler, backtracks, CMP(bit == 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0])); return TRUE; case 2: - if (readch) - read_char(common); - OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]); - add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2])); + if (ranges[0] + 1 != ranges[1]) + { + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]); + add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0])); + } + else + add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0])); return TRUE; - case 4: - if (ranges[2] + 1 == ranges[3] && ranges[4] + 1 == ranges[5]) + case 3: + if (bit != 0) { - if (readch) - read_char(common); - if (ranges[1] != 0) + add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2])); + if (ranges[0] + 1 != ranges[1]) { - add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2])); - add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4])); + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]); + add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0])); } else - { - jump = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]); - add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4])); - JUMPHERE(jump); - } + add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0])); return TRUE; } - if ((ranges[3] - ranges[2]) == (ranges[5] - ranges[4]) && is_powerof2(ranges[4] - ranges[2])) + + add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[0])); + if (ranges[1] + 1 != ranges[2]) { - if (readch) - read_char(common); - OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[2]); - OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4]); - add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[4])); - return TRUE; + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[1]); + add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[1])); } - return FALSE; - - default: - return FALSE; - } -} - -static void get_ctype_ranges(compiler_common *common, int flag, int *ranges) -{ -int i, bit, length; -const pcre_uint8 *ctypes = (const pcre_uint8*)common->ctypes; - -bit = ctypes[0] & flag; -ranges[0] = -1; -ranges[1] = bit != 0 ? 1 : 0; -length = 0; + else + add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1])); + return TRUE; -for (i = 1; i < 256; i++) - if ((ctypes[i] & flag) != bit) + case 4: + if ((ranges[1] - ranges[0]) == (ranges[3] - ranges[2]) + && (ranges[0] | (ranges[2] - ranges[0])) == ranges[2] + && is_powerof2(ranges[2] - ranges[0])) { - if (length >= MAX_RANGE_SIZE) - return; - ranges[2 + length] = i; - length++; - bit ^= flag; + OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[0]); + if (ranges[2] + 1 != ranges[3]) + { + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]); + add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2])); + } + else + add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2])); + return TRUE; } -if (bit != 0) - { - if (length >= MAX_RANGE_SIZE) - return; - ranges[2 + length] = 256; - length++; - } -ranges[0] = length; -} - -static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, jump_list **backtracks) -{ -int ranges[2 + MAX_RANGE_SIZE]; -pcre_uint8 bit, cbit, all; -int i, byte, length = 0; - -bit = bits[0] & 0x1; -ranges[1] = bit; -/* Can be 0 or 255. */ -all = -bit; - -for (i = 0; i < 256; ) - { - byte = i >> 3; - if ((i & 0x7) == 0 && bits[byte] == all) - i += 8; - else + if (bit != 0) { - cbit = (bits[byte] >> (i & 0x7)) & 0x1; - if (cbit != bit) + i = 0; + if (ranges[0] + 1 != ranges[1]) { - if (length >= MAX_RANGE_SIZE) - return FALSE; - ranges[2 + length] = i; - length++; - bit = cbit; - all = -cbit; + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]); + add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0])); + i = ranges[0]; } - i++; + else + add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0])); + + if (ranges[2] + 1 != ranges[3]) + { + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - i); + add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2])); + } + else + add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2] - i)); + return TRUE; } - } -if (((bit == 0) && nclass) || ((bit == 1) && !nclass)) - { - if (length >= MAX_RANGE_SIZE) - return FALSE; - ranges[2 + length] = 256; - length++; - } -ranges[0] = length; + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]); + add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[0])); + if (ranges[1] + 1 != ranges[2]) + { + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]); + add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[1])); + } + else + add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0])); + return TRUE; -return check_ranges(common, ranges, backtracks, FALSE); + default: + SLJIT_ASSERT_STOP(); + return FALSE; + } } static void check_anynewline(compiler_common *common) @@ -4000,20 +4713,20 @@ #define SET_TYPE_OFFSET(value) \ if ((value) != typeoffset) \ { \ - if ((value) > typeoffset) \ - OP2(SLJIT_SUB, typereg, 0, typereg, 0, SLJIT_IMM, (value) - typeoffset); \ - else \ + if ((value) < typeoffset) \ OP2(SLJIT_ADD, typereg, 0, typereg, 0, SLJIT_IMM, typeoffset - (value)); \ + else \ + OP2(SLJIT_SUB, typereg, 0, typereg, 0, SLJIT_IMM, (value) - typeoffset); \ } \ typeoffset = (value); #define SET_CHAR_OFFSET(value) \ if ((value) != charoffset) \ { \ - if ((value) > charoffset) \ - OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, (value) - charoffset); \ + if ((value) < charoffset) \ + OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(charoffset - (value))); \ else \ - OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, charoffset - (value)); \ + OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)((value) - charoffset)); \ } \ charoffset = (value); @@ -4021,84 +4734,53 @@ { DEFINE_COMPILER; jump_list *found = NULL; -jump_list **list = (*cc & XCL_NOT) == 0 ? &found : backtracks; -pcre_int32 c, charoffset; +jump_list **list = (cc[0] & XCL_NOT) == 0 ? &found : backtracks; +sljit_uw c, charoffset, max = 256, min = READ_CHAR_MAX; struct sljit_jump *jump = NULL; pcre_uchar *ccbegin; int compares, invertcmp, numberofcmps; +#if defined SUPPORT_UTF && (defined COMPILE_PCRE8 || defined COMPILE_PCRE16) +BOOL utf = common->utf; +#endif #ifdef SUPPORT_UCP BOOL needstype = FALSE, needsscript = FALSE, needschar = FALSE; BOOL charsaved = FALSE; int typereg = TMP1, scriptreg = TMP1; const pcre_uint32 *other_cases; -pcre_int32 typeoffset; +sljit_uw typeoffset; #endif -/* Although SUPPORT_UTF must be defined, we are - not necessary in utf mode even in 8 bit mode. */ -detect_partial_match(common, backtracks); -read_char(common); - -if ((*cc++ & XCL_MAP) != 0) +/* Scanning the necessary info. */ +cc++; +ccbegin = cc; +compares = 0; +if (cc[-1] & XCL_MAP) { - OP1(SLJIT_MOV, TMP3, 0, TMP1, 0); -#ifndef COMPILE_PCRE8 - jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255); -#elif defined SUPPORT_UTF - if (common->utf) - jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255); -#endif - - if (!check_class_ranges(common, (const pcre_uint8 *)cc, TRUE, list)) - { - OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); - OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); - OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); - OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); - OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); - add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO)); - } - -#ifndef COMPILE_PCRE8 - JUMPHERE(jump); -#elif defined SUPPORT_UTF - if (common->utf) - JUMPHERE(jump); -#endif - OP1(SLJIT_MOV, TMP1, 0, TMP3, 0); -#ifdef SUPPORT_UCP - charsaved = TRUE; -#endif + min = 0; cc += 32 / sizeof(pcre_uchar); } -/* Scanning the necessary info. */ -ccbegin = cc; -compares = 0; while (*cc != XCL_END) { compares++; if (*cc == XCL_SINGLE) { - cc += 2; -#ifdef SUPPORT_UTF - if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]); -#endif + cc ++; + GETCHARINCTEST(c, cc); + if (c > max) max = c; + if (c < min) min = c; #ifdef SUPPORT_UCP needschar = TRUE; #endif } else if (*cc == XCL_RANGE) { - cc += 2; -#ifdef SUPPORT_UTF - if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]); -#endif - cc++; -#ifdef SUPPORT_UTF - if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]); -#endif + cc ++; + GETCHARINCTEST(c, cc); + if (c < min) min = c; + GETCHARINCTEST(c, cc); + if (c > max) max = c; #ifdef SUPPORT_UCP needschar = TRUE; #endif @@ -4108,6 +4790,22 @@ { SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP); cc++; + if (*cc == PT_CLIST) + { + other_cases = PRIV(ucd_caseless_sets) + cc[1]; + while (*other_cases != NOTACHAR) + { + if (*other_cases > max) max = *other_cases; + if (*other_cases < min) min = *other_cases; + other_cases++; + } + } + else + { + max = READ_CHAR_MAX; + min = 0; + } + switch(*cc) { case PT_ANY: @@ -4148,6 +4846,64 @@ #endif } +/* We are not necessary in utf mode even in 8 bit mode. */ +cc = ccbegin; +detect_partial_match(common, backtracks); +read_char_range(common, min, max, (cc[-1] & XCL_NOT) != 0); + +if ((cc[-1] & XCL_HASPROP) == 0) + { + if ((cc[-1] & XCL_MAP) != 0) + { + jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255); + if (!check_class_ranges(common, (const pcre_uint8 *)cc, (((const pcre_uint8 *)cc)[31] & 0x80) != 0, TRUE, &found)) + { + OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); + OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); + OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); + OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); + OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); + add_jump(compiler, &found, JUMP(SLJIT_C_NOT_ZERO)); + } + + add_jump(compiler, backtracks, JUMP(SLJIT_JUMP)); + JUMPHERE(jump); + + cc += 32 / sizeof(pcre_uchar); + } + else + { + OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, min); + add_jump(compiler, (cc[-1] & XCL_NOT) == 0 ? backtracks : &found, CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, max - min)); + } + } +else if ((cc[-1] & XCL_MAP) != 0) + { + OP1(SLJIT_MOV, TMP3, 0, TMP1, 0); +#ifdef SUPPORT_UCP + charsaved = TRUE; +#endif + if (!check_class_ranges(common, (const pcre_uint8 *)cc, FALSE, TRUE, list)) + { +#ifdef COMPILE_PCRE8 + SLJIT_ASSERT(common->utf); +#endif + jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255); + + OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); + OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); + OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); + OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); + OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); + add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO)); + + JUMPHERE(jump); + } + + OP1(SLJIT_MOV, TMP1, 0, TMP3, 0); + cc += 32 / sizeof(pcre_uchar); + } + #ifdef SUPPORT_UCP /* Simple register allocation. TMP1 is preferred if possible. */ if (needstype || needsscript) @@ -4189,7 +4945,6 @@ #endif /* Generating code. */ -cc = ccbegin; charoffset = 0; numberofcmps = 0; #ifdef SUPPORT_UCP @@ -4205,70 +4960,50 @@ if (*cc == XCL_SINGLE) { cc ++; -#ifdef SUPPORT_UTF - if (common->utf) - { - GETCHARINC(c, cc); - } - else -#endif - c = *cc++; + GETCHARINCTEST(c, cc); if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE)) { - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, numberofcmps == 0 ? SLJIT_UNUSED : TMP2, 0, SLJIT_C_EQUAL); numberofcmps++; } else if (numberofcmps > 0) { - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL); jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp); numberofcmps = 0; } else { - jump = CMP(SLJIT_C_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, c - charoffset); + jump = CMP(SLJIT_C_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); numberofcmps = 0; } } else if (*cc == XCL_RANGE) { cc ++; -#ifdef SUPPORT_UTF - if (common->utf) - { - GETCHARINC(c, cc); - } - else -#endif - c = *cc++; + GETCHARINCTEST(c, cc); SET_CHAR_OFFSET(c); -#ifdef SUPPORT_UTF - if (common->utf) - { - GETCHARINC(c, cc); - } - else -#endif - c = *cc++; + GETCHARINCTEST(c, cc); + if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE)) { - OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, numberofcmps == 0 ? SLJIT_UNUSED : TMP2, 0, SLJIT_C_LESS_EQUAL); numberofcmps++; } else if (numberofcmps > 0) { - OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL); jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp); numberofcmps = 0; } else { - jump = CMP(SLJIT_C_LESS_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, c - charoffset); + jump = CMP(SLJIT_C_LESS_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset)); numberofcmps = 0; } } @@ -4334,7 +5069,7 @@ break; case PT_WORD: - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_UNDERSCORE - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_UNDERSCORE - charoffset)); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL); /* Fall through. */ @@ -4382,35 +5117,35 @@ OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[2]); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL); - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, other_cases[0] - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(other_cases[0] - charoffset)); OP_FLAGS(SLJIT_OR | ((other_cases[3] == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, TMP2, 0, SLJIT_C_EQUAL); other_cases += 3; } else { - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset)); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL); } while (*other_cases != NOTACHAR) { - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset)); OP_FLAGS(SLJIT_OR | ((*other_cases == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, TMP2, 0, SLJIT_C_EQUAL); } jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp); break; case PT_UCNC: - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_DOLLAR_SIGN - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_DOLLAR_SIGN - charoffset)); OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL); - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_COMMERCIAL_AT - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_COMMERCIAL_AT - charoffset)); OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL); - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_GRAVE_ACCENT - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_GRAVE_ACCENT - charoffset)); OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL); SET_CHAR_OFFSET(0xa0); - OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd7ff - charoffset); + OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(0xd7ff - charoffset)); OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL); SET_CHAR_OFFSET(0); OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xe000 - 0); @@ -4509,7 +5244,7 @@ #ifdef SUPPORT_UCP pcre_uchar propdata[5]; #endif -#endif +#endif /* SUPPORT_UTF */ switch(type) { @@ -4534,26 +5269,27 @@ case OP_NOT_DIGIT: case OP_DIGIT: /* Digits are usually 0-9, so it is worth to optimize them. */ - if (common->digits[0] == -2) - get_ctype_ranges(common, ctype_digit, common->digits); detect_partial_match(common, backtracks); - /* Flip the starting bit in the negative case. */ - if (type == OP_NOT_DIGIT) - common->digits[1] ^= 1; - if (!check_ranges(common, common->digits, backtracks, TRUE)) - { - read_char8_type(common); - OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_digit); - add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO)); - } - if (type == OP_NOT_DIGIT) - common->digits[1] ^= 1; +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_digit, FALSE)) + read_char7_type(common, type == OP_NOT_DIGIT); + else +#endif + read_char8_type(common, type == OP_NOT_DIGIT); + /* Flip the starting bit in the negative case. */ + OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_digit); + add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO)); return cc; case OP_NOT_WHITESPACE: case OP_WHITESPACE: detect_partial_match(common, backtracks); - read_char8_type(common); +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_space, FALSE)) + read_char7_type(common, type == OP_NOT_WHITESPACE); + else +#endif + read_char8_type(common, type == OP_NOT_WHITESPACE); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_space); add_jump(compiler, backtracks, JUMP(type == OP_WHITESPACE ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO)); return cc; @@ -4561,14 +5297,19 @@ case OP_NOT_WORDCHAR: case OP_WORDCHAR: detect_partial_match(common, backtracks); - read_char8_type(common); +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_word, FALSE)) + read_char7_type(common, type == OP_NOT_WORDCHAR); + else +#endif + read_char8_type(common, type == OP_NOT_WORDCHAR); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_word); add_jump(compiler, backtracks, JUMP(type == OP_WORDCHAR ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO)); return cc; case OP_ANY: detect_partial_match(common, backtracks); - read_char(common); + read_char_range(common, common->nlmin, common->nlmax, TRUE); if (common->nltype == NLTYPE_FIXED && common->newline > 255) { jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff); @@ -4624,7 +5365,7 @@ #ifdef SUPPORT_UCP case OP_NOTPROP: case OP_PROP: - propdata[0] = 0; + propdata[0] = XCL_HASPROP; propdata[1] = type == OP_NOTPROP ? XCL_NOTPROP : XCL_PROP; propdata[2] = cc[0]; propdata[3] = cc[1]; @@ -4636,7 +5377,7 @@ case OP_ANYNL: detect_partial_match(common, backtracks); - read_char(common); + read_char_range(common, common->bsr_nlmin, common->bsr_nlmax, FALSE); jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR); /* We don't need to handle soft partial matching case. */ end_list = NULL; @@ -4658,7 +5399,7 @@ case OP_NOT_HSPACE: case OP_HSPACE: detect_partial_match(common, backtracks); - read_char(common); + read_char_range(common, 0x9, 0x3000, type == OP_NOT_HSPACE); add_jump(compiler, &common->hspace, JUMP(SLJIT_FAST_CALL)); add_jump(compiler, backtracks, JUMP(type == OP_NOT_HSPACE ? SLJIT_C_NOT_ZERO : SLJIT_C_ZERO)); return cc; @@ -4666,7 +5407,7 @@ case OP_NOT_VSPACE: case OP_VSPACE: detect_partial_match(common, backtracks); - read_char(common); + read_char_range(common, 0xa, 0x2029, type == OP_NOT_VSPACE); add_jump(compiler, &common->vspace, JUMP(SLJIT_FAST_CALL)); add_jump(compiler, backtracks, JUMP(type == OP_NOT_VSPACE ? SLJIT_C_NOT_ZERO : SLJIT_C_ZERO)); return cc; @@ -4765,7 +5506,7 @@ else { OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, STR_PTR, 0); - read_char(common); + read_char_range(common, common->nlmin, common->nlmax, TRUE); add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, STR_PTR, 0, STR_END, 0)); add_jump(compiler, &common->anynewline, JUMP(SLJIT_FAST_CALL)); add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO)); @@ -4813,7 +5554,7 @@ else { skip_char_back(common); - read_char(common); + read_char_range(common, common->nlmin, common->nlmax, TRUE); check_newlinechar(common, common->nltype, backtracks, FALSE); } JUMPHERE(jump[0]); @@ -4864,7 +5605,7 @@ } else { - peek_char(common); + peek_char(common, common->nlmax); check_newlinechar(common, common->nltype, backtracks, FALSE); } JUMPHERE(jump[0]); @@ -4888,8 +5629,8 @@ #endif return byte_sequence_compare(common, type == OP_CHARI, cc, &context, backtracks); } + detect_partial_match(common, backtracks); - read_char(common); #ifdef SUPPORT_UTF if (common->utf) { @@ -4898,12 +5639,15 @@ else #endif c = *cc; + if (type == OP_CHAR || !char_has_othercase(common, cc)) { + read_char_range(common, c, c, FALSE); add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, c)); return cc + length; } oc = char_othercase(common, c); + read_char_range(common, c < oc ? c : oc, c > oc ? c : oc, FALSE); bit = c ^ oc; if (is_powerof2(bit)) { @@ -4911,11 +5655,9 @@ add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, c | bit)); return cc + length; } - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c); - OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL); - OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc); - OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL); - add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO)); + jump[0] = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, c); + add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, oc)); + JUMPHERE(jump[0]); return cc + length; case OP_NOT: @@ -4950,21 +5692,21 @@ #endif /* COMPILE_PCRE8 */ { GETCHARLEN(c, cc, length); - read_char(common); } } else #endif /* SUPPORT_UTF */ - { - read_char(common); c = *cc; - } if (type == OP_NOT || !char_has_othercase(common, cc)) + { + read_char_range(common, c, c, TRUE); add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, c)); + } else { oc = char_othercase(common, c); + read_char_range(common, c < oc ? c : oc, c > oc ? c : oc, TRUE); bit = c ^ oc; if (is_powerof2(bit)) { @@ -4982,36 +5724,49 @@ case OP_CLASS: case OP_NCLASS: detect_partial_match(common, backtracks); - read_char(common); - if (check_class_ranges(common, (const pcre_uint8 *)cc, type == OP_NCLASS, backtracks)) + +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + bit = (common->utf && is_char7_bitset((const pcre_uint8 *)cc, type == OP_NCLASS)) ? 127 : 255; + read_char_range(common, 0, bit, type == OP_NCLASS); +#else + read_char_range(common, 0, 255, type == OP_NCLASS); +#endif + + if (check_class_ranges(common, (const pcre_uint8 *)cc, type == OP_NCLASS, FALSE, backtracks)) return cc + 32 / sizeof(pcre_uchar); -#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 jump[0] = NULL; -#ifdef COMPILE_PCRE8 - /* This check only affects 8 bit mode. In other modes, we - always need to compare the value with 255. */ if (common->utf) -#endif /* COMPILE_PCRE8 */ { - jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255); + jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, bit); if (type == OP_CLASS) { add_jump(compiler, backtracks, jump[0]); jump[0] = NULL; } } -#endif /* SUPPORT_UTF || !COMPILE_PCRE8 */ +#elif !defined COMPILE_PCRE8 + jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255); + if (type == OP_CLASS) + { + add_jump(compiler, backtracks, jump[0]); + jump[0] = NULL; + } +#endif /* SUPPORT_UTF && COMPILE_PCRE8 */ + OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7); OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3); OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc); OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0); add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO)); + #if defined SUPPORT_UTF || !defined COMPILE_PCRE8 if (jump[0] != NULL) JUMPHERE(jump[0]); -#endif /* SUPPORT_UTF || !COMPILE_PCRE8 */ +#endif + return cc + 32 / sizeof(pcre_uchar); #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32 @@ -7345,7 +8100,7 @@ return cc + 1; } -if (*cc == OP_ASSERT_ACCEPT || common->currententry != NULL) +if (*cc == OP_ASSERT_ACCEPT || common->currententry != NULL || !common->might_be_empty) { /* No need to check notempty conditions. */ if (common->accept_label == NULL) @@ -8047,21 +8802,21 @@ static void compile_bracket_backtrackingpath(compiler_common *common, struct backtrack_common *current) { DEFINE_COMPILER; -int opcode, stacksize, count; +int opcode, stacksize, alt_count, alt_max; int offset = 0; int private_data_ptr = CURRENT_AS(bracket_backtrack)->private_data_ptr; int repeat_ptr = 0, repeat_type = 0, repeat_count = 0; pcre_uchar *cc = current->cc; pcre_uchar *ccbegin; pcre_uchar *ccprev; -jump_list *jumplist = NULL; -jump_list *jumplistitem = NULL; pcre_uchar bra = OP_BRA; pcre_uchar ket; assert_backtrack *assert; BOOL has_alternatives; BOOL needs_control_head = FALSE; struct sljit_jump *brazero = NULL; +struct sljit_jump *alt1 = NULL; +struct sljit_jump *alt2 = NULL; struct sljit_jump *once = NULL; struct sljit_jump *cond = NULL; struct sljit_label *rmin_label = NULL; @@ -8099,6 +8854,8 @@ if (SLJIT_UNLIKELY(opcode == OP_ONCE_NC)) opcode = OP_ONCE; +alt_max = has_alternatives ? no_alternatives(ccbegin) : 0; + /* Decoding the needs_control_head in framesize. */ if (opcode == OP_ONCE) { @@ -8212,44 +8969,27 @@ OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); free_stack(common, 1); - jumplistitem = sljit_alloc_memory(compiler, sizeof(jump_list)); - if (SLJIT_UNLIKELY(!jumplistitem)) - return; - jumplist = jumplistitem; - jumplistitem->next = NULL; - jumplistitem->jump = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, 1); + alt_max = 2; + alt1 = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, sizeof(sljit_uw)); } } -else if (*cc == OP_ALT) +else if (has_alternatives) { - /* Build a jump list. Get the last successfully matched branch index. */ OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0)); free_stack(common, 1); - count = 1; - do - { - /* Append as the last item. */ - if (jumplist != NULL) - { - jumplistitem->next = sljit_alloc_memory(compiler, sizeof(jump_list)); - jumplistitem = jumplistitem->next; - } - else - { - jumplistitem = sljit_alloc_memory(compiler, sizeof(jump_list)); - jumplist = jumplistitem; - } - - if (SLJIT_UNLIKELY(!jumplistitem)) - return; - jumplistitem->next = NULL; - jumplistitem->jump = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, count++); - cc += GET(cc, 1); + if (alt_max > 4) + { + /* Table jump if alt_max is greater than 4. */ + sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_MEM1(TMP1), (sljit_sw)common->read_only_data_ptr); + add_label_addr(common); + } + else + { + if (alt_max == 4) + alt2 = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_uw)); + alt1 = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, sizeof(sljit_uw)); } - while (*cc == OP_ALT); - - cc = ccbegin + GET(ccbegin, 1); } COMPILE_BACKTRACKINGPATH(current->top); @@ -8284,7 +9024,7 @@ if (has_alternatives) { - count = 1; + alt_count = sizeof(sljit_uw); do { current->top = NULL; @@ -8360,7 +9100,7 @@ stacksize = match_capture_common(common, stacksize, offset, private_data_ptr); if (opcode != OP_ONCE) - OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, count++); + OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, alt_count); if (offset != 0 && ket == OP_KETRMAX && common->optimized_cbracket[offset >> 1] != 0) { @@ -8373,9 +9113,24 @@ if (opcode != OP_ONCE) { - SLJIT_ASSERT(jumplist); - JUMPHERE(jumplist->jump); - jumplist = jumplist->next; + if (alt_max > 4) + add_label_addr(common); + else + { + if (alt_count != 2 * sizeof(sljit_uw)) + { + JUMPHERE(alt1); + if (alt_max == 3 && alt_count == sizeof(sljit_uw)) + alt2 = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_uw)); + } + else + { + JUMPHERE(alt2); + if (alt_max == 4) + alt1 = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 3 * sizeof(sljit_uw)); + } + } + alt_count += sizeof(sljit_uw); } COMPILE_BACKTRACKINGPATH(current->top); @@ -8384,7 +9139,6 @@ SLJIT_ASSERT(!current->nextbacktracks); } while (*cc == OP_ALT); - SLJIT_ASSERT(!jumplist); if (cond != NULL) { @@ -8985,16 +9739,18 @@ executable_functions *functions; void *executable_func; sljit_uw executable_size; +sljit_uw total_length; +label_addr_list *label_addr; struct sljit_label *mainloop_label = NULL; struct sljit_label *continue_match_label; -struct sljit_label *empty_match_found_label; -struct sljit_label *empty_match_backtrack_label; +struct sljit_label *empty_match_found_label = NULL; +struct sljit_label *empty_match_backtrack_label = NULL; struct sljit_label *reset_match_label; +struct sljit_label *quit_label; struct sljit_jump *jump; struct sljit_jump *minlength_check_failed = NULL; struct sljit_jump *reqbyte_notfound = NULL; -struct sljit_jump *empty_match; -struct sljit_label *quit_label; +struct sljit_jump *empty_match = NULL; SLJIT_ASSERT((extra->flags & PCRE_EXTRA_STUDY_DATA) != 0); study = extra->study_data; @@ -9007,9 +9763,13 @@ rootbacktrack.cc = (pcre_uchar *)re + re->name_table_offset + re->name_count * re->name_entry_size; common->start = rootbacktrack.cc; +common->read_only_data = NULL; +common->read_only_data_size = 0; +common->read_only_data_ptr = NULL; common->fcc = tables + fcc_offset; common->lcc = (sljit_sw)(tables + lcc_offset); common->mode = mode; +common->might_be_empty = study->minlength == 0; common->nltype = NLTYPE_FIXED; switch(re->options & PCRE_NEWLINE_BITS) { @@ -9030,6 +9790,8 @@ case PCRE_NEWLINE_ANYCRLF: common->newline = (CHAR_CR << 8) | CHAR_NL; common->nltype = NLTYPE_ANYCRLF; break; default: return; } +common->nlmax = READ_CHAR_MAX; +common->nlmin = 0; if ((re->options & PCRE_BSR_ANYCRLF) != 0) common->bsr_nltype = NLTYPE_ANYCRLF; else if ((re->options & PCRE_BSR_UNICODE) != 0) @@ -9042,9 +9804,10 @@ common->bsr_nltype = NLTYPE_ANY; #endif } +common->bsr_nlmax = READ_CHAR_MAX; +common->bsr_nlmin = 0; common->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0; common->ctypes = (sljit_sw)(tables + ctypes_offset); -common->digits[0] = -2; common->name_table = ((pcre_uchar *)re) + re->name_table_offset; common->name_count = re->name_count; common->name_entry_size = re->name_entry_size; @@ -9055,8 +9818,31 @@ #ifdef SUPPORT_UCP common->use_ucp = (re->options & PCRE_UCP) != 0; #endif +if (common->utf) + { + if (common->nltype == NLTYPE_ANY) + common->nlmax = 0x2029; + else if (common->nltype == NLTYPE_ANYCRLF) + common->nlmax = (CHAR_CR > CHAR_NL) ? CHAR_CR : CHAR_NL; + else + { + /* We only care about the first newline character. */ + common->nlmax = common->newline & 0xff; + } + + if (common->nltype == NLTYPE_FIXED) + common->nlmin = common->newline & 0xff; + else + common->nlmin = (CHAR_CR < CHAR_NL) ? CHAR_CR : CHAR_NL; + + if (common->bsr_nltype == NLTYPE_ANY) + common->bsr_nlmax = 0x2029; + else + common->bsr_nlmax = (CHAR_CR > CHAR_NL) ? CHAR_CR : CHAR_NL; + common->bsr_nlmin = (CHAR_CR < CHAR_NL) ? CHAR_CR : CHAR_NL; + } #endif /* SUPPORT_UTF */ -ccend = bracketend(rootbacktrack.cc); +ccend = bracketend(common->start); /* Calculate the local space size on the stack. */ common->ovector_start = LIMIT_MATCH + sizeof(sljit_sw); @@ -9069,12 +9855,12 @@ memset(common->optimized_cbracket, 1, re->top_bracket + 1); #endif -SLJIT_ASSERT(*rootbacktrack.cc == OP_BRA && ccend[-(1 + LINK_SIZE)] == OP_KET); +SLJIT_ASSERT(*common->start == OP_BRA && ccend[-(1 + LINK_SIZE)] == OP_KET); #if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 2 common->capture_last_ptr = common->ovector_start; common->ovector_start += sizeof(sljit_sw); #endif -if (!check_opcode_types(common, rootbacktrack.cc, ccend)) +if (!check_opcode_types(common, common->start, ccend)) { SLJIT_FREE(common->optimized_cbracket); return; @@ -9137,13 +9923,14 @@ SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0)); common->cbra_ptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw); -common->private_data_ptrs = (int *)SLJIT_MALLOC((ccend - rootbacktrack.cc) * sizeof(sljit_si)); +total_length = ccend - common->start; +common->private_data_ptrs = (sljit_si *)SLJIT_MALLOC(total_length * (sizeof(sljit_si) + (common->has_then ? 1 : 0))); if (!common->private_data_ptrs) { SLJIT_FREE(common->optimized_cbracket); return; } -memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int)); +memset(common->private_data_ptrs, 0, total_length * sizeof(sljit_si)); private_data_size = common->cbra_ptr + (re->top_bracket + 1) * sizeof(sljit_sw); set_private_data_ptrs(common, &private_data_size, ccend); @@ -9156,15 +9943,21 @@ if (common->has_then) { - common->then_offsets = (pcre_uint8 *)SLJIT_MALLOC(ccend - rootbacktrack.cc); - if (!common->then_offsets) + common->then_offsets = (pcre_uint8 *)(common->private_data_ptrs + total_length); + memset(common->then_offsets, 0, total_length); + set_then_offsets(common, common->start, NULL); + } + +if (common->read_only_data_size > 0) + { + common->read_only_data = (sljit_uw *)SLJIT_MALLOC(common->read_only_data_size); + if (common->read_only_data == NULL) { SLJIT_FREE(common->optimized_cbracket); SLJIT_FREE(common->private_data_ptrs); return; } - memset(common->then_offsets, 0, ccend - rootbacktrack.cc); - set_then_offsets(common, rootbacktrack.cc, NULL); + common->read_only_data_ptr = common->read_only_data; } compiler = sljit_create_compiler(); @@ -9172,8 +9965,8 @@ { SLJIT_FREE(common->optimized_cbracket); SLJIT_FREE(common->private_data_ptrs); - if (common->has_then) - SLJIT_FREE(common->then_offsets); + if (common->read_only_data) + SLJIT_FREE(common->read_only_data); return; } common->compiler = compiler; @@ -9212,13 +10005,22 @@ if ((re->options & PCRE_NO_START_OPTIMIZE) == 0) { if (mode == JIT_COMPILE && fast_forward_first_n_chars(common, (re->options & PCRE_FIRSTLINE) != 0)) - { /* Do nothing */ } + { + /* If read_only_data is reallocated, we might have an allocation failure. */ + if (common->read_only_data_size > 0 && common->read_only_data == NULL) + { + sljit_free_compiler(compiler); + SLJIT_FREE(common->optimized_cbracket); + SLJIT_FREE(common->private_data_ptrs); + return; + } + } else if ((re->flags & PCRE_FIRSTSET) != 0) fast_forward_first_char(common, (pcre_uchar)re->first_char, (re->flags & PCRE_FCH_CASELESS) != 0, (re->options & PCRE_FIRSTLINE) != 0); else if ((re->flags & PCRE_STARTLINE) != 0) fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0); else if ((re->flags & PCRE_STARTLINE) == 0 && study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0) - fast_forward_start_bits(common, (sljit_uw)study->start_bits, (re->options & PCRE_FIRSTLINE) != 0); + fast_forward_start_bits(common, study->start_bits, (re->options & PCRE_FIRSTLINE) != 0); } } else @@ -9259,19 +10061,22 @@ else if (mode == JIT_PARTIAL_HARD_COMPILE) OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0); -compile_matchingpath(common, rootbacktrack.cc, ccend, &rootbacktrack); +compile_matchingpath(common, common->start, ccend, &rootbacktrack); if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) { sljit_free_compiler(compiler); SLJIT_FREE(common->optimized_cbracket); SLJIT_FREE(common->private_data_ptrs); - if (common->has_then) - SLJIT_FREE(common->then_offsets); + if (common->read_only_data) + SLJIT_FREE(common->read_only_data); return; } -empty_match = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0)); -empty_match_found_label = LABEL(); +if (common->might_be_empty) + { + empty_match = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0)); + empty_match_found_label = LABEL(); + } common->accept_label = LABEL(); if (common->accept != NULL) @@ -9295,15 +10100,16 @@ return_with_partial_match(common, common->quit_label); } -empty_match_backtrack_label = LABEL(); +if (common->might_be_empty) + empty_match_backtrack_label = LABEL(); compile_backtrackingpath(common, rootbacktrack.top); if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) { sljit_free_compiler(compiler); SLJIT_FREE(common->optimized_cbracket); SLJIT_FREE(common->private_data_ptrs); - if (common->has_then) - SLJIT_FREE(common->then_offsets); + if (common->read_only_data) + SLJIT_FREE(common->read_only_data); return; } @@ -9331,10 +10137,19 @@ if ((re->options & PCRE_ANCHORED) == 0) { - if ((re->options & PCRE_FIRSTLINE) == 0) - CMPTO(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0, mainloop_label); + if (common->ff_newline_shortcut != NULL) + { + if ((re->options & PCRE_FIRSTLINE) == 0) + CMPTO(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0, common->ff_newline_shortcut); + /* There cannot be more newlines here. */ + } else - CMPTO(SLJIT_C_LESS, STR_PTR, 0, TMP1, 0, mainloop_label); + { + if ((re->options & PCRE_FIRSTLINE) == 0) + CMPTO(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0, mainloop_label); + else + CMPTO(SLJIT_C_LESS, STR_PTR, 0, TMP1, 0, mainloop_label); + } } /* No more remaining characters. */ @@ -9349,15 +10164,18 @@ flush_stubs(common); -JUMPHERE(empty_match); -OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); -OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty)); -CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_backtrack_label); -OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart)); -CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_found_label); -OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); -CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label); -JUMPTO(SLJIT_JUMP, empty_match_backtrack_label); +if (common->might_be_empty) + { + JUMPHERE(empty_match); + OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); + OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty)); + CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_backtrack_label); + OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart)); + CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_found_label); + OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); + CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label); + JUMPTO(SLJIT_JUMP, empty_match_backtrack_label); + } common->currententry = common->entries; common->local_exit = TRUE; @@ -9371,8 +10189,8 @@ sljit_free_compiler(compiler); SLJIT_FREE(common->optimized_cbracket); SLJIT_FREE(common->private_data_ptrs); - if (common->has_then) - SLJIT_FREE(common->then_offsets); + if (common->read_only_data) + SLJIT_FREE(common->read_only_data); return; } flush_stubs(common); @@ -9456,14 +10274,17 @@ JUMPTO(SLJIT_JUMP, reset_match_label); } #ifdef SUPPORT_UTF -#ifndef COMPILE_PCRE32 +#ifdef COMPILE_PCRE8 if (common->utfreadchar != NULL) { set_jumps(common->utfreadchar, LABEL()); do_utfreadchar(common); } -#endif /* !COMPILE_PCRE32 */ -#ifdef COMPILE_PCRE8 +if (common->utfreadchar16 != NULL) + { + set_jumps(common->utfreadchar16, LABEL()); + do_utfreadchar16(common); + } if (common->utfreadtype8 != NULL) { set_jumps(common->utfreadtype8, LABEL()); @@ -9479,16 +10300,25 @@ } #endif +SLJIT_ASSERT(common->read_only_data + (common->read_only_data_size >> SLJIT_WORD_SHIFT) == common->read_only_data_ptr); SLJIT_FREE(common->optimized_cbracket); SLJIT_FREE(common->private_data_ptrs); -if (common->has_then) - SLJIT_FREE(common->then_offsets); executable_func = sljit_generate_code(compiler); executable_size = sljit_get_generated_code_size(compiler); +label_addr = common->label_addrs; +while (label_addr != NULL) + { + *label_addr->addr = sljit_get_label_addr(label_addr->label); + label_addr = label_addr->next; + } sljit_free_compiler(compiler); if (executable_func == NULL) + { + if (common->read_only_data) + SLJIT_FREE(common->read_only_data); return; + } /* Reuse the function descriptor if possible. */ if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 && extra->executable_jit != NULL) @@ -9508,8 +10338,10 @@ if (functions == NULL) { /* This case is highly unlikely since we just recently - freed a lot of memory. Although not impossible. */ + freed a lot of memory. Not impossible though. */ sljit_free_code(executable_func); + if (common->read_only_data) + SLJIT_FREE(common->read_only_data); return; } memset(functions, 0, sizeof(executable_functions)); @@ -9520,6 +10352,7 @@ } functions->executable_funcs[mode] = executable_func; +functions->read_only_data[mode] = common->read_only_data; functions->executable_sizes[mode] = executable_size; } @@ -9706,6 +10539,8 @@ { if (functions->executable_funcs[i] != NULL) sljit_free_code(functions->executable_funcs[i]); + if (functions->read_only_data[i] != NULL) + SLJIT_FREE(functions->read_only_data[i]); } SLJIT_FREE(functions); } diff -Nru r-base-3.1.0/src/extra/pcre/pcre_study.c r-base-3.1.1/src/extra/pcre/pcre_study.c --- r-base-3.1.0/src/extra/pcre/pcre_study.c 2013-12-30 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/pcre_study.c 2014-04-20 22:15:04.000000000 +0000 @@ -879,9 +879,6 @@ case OP_SOM: case OP_THEN: case OP_THEN_ARG: -#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 - case OP_XCLASS: -#endif return SSB_FAIL; /* We can ignore word boundary tests. */ @@ -1257,6 +1254,16 @@ with a value >= 0xc4 is a potentially valid starter because it starts a character with a value > 255. */ +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 + case OP_XCLASS: + if ((tcode[1 + LINK_SIZE] & XCL_HASPROP) != 0) + return SSB_FAIL; + /* All bits are set. */ + if ((tcode[1 + LINK_SIZE] & XCL_MAP) == 0 && (tcode[1 + LINK_SIZE] & XCL_NOT) != 0) + return SSB_FAIL; +#endif + /* Fall through */ + case OP_NCLASS: #if defined SUPPORT_UTF && defined COMPILE_PCRE8 if (utf) @@ -1273,8 +1280,21 @@ case OP_CLASS: { pcre_uint8 *map; - tcode++; - map = (pcre_uint8 *)tcode; +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 + map = NULL; + if (*tcode == OP_XCLASS) + { + if ((tcode[1 + LINK_SIZE] & XCL_MAP) != 0) + map = (pcre_uint8 *)(tcode + 1 + LINK_SIZE + 1); + tcode += GET(tcode, 1); + } + else +#endif + { + tcode++; + map = (pcre_uint8 *)tcode; + tcode += 32 / sizeof(pcre_uchar); + } /* In UTF-8 mode, the bits in a bit map correspond to character values, not to byte values. However, the bit map we are constructing is @@ -1282,31 +1302,35 @@ value is > 127. In fact, there are only two possible starting bytes for characters in the range 128 - 255. */ -#if defined SUPPORT_UTF && defined COMPILE_PCRE8 - if (utf) +#if defined SUPPORT_UTF || !defined COMPILE_PCRE8 + if (map != NULL) +#endif { - for (c = 0; c < 16; c++) start_bits[c] |= map[c]; - for (c = 128; c < 256; c++) +#if defined SUPPORT_UTF && defined COMPILE_PCRE8 + if (utf) { - if ((map[c/8] && (1 << (c&7))) != 0) + for (c = 0; c < 16; c++) start_bits[c] |= map[c]; + for (c = 128; c < 256; c++) { - int d = (c >> 6) | 0xc0; /* Set bit for this starter */ - start_bits[d/8] |= (1 << (d&7)); /* and then skip on to the */ - c = (c & 0xc0) + 0x40 - 1; /* next relevant character. */ + if ((map[c/8] && (1 << (c&7))) != 0) + { + int d = (c >> 6) | 0xc0; /* Set bit for this starter */ + start_bits[d/8] |= (1 << (d&7)); /* and then skip on to the */ + c = (c & 0xc0) + 0x40 - 1; /* next relevant character. */ + } } } - } - else + else #endif - { - /* In non-UTF-8 mode, the two bit maps are completely compatible. */ - for (c = 0; c < 32; c++) start_bits[c] |= map[c]; + { + /* In non-UTF-8 mode, the two bit maps are completely compatible. */ + for (c = 0; c < 32; c++) start_bits[c] |= map[c]; + } } /* Advance past the bit map, and act on what follows. For a zero minimum repeat, continue; otherwise stop processing. */ - tcode += 32 / sizeof(pcre_uchar); switch (*tcode) { case OP_CRSTAR: diff -Nru r-base-3.1.0/src/extra/pcre/pcre_xclass.c r-base-3.1.1/src/extra/pcre/pcre_xclass.c --- r-base-3.1.0/src/extra/pcre/pcre_xclass.c 2013-12-30 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/pcre_xclass.c 2014-04-20 22:15:04.000000000 +0000 @@ -81,6 +81,11 @@ if (c < 256) { + if ((*data & XCL_HASPROP) == 0) + { + if ((*data & XCL_MAP) == 0) return negated; + return (((pcre_uint8 *)(data + 1))[c/8] & (1 << (c&7))) != 0; + } if ((*data & XCL_MAP) != 0 && (((pcre_uint8 *)(data + 1))[c/8] & (1 << (c&7))) != 0) return !negated; /* char found */ diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitConfig.h r-base-3.1.1/src/extra/pcre/sljit/sljitConfig.h --- r-base-3.1.0/src/extra/pcre/sljit/sljitConfig.h 2013-12-30 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitConfig.h 2014-04-20 22:15:03.000000000 +0000 @@ -44,9 +44,11 @@ /* #define SLJIT_CONFIG_ARM_V5 1 */ /* #define SLJIT_CONFIG_ARM_V7 1 */ /* #define SLJIT_CONFIG_ARM_THUMB2 1 */ +/* #define SLJIT_CONFIG_ARM_64 1 */ /* #define SLJIT_CONFIG_PPC_32 1 */ /* #define SLJIT_CONFIG_PPC_64 1 */ /* #define SLJIT_CONFIG_MIPS_32 1 */ +/* #define SLJIT_CONFIG_MIPS_64 1 */ /* #define SLJIT_CONFIG_SPARC_32 1 */ /* #define SLJIT_CONFIG_TILEGX 1 */ @@ -106,6 +108,13 @@ #define SLJIT_VERBOSE 1 #endif -/* See the beginning of sljitConfigInternal.h */ +/* + SLJIT_IS_FPU_AVAILABLE + The availability of the FPU can be controlled by SLJIT_IS_FPU_AVAILABLE. + zero value - FPU is NOT present. + nonzero value - FPU is present. +*/ + +/* For further configurations, see the beginning of sljitConfigInternal.h */ #endif diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitConfigInternal.h r-base-3.1.1/src/extra/pcre/sljit/sljitConfigInternal.h --- r-base-3.1.0/src/extra/pcre/sljit/sljitConfigInternal.h 2013-12-30 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitConfigInternal.h 2014-04-20 22:15:03.000000000 +0000 @@ -59,9 +59,11 @@ || (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \ || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \ || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \ + || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \ || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \ || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \ || (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \ + || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \ || (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \ || (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \ || (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \ @@ -75,10 +77,12 @@ + (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \ + (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \ + (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \ + + (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \ + (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \ + (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \ + (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \ + (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \ + + (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \ + (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \ + (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \ + (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2 @@ -102,12 +106,16 @@ #else #define SLJIT_CONFIG_ARM_V5 1 #endif +#elif defined (__aarch64__) +#define SLJIT_CONFIG_ARM_64 1 #elif defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) || (defined(_POWER) && defined(__64BIT__)) #define SLJIT_CONFIG_PPC_64 1 #elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER) #define SLJIT_CONFIG_PPC_32 1 #elif defined(__mips__) && !defined(_LP64) #define SLJIT_CONFIG_MIPS_32 1 +#elif defined(__mips64) +#define SLJIT_CONFIG_MIPS_64 1 #elif defined(__sparc__) || defined(__sparc) #define SLJIT_CONFIG_SPARC_32 1 #elif defined(__tilegx__) @@ -275,7 +283,9 @@ typedef unsigned long int sljit_uw; typedef long int sljit_sw; #elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \ + && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \ && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \ + && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \ && !(defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) #define SLJIT_32BIT_ARCHITECTURE 1 #define SLJIT_WORD_SHIFT 2 @@ -353,13 +363,18 @@ #if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN) -/* These macros are useful for the application. */ +/* These macros are useful for the applications. */ #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \ - || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \ - || (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) + || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + +#ifdef __LITTLE_ENDIAN__ +#define SLJIT_LITTLE_ENDIAN 1 +#else #define SLJIT_BIG_ENDIAN 1 +#endif -#elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) +#elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \ + || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) #ifdef __MIPSEL__ #define SLJIT_LITTLE_ENDIAN 1 @@ -367,6 +382,10 @@ #define SLJIT_BIG_ENDIAN 1 #endif +#elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) + +#define SLJIT_BIG_ENDIAN 1 + #else #define SLJIT_LITTLE_ENDIAN 1 #endif @@ -383,7 +402,8 @@ #endif #ifndef SLJIT_INDIRECT_CALL -#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32 && defined _AIX) +#if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)) \ + || ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX) /* It seems certain ppc compilers use an indirect addressing for functions which makes things complicated. */ #define SLJIT_INDIRECT_CALL 1 @@ -420,6 +440,7 @@ || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \ || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \ || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \ + || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \ || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \ || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) #define SLJIT_UNALIGNED 1 diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitLir.c r-base-3.1.1/src/extra/pcre/sljit/sljitLir.c --- r-base-3.1.0/src/extra/pcre/sljit/sljitLir.c 2013-12-30 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitLir.c 2014-04-20 22:15:03.000000000 +0000 @@ -83,13 +83,13 @@ #if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) #define GET_OPCODE(op) \ - ((op) & ~(SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS)) + ((op) & ~(SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS)) #define GET_FLAGS(op) \ - ((op) & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C)) + ((op) & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C)) #define GET_ALL_FLAGS(op) \ - ((op) & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS)) + ((op) & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS)) #define TYPE_CAST_NEEDED(op) \ (((op) >= SLJIT_MOV_UB && (op) <= SLJIT_MOV_SH) || ((op) >= SLJIT_MOVU_UB && (op) <= SLJIT_MOVU_SH)) @@ -102,6 +102,16 @@ #define ABUF_SIZE 4096 #endif +/* Parameter parsing. */ +#define REG_MASK 0x3f +#define OFFS_REG(reg) (((reg) >> 8) & REG_MASK) +#define OFFS_REG_MASK (REG_MASK << 8) +#define TO_OFFS_REG(reg) ((reg) << 8) +/* When reg cannot be unused. */ +#define FAST_IS_REG(reg) ((reg) <= REG_MASK) +/* When reg can be unused. */ +#define SLOW_IS_REG(reg) ((reg) > 0 && (reg) <= REG_MASK) + /* Jump flags. */ #define JUMP_LABEL 0x1 #define JUMP_ADDR 0x2 @@ -127,39 +137,59 @@ #if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) # define IS_COND 0x04 # define IS_BL 0x08 - /* cannot be encoded as branch */ -# define B_TYPE0 0x00 /* conditional + imm8 */ -# define B_TYPE1 0x10 +# define PATCH_TYPE1 0x10 /* conditional + imm20 */ -# define B_TYPE2 0x20 +# define PATCH_TYPE2 0x20 /* IT + imm24 */ -# define B_TYPE3 0x30 +# define PATCH_TYPE3 0x30 /* imm11 */ -# define B_TYPE4 0x40 +# define PATCH_TYPE4 0x40 /* imm24 */ -# define B_TYPE5 0x50 +# define PATCH_TYPE5 0x50 /* BL + imm24 */ -# define BL_TYPE6 0x60 +# define PATCH_BL 0x60 /* 0xf00 cc code for branches */ #endif +#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) +# define IS_COND 0x004 +# define IS_CBZ 0x008 +# define IS_BL 0x010 +# define PATCH_B 0x020 +# define PATCH_COND 0x040 +# define PATCH_ABS48 0x080 +# define PATCH_ABS64 0x100 +#endif + #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) -# define UNCOND_B 0x04 -# define PATCH_B 0x08 -# define ABSOLUTE_B 0x10 +# define IS_COND 0x004 +# define IS_CALL 0x008 +# define PATCH_B 0x010 +# define PATCH_ABS_B 0x020 +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) +# define PATCH_ABS32 0x040 +# define PATCH_ABS48 0x080 +#endif +# define REMOVE_COND 0x100 #endif -#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) -# define IS_MOVABLE 0x04 -# define IS_JAL 0x08 -# define IS_BIT26_COND 0x10 -# define IS_BIT16_COND 0x20 +#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) +# define IS_MOVABLE 0x004 +# define IS_JAL 0x008 +# define IS_CALL 0x010 +# define IS_BIT26_COND 0x020 +# define IS_BIT16_COND 0x040 # define IS_COND (IS_BIT26_COND | IS_BIT16_COND) -# define PATCH_B 0x40 -# define PATCH_J 0x80 +# define PATCH_B 0x080 +# define PATCH_J 0x100 + +#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) +# define PATCH_ABS32 0x200 +# define PATCH_ABS48 0x400 +#endif /* instruction types */ # define MOVABLE_INS 0 @@ -167,15 +197,15 @@ /* no destination (i.e: store) */ # define UNMOVABLE_INS 32 /* FPU status register */ -# define FCSR_FCC 33 +# define FCSR_FCC 33 #endif #if (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) -# define IS_JAL 0x04 -# define IS_COND 0x08 +# define IS_JAL 0x04 +# define IS_COND 0x08 -# define PATCH_B 0x10 -# define PATCH_J 0x20 +# define PATCH_B 0x10 +# define PATCH_J 0x20 #endif #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) @@ -215,9 +245,13 @@ #endif #endif +#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) +#define SLJIT_HAS_VARIABLE_LOCALS_OFFSET 1 +#endif + #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1 -#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) +#ifdef _AIX #define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_sw)) #else #define FIXED_LOCALS_OFFSET (2 * sizeof(sljit_sw)) @@ -234,6 +268,11 @@ #define FIXED_LOCALS_OFFSET (4 * sizeof(sljit_sw)) #endif +#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) +#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1 +#define FIXED_LOCALS_OFFSET 0 +#endif + #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) #define SLJIT_HAS_FIXED_LOCALS_OFFSET 1 #define FIXED_LOCALS_OFFSET (23 * sizeof(sljit_sw)) @@ -343,7 +382,7 @@ compiler->cpool_diff = 0xffffffff; #endif -#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) +#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) compiler->delay_slot = UNMOVABLE_INS; #endif @@ -418,8 +457,6 @@ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target) { if (SLJIT_LIKELY(!!jump)) { - SLJIT_ASSERT(jump->flags & SLJIT_REWRITABLE_JUMP); - jump->flags &= ~JUMP_LABEL; jump->flags |= JUMP_ADDR; jump->u.target = target; @@ -534,7 +571,7 @@ } #define ADDRESSING_DEPENDS_ON(exp, reg) \ - (((exp) & SLJIT_MEM) && (((exp) & 0xf) == reg || (((exp) >> 4) & 0xf) == reg)) + (((exp) & SLJIT_MEM) && (((exp) & REG_MASK) == reg || OFFS_REG(exp) == reg)) #if (defined SLJIT_DEBUG && SLJIT_DEBUG) #define FUNCTION_CHECK_OP() \ @@ -548,41 +585,43 @@ case SLJIT_SHL: \ case SLJIT_LSHR: \ case SLJIT_ASHR: \ - SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C))); \ + SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C))); \ break; \ case SLJIT_NEG: \ - SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_C))); \ + SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \ break; \ case SLJIT_MUL: \ - SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_C))); \ + SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \ break; \ case SLJIT_CMPD: \ SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \ SLJIT_ASSERT((op & (SLJIT_SET_E | SLJIT_SET_S))); \ break; \ case SLJIT_ADD: \ - SLJIT_ASSERT(!(op & (SLJIT_SET_S | SLJIT_SET_U))); \ + SLJIT_ASSERT(!(op & (SLJIT_SET_U | SLJIT_SET_S))); \ break; \ case SLJIT_SUB: \ break; \ case SLJIT_ADDC: \ case SLJIT_SUBC: \ - SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O))); \ + SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O))); \ break; \ case SLJIT_BREAKPOINT: \ case SLJIT_NOP: \ case SLJIT_UMUL: \ case SLJIT_SMUL: \ case SLJIT_MOV: \ + case SLJIT_MOV_UI: \ case SLJIT_MOV_P: \ case SLJIT_MOVU: \ + case SLJIT_MOVU_UI: \ case SLJIT_MOVU_P: \ /* Nothing allowed */ \ - SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \ + SLJIT_ASSERT(!(op & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \ break; \ default: \ /* Only SLJIT_INT_OP or SLJIT_SINGLE_OP is allowed. */ \ - SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \ + SLJIT_ASSERT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \ break; \ } @@ -600,12 +639,12 @@ else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \ SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \ else if ((p) & SLJIT_MEM) { \ - SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \ - if ((p) & 0xf0) { \ - SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \ + SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & REG_MASK)); \ + if ((p) & OFFS_REG_MASK) { \ + SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \ SLJIT_ASSERT(!((i) & ~0x3)); \ } \ - SLJIT_ASSERT(((p) >> 9) == 0); \ + SLJIT_ASSERT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \ } \ else \ SLJIT_ASSERT_STOP(); @@ -617,12 +656,12 @@ else if ((p) == (SLJIT_MEM1(SLJIT_LOCALS_REG))) \ SLJIT_ASSERT((i) >= 0 && (i) < compiler->logical_local_size); \ else if ((p) & SLJIT_MEM) { \ - SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \ - if ((p) & 0xf0) { \ - SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \ + SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & REG_MASK)); \ + if ((p) & OFFS_REG_MASK) { \ + SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \ SLJIT_ASSERT(!((i) & ~0x3)); \ } \ - SLJIT_ASSERT(((p) >> 9) == 0); \ + SLJIT_ASSERT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \ } \ else \ SLJIT_ASSERT_STOP(); @@ -631,23 +670,23 @@ if ((p) >= SLJIT_FLOAT_REG1 && (p) <= SLJIT_FLOAT_REG6) \ SLJIT_ASSERT(i == 0); \ else if ((p) & SLJIT_MEM) { \ - SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & 0xf)); \ - if ((p) & 0xf0) { \ - SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(((p) >> 4) & 0xf)); \ - SLJIT_ASSERT(((p) & 0xf0) != (SLJIT_LOCALS_REG << 4) && !(i & ~0x3)); \ + SLJIT_ASSERT(FUNCTION_CHECK_IS_REG((p) & REG_MASK)); \ + if ((p) & OFFS_REG_MASK) { \ + SLJIT_ASSERT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \ + SLJIT_ASSERT(((p) & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_LOCALS_REG) && !(i & ~0x3)); \ } else \ - SLJIT_ASSERT((((p) >> 4) & 0xf) == 0); \ - SLJIT_ASSERT(((p) >> 9) == 0); \ + SLJIT_ASSERT(OFFS_REG(p) == 0); \ + SLJIT_ASSERT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \ } \ else \ SLJIT_ASSERT_STOP(); #define FUNCTION_CHECK_OP1() \ if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_P) { \ - SLJIT_ASSERT(!(src & SLJIT_MEM) || (src & 0xf) != SLJIT_LOCALS_REG); \ - SLJIT_ASSERT(!(dst & SLJIT_MEM) || (dst & 0xf) != SLJIT_LOCALS_REG); \ - if ((src & SLJIT_MEM) && (src & 0xf)) \ - SLJIT_ASSERT((dst & 0xf) != (src & 0xf) && ((dst >> 4) & 0xf) != (src & 0xf)); \ + SLJIT_ASSERT(!(src & SLJIT_MEM) || (src & REG_MASK) != SLJIT_LOCALS_REG); \ + SLJIT_ASSERT(!(dst & SLJIT_MEM) || (dst & REG_MASK) != SLJIT_LOCALS_REG); \ + if ((src & SLJIT_MEM) && (src & REG_MASK)) \ + SLJIT_ASSERT((dst & REG_MASK) != (src & REG_MASK) && OFFS_REG(dst) != (src & REG_MASK)); \ } #endif @@ -670,7 +709,7 @@ (char*)"f4", (char*)"f5", (char*)"f6" }; -#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) +#if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE) #ifdef _WIN64 # define SLJIT_PRINT_D "I64" #else @@ -684,18 +723,18 @@ if ((p) & SLJIT_IMM) \ fprintf(compiler->verbose, "#%" SLJIT_PRINT_D "d", (i)); \ else if ((p) & SLJIT_MEM) { \ - if ((p) & 0xf) { \ + if ((p) & REG_MASK) { \ if (i) { \ - if (((p) >> 4) & 0xf) \ - fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \ + if ((p) & OFFS_REG_MASK) \ + fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & REG_MASK], reg_names[OFFS_REG(p)], 1 << (i)); \ else \ - fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \ + fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & REG_MASK], (i)); \ } \ else { \ - if (((p) >> 4) & 0xf) \ - fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF]); \ + if ((p) & OFFS_REG_MASK) \ + fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & REG_MASK], reg_names[OFFS_REG(p)]); \ else \ - fprintf(compiler->verbose, "[%s]", reg_names[(p) & 0xF]); \ + fprintf(compiler->verbose, "[%s]", reg_names[(p) & REG_MASK]); \ } \ } \ else \ @@ -704,18 +743,18 @@ fprintf(compiler->verbose, "%s", reg_names[p]); #define sljit_verbose_fparam(p, i) \ if ((p) & SLJIT_MEM) { \ - if ((p) & 0xf) { \ + if ((p) & REG_MASK) { \ if (i) { \ - if (((p) >> 4) & 0xf) \ - fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF], 1 << (i)); \ + if ((p) & OFFS_REG_MASK) \ + fprintf(compiler->verbose, "[%s + %s * %d]", reg_names[(p) & REG_MASK], reg_names[OFFS_REG(p)], 1 << (i)); \ else \ - fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & 0xF], (i)); \ + fprintf(compiler->verbose, "[%s + #%" SLJIT_PRINT_D "d]", reg_names[(p) & REG_MASK], (i)); \ } \ else { \ - if (((p) >> 4) & 0xF) \ - fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & 0xF], reg_names[((p) >> 4)& 0xF]); \ + if ((p) & OFFS_REG_MASK) \ + fprintf(compiler->verbose, "[%s + %s]", reg_names[(p) & REG_MASK], reg_names[OFFS_REG(p)]); \ else \ - fprintf(compiler->verbose, "[%s]", reg_names[(p) & 0xF]); \ + fprintf(compiler->verbose, "[%s]", reg_names[(p) & REG_MASK]); \ } \ } \ else \ @@ -941,7 +980,7 @@ #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) if (SLJIT_UNLIKELY(!!compiler->verbose)) { fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)], - !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_S) ? "" : ".s", !(op & SLJIT_SET_U) ? "" : ".u", + !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_U) ? "" : ".u", !(op & SLJIT_SET_S) ? "" : ".s", !(op & SLJIT_SET_O) ? "" : ".o", !(op & SLJIT_SET_C) ? "" : ".c", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k"); sljit_verbose_param(dst, dstw); fprintf(compiler->verbose, ", "); @@ -983,7 +1022,7 @@ #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) if (SLJIT_UNLIKELY(!!compiler->verbose)) { fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op_names[GET_OPCODE(op)], - !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_S) ? "" : ".s", !(op & SLJIT_SET_U) ? "" : ".u", + !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_U) ? "" : ".u", !(op & SLJIT_SET_S) ? "" : ".s", !(op & SLJIT_SET_O) ? "" : ".o", !(op & SLJIT_SET_C) ? "" : ".c", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k"); sljit_verbose_param(dst, dstw); fprintf(compiler->verbose, ", "); @@ -1225,7 +1264,7 @@ SLJIT_ASSERT(type >= SLJIT_C_EQUAL && type < SLJIT_JUMP); SLJIT_ASSERT(op == SLJIT_MOV || GET_OPCODE(op) == SLJIT_MOV_UI || GET_OPCODE(op) == SLJIT_MOV_SI || (GET_OPCODE(op) >= SLJIT_AND && GET_OPCODE(op) <= SLJIT_XOR)); - SLJIT_ASSERT((op & (SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C)) == 0); + SLJIT_ASSERT((op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C)) == 0); SLJIT_ASSERT((op & (SLJIT_SET_E | SLJIT_KEEP_FLAGS)) != (SLJIT_SET_E | SLJIT_KEEP_FLAGS)); #if (defined SLJIT_DEBUG && SLJIT_DEBUG) if (GET_OPCODE(op) < SLJIT_ADD) { @@ -1340,24 +1379,28 @@ #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) # include "sljitNativeX86_common.c" #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) -# include "sljitNativeARM_v5.c" +# include "sljitNativeARM_32.c" #elif (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) -# include "sljitNativeARM_v5.c" +# include "sljitNativeARM_32.c" #elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) -# include "sljitNativeARM_Thumb2.c" +# include "sljitNativeARM_T2_32.c" +#elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) +# include "sljitNativeARM_64.c" #elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) # include "sljitNativePPC_common.c" #elif (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) # include "sljitNativePPC_common.c" #elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) # include "sljitNativeMIPS_common.c" +#elif (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) +# include "sljitNativeMIPS_common.c" #elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) # include "sljitNativeSPARC_common.c" #elif (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) -# include "sljitNativeTILEGX.c" +# include "sljitNativeTILEGX_64.c" #endif -#if !(defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) +#if !(defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, sljit_si type, sljit_si src1, sljit_sw src1w, @@ -1371,6 +1414,19 @@ check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w); condition = type & 0xff; +#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) + if ((condition == SLJIT_C_EQUAL || condition == SLJIT_C_NOT_EQUAL)) { + if ((src1 & SLJIT_IMM) && !src1w) { + src1 = src2; + src1w = src2w; + src2 = SLJIT_IMM; + src2w = 0; + } + if ((src2 & SLJIT_IMM) && !src2w) + return emit_cmp_to0(compiler, type, src1, src1w); + } +#endif + if (SLJIT_UNLIKELY((src1 & SLJIT_IMM) && !(src2 & SLJIT_IMM))) { /* Immediate is prefered as second argument by most architectures. */ switch (condition) { diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitLir.h r-base-3.1.1/src/extra/pcre/sljit/sljitLir.h --- r-base-3.1.0/src/extra/pcre/sljit/sljitLir.h 2013-12-30 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitLir.h 2014-04-20 22:15:03.000000000 +0000 @@ -265,13 +265,19 @@ sljit_sw cache_argw; #endif +#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) + sljit_si locals_offset; + sljit_si cache_arg; + sljit_sw cache_argw; +#endif + #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) sljit_sw imm; sljit_si cache_arg; sljit_sw cache_argw; #endif -#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) +#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) sljit_si delay_slot; sljit_si cache_arg; sljit_sw cache_argw; @@ -478,11 +484,11 @@ /* Register output: simply the name of the register. For destination, you can use SLJIT_UNUSED as well. */ -#define SLJIT_MEM 0x100 +#define SLJIT_MEM 0x80 #define SLJIT_MEM0() (SLJIT_MEM) #define SLJIT_MEM1(r1) (SLJIT_MEM | (r1)) -#define SLJIT_MEM2(r1, r2) (SLJIT_MEM | (r1) | ((r2) << 4)) -#define SLJIT_IMM 0x200 +#define SLJIT_MEM2(r1, r2) (SLJIT_MEM | (r1) | ((r2) << 8)) +#define SLJIT_IMM 0x40 /* Set 32 bit operation mode (I) on 64 bit CPUs. The flag is totally ignored on 32 bit CPUs. If this flag is set for an arithmetic operation, it uses only the @@ -494,12 +500,12 @@ is specified, all register arguments must be the result of other operations with the same SLJIT_INT_OP flag. In other words, although a register can hold either a 64 or 32 bit value, these values cannot be mixed. The only exceptions are - SLJIT_IMOV and SLJIT_IMOVU (SLJIT_MOV_SI/SLJIT_MOV_UI/SLJIT_MOVU_SI/SLJIT_MOV_UI - with SLJIT_INT_OP flag) which can convert any source argument to SLJIT_INT_OP - compatible result. This conversion might be unnecessary on some CPUs like x86-64, - since the upper 32 bit is always ignored. In this case SLJIT is clever enough - to not generate any instructions if the source and destination operands are the - same registers. Affects sljit_emit_op0, sljit_emit_op1 and sljit_emit_op2. */ + SLJIT_IMOV and SLJIT_IMOVU (SLJIT_MOV_SI/SLJIT_MOVU_SI with SLJIT_INT_OP flag) + which can convert any source argument to SLJIT_INT_OP compatible result. This + conversion might be unnecessary on some CPUs like x86-64, since the upper 32 + bit is always ignored. In this case SLJIT is clever enough to not generate any + instructions if the source and destination operands are the same registers. + Affects sljit_emit_op0, sljit_emit_op1 and sljit_emit_op2. */ #define SLJIT_INT_OP 0x100 /* Single precision mode (SP). This flag is similar to SLJIT_INT_OP, just @@ -525,10 +531,10 @@ /* Set Equal (Zero) status flag (E). */ #define SLJIT_SET_E 0x0200 +/* Set unsigned status flag (U). */ +#define SLJIT_SET_U 0x0400 /* Set signed status flag (S). */ -#define SLJIT_SET_S 0x0400 -/* Set unsgined status flag (U). */ -#define SLJIT_SET_U 0x0800 +#define SLJIT_SET_S 0x0800 /* Set signed overflow flag (O). */ #define SLJIT_SET_O 0x1000 /* Set carry flag (C). @@ -575,7 +581,7 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op); /* Notes for MOV instructions: - U = Mov with update (post form). If source or destination defined as SLJIT_MEM1(r1) + U = Mov with update (pre form). If source or destination defined as SLJIT_MEM1(r1) or SLJIT_MEM2(r1, r2), r1 is increased by the sum of r2 and the constant argument UB = unsigned byte (8 bit) SB = signed byte (8 bit) @@ -602,7 +608,7 @@ /* Flags: I - (never set any flags) Note: see SLJIT_INT_OP for further details. */ #define SLJIT_MOV_UI 11 -/* No SLJIT_INT_OP form, since it the same as SLJIT_IMOVU. */ +/* No SLJIT_INT_OP form, since it is the same as SLJIT_IMOV. */ /* Flags: I - (never set any flags) Note: see SLJIT_INT_OP for further details. */ #define SLJIT_MOV_SI 12 @@ -626,7 +632,7 @@ /* Flags: I - (never set any flags) Note: see SLJIT_INT_OP for further details. */ #define SLJIT_MOVU_UI 19 -/* No SLJIT_INT_OP form, since it the same as SLJIT_IMOVU. */ +/* No SLJIT_INT_OP form, since it is the same as SLJIT_IMOVU. */ /* Flags: I - (never set any flags) Note: see SLJIT_INT_OP for further details. */ #define SLJIT_MOVU_SI 20 @@ -656,7 +662,7 @@ /* Flags: I | C | K */ #define SLJIT_ADDC 26 #define SLJIT_IADDC (SLJIT_ADDC | SLJIT_INT_OP) -/* Flags: I | E | S | U | O | C | K */ +/* Flags: I | E | U | S | O | C | K */ #define SLJIT_SUB 27 #define SLJIT_ISUB (SLJIT_SUB | SLJIT_INT_OP) /* Flags: I | C | K */ @@ -851,8 +857,7 @@ /* Set the destination of the jump to this label. */ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label); -/* Only for jumps defined with SLJIT_REWRITABLE_JUMP flag. - Note: use sljit_emit_ijump for fixed jumps. */ +/* Set the destination address of the jump to this label. */ SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target); /* Call function or jump anywhere. Both direct and indirect form diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitNativePPC_32.c r-base-3.1.1/src/extra/pcre/sljit/sljitNativePPC_32.c --- r-base-3.1.0/src/extra/pcre/sljit/sljitNativePPC_32.c 2013-02-04 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitNativePPC_32.c 2014-04-20 22:15:03.000000000 +0000 @@ -32,7 +32,7 @@ return push_inst(compiler, ADDI | D(reg) | A(0) | IMM(imm)); if (!(imm & ~0xffff)) - return push_inst(compiler, ORI | S(ZERO_REG) | A(reg) | IMM(imm)); + return push_inst(compiler, ORI | S(TMP_ZERO) | A(reg) | IMM(imm)); FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(imm >> 16))); return (imm & 0xffff) ? push_inst(compiler, ORI | S(reg) | A(reg) | IMM(imm)) : SLJIT_SUCCESS; diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitNativePPC_64.c r-base-3.1.1/src/extra/pcre/sljit/sljitNativePPC_64.c --- r-base-3.1.0/src/extra/pcre/sljit/sljitNativePPC_64.c 2013-02-04 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitNativePPC_64.c 2014-04-20 22:15:03.000000000 +0000 @@ -52,9 +52,9 @@ return push_inst(compiler, ADDI | D(reg) | A(0) | IMM(imm)); if (!(imm & ~0xffff)) - return push_inst(compiler, ORI | S(ZERO_REG) | A(reg) | IMM(imm)); + return push_inst(compiler, ORI | S(TMP_ZERO) | A(reg) | IMM(imm)); - if (imm <= SLJIT_W(0x7fffffff) && imm >= SLJIT_W(-0x80000000)) { + if (imm <= 0x7fffffffl && imm >= -0x80000000l) { FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(imm >> 16))); return (imm & 0xffff) ? push_inst(compiler, ORI | S(reg) | A(reg) | IMM(imm)) : SLJIT_SUCCESS; } diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitNativePPC_common.c r-base-3.1.1/src/extra/pcre/sljit/sljitNativePPC_common.c --- r-base-3.1.0/src/extra/pcre/sljit/sljitNativePPC_common.c 2013-06-05 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitNativePPC_common.c 2014-04-20 22:15:03.000000000 +0000 @@ -33,10 +33,19 @@ Both for ppc-32 and ppc-64. */ typedef sljit_ui sljit_ins; +#if ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && (defined _AIX)) \ + || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) +#define SLJIT_PPC_STACK_FRAME_V2 1 +#endif + #ifdef _AIX #include #endif +#if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN) +#define SLJIT_PASS_ENTRY_ADDR_TO_CALL 1 +#endif + static void ppc_cache_flush(sljit_ins *from, sljit_ins *to) { #ifdef _AIX @@ -81,13 +90,19 @@ #define TMP_REG1 (SLJIT_NO_REGISTERS + 1) #define TMP_REG2 (SLJIT_NO_REGISTERS + 2) #define TMP_REG3 (SLJIT_NO_REGISTERS + 3) -#define ZERO_REG (SLJIT_NO_REGISTERS + 4) +#define TMP_ZERO (SLJIT_NO_REGISTERS + 4) + +#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL) +#define TMP_CALL_REG (SLJIT_NO_REGISTERS + 5) +#else +#define TMP_CALL_REG TMP_REG2 +#endif #define TMP_FREG1 (0) #define TMP_FREG2 (SLJIT_FLOAT_REG6 + 1) -static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 5] = { - 0, 3, 4, 5, 6, 7, 30, 29, 28, 27, 26, 1, 8, 9, 10, 31 +static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 6] = { + 0, 3, 4, 5, 6, 7, 30, 29, 28, 27, 26, 1, 8, 9, 10, 31, 12 }; /* --------------------------------------------------------------------- */ @@ -224,13 +239,19 @@ return SLJIT_SUCCESS; } -static SLJIT_INLINE sljit_si optimize_jump(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code) +static SLJIT_INLINE sljit_si detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code) { sljit_sw diff; sljit_uw target_addr; + sljit_sw extra_jump_flags; +#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL) && (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) + if (jump->flags & (SLJIT_REWRITABLE_JUMP | IS_CALL)) + return 0; +#else if (jump->flags & SLJIT_REWRITABLE_JUMP) return 0; +#endif if (jump->flags & JUMP_ADDR) target_addr = jump->u.target; @@ -238,28 +259,52 @@ SLJIT_ASSERT(jump->flags & JUMP_LABEL); target_addr = (sljit_uw)(code + jump->u.label->size); } + +#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL) && (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + if (jump->flags & IS_CALL) + goto keep_address; +#endif + diff = ((sljit_sw)target_addr - (sljit_sw)(code_ptr)) & ~0x3l; - if (jump->flags & UNCOND_B) { - if (diff <= 0x01ffffff && diff >= -0x02000000) { - jump->flags |= PATCH_B; - return 1; - } - if (target_addr <= 0x03ffffff) { - jump->flags |= PATCH_B | ABSOLUTE_B; - return 1; - } - } - else { + extra_jump_flags = 0; + if (jump->flags & IS_COND) { if (diff <= 0x7fff && diff >= -0x8000) { jump->flags |= PATCH_B; return 1; } if (target_addr <= 0xffff) { - jump->flags |= PATCH_B | ABSOLUTE_B; + jump->flags |= PATCH_B | PATCH_ABS_B; return 1; } + extra_jump_flags = REMOVE_COND; + + diff -= sizeof(sljit_ins); + } + + if (diff <= 0x01ffffff && diff >= -0x02000000) { + jump->flags |= PATCH_B | extra_jump_flags; + return 1; } + if (target_addr <= 0x03ffffff) { + jump->flags |= PATCH_B | PATCH_ABS_B | extra_jump_flags; + return 1; + } + +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) +#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL) +keep_address: +#endif + if (target_addr <= 0x7fffffff) { + jump->flags |= PATCH_ABS32; + return 1; + } + if (target_addr <= 0x7fffffffffffl) { + jump->flags |= PATCH_ABS48; + return 1; + } +#endif + return 0; } @@ -318,19 +363,42 @@ #else jump->addr = (sljit_uw)(code_ptr - 6); #endif - if (optimize_jump(jump, code_ptr, code)) { + if (detect_jump_type(jump, code_ptr, code)) { #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) code_ptr[-3] = code_ptr[0]; code_ptr -= 3; #else - code_ptr[-6] = code_ptr[0]; - code_ptr -= 6; + if (jump->flags & PATCH_ABS32) { + code_ptr -= 3; + code_ptr[-1] = code_ptr[2]; + code_ptr[0] = code_ptr[3]; + } + else if (jump->flags & PATCH_ABS48) { + code_ptr--; + code_ptr[-1] = code_ptr[0]; + code_ptr[0] = code_ptr[1]; + /* rldicr rX,rX,32,31 -> rX,rX,16,47 */ + SLJIT_ASSERT((code_ptr[-3] & 0xfc00ffff) == 0x780007c6); + code_ptr[-3] ^= 0x8422; + /* oris -> ori */ + code_ptr[-2] ^= 0x4000000; + } + else { + code_ptr[-6] = code_ptr[0]; + code_ptr -= 6; + } #endif + if (jump->flags & REMOVE_COND) { + code_ptr[0] = BCx | (2 << 2) | ((code_ptr[0] ^ (8 << 21)) & 0x03ff0001); + code_ptr++; + jump->addr += sizeof(sljit_ins); + code_ptr[0] = Bx; + jump->flags -= IS_COND; + } } jump = jump->next; } if (const_ && const_->addr == word_count) { - /* Just recording the address. */ const_->addr = (sljit_uw)code_ptr; const_ = const_->next; } @@ -362,29 +430,27 @@ addr = (jump->flags & JUMP_LABEL) ? jump->u.label->addr : jump->u.target; buf_ptr = (sljit_ins*)jump->addr; if (jump->flags & PATCH_B) { - if (jump->flags & UNCOND_B) { - if (!(jump->flags & ABSOLUTE_B)) { + if (jump->flags & IS_COND) { + if (!(jump->flags & PATCH_ABS_B)) { addr = addr - jump->addr; - SLJIT_ASSERT((sljit_sw)addr <= 0x01ffffff && (sljit_sw)addr >= -0x02000000); - *buf_ptr = Bx | (addr & 0x03fffffc) | ((*buf_ptr) & 0x1); + SLJIT_ASSERT((sljit_sw)addr <= 0x7fff && (sljit_sw)addr >= -0x8000); + *buf_ptr = BCx | (addr & 0xfffc) | ((*buf_ptr) & 0x03ff0001); } else { - SLJIT_ASSERT(addr <= 0x03ffffff); - *buf_ptr = Bx | (addr & 0x03fffffc) | 0x2 | ((*buf_ptr) & 0x1); + SLJIT_ASSERT(addr <= 0xffff); + *buf_ptr = BCx | (addr & 0xfffc) | 0x2 | ((*buf_ptr) & 0x03ff0001); } } else { - if (!(jump->flags & ABSOLUTE_B)) { + if (!(jump->flags & PATCH_ABS_B)) { addr = addr - jump->addr; - SLJIT_ASSERT((sljit_sw)addr <= 0x7fff && (sljit_sw)addr >= -0x8000); - *buf_ptr = BCx | (addr & 0xfffc) | ((*buf_ptr) & 0x03ff0001); + SLJIT_ASSERT((sljit_sw)addr <= 0x01ffffff && (sljit_sw)addr >= -0x02000000); + *buf_ptr = Bx | (addr & 0x03fffffc) | ((*buf_ptr) & 0x1); } else { - addr = addr & ~0x3l; - SLJIT_ASSERT(addr <= 0xffff); - *buf_ptr = BCx | (addr & 0xfffc) | 0x2 | ((*buf_ptr) & 0x03ff0001); + SLJIT_ASSERT(addr <= 0x03ffffff); + *buf_ptr = Bx | (addr & 0x03fffffc) | 0x2 | ((*buf_ptr) & 0x1); } - } break; } @@ -393,6 +459,19 @@ buf_ptr[0] = (buf_ptr[0] & 0xffff0000) | ((addr >> 16) & 0xffff); buf_ptr[1] = (buf_ptr[1] & 0xffff0000) | (addr & 0xffff); #else + if (jump->flags & PATCH_ABS32) { + SLJIT_ASSERT(addr <= 0x7fffffff); + buf_ptr[0] = (buf_ptr[0] & 0xffff0000) | ((addr >> 16) & 0xffff); + buf_ptr[1] = (buf_ptr[1] & 0xffff0000) | (addr & 0xffff); + break; + } + if (jump->flags & PATCH_ABS48) { + SLJIT_ASSERT(addr <= 0x7fffffffffff); + buf_ptr[0] = (buf_ptr[0] & 0xffff0000) | ((addr >> 32) & 0xffff); + buf_ptr[1] = (buf_ptr[1] & 0xffff0000) | ((addr >> 16) & 0xffff); + buf_ptr[3] = (buf_ptr[3] & 0xffff0000) | (addr & 0xffff); + break; + } buf_ptr[0] = (buf_ptr[0] & 0xffff0000) | ((addr >> 48) & 0xffff); buf_ptr[1] = (buf_ptr[1] & 0xffff0000) | ((addr >> 32) & 0xffff); buf_ptr[3] = (buf_ptr[3] & 0xffff0000) | ((addr >> 16) & 0xffff); @@ -498,7 +577,7 @@ #endif FAIL_IF(push_inst(compiler, MFLR | D(0))); - FAIL_IF(push_inst(compiler, STACK_STORE | S(ZERO_REG) | A(SLJIT_LOCALS_REG) | IMM(-(sljit_si)(sizeof(sljit_sw))) )); + FAIL_IF(push_inst(compiler, STACK_STORE | S(TMP_ZERO) | A(SLJIT_LOCALS_REG) | IMM(-(sljit_si)(sizeof(sljit_sw))) )); if (saveds >= 1) FAIL_IF(push_inst(compiler, STACK_STORE | S(SLJIT_SAVED_REG1) | A(SLJIT_LOCALS_REG) | IMM(-2 * (sljit_si)(sizeof(sljit_sw))) )); if (saveds >= 2) @@ -509,9 +588,13 @@ FAIL_IF(push_inst(compiler, STACK_STORE | S(SLJIT_SAVED_EREG1) | A(SLJIT_LOCALS_REG) | IMM(-5 * (sljit_si)(sizeof(sljit_sw))) )); if (saveds >= 5) FAIL_IF(push_inst(compiler, STACK_STORE | S(SLJIT_SAVED_EREG2) | A(SLJIT_LOCALS_REG) | IMM(-6 * (sljit_si)(sizeof(sljit_sw))) )); +#if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2) + FAIL_IF(push_inst(compiler, STACK_STORE | S(0) | A(SLJIT_LOCALS_REG) | IMM(2 * sizeof(sljit_sw)) )); +#else FAIL_IF(push_inst(compiler, STACK_STORE | S(0) | A(SLJIT_LOCALS_REG) | IMM(sizeof(sljit_sw)) )); +#endif - FAIL_IF(push_inst(compiler, ADDI | D(ZERO_REG) | A(0) | 0)); + FAIL_IF(push_inst(compiler, ADDI | D(TMP_ZERO) | A(0) | 0)); if (args >= 1) FAIL_IF(push_inst(compiler, OR | S(SLJIT_SCRATCH_REG1) | A(SLJIT_SAVED_REG1) | B(SLJIT_SCRATCH_REG1))); if (args >= 2) @@ -519,7 +602,7 @@ if (args >= 3) FAIL_IF(push_inst(compiler, OR | S(SLJIT_SCRATCH_REG3) | A(SLJIT_SAVED_REG3) | B(SLJIT_SCRATCH_REG3))); -#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) +#if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2) compiler->local_size = (1 + saveds + 6 + 8) * sizeof(sljit_sw) + local_size; #else compiler->local_size = (1 + saveds + 2) * sizeof(sljit_sw) + local_size; @@ -556,7 +639,7 @@ compiler->logical_local_size = local_size; #endif -#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) +#if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2) compiler->local_size = (1 + saveds + 6 + 8) * sizeof(sljit_sw) + local_size; #else compiler->local_size = (1 + saveds + 2) * sizeof(sljit_sw) + local_size; @@ -578,7 +661,11 @@ FAIL_IF(push_inst(compiler, ADD | D(SLJIT_LOCALS_REG) | A(SLJIT_LOCALS_REG) | B(0))); } +#if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2) + FAIL_IF(push_inst(compiler, STACK_LOAD | D(0) | A(SLJIT_LOCALS_REG) | IMM(2 * sizeof(sljit_sw)))); +#else FAIL_IF(push_inst(compiler, STACK_LOAD | D(0) | A(SLJIT_LOCALS_REG) | IMM(sizeof(sljit_sw)))); +#endif if (compiler->saveds >= 5) FAIL_IF(push_inst(compiler, STACK_LOAD | D(SLJIT_SAVED_EREG2) | A(SLJIT_LOCALS_REG) | IMM(-6 * (sljit_si)(sizeof(sljit_sw))) )); if (compiler->saveds >= 4) @@ -589,7 +676,7 @@ FAIL_IF(push_inst(compiler, STACK_LOAD | D(SLJIT_SAVED_REG2) | A(SLJIT_LOCALS_REG) | IMM(-3 * (sljit_si)(sizeof(sljit_sw))) )); if (compiler->saveds >= 1) FAIL_IF(push_inst(compiler, STACK_LOAD | D(SLJIT_SAVED_REG1) | A(SLJIT_LOCALS_REG) | IMM(-2 * (sljit_si)(sizeof(sljit_sw))) )); - FAIL_IF(push_inst(compiler, STACK_LOAD | D(ZERO_REG) | A(SLJIT_LOCALS_REG) | IMM(-(sljit_si)(sizeof(sljit_sw))) )); + FAIL_IF(push_inst(compiler, STACK_LOAD | D(TMP_ZERO) | A(SLJIT_LOCALS_REG) | IMM(-(sljit_si)(sizeof(sljit_sw))) )); FAIL_IF(push_inst(compiler, MTLR | S(0))); FAIL_IF(push_inst(compiler, BLR)); @@ -612,7 +699,7 @@ It contans 32 items, but not all are different. */ /* 64 bit only: [reg+imm] must be aligned to 4 bytes. */ -#define ADDR_MODE2 0x10000 +#define INT_ALIGNED 0x10000 /* 64-bit only: there is no lwau instruction. */ #define UPDATE_REQ 0x20000 @@ -623,7 +710,7 @@ #else #define ARCH_32_64(a, b) b #define INST_CODE_AND_DST(inst, flags, reg) \ - (((inst) & ~(ADDR_MODE2 | UPDATE_REQ)) | (((flags) & MEM_MASK) <= GPR_REG ? D(reg) : FD(reg))) + (((inst) & ~(INT_ALIGNED | UPDATE_REQ)) | (((flags) & MEM_MASK) <= GPR_REG ? D(reg) : FD(reg))) #endif static SLJIT_CONST sljit_ins data_transfer_insts[64 + 8] = { @@ -632,13 +719,13 @@ /* Word. */ -/* u w n i s */ ARCH_32_64(HI(36) /* stw */, HI(62) | ADDR_MODE2 | 0x0 /* std */), -/* u w n i l */ ARCH_32_64(HI(32) /* lwz */, HI(58) | ADDR_MODE2 | 0x0 /* ld */), +/* u w n i s */ ARCH_32_64(HI(36) /* stw */, HI(62) | INT_ALIGNED | 0x0 /* std */), +/* u w n i l */ ARCH_32_64(HI(32) /* lwz */, HI(58) | INT_ALIGNED | 0x0 /* ld */), /* u w n x s */ ARCH_32_64(HI(31) | LO(151) /* stwx */, HI(31) | LO(149) /* stdx */), /* u w n x l */ ARCH_32_64(HI(31) | LO(23) /* lwzx */, HI(31) | LO(21) /* ldx */), -/* u w w i s */ ARCH_32_64(HI(37) /* stwu */, HI(62) | ADDR_MODE2 | 0x1 /* stdu */), -/* u w w i l */ ARCH_32_64(HI(33) /* lwzu */, HI(58) | ADDR_MODE2 | 0x1 /* ldu */), +/* u w w i s */ ARCH_32_64(HI(37) /* stwu */, HI(62) | INT_ALIGNED | 0x1 /* stdu */), +/* u w w i l */ ARCH_32_64(HI(33) /* lwzu */, HI(58) | INT_ALIGNED | 0x1 /* ldu */), /* u w w x s */ ARCH_32_64(HI(31) | LO(183) /* stwux */, HI(31) | LO(181) /* stdux */), /* u w w x l */ ARCH_32_64(HI(31) | LO(55) /* lwzux */, HI(31) | LO(53) /* ldux */), @@ -682,13 +769,13 @@ /* Word. */ -/* s w n i s */ ARCH_32_64(HI(36) /* stw */, HI(62) | ADDR_MODE2 | 0x0 /* std */), -/* s w n i l */ ARCH_32_64(HI(32) /* lwz */, HI(58) | ADDR_MODE2 | 0x0 /* ld */), +/* s w n i s */ ARCH_32_64(HI(36) /* stw */, HI(62) | INT_ALIGNED | 0x0 /* std */), +/* s w n i l */ ARCH_32_64(HI(32) /* lwz */, HI(58) | INT_ALIGNED | 0x0 /* ld */), /* s w n x s */ ARCH_32_64(HI(31) | LO(151) /* stwx */, HI(31) | LO(149) /* stdx */), /* s w n x l */ ARCH_32_64(HI(31) | LO(23) /* lwzx */, HI(31) | LO(21) /* ldx */), -/* s w w i s */ ARCH_32_64(HI(37) /* stwu */, HI(62) | ADDR_MODE2 | 0x1 /* stdu */), -/* s w w i l */ ARCH_32_64(HI(33) /* lwzu */, HI(58) | ADDR_MODE2 | 0x1 /* ldu */), +/* s w w i s */ ARCH_32_64(HI(37) /* stwu */, HI(62) | INT_ALIGNED | 0x1 /* stdu */), +/* s w w i l */ ARCH_32_64(HI(33) /* lwzu */, HI(58) | INT_ALIGNED | 0x1 /* ldu */), /* s w w x s */ ARCH_32_64(HI(31) | LO(183) /* stwux */, HI(31) | LO(181) /* stdux */), /* s w w x l */ ARCH_32_64(HI(31) | LO(55) /* lwzux */, HI(31) | LO(53) /* ldux */), @@ -719,12 +806,12 @@ /* Int. */ /* s i n i s */ HI(36) /* stw */, -/* s i n i l */ ARCH_32_64(HI(32) /* lwz */, HI(58) | ADDR_MODE2 | 0x2 /* lwa */), +/* s i n i l */ ARCH_32_64(HI(32) /* lwz */, HI(58) | INT_ALIGNED | 0x2 /* lwa */), /* s i n x s */ HI(31) | LO(151) /* stwx */, /* s i n x l */ ARCH_32_64(HI(31) | LO(23) /* lwzx */, HI(31) | LO(341) /* lwax */), /* s i w i s */ HI(37) /* stwu */, -/* s i w i l */ ARCH_32_64(HI(33) /* lwzu */, HI(58) | ADDR_MODE2 | UPDATE_REQ | 0x2 /* lwa */), +/* s i w i l */ ARCH_32_64(HI(33) /* lwzu */, HI(58) | INT_ALIGNED | UPDATE_REQ | 0x2 /* lwa */), /* s i w x s */ HI(31) | LO(183) /* stwux */, /* s i w x l */ ARCH_32_64(HI(31) | LO(55) /* lwzux */, HI(31) | LO(373) /* lwaux */), @@ -748,74 +835,48 @@ static sljit_si getput_arg_fast(struct sljit_compiler *compiler, sljit_si inp_flags, sljit_si reg, sljit_si arg, sljit_sw argw) { sljit_ins inst; -#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) - sljit_si tmp_reg; -#endif + /* Should work when (arg & REG_MASK) == 0. */ + SLJIT_COMPILE_ASSERT(A(0) == 0, a0_must_be_0); SLJIT_ASSERT(arg & SLJIT_MEM); - if (!(arg & 0xf)) { -#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) - if (argw <= SIMM_MAX && argw >= SIMM_MIN) { - if (inp_flags & ARG_TEST) - return 1; - - inst = data_transfer_insts[(inp_flags & ~WRITE_BACK) & MEM_MASK]; - SLJIT_ASSERT(!(inst & (ADDR_MODE2 | UPDATE_REQ))); - push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | IMM(argw)); - return -1; - } -#else - inst = data_transfer_insts[(inp_flags & ~WRITE_BACK) & MEM_MASK]; - if (argw <= SIMM_MAX && argw >= SIMM_MIN && - (!(inst & ADDR_MODE2) || (argw & 0x3) == 0)) { - if (inp_flags & ARG_TEST) - return 1; - push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | IMM(argw)); - return -1; - } -#endif - return 0; - } - - if (!(arg & 0xf0)) { -#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) - if (argw <= SIMM_MAX && argw >= SIMM_MIN) { - if (inp_flags & ARG_TEST) - return 1; - - inst = data_transfer_insts[inp_flags & MEM_MASK]; - SLJIT_ASSERT(!(inst & (ADDR_MODE2 | UPDATE_REQ))); - push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & 0xf) | IMM(argw)); - return -1; - } -#else - inst = data_transfer_insts[inp_flags & MEM_MASK]; - if (argw <= SIMM_MAX && argw >= SIMM_MIN && (!(inst & ADDR_MODE2) || (argw & 0x3) == 0)) { - if (inp_flags & ARG_TEST) - return 1; - - if ((inp_flags & WRITE_BACK) && (inst & UPDATE_REQ)) { - tmp_reg = (inp_flags & LOAD_DATA) ? (arg & 0xf) : TMP_REG3; - if (push_inst(compiler, ADDI | D(tmp_reg) | A(arg & 0xf) | IMM(argw))) - return -1; - arg = tmp_reg | SLJIT_MEM; - argw = 0; - } - push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & 0xf) | IMM(argw)); - return -1; - } -#endif - } - else if (!(argw & 0x3)) { + if (arg & OFFS_REG_MASK) { + if (argw & 0x3) + return 0; if (inp_flags & ARG_TEST) return 1; + inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK]; - SLJIT_ASSERT(!(inst & (ADDR_MODE2 | UPDATE_REQ))); - push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & 0xf) | B((arg >> 4) & 0xf)); + SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ))); + FAIL_IF(push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(OFFS_REG(arg)))); return -1; } - return 0; + + if (SLJIT_UNLIKELY(!(arg & REG_MASK))) + inp_flags &= ~WRITE_BACK; + +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + inst = data_transfer_insts[inp_flags & MEM_MASK]; + SLJIT_ASSERT((arg & REG_MASK) || !(inst & UPDATE_REQ)); + + if (argw > SIMM_MAX || argw < SIMM_MIN || ((inst & INT_ALIGNED) && (argw & 0x3)) || (inst & UPDATE_REQ)) + return 0; + if (inp_flags & ARG_TEST) + return 1; +#endif + +#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) + if (argw > SIMM_MAX || argw < SIMM_MIN) + return 0; + if (inp_flags & ARG_TEST) + return 1; + + inst = data_transfer_insts[inp_flags & MEM_MASK]; + SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ))); +#endif + + FAIL_IF(push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | IMM(argw))); + return -1; } /* See getput_arg below. @@ -823,35 +884,50 @@ uses word arguments without write back. */ static sljit_si can_cache(sljit_si arg, sljit_sw argw, sljit_si next_arg, sljit_sw next_argw) { + sljit_sw high_short, next_high_short; +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + sljit_sw diff; +#endif + SLJIT_ASSERT((arg & SLJIT_MEM) && (next_arg & SLJIT_MEM)); - if (!(arg & 0xf)) - return (next_arg & SLJIT_MEM) && ((sljit_uw)argw - (sljit_uw)next_argw <= SIMM_MAX || (sljit_uw)next_argw - (sljit_uw)argw <= SIMM_MAX); + if (arg & OFFS_REG_MASK) + return ((arg & OFFS_REG_MASK) == (next_arg & OFFS_REG_MASK) && (argw & 0x3) == (next_argw & 0x3)); - if (arg & 0xf0) - return ((arg & 0xf0) == (next_arg & 0xf0) && (argw & 0x3) == (next_argw & 0x3)); + if (next_arg & OFFS_REG_MASK) + return 0; - if (argw <= SIMM_MAX && argw >= SIMM_MIN) { - if (arg == next_arg && (next_argw >= SIMM_MAX && next_argw <= SIMM_MIN)) +#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) + high_short = (argw + ((argw & 0x8000) << 1)) & ~0xffff; + next_high_short = (next_argw + ((next_argw & 0x8000) << 1)) & ~0xffff; + return high_short == next_high_short; +#else + if (argw <= 0x7fffffffl && argw >= -0x80000000l) { + high_short = (argw + ((argw & 0x8000) << 1)) & ~0xffff; + next_high_short = (next_argw + ((next_argw & 0x8000) << 1)) & ~0xffff; + if (high_short == next_high_short) return 1; } - if (arg == next_arg && ((sljit_uw)argw - (sljit_uw)next_argw <= SIMM_MAX || (sljit_uw)next_argw - (sljit_uw)argw <= SIMM_MAX)) + diff = argw - next_argw; + if (!(arg & REG_MASK)) + return diff <= SIMM_MAX && diff >= SIMM_MIN; + + if (arg == next_arg && diff <= SIMM_MAX && diff >= SIMM_MIN) return 1; return 0; +#endif } #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) #define ADJUST_CACHED_IMM(imm) \ - if ((inst & ADDR_MODE2) && (imm & 0x3)) { \ + if ((inst & INT_ALIGNED) && (imm & 0x3)) { \ /* Adjust cached value. Fortunately this is really a rare case */ \ compiler->cache_argw += imm & 0x3; \ FAIL_IF(push_inst(compiler, ADDI | D(TMP_REG3) | A(TMP_REG3) | (imm & 0x3))); \ imm &= ~0x3; \ } -#else -#define ADJUST_CACHED_IMM(imm) #endif /* Emit the necessary instructions. See can_cache above. */ @@ -859,72 +935,125 @@ { sljit_si tmp_r; sljit_ins inst; + sljit_sw high_short, next_high_short; +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + sljit_sw diff; +#endif SLJIT_ASSERT(arg & SLJIT_MEM); tmp_r = ((inp_flags & LOAD_DATA) && ((inp_flags) & MEM_MASK) <= GPR_REG) ? reg : TMP_REG1; /* Special case for "mov reg, [reg, ... ]". */ - if ((arg & 0xf) == tmp_r) + if ((arg & REG_MASK) == tmp_r) tmp_r = TMP_REG1; - if (!(arg & 0xf)) { - inst = data_transfer_insts[(inp_flags & ~WRITE_BACK) & MEM_MASK]; - if ((compiler->cache_arg & SLJIT_IMM) && (((sljit_uw)argw - (sljit_uw)compiler->cache_argw) <= SIMM_MAX || ((sljit_uw)compiler->cache_argw - (sljit_uw)argw) <= SIMM_MAX)) { - argw = argw - compiler->cache_argw; - ADJUST_CACHED_IMM(argw); - SLJIT_ASSERT(!(inst & UPDATE_REQ)); - return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(TMP_REG3) | IMM(argw)); - } - - if ((next_arg & SLJIT_MEM) && (argw - next_argw <= SIMM_MAX || next_argw - argw <= SIMM_MAX)) { - SLJIT_ASSERT(inp_flags & LOAD_DATA); - - compiler->cache_arg = SLJIT_IMM; - compiler->cache_argw = argw; - tmp_r = TMP_REG3; - } - - FAIL_IF(load_immediate(compiler, tmp_r, argw)); - return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(tmp_r)); - } - - if (SLJIT_UNLIKELY(arg & 0xf0)) { + if (SLJIT_UNLIKELY(arg & OFFS_REG_MASK)) { argw &= 0x3; /* Otherwise getput_arg_fast would capture it. */ SLJIT_ASSERT(argw); - if ((SLJIT_MEM | (arg & 0xf0)) == compiler->cache_arg && argw == compiler->cache_argw) + if ((SLJIT_MEM | (arg & OFFS_REG_MASK)) == compiler->cache_arg && argw == compiler->cache_argw) tmp_r = TMP_REG3; else { - if ((arg & 0xf0) == (next_arg & 0xf0) && argw == (next_argw & 0x3)) { - compiler->cache_arg = SLJIT_MEM | (arg & 0xf0); + if ((arg & OFFS_REG_MASK) == (next_arg & OFFS_REG_MASK) && argw == (next_argw & 0x3)) { + compiler->cache_arg = SLJIT_MEM | (arg & OFFS_REG_MASK); compiler->cache_argw = argw; tmp_r = TMP_REG3; } #if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) - FAIL_IF(push_inst(compiler, RLWINM | S((arg >> 4) & 0xf) | A(tmp_r) | (argw << 11) | ((31 - argw) << 1))); + FAIL_IF(push_inst(compiler, RLWINM | S(OFFS_REG(arg)) | A(tmp_r) | (argw << 11) | ((31 - argw) << 1))); #else - FAIL_IF(push_inst(compiler, RLDI(tmp_r, (arg >> 4) & 0xf, argw, 63 - argw, 1))); + FAIL_IF(push_inst(compiler, RLDI(tmp_r, OFFS_REG(arg), argw, 63 - argw, 1))); #endif } inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK]; - SLJIT_ASSERT(!(inst & (ADDR_MODE2 | UPDATE_REQ))); - return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & 0xf) | B(tmp_r)); + SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ))); + return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(tmp_r)); } + if (SLJIT_UNLIKELY(!(arg & REG_MASK))) + inp_flags &= ~WRITE_BACK; + inst = data_transfer_insts[inp_flags & MEM_MASK]; + SLJIT_ASSERT((arg & REG_MASK) || !(inst & UPDATE_REQ)); + +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + if (argw <= 0x7fff7fffl && argw >= -0x80000000l + && (!(inst & INT_ALIGNED) || !(argw & 0x3)) && !(inst & UPDATE_REQ)) { +#endif + + arg &= REG_MASK; + high_short = (sljit_si)(argw + ((argw & 0x8000) << 1)) & ~0xffff; + /* The getput_arg_fast should handle this otherwise. */ +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + SLJIT_ASSERT(high_short && high_short <= 0x7fffffffl && high_short >= -0x80000000l); +#else + SLJIT_ASSERT(high_short && !(inst & (INT_ALIGNED | UPDATE_REQ))); +#endif + + if (inp_flags & WRITE_BACK) { + if (arg == reg) { + FAIL_IF(push_inst(compiler, OR | S(reg) | A(tmp_r) | B(reg))); + reg = tmp_r; + } + tmp_r = arg; + FAIL_IF(push_inst(compiler, ADDIS | D(arg) | A(arg) | IMM(high_short >> 16))); + } + else if (compiler->cache_arg != arg || high_short != compiler->cache_argw) { + if ((next_arg & SLJIT_MEM) && !(next_arg & OFFS_REG_MASK)) { + next_high_short = (sljit_si)(next_argw + ((next_argw & 0x8000) << 1)) & ~0xffff; + if (high_short == next_high_short) { + compiler->cache_arg = SLJIT_IMM | arg; + compiler->cache_argw = next_high_short; + tmp_r = TMP_REG3; + } + } + FAIL_IF(push_inst(compiler, ADDIS | D(tmp_r) | A(arg & REG_MASK) | IMM(high_short >> 16))); + } + else + tmp_r = TMP_REG3; + + return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(tmp_r) | IMM(argw)); + +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + } + + /* Everything else is PPC-64 only. */ + if (SLJIT_UNLIKELY(!(arg & REG_MASK))) { + diff = argw - compiler->cache_argw; + if ((compiler->cache_arg & SLJIT_IMM) && diff <= SIMM_MAX && diff >= SIMM_MIN) { + ADJUST_CACHED_IMM(diff); + return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(TMP_REG3) | IMM(diff)); + } + + diff = argw - next_argw; + if ((next_arg & SLJIT_MEM) && diff <= SIMM_MAX && diff >= SIMM_MIN) { + SLJIT_ASSERT(inp_flags & LOAD_DATA); + + compiler->cache_arg = SLJIT_IMM; + compiler->cache_argw = argw; + tmp_r = TMP_REG3; + } + + FAIL_IF(load_immediate(compiler, tmp_r, argw)); + return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(tmp_r)); + } - if (compiler->cache_arg == arg && ((sljit_uw)argw - (sljit_uw)compiler->cache_argw <= SIMM_MAX || (sljit_uw)compiler->cache_argw - (sljit_uw)argw <= SIMM_MAX)) { - SLJIT_ASSERT(!(inp_flags & WRITE_BACK)); - argw = argw - compiler->cache_argw; - ADJUST_CACHED_IMM(argw); - return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(TMP_REG3) | IMM(argw)); + diff = argw - compiler->cache_argw; + if (compiler->cache_arg == arg && diff <= SIMM_MAX && diff >= SIMM_MIN) { + SLJIT_ASSERT(!(inp_flags & WRITE_BACK) && !(inst & UPDATE_REQ)); + ADJUST_CACHED_IMM(diff); + return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(TMP_REG3) | IMM(diff)); } - if ((compiler->cache_arg & SLJIT_IMM) && compiler->cache_argw == argw) { + if ((compiler->cache_arg & SLJIT_IMM) && diff <= SIMM_MAX && diff >= SIMM_MIN) { inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK]; - SLJIT_ASSERT(!(inst & (ADDR_MODE2 | UPDATE_REQ))); - return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & 0xf) | B(TMP_REG3)); + SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ))); + if (compiler->cache_argw != argw) { + FAIL_IF(push_inst(compiler, ADDI | D(TMP_REG3) | A(TMP_REG3) | IMM(diff))); + compiler->cache_argw = argw; + } + return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(TMP_REG3)); } if (argw == next_argw && (next_arg & SLJIT_MEM)) { @@ -935,14 +1064,15 @@ compiler->cache_argw = argw; inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK]; - SLJIT_ASSERT(!(inst & (ADDR_MODE2 | UPDATE_REQ))); - return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & 0xf) | B(TMP_REG3)); + SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ))); + return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(TMP_REG3)); } - if (arg == next_arg && !(inp_flags & WRITE_BACK) && ((sljit_uw)argw - (sljit_uw)next_argw <= SIMM_MAX || (sljit_uw)next_argw - (sljit_uw)argw <= SIMM_MAX)) { + diff = argw - next_argw; + if (arg == next_arg && !(inp_flags & WRITE_BACK) && diff <= SIMM_MAX && diff >= SIMM_MIN) { SLJIT_ASSERT(inp_flags & LOAD_DATA); FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); - FAIL_IF(push_inst(compiler, ADD | D(TMP_REG3) | A(TMP_REG3) | B(arg & 0xf))); + FAIL_IF(push_inst(compiler, ADD | D(TMP_REG3) | A(TMP_REG3) | B(arg & REG_MASK))); compiler->cache_arg = arg; compiler->cache_argw = argw; @@ -950,11 +1080,22 @@ return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(TMP_REG3)); } + if ((next_arg & SLJIT_MEM) && !(next_arg & OFFS_REG_MASK) && diff <= SIMM_MAX && diff >= SIMM_MIN) { + SLJIT_ASSERT(inp_flags & LOAD_DATA); + FAIL_IF(load_immediate(compiler, TMP_REG3, argw)); + + compiler->cache_arg = SLJIT_IMM; + compiler->cache_argw = argw; + tmp_r = TMP_REG3; + } + else + FAIL_IF(load_immediate(compiler, tmp_r, argw)); + /* Get the indexed version instead of the normal one. */ inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK]; - SLJIT_ASSERT(!(inst & (ADDR_MODE2 | UPDATE_REQ))); - FAIL_IF(load_immediate(compiler, tmp_r, argw)); - return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & 0xf) | B(tmp_r)); + SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ))); + return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(tmp_r)); +#endif } static SLJIT_INLINE sljit_si emit_op_mem2(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, sljit_si arg1, sljit_sw arg1w, sljit_si arg2, sljit_sw arg2w) @@ -990,7 +1131,7 @@ return SLJIT_SUCCESS; dst_r = TMP_REG2; } - else if (dst <= ZERO_REG) { + else if (FAST_IS_REG(dst)) { dst_r = dst; flags |= REG_DEST; if (op >= SLJIT_MOV && op <= SLJIT_MOVU_SI) @@ -1009,7 +1150,7 @@ } /* Source 1. */ - if (src1 <= ZERO_REG) { + if (FAST_IS_REG(src1)) { src1_r = src1; flags |= REG1_SOURCE; } @@ -1025,7 +1166,7 @@ src1_r = 0; /* Source 2. */ - if (src2 <= ZERO_REG) { + if (FAST_IS_REG(src2)) { src2_r = src2; flags |= REG2_SOURCE; if (!(flags & REG_DEST) && op >= SLJIT_MOV && op <= SLJIT_MOVU_SI) @@ -1095,38 +1236,42 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op) { +#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) + sljit_si int_op = op & SLJIT_INT_OP; +#endif + CHECK_ERROR(); check_sljit_emit_op0(compiler, op); - switch (GET_OPCODE(op)) { + op = GET_OPCODE(op); + switch (op) { case SLJIT_BREAKPOINT: case SLJIT_NOP: return push_inst(compiler, NOP); - break; case SLJIT_UMUL: case SLJIT_SMUL: FAIL_IF(push_inst(compiler, OR | S(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG1))); #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2))); - return push_inst(compiler, (GET_OPCODE(op) == SLJIT_UMUL ? MULHDU : MULHD) | D(SLJIT_SCRATCH_REG2) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2)); + return push_inst(compiler, (op == SLJIT_UMUL ? MULHDU : MULHD) | D(SLJIT_SCRATCH_REG2) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2)); #else FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2))); - return push_inst(compiler, (GET_OPCODE(op) == SLJIT_UMUL ? MULHWU : MULHW) | D(SLJIT_SCRATCH_REG2) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2)); + return push_inst(compiler, (op == SLJIT_UMUL ? MULHWU : MULHW) | D(SLJIT_SCRATCH_REG2) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2)); #endif case SLJIT_UDIV: case SLJIT_SDIV: FAIL_IF(push_inst(compiler, OR | S(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG1))); #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) - if (op & SLJIT_INT_OP) { - FAIL_IF(push_inst(compiler, (GET_OPCODE(op) == SLJIT_UDIV ? DIVWU : DIVW) | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2))); + if (int_op) { + FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVWU : DIVW) | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2))); FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG1) | B(SLJIT_SCRATCH_REG2))); - return push_inst(compiler, SUBF | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG2) | B(TMP_REG1)); + } else { + FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVDU : DIVD) | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2))); + FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG1) | B(SLJIT_SCRATCH_REG2))); } - FAIL_IF(push_inst(compiler, (GET_OPCODE(op) == SLJIT_UDIV ? DIVDU : DIVD) | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2))); - FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG1) | B(SLJIT_SCRATCH_REG2))); return push_inst(compiler, SUBF | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG2) | B(TMP_REG1)); #else - FAIL_IF(push_inst(compiler, (GET_OPCODE(op) == SLJIT_UDIV ? DIVWU : DIVW) | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2))); + FAIL_IF(push_inst(compiler, (op == SLJIT_UDIV ? DIVWU : DIVW) | D(SLJIT_SCRATCH_REG1) | A(TMP_REG1) | B(SLJIT_SCRATCH_REG2))); FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG1) | B(SLJIT_SCRATCH_REG2))); return push_inst(compiler, SUBF | D(SLJIT_SCRATCH_REG2) | A(SLJIT_SCRATCH_REG2) | B(TMP_REG1)); #endif @@ -1152,14 +1297,14 @@ op = GET_OPCODE(op); if ((src & SLJIT_IMM) && srcw == 0) - src = ZERO_REG; + src = TMP_ZERO; if (op_flags & SLJIT_SET_O) - FAIL_IF(push_inst(compiler, MTXER | S(ZERO_REG))); + FAIL_IF(push_inst(compiler, MTXER | S(TMP_ZERO))); if (op_flags & SLJIT_INT_OP) { - if (op >= SLJIT_MOV && op <= SLJIT_MOVU_P) { - if (src <= ZERO_REG && src == dst) { + if (op < SLJIT_NOT) { + if (FAST_IS_REG(src) && src == dst) { if (!TYPE_CAST_NEEDED(op)) return SLJIT_SUCCESS; } @@ -1268,7 +1413,7 @@ #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) #define TEST_SH_IMM(src, srcw) \ - (((src) & SLJIT_IMM) && !((srcw) & 0xffff) && (srcw) <= SLJIT_W(0x7fffffff) && (srcw) >= SLJIT_W(-0x80000000)) + (((src) & SLJIT_IMM) && !((srcw) & 0xffff) && (srcw) <= 0x7fffffffl && (srcw) >= -0x80000000l) #else #define TEST_SH_IMM(src, srcw) \ (((src) & SLJIT_IMM) && !((srcw) & 0xffff)) @@ -1279,7 +1424,7 @@ #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) #define TEST_ADD_IMM(src, srcw) \ - (((src) & SLJIT_IMM) && (srcw) <= SLJIT_W(0x7fff7fff) && (srcw) >= SLJIT_W(-0x80000000)) + (((src) & SLJIT_IMM) && (srcw) <= 0x7fff7fffl && (srcw) >= -0x80000000l) #else #define TEST_ADD_IMM(src, srcw) \ ((src) & SLJIT_IMM) @@ -1307,9 +1452,9 @@ ADJUST_LOCAL_OFFSET(src2, src2w); if ((src1 & SLJIT_IMM) && src1w == 0) - src1 = ZERO_REG; + src1 = TMP_ZERO; if ((src2 & SLJIT_IMM) && src2w == 0) - src2 = ZERO_REG; + src2 = TMP_ZERO; #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) if (op & SLJIT_INT_OP) { @@ -1324,7 +1469,7 @@ } #endif if (op & SLJIT_SET_O) - FAIL_IF(push_inst(compiler, MTXER | S(ZERO_REG))); + FAIL_IF(push_inst(compiler, MTXER | S(TMP_ZERO))); if (src2 == TMP_REG2) flags |= ALT_KEEP_CACHE; @@ -1392,7 +1537,7 @@ return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM4, dst, dstw, src1, src1w, TMP_REG2, 0); } } - if (dst == SLJIT_UNUSED && (op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U)) && !(op & (SLJIT_SET_O | SLJIT_SET_C))) { + if (dst == SLJIT_UNUSED && (op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S)) && !(op & (SLJIT_SET_O | SLJIT_SET_C))) { if (!(op & SLJIT_SET_U)) { /* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */ if (TEST_SL_IMM(src2, src2w)) { @@ -1418,7 +1563,7 @@ } return emit_op(compiler, SLJIT_SUB, flags | ((op & SLJIT_SET_U) ? ALT_FORM4 : 0) | ((op & (SLJIT_SET_E | SLJIT_SET_S)) ? ALT_FORM5 : 0), dst, dstw, src1, src1w, src2, src2w); } - if (!(op & (SLJIT_SET_E | SLJIT_SET_S | SLJIT_SET_U | SLJIT_SET_O))) { + if (!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O))) { if (TEST_SL_IMM(src2, -src2w)) { compiler->imm = (-src2w) & 0xffff; return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0); @@ -1529,8 +1674,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void) { - /* Always available. */ +#ifdef SLJIT_IS_FPU_AVAILABLE + return SLJIT_IS_FPU_AVAILABLE; +#else + /* Available by default. */ return 1; +#endif } #define FLOAT_DATA(op) (DOUBLE_DATA | ((op & SLJIT_SINGLE_OP) >> 6)) @@ -1550,12 +1699,12 @@ compiler->cache_argw = 0; if (GET_OPCODE(op) == SLJIT_CMPD) { - if (dst > SLJIT_FLOAT_REG6) { + if (dst & SLJIT_MEM) { FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, dst, dstw, src, srcw)); dst = TMP_FREG1; } - if (src > SLJIT_FLOAT_REG6) { + if (src & SLJIT_MEM) { FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src, srcw, 0, 0)); src = TMP_FREG2; } @@ -1563,9 +1712,9 @@ return push_inst(compiler, FCMPU | CRD(4) | FA(dst) | FB(src)); } - dst_fr = (dst > SLJIT_FLOAT_REG6) ? TMP_FREG1 : dst; + dst_fr = FAST_IS_REG(dst) ? dst : TMP_FREG1; - if (src > SLJIT_FLOAT_REG6) { + if (src & SLJIT_MEM) { FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, dst_fr, src, srcw, dst, dstw)); src = dst_fr; } @@ -1605,9 +1754,9 @@ compiler->cache_arg = 0; compiler->cache_argw = 0; - dst_fr = (dst > SLJIT_FLOAT_REG6) ? TMP_FREG2 : dst; + dst_fr = FAST_IS_REG(dst) ? dst : TMP_FREG2; - if (src1 > SLJIT_FLOAT_REG6) { + if (src1 & SLJIT_MEM) { if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w)) { FAIL_IF(compiler->error); src1 = TMP_FREG1; @@ -1615,7 +1764,7 @@ flags |= ALT_FORM1; } - if (src2 > SLJIT_FLOAT_REG6) { + if (src2 & SLJIT_MEM) { if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w)) { FAIL_IF(compiler->error); src2 = TMP_FREG2; @@ -1684,7 +1833,7 @@ if (dst == SLJIT_UNUSED) return SLJIT_SUCCESS; - if (dst <= ZERO_REG) + if (FAST_IS_REG(dst)) return push_inst(compiler, MFLR | D(dst)); /* Memory. */ @@ -1698,7 +1847,7 @@ check_sljit_emit_fast_return(compiler, src, srcw); ADJUST_LOCAL_OFFSET(src, srcw); - if (src <= ZERO_REG) + if (FAST_IS_REG(src)) FAIL_IF(push_inst(compiler, MTLR | S(src))); else { if (src & SLJIT_MEM) @@ -1811,11 +1960,15 @@ type &= 0xff; /* In PPC, we don't need to touch the arguments. */ - if (type >= SLJIT_JUMP) - jump->flags |= UNCOND_B; + if (type < SLJIT_JUMP) + jump->flags |= IS_COND; +#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL) + if (type >= SLJIT_CALL0) + jump->flags |= IS_CALL; +#endif - PTR_FAIL_IF(emit_const(compiler, TMP_REG1, 0)); - PTR_FAIL_IF(push_inst(compiler, MTCTR | S(TMP_REG1))); + PTR_FAIL_IF(emit_const(compiler, TMP_CALL_REG, 0)); + PTR_FAIL_IF(push_inst(compiler, MTCTR | S(TMP_CALL_REG))); jump->addr = compiler->size; PTR_FAIL_IF(push_inst(compiler, BCCTR | bo_bi_flags | (type >= SLJIT_FAST_CALL ? 1 : 0))); return jump; @@ -1830,20 +1983,32 @@ check_sljit_emit_ijump(compiler, type, src, srcw); ADJUST_LOCAL_OFFSET(src, srcw); - if (src <= ZERO_REG) + if (FAST_IS_REG(src)) { +#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL) + if (type >= SLJIT_CALL0) { + FAIL_IF(push_inst(compiler, OR | S(src) | A(TMP_CALL_REG) | B(src))); + src_r = TMP_CALL_REG; + } + else + src_r = src; +#else src_r = src; - else if (src & SLJIT_IMM) { +#endif + } else if (src & SLJIT_IMM) { jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); FAIL_IF(!jump); - set_jump(jump, compiler, JUMP_ADDR | UNCOND_B); + set_jump(jump, compiler, JUMP_ADDR); jump->u.target = srcw; - - FAIL_IF(emit_const(compiler, TMP_REG2, 0)); - src_r = TMP_REG2; +#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL) + if (type >= SLJIT_CALL0) + jump->flags |= IS_CALL; +#endif + FAIL_IF(emit_const(compiler, TMP_CALL_REG, 0)); + src_r = TMP_CALL_REG; } else { - FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, TMP_REG2, 0, TMP_REG1, 0, src, srcw)); - src_r = TMP_REG2; + FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, TMP_CALL_REG, 0, TMP_REG1, 0, src, srcw)); + src_r = TMP_CALL_REG; } FAIL_IF(push_inst(compiler, MTCTR | S(src_r))); @@ -1867,6 +2032,7 @@ { sljit_si reg, input_flags; sljit_si flags = GET_ALL_FLAGS(op); + sljit_sw original_dstw = dstw; CHECK_ERROR(); check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type); @@ -1876,7 +2042,7 @@ return SLJIT_SUCCESS; op = GET_OPCODE(op); - reg = (op < SLJIT_ADD && dst <= ZERO_REG) ? dst : TMP_REG2; + reg = (op < SLJIT_ADD && FAST_IS_REG(dst)) ? dst : TMP_REG2; compiler->cache_arg = 0; compiler->cache_argw = 0; @@ -1988,13 +2154,15 @@ op = SLJIT_MOV; input_flags = WORD_DATA; #endif - return (reg == TMP_REG2) ? emit_op(compiler, op, input_flags, dst, dstw, TMP_REG1, 0, TMP_REG2, 0) : SLJIT_SUCCESS; + if (reg != TMP_REG2) + return SLJIT_SUCCESS; + return emit_op(compiler, op, input_flags, dst, dstw, TMP_REG1, 0, TMP_REG2, 0); } #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG) compiler->skip_checks = 1; #endif - return sljit_emit_op2(compiler, op | flags, dst, dstw, src, srcw, TMP_REG2, 0); + return sljit_emit_op2(compiler, op | flags, dst, original_dstw, src, srcw, TMP_REG2, 0); } SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value) @@ -2010,7 +2178,7 @@ PTR_FAIL_IF(!const_); set_const(const_, compiler); - reg = (dst <= ZERO_REG) ? dst : TMP_REG2; + reg = SLOW_IS_REG(dst) ? dst : TMP_REG2; PTR_FAIL_IF(emit_const(compiler, reg, init_value)); diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitNativeSPARC_common.c r-base-3.1.1/src/extra/pcre/sljit/sljitNativeSPARC_common.c --- r-base-3.1.0/src/extra/pcre/sljit/sljitNativeSPARC_common.c 2013-06-05 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitNativeSPARC_common.c 2014-04-20 22:15:03.000000000 +0000 @@ -87,7 +87,7 @@ #define TMP_REG2 (SLJIT_NO_REGISTERS + 2) #define TMP_REG3 (SLJIT_NO_REGISTERS + 3) #define TMP_REG4 (SLJIT_NO_REGISTERS + 4) -#define LINK_REG (SLJIT_NO_REGISTERS + 5) +#define TMP_LINK (SLJIT_NO_REGISTERS + 5) #define TMP_FREG1 (0) #define TMP_FREG2 ((SLJIT_FLOAT_REG6 + 1) << 1) @@ -190,7 +190,7 @@ return SLJIT_SUCCESS; } -static SLJIT_INLINE sljit_ins* optimize_jump(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code) +static SLJIT_INLINE sljit_ins* detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code) { sljit_sw diff; sljit_uw target_addr; @@ -311,7 +311,7 @@ #else jump->addr = (sljit_uw)(code_ptr - 6); #endif - code_ptr = optimize_jump(jump, code_ptr, code); + code_ptr = detect_jump_type(jump, code_ptr, code); jump = jump->next; } if (const_ && const_->addr == word_count) { @@ -465,7 +465,7 @@ CHECK_ERROR(); check_sljit_emit_return(compiler, op, src, srcw); - if (op != SLJIT_MOV || !(src <= TMP_REG3)) { + if (op != SLJIT_MOV || !FAST_IS_REG(src)) { FAIL_IF(emit_mov_before_return(compiler, op, src, srcw)); src = SLJIT_SCRATCH_REG1; } @@ -516,15 +516,15 @@ { SLJIT_ASSERT(arg & SLJIT_MEM); - if (!(flags & WRITE_BACK) || !(arg & 0xf)) { - if ((!(arg & 0xf0) && argw <= SIMM_MAX && argw >= SIMM_MIN) - || ((arg & 0xf0) && (argw & 0x3) == 0)) { + if (!(flags & WRITE_BACK) || !(arg & REG_MASK)) { + if ((!(arg & OFFS_REG_MASK) && argw <= SIMM_MAX && argw >= SIMM_MIN) + || ((arg & OFFS_REG_MASK) && (argw & 0x3) == 0)) { /* Works for both absoulte and relative addresses (immediate case). */ if (SLJIT_UNLIKELY(flags & ARG_TEST)) return 1; FAIL_IF(push_inst(compiler, data_transfer_insts[flags & MEM_MASK] | ((flags & MEM_MASK) <= GPR_REG ? D(reg) : DA(reg)) - | S1(arg & 0xf) | ((arg & 0xf0) ? S2((arg >> 4) & 0xf) : IMM(argw)), + | S1(arg & REG_MASK) | ((arg & OFFS_REG_MASK) ? S2(OFFS_REG(arg)) : IMM(argw)), ((flags & MEM_MASK) <= GPR_REG && (flags & LOAD_DATA)) ? DR(reg) : MOVABLE_INS)); return -1; } @@ -540,11 +540,11 @@ SLJIT_ASSERT((arg & SLJIT_MEM) && (next_arg & SLJIT_MEM)); /* Simple operation except for updates. */ - if (arg & 0xf0) { + if (arg & OFFS_REG_MASK) { argw &= 0x3; SLJIT_ASSERT(argw); next_argw &= 0x3; - if ((arg & 0xf0) == (next_arg & 0xf0) && argw == next_argw) + if ((arg & OFFS_REG_MASK) == (next_arg & OFFS_REG_MASK) && argw == next_argw) return 1; return 0; } @@ -566,25 +566,25 @@ next_argw = 0; } - base = arg & 0xf; - if (SLJIT_UNLIKELY(arg & 0xf0)) { + base = arg & REG_MASK; + if (SLJIT_UNLIKELY(arg & OFFS_REG_MASK)) { argw &= 0x3; SLJIT_ASSERT(argw != 0); /* Using the cache. */ - if (((SLJIT_MEM | (arg & 0xf0)) == compiler->cache_arg) && (argw == compiler->cache_argw)) + if (((SLJIT_MEM | (arg & OFFS_REG_MASK)) == compiler->cache_arg) && (argw == compiler->cache_argw)) arg2 = TMP_REG3; else { - if ((arg & 0xf0) == (next_arg & 0xf0) && argw == (next_argw & 0x3)) { - compiler->cache_arg = SLJIT_MEM | (arg & 0xf0); + if ((arg & OFFS_REG_MASK) == (next_arg & OFFS_REG_MASK) && argw == (next_argw & 0x3)) { + compiler->cache_arg = SLJIT_MEM | (arg & OFFS_REG_MASK); compiler->cache_argw = argw; arg2 = TMP_REG3; } - else if ((flags & LOAD_DATA) && ((flags & MEM_MASK) <= GPR_REG) && reg != base && (reg << 4) != (arg & 0xf0)) + else if ((flags & LOAD_DATA) && ((flags & MEM_MASK) <= GPR_REG) && reg != base && reg != OFFS_REG(arg)) arg2 = reg; else /* It must be a mov operation, so tmp1 must be free to use. */ arg2 = TMP_REG1; - FAIL_IF(push_inst(compiler, SLL_W | D(arg2) | S1((arg >> 4) & 0xf) | IMM_ARG | argw, DR(arg2))); + FAIL_IF(push_inst(compiler, SLL_W | D(arg2) | S1(OFFS_REG(arg)) | IMM_ARG | argw, DR(arg2))); } } else { @@ -658,7 +658,7 @@ if (op >= SLJIT_MOV && op <= SLJIT_MOVU_SI && !(src2 & SLJIT_MEM)) return SLJIT_SUCCESS; } - else if (dst <= TMP_REG3) { + else if (FAST_IS_REG(dst)) { dst_r = dst; flags |= REG_DEST; if (op >= SLJIT_MOV && op <= SLJIT_MOVU_SI) @@ -689,7 +689,7 @@ } /* Source 1. */ - if (src1 <= TMP_REG3) + if (FAST_IS_REG(src1)) src1_r = src1; else if (src1 & SLJIT_IMM) { if (src1w) { @@ -708,7 +708,7 @@ } /* Source 2. */ - if (src2 <= TMP_REG3) { + if (FAST_IS_REG(src2)) { src2_r = src2; flags |= REG2_SOURCE; if (!(flags & REG_DEST) && op >= SLJIT_MOV && op <= SLJIT_MOVU_SI) @@ -943,7 +943,12 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void) { +#ifdef SLJIT_IS_FPU_AVAILABLE + return SLJIT_IS_FPU_AVAILABLE; +#else + /* Available by default. */ return 1; +#endif } #define FLOAT_DATA(op) (DOUBLE_DATA | ((op & SLJIT_SINGLE_OP) >> 7)) @@ -963,14 +968,14 @@ compiler->cache_argw = 0; if (GET_OPCODE(op) == SLJIT_CMPD) { - if (dst > SLJIT_FLOAT_REG6) { + if (dst & SLJIT_MEM) { FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, dst, dstw, src, srcw)); dst = TMP_FREG1; } else dst <<= 1; - if (src > SLJIT_FLOAT_REG6) { + if (src & SLJIT_MEM) { FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src, srcw, 0, 0)); src = TMP_FREG2; } @@ -980,9 +985,9 @@ return push_inst(compiler, SELECT_FOP(op, FCMPS, FCMPD) | S1A(dst) | S2A(src), FCC_IS_SET | MOVABLE_INS); } - dst_fr = (dst > SLJIT_FLOAT_REG6) ? TMP_FREG1 : (dst << 1); + dst_fr = FAST_IS_REG(dst) ? (dst << 1) : TMP_FREG1; - if (src > SLJIT_FLOAT_REG6) { + if (src & SLJIT_MEM) { FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, dst_fr, src, srcw, dst, dstw)); src = dst_fr; } @@ -1031,9 +1036,9 @@ compiler->cache_arg = 0; compiler->cache_argw = 0; - dst_fr = (dst > SLJIT_FLOAT_REG6) ? TMP_FREG2 : (dst << 1); + dst_fr = FAST_IS_REG(dst) ? (dst << 1) : TMP_FREG2; - if (src1 > SLJIT_FLOAT_REG6) { + if (src1 & SLJIT_MEM) { if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w)) { FAIL_IF(compiler->error); src1 = TMP_FREG1; @@ -1043,7 +1048,7 @@ else src1 <<= 1; - if (src2 > SLJIT_FLOAT_REG6) { + if (src2 & SLJIT_MEM) { if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w)) { FAIL_IF(compiler->error); src2 = TMP_FREG2; @@ -1114,11 +1119,11 @@ if (dst == SLJIT_UNUSED) return SLJIT_SUCCESS; - if (dst <= TMP_REG3) - return push_inst(compiler, OR | D(dst) | S1(0) | S2(LINK_REG), DR(dst)); + if (FAST_IS_REG(dst)) + return push_inst(compiler, OR | D(dst) | S1(0) | S2(TMP_LINK), DR(dst)); /* Memory. */ - return emit_op_mem(compiler, WORD_DATA, LINK_REG, dst, dstw); + return emit_op_mem(compiler, WORD_DATA, TMP_LINK, dst, dstw); } SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw) @@ -1127,14 +1132,14 @@ check_sljit_emit_fast_return(compiler, src, srcw); ADJUST_LOCAL_OFFSET(src, srcw); - if (src <= TMP_REG3) - FAIL_IF(push_inst(compiler, OR | D(LINK_REG) | S1(0) | S2(src), DR(LINK_REG))); + if (FAST_IS_REG(src)) + FAIL_IF(push_inst(compiler, OR | D(TMP_LINK) | S1(0) | S2(src), DR(TMP_LINK))); else if (src & SLJIT_MEM) - FAIL_IF(emit_op_mem(compiler, WORD_DATA | LOAD_DATA, LINK_REG, src, srcw)); + FAIL_IF(emit_op_mem(compiler, WORD_DATA | LOAD_DATA, TMP_LINK, src, srcw)); else if (src & SLJIT_IMM) - FAIL_IF(load_immediate(compiler, LINK_REG, srcw)); + FAIL_IF(load_immediate(compiler, TMP_LINK, srcw)); - FAIL_IF(push_inst(compiler, JMPL | D(0) | S1(LINK_REG) | IMM(8), UNMOVABLE_INS)); + FAIL_IF(push_inst(compiler, JMPL | D(0) | S1(TMP_LINK) | IMM(8), UNMOVABLE_INS)); return push_inst(compiler, NOP, UNMOVABLE_INS); } @@ -1269,7 +1274,7 @@ } PTR_FAIL_IF(emit_const(compiler, TMP_REG2, 0)); - PTR_FAIL_IF(push_inst(compiler, JMPL | D(type >= SLJIT_FAST_CALL ? LINK_REG : 0) | S1(TMP_REG2) | IMM(0), UNMOVABLE_INS)); + PTR_FAIL_IF(push_inst(compiler, JMPL | D(type >= SLJIT_FAST_CALL ? TMP_LINK : 0) | S1(TMP_REG2) | IMM(0), UNMOVABLE_INS)); jump->addr = compiler->size; PTR_FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS)); @@ -1285,7 +1290,7 @@ check_sljit_emit_ijump(compiler, type, src, srcw); ADJUST_LOCAL_OFFSET(src, srcw); - if (src <= TMP_REG3) + if (FAST_IS_REG(src)) src_r = src; else if (src & SLJIT_IMM) { jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump)); @@ -1305,7 +1310,7 @@ src_r = TMP_REG2; } - FAIL_IF(push_inst(compiler, JMPL | D(type >= SLJIT_FAST_CALL ? LINK_REG : 0) | S1(src_r) | IMM(0), UNMOVABLE_INS)); + FAIL_IF(push_inst(compiler, JMPL | D(type >= SLJIT_FAST_CALL ? TMP_LINK : 0) | S1(src_r) | IMM(0), UNMOVABLE_INS)); if (jump) jump->addr = compiler->size; return push_inst(compiler, NOP, UNMOVABLE_INS); @@ -1327,7 +1332,7 @@ #if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) op = GET_OPCODE(op); - reg = (op < SLJIT_ADD && dst <= TMP_REG3) ? dst : TMP_REG2; + reg = (op < SLJIT_ADD && FAST_IS_REG(dst)) ? dst : TMP_REG2; compiler->cache_arg = 0; compiler->cache_argw = 0; @@ -1368,12 +1373,11 @@ PTR_FAIL_IF(!const_); set_const(const_, compiler); - reg = (dst <= TMP_REG3) ? dst : TMP_REG2; + reg = SLOW_IS_REG(dst) ? dst : TMP_REG2; PTR_FAIL_IF(emit_const(compiler, reg, init_value)); if (dst & SLJIT_MEM) PTR_FAIL_IF(emit_op_mem(compiler, WORD_DATA, TMP_REG2, dst, dstw)); - return const_; } diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitNativeX86_32.c r-base-3.1.1/src/extra/pcre/sljit/sljitNativeX86_32.c --- r-base-3.1.0/src/extra/pcre/sljit/sljitNativeX86_32.c 2013-06-05 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitNativeX86_32.c 2014-04-20 22:15:03.000000000 +0000 @@ -89,11 +89,11 @@ FAIL_IF(!inst); INC_SIZE(size); - PUSH_REG(reg_map[TMP_REGISTER]); + PUSH_REG(reg_map[TMP_REG1]); #if !(defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL) if (args > 0) { *inst++ = MOV_r_rm; - *inst++ = MOD_REG | (reg_map[TMP_REGISTER] << 3) | 0x4 /* esp */; + *inst++ = MOD_REG | (reg_map[TMP_REG1] << 3) | 0x4 /* esp */; } #endif if (saveds > 2) @@ -121,17 +121,17 @@ #else if (args > 0) { *inst++ = MOV_r_rm; - *inst++ = MOD_DISP8 | (reg_map[SLJIT_SAVED_REG1] << 3) | reg_map[TMP_REGISTER]; + *inst++ = MOD_DISP8 | (reg_map[SLJIT_SAVED_REG1] << 3) | reg_map[TMP_REG1]; *inst++ = sizeof(sljit_sw) * 2; } if (args > 1) { *inst++ = MOV_r_rm; - *inst++ = MOD_DISP8 | (reg_map[SLJIT_SAVED_REG2] << 3) | reg_map[TMP_REGISTER]; + *inst++ = MOD_DISP8 | (reg_map[SLJIT_SAVED_REG2] << 3) | reg_map[TMP_REG1]; *inst++ = sizeof(sljit_sw) * 3; } if (args > 2) { *inst++ = MOV_r_rm; - *inst++ = MOD_DISP8 | (reg_map[SLJIT_SAVED_REG3] << 3) | reg_map[TMP_REGISTER]; + *inst++ = MOD_DISP8 | (reg_map[SLJIT_SAVED_REG3] << 3) | reg_map[TMP_REG1]; *inst++ = sizeof(sljit_sw) * 4; } #endif @@ -245,7 +245,7 @@ POP_REG(reg_map[SLJIT_SAVED_REG2]); if (compiler->saveds > 2) POP_REG(reg_map[SLJIT_SAVED_REG3]); - POP_REG(reg_map[TMP_REGISTER]); + POP_REG(reg_map[TMP_REG1]); #if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL) if (compiler->args > 2) RET_I16(sizeof(sljit_sw)); @@ -301,9 +301,9 @@ /* Calculate size of b. */ inst_size += 1; /* mod r/m byte. */ if (b & SLJIT_MEM) { - if ((b & 0x0f) == SLJIT_UNUSED) + if ((b & REG_MASK) == SLJIT_UNUSED) inst_size += sizeof(sljit_sw); - else if (immb != 0 && !(b & 0xf0)) { + else if (immb != 0 && !(b & OFFS_REG_MASK)) { /* Immediate operand. */ if (immb <= 127 && immb >= -128) inst_size += sizeof(sljit_sb); @@ -311,10 +311,10 @@ inst_size += sizeof(sljit_sw); } - if ((b & 0xf) == SLJIT_LOCALS_REG && !(b & 0xf0)) - b |= SLJIT_LOCALS_REG << 4; + if ((b & REG_MASK) == SLJIT_LOCALS_REG && !(b & OFFS_REG_MASK)) + b |= TO_OFFS_REG(SLJIT_LOCALS_REG); - if ((b & 0xf0) != SLJIT_UNUSED) + if ((b & OFFS_REG_MASK) != SLJIT_UNUSED) inst_size += 1; /* SIB byte. */ } @@ -393,8 +393,8 @@ #else *buf_ptr++ |= MOD_REG + reg_map[b]; #endif - else if ((b & 0x0f) != SLJIT_UNUSED) { - if ((b & 0xf0) == SLJIT_UNUSED || (b & 0xf0) == (SLJIT_LOCALS_REG << 4)) { + else if ((b & REG_MASK) != SLJIT_UNUSED) { + if ((b & OFFS_REG_MASK) == SLJIT_UNUSED || (b & OFFS_REG_MASK) == TO_OFFS_REG(SLJIT_LOCALS_REG)) { if (immb != 0) { if (immb <= 127 && immb >= -128) *buf_ptr |= 0x40; @@ -402,11 +402,11 @@ *buf_ptr |= 0x80; } - if ((b & 0xf0) == SLJIT_UNUSED) - *buf_ptr++ |= reg_map[b & 0x0f]; + if ((b & OFFS_REG_MASK) == SLJIT_UNUSED) + *buf_ptr++ |= reg_map[b & REG_MASK]; else { *buf_ptr++ |= 0x04; - *buf_ptr++ = reg_map[b & 0x0f] | (reg_map[(b >> 4) & 0x0f] << 3); + *buf_ptr++ = reg_map[b & REG_MASK] | (reg_map[OFFS_REG(b)] << 3); } if (immb != 0) { @@ -420,7 +420,7 @@ } else { *buf_ptr++ |= 0x04; - *buf_ptr++ = reg_map[b & 0x0f] | (reg_map[(b >> 4) & 0x0f] << 3) | (immb << 6); + *buf_ptr++ = reg_map[b & REG_MASK] | (reg_map[OFFS_REG(b)] << 3) | (immb << 6); } } else { @@ -495,9 +495,9 @@ /* For UNUSED dst. Uncommon, but possible. */ if (dst == SLJIT_UNUSED) - dst = TMP_REGISTER; + dst = TMP_REG1; - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { /* Unused dest is possible here. */ inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); FAIL_IF(!inst); @@ -524,7 +524,7 @@ CHECK_EXTRA_REGS(src, srcw, (void)0); - if (src <= TMP_REGISTER) { + if (FAST_IS_REG(src)) { inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 1); FAIL_IF(!inst); diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitNativeX86_64.c r-base-3.1.1/src/extra/pcre/sljit/sljitNativeX86_64.c --- r-base-3.1.0/src/extra/pcre/sljit/sljitNativeX86_64.c 2013-02-04 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitNativeX86_64.c 2014-04-20 22:15:03.000000000 +0000 @@ -69,7 +69,7 @@ { sljit_sw delta = addr - ((sljit_sw)code_ptr + 1 + sizeof(sljit_si)); - if (delta <= SLJIT_W(0x7fffffff) && delta >= SLJIT_W(-0x80000000)) { + if (delta <= HALFWORD_MAX && delta >= HALFWORD_MIN) { *code_ptr++ = (type == 2) ? CALL_i32 : JMP_i32; *(sljit_sw*)code_ptr = delta; } @@ -420,12 +420,12 @@ size &= 0xf; inst_size = size; - if ((b & SLJIT_MEM) && !(b & 0xf0) && NOT_HALFWORD(immb)) { + if ((b & SLJIT_MEM) && !(b & OFFS_REG_MASK) && NOT_HALFWORD(immb)) { if (emit_load_imm64(compiler, TMP_REG3, immb)) return NULL; immb = 0; - if (b & 0xf) - b |= TMP_REG3 << 4; + if (b & REG_MASK) + b |= TO_OFFS_REG(TMP_REG3); else b |= TMP_REG3; } @@ -445,12 +445,12 @@ /* Calculate size of b. */ inst_size += 1; /* mod r/m byte. */ if (b & SLJIT_MEM) { - if ((b & 0x0f) == SLJIT_UNUSED) + if ((b & REG_MASK) == SLJIT_UNUSED) inst_size += 1 + sizeof(sljit_si); /* SIB byte required to avoid RIP based addressing. */ else { - if (reg_map[b & 0x0f] >= 8) + if (reg_map[b & REG_MASK] >= 8) rex |= REX_B; - if (immb != 0 && !(b & 0xf0)) { + if (immb != 0 && !(b & OFFS_REG_MASK)) { /* Immediate operand. */ if (immb <= 127 && immb >= -128) inst_size += sizeof(sljit_sb); @@ -459,12 +459,12 @@ } } - if ((b & 0xf) == SLJIT_LOCALS_REG && !(b & 0xf0)) - b |= SLJIT_LOCALS_REG << 4; + if ((b & REG_MASK) == SLJIT_LOCALS_REG && !(b & OFFS_REG_MASK)) + b |= TO_OFFS_REG(SLJIT_LOCALS_REG); - if ((b & 0xf0) != SLJIT_UNUSED) { + if ((b & OFFS_REG_MASK) != SLJIT_UNUSED) { inst_size += 1; /* SIB byte. */ - if (reg_map[(b >> 4) & 0x0f] >= 8) + if (reg_map[OFFS_REG(b)] >= 8) rex |= REX_X; } } @@ -563,8 +563,8 @@ #else *buf_ptr++ |= MOD_REG + reg_lmap[b]; #endif - else if ((b & 0x0f) != SLJIT_UNUSED) { - if ((b & 0xf0) == SLJIT_UNUSED || (b & 0xf0) == (SLJIT_LOCALS_REG << 4)) { + else if ((b & REG_MASK) != SLJIT_UNUSED) { + if ((b & OFFS_REG_MASK) == SLJIT_UNUSED || (b & OFFS_REG_MASK) == TO_OFFS_REG(SLJIT_LOCALS_REG)) { if (immb != 0) { if (immb <= 127 && immb >= -128) *buf_ptr |= 0x40; @@ -572,11 +572,11 @@ *buf_ptr |= 0x80; } - if ((b & 0xf0) == SLJIT_UNUSED) - *buf_ptr++ |= reg_lmap[b & 0x0f]; + if ((b & OFFS_REG_MASK) == SLJIT_UNUSED) + *buf_ptr++ |= reg_lmap[b & REG_MASK]; else { *buf_ptr++ |= 0x04; - *buf_ptr++ = reg_lmap[b & 0x0f] | (reg_lmap[(b >> 4) & 0x0f] << 3); + *buf_ptr++ = reg_lmap[b & REG_MASK] | (reg_lmap[OFFS_REG(b)] << 3); } if (immb != 0) { @@ -590,7 +590,7 @@ } else { *buf_ptr++ |= 0x04; - *buf_ptr++ = reg_lmap[b & 0x0f] | (reg_lmap[(b >> 4) & 0x0f] << 3) | (immb << 6); + *buf_ptr++ = reg_lmap[b & REG_MASK] | (reg_lmap[OFFS_REG(b)] << 3) | (immb << 6); } } else { @@ -662,9 +662,9 @@ /* For UNUSED dst. Uncommon, but possible. */ if (dst == SLJIT_UNUSED) - dst = TMP_REGISTER; + dst = TMP_REG1; - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { if (reg_map[dst] < 8) { inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); FAIL_IF(!inst); @@ -698,11 +698,11 @@ ADJUST_LOCAL_OFFSET(src, srcw); if ((src & SLJIT_IMM) && NOT_HALFWORD(srcw)) { - FAIL_IF(emit_load_imm64(compiler, TMP_REGISTER, srcw)); - src = TMP_REGISTER; + FAIL_IF(emit_load_imm64(compiler, TMP_REG1, srcw)); + src = TMP_REG1; } - if (src <= TMP_REGISTER) { + if (FAST_IS_REG(src)) { if (reg_map[src] < 8) { inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 1); FAIL_IF(!inst); @@ -765,7 +765,7 @@ return SLJIT_SUCCESS; /* Empty instruction. */ if (src & SLJIT_IMM) { - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { if (sign || ((sljit_uw)srcw <= 0x7fffffff)) { inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, (sljit_sw)(sljit_si)srcw, dst, dstw); FAIL_IF(!inst); @@ -782,9 +782,9 @@ return SLJIT_SUCCESS; } - dst_r = (dst <= TMP_REGISTER) ? dst : TMP_REGISTER; + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; - if ((dst & SLJIT_MEM) && (src <= TMP_REGISTER)) + if ((dst & SLJIT_MEM) && FAST_IS_REG(src)) dst_r = src; else { if (sign) { diff -Nru r-base-3.1.0/src/extra/pcre/sljit/sljitNativeX86_common.c r-base-3.1.1/src/extra/pcre/sljit/sljitNativeX86_common.c --- r-base-3.1.0/src/extra/pcre/sljit/sljitNativeX86_common.c 2013-06-05 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/extra/pcre/sljit/sljitNativeX86_common.c 2014-04-20 22:15:03.000000000 +0000 @@ -64,7 +64,7 @@ #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) /* Last register + 1. */ -#define TMP_REGISTER (SLJIT_NO_REGISTERS + 1) +#define TMP_REG1 (SLJIT_NO_REGISTERS + 1) static SLJIT_CONST sljit_ub reg_map[SLJIT_NO_REGISTERS + 2] = { 0, 0, 2, 1, 0, 0, 3, 6, 7, 0, 0, 4, 5 @@ -85,7 +85,7 @@ #else /* SLJIT_CONFIG_X86_32 */ /* Last register + 1. */ -#define TMP_REGISTER (SLJIT_NO_REGISTERS + 1) +#define TMP_REG1 (SLJIT_NO_REGISTERS + 1) #define TMP_REG2 (SLJIT_NO_REGISTERS + 2) #define TMP_REG3 (SLJIT_NO_REGISTERS + 3) @@ -118,8 +118,16 @@ #define REX_B 0x41 #define REX 0x40 -#define IS_HALFWORD(x) ((x) <= 0x7fffffffll && (x) >= -0x80000000ll) -#define NOT_HALFWORD(x) ((x) > 0x7fffffffll || (x) < -0x80000000ll) +#ifndef _WIN64 +#define HALFWORD_MAX 0x7fffffffl +#define HALFWORD_MIN -0x80000000l +#else +#define HALFWORD_MAX 0x7fffffffll +#define HALFWORD_MIN -0x80000000ll +#endif + +#define IS_HALFWORD(x) ((x) <= HALFWORD_MAX && (x) >= HALFWORD_MIN) +#define NOT_HALFWORD(x) ((x) > HALFWORD_MAX || (x) < HALFWORD_MIN) #define CHECK_EXTRA_REGS(p, w, do) @@ -397,7 +405,7 @@ short_jump = (sljit_sw)(label_addr - (jump->addr + 2)) >= -128 && (sljit_sw)(label_addr - (jump->addr + 2)) <= 127; #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) - if ((sljit_sw)(label_addr - (jump->addr + 1)) > 0x7fffffffll || (sljit_sw)(label_addr - (jump->addr + 1)) < -0x80000000ll) + if ((sljit_sw)(label_addr - (jump->addr + 1)) > HALFWORD_MAX || (sljit_sw)(label_addr - (jump->addr + 1)) < HALFWORD_MIN) return generate_far_jump_code(jump, code_ptr, type); #endif @@ -526,7 +534,7 @@ #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) *(sljit_sw*)jump->addr = (sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_sw))); #else - SLJIT_ASSERT((sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_si))) >= -0x80000000ll && (sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_si))) <= 0x7fffffffll); + SLJIT_ASSERT((sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_si))) >= HALFWORD_MIN && (sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_si))) <= HALFWORD_MAX); *(sljit_si*)jump->addr = (sljit_si)(jump->u.label->addr - (jump->addr + sizeof(sljit_si))); #endif } @@ -534,7 +542,7 @@ #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) *(sljit_sw*)jump->addr = (sljit_sw)(jump->u.target - (jump->addr + sizeof(sljit_sw))); #else - SLJIT_ASSERT((sljit_sw)(jump->u.target - (jump->addr + sizeof(sljit_si))) >= -0x80000000ll && (sljit_sw)(jump->u.target - (jump->addr + sizeof(sljit_si))) <= 0x7fffffffll); + SLJIT_ASSERT((sljit_sw)(jump->u.target - (jump->addr + sizeof(sljit_si))) >= HALFWORD_MIN && (sljit_sw)(jump->u.target - (jump->addr + sizeof(sljit_si))) <= HALFWORD_MAX); *(sljit_si*)jump->addr = (sljit_si)(jump->u.target - (jump->addr + sizeof(sljit_si))); #endif } @@ -633,7 +641,7 @@ CPU cycles if the stack is large enough. However, you don't know it in advance, so it must always be called. I think this is a bad design in general even if it has some reasons. */ - *(sljit_si*)alloca(local_size) = 0; + *(volatile sljit_si*)alloca(local_size) = 0; } #endif @@ -653,20 +661,20 @@ if (dst == SLJIT_UNUSED) { /* No destination, doesn't need to setup flags. */ if (src & SLJIT_MEM) { - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, src, srcw); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); FAIL_IF(!inst); *inst = MOV_r_rm; } return SLJIT_SUCCESS; } - if (src <= TMP_REGISTER) { + if (FAST_IS_REG(src)) { inst = emit_x86_instruction(compiler, 1, src, 0, dst, dstw); FAIL_IF(!inst); *inst = MOV_rm_r; return SLJIT_SUCCESS; } if (src & SLJIT_IMM) { - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); #else @@ -692,7 +700,7 @@ *inst = MOV_rm_i32; return SLJIT_SUCCESS; } - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { inst = emit_x86_instruction(compiler, 1, dst, 0, src, srcw); FAIL_IF(!inst); *inst = MOV_r_rm; @@ -700,10 +708,10 @@ } /* Memory to memory move. Requires two instruction. */ - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, src, srcw); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw); FAIL_IF(!inst); *inst = MOV_r_rm; - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, dst, dstw); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); FAIL_IF(!inst); *inst = MOV_rm_r; return SLJIT_SUCCESS; @@ -745,13 +753,13 @@ SLJIT_COMPILE_ASSERT( reg_map[SLJIT_SCRATCH_REG1] == 0 && reg_map[SLJIT_SCRATCH_REG2] == 2 - && reg_map[TMP_REGISTER] > 7, + && reg_map[TMP_REG1] > 7, invalid_register_assignment_for_div_mul); #else SLJIT_COMPILE_ASSERT( reg_map[SLJIT_SCRATCH_REG1] == 0 && reg_map[SLJIT_SCRATCH_REG2] < 7 - && reg_map[TMP_REGISTER] == 2, + && reg_map[TMP_REG1] == 2, invalid_register_assignment_for_div_mul); #endif compiler->mode32 = op & SLJIT_INT_OP; @@ -760,10 +768,10 @@ op = GET_OPCODE(op); if (op == SLJIT_UDIV) { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64) - EMIT_MOV(compiler, TMP_REGISTER, 0, SLJIT_SCRATCH_REG2, 0); + EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_SCRATCH_REG2, 0); inst = emit_x86_instruction(compiler, 1, SLJIT_SCRATCH_REG2, 0, SLJIT_SCRATCH_REG2, 0); #else - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); #endif FAIL_IF(!inst); *inst = XOR_r_rm; @@ -771,7 +779,7 @@ if (op == SLJIT_SDIV) { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64) - EMIT_MOV(compiler, TMP_REGISTER, 0, SLJIT_SCRATCH_REG2, 0); + EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_SCRATCH_REG2, 0); #endif #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) @@ -800,7 +808,7 @@ FAIL_IF(!inst); INC_SIZE(2); *inst++ = GROUP_F7; - *inst = MOD_REG | ((op >= SLJIT_UDIV) ? reg_map[TMP_REGISTER] : reg_map[SLJIT_SCRATCH_REG2]); + *inst = MOD_REG | ((op >= SLJIT_UDIV) ? reg_map[TMP_REG1] : reg_map[SLJIT_SCRATCH_REG2]); #else #ifdef _WIN64 size = (!compiler->mode32 || op >= SLJIT_UDIV) ? 3 : 2; @@ -816,7 +824,7 @@ else if (op >= SLJIT_UDIV) *inst++ = REX_B; *inst++ = GROUP_F7; - *inst = MOD_REG | ((op >= SLJIT_UDIV) ? reg_lmap[TMP_REGISTER] : reg_lmap[SLJIT_SCRATCH_REG2]); + *inst = MOD_REG | ((op >= SLJIT_UDIV) ? reg_lmap[TMP_REG1] : reg_lmap[SLJIT_SCRATCH_REG2]); #else if (!compiler->mode32) *inst++ = REX_W; @@ -839,7 +847,7 @@ break; } #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && !defined(_WIN64) - EMIT_MOV(compiler, SLJIT_SCRATCH_REG2, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, SLJIT_SCRATCH_REG2, 0, TMP_REG1, 0); #endif break; } @@ -873,7 +881,7 @@ return SLJIT_SUCCESS; /* Empty instruction. */ if (src & SLJIT_IMM) { - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); #else @@ -889,13 +897,13 @@ return SLJIT_SUCCESS; } - dst_r = (dst <= TMP_REGISTER) ? dst : TMP_REGISTER; + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; - if ((dst & SLJIT_MEM) && src <= TMP_REGISTER) { + if ((dst & SLJIT_MEM) && FAST_IS_REG(src)) { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) if (reg_map[src] >= 4) { - SLJIT_ASSERT(dst_r == TMP_REGISTER); - EMIT_MOV(compiler, TMP_REGISTER, 0, src, 0); + SLJIT_ASSERT(dst_r == TMP_REG1); + EMIT_MOV(compiler, TMP_REG1, 0, src, 0); } else dst_r = src; #else @@ -903,9 +911,9 @@ #endif } #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) - else if (src <= TMP_REGISTER && reg_map[src] >= 4) { + else if (FAST_IS_REG(src) && reg_map[src] >= 4) { /* src, dst are registers. */ - SLJIT_ASSERT(dst >= SLJIT_SCRATCH_REG1 && dst <= TMP_REGISTER); + SLJIT_ASSERT(SLOW_IS_REG(dst)); if (reg_map[dst] < 4) { if (dst != src) EMIT_MOV(compiler, dst, 0, src, 0); @@ -946,25 +954,25 @@ if (dst & SLJIT_MEM) { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) - if (dst_r == TMP_REGISTER) { + if (dst_r == TMP_REG1) { /* Find a non-used register, whose reg_map[src] < 4. */ - if ((dst & 0xf) == SLJIT_SCRATCH_REG1) { - if ((dst & 0xf0) == (SLJIT_SCRATCH_REG2 << 4)) + if ((dst & REG_MASK) == SLJIT_SCRATCH_REG1) { + if ((dst & OFFS_REG_MASK) == TO_OFFS_REG(SLJIT_SCRATCH_REG2)) work_r = SLJIT_SCRATCH_REG3; else work_r = SLJIT_SCRATCH_REG2; } else { - if ((dst & 0xf0) != (SLJIT_SCRATCH_REG1 << 4)) + if ((dst & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_SCRATCH_REG1)) work_r = SLJIT_SCRATCH_REG1; - else if ((dst & 0xf) == SLJIT_SCRATCH_REG2) + else if ((dst & REG_MASK) == SLJIT_SCRATCH_REG2) work_r = SLJIT_SCRATCH_REG3; else work_r = SLJIT_SCRATCH_REG2; } if (work_r == SLJIT_SCRATCH_REG1) { - ENCODE_PREFIX(XCHG_EAX_r + reg_map[TMP_REGISTER]); + ENCODE_PREFIX(XCHG_EAX_r + reg_map[TMP_REG1]); } else { inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); @@ -977,7 +985,7 @@ *inst = MOV_rm8_r8; if (work_r == SLJIT_SCRATCH_REG1) { - ENCODE_PREFIX(XCHG_EAX_r + reg_map[TMP_REGISTER]); + ENCODE_PREFIX(XCHG_EAX_r + reg_map[TMP_REG1]); } else { inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0); @@ -1015,7 +1023,7 @@ return SLJIT_SUCCESS; /* Empty instruction. */ if (src & SLJIT_IMM) { - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw); #else @@ -1031,9 +1039,9 @@ return SLJIT_SUCCESS; } - dst_r = (dst <= TMP_REGISTER) ? dst : TMP_REGISTER; + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; - if ((dst & SLJIT_MEM) && src <= TMP_REGISTER) + if ((dst & SLJIT_MEM) && FAST_IS_REG(src)) dst_r = src; else { inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw); @@ -1058,8 +1066,8 @@ sljit_ub* inst; if (dst == SLJIT_UNUSED) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src, srcw); - inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); + inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst++ = GROUP_F7; *inst |= opcode; @@ -1073,7 +1081,7 @@ *inst |= opcode; return SLJIT_SUCCESS; } - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { EMIT_MOV(compiler, dst, 0, src, srcw); inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); FAIL_IF(!inst); @@ -1081,12 +1089,12 @@ *inst |= opcode; return SLJIT_SUCCESS; } - EMIT_MOV(compiler, TMP_REGISTER, 0, src, srcw); - inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); + inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst++ = GROUP_F7; *inst |= opcode; - EMIT_MOV(compiler, dst, dstw, TMP_REGISTER, 0); + EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); return SLJIT_SUCCESS; } @@ -1097,17 +1105,17 @@ sljit_ub* inst; if (dst == SLJIT_UNUSED) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src, srcw); - inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); + inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst++ = GROUP_F7; *inst |= NOT_rm; - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst = OR_r_rm; return SLJIT_SUCCESS; } - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { EMIT_MOV(compiler, dst, 0, src, srcw); inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw); FAIL_IF(!inst); @@ -1118,15 +1126,15 @@ *inst = OR_r_rm; return SLJIT_SUCCESS; } - EMIT_MOV(compiler, TMP_REGISTER, 0, src, srcw); - inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); + inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst++ = GROUP_F7; *inst |= NOT_rm; - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst = OR_r_rm; - EMIT_MOV(compiler, dst, dstw, TMP_REGISTER, 0); + EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); return SLJIT_SUCCESS; } @@ -1140,15 +1148,15 @@ SLJIT_UNUSED_ARG(op_flags); if (SLJIT_UNLIKELY(dst == SLJIT_UNUSED)) { /* Just set the zero flag. */ - EMIT_MOV(compiler, TMP_REGISTER, 0, src, srcw); - inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, TMP_REG1, 0, src, srcw); + inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst++ = GROUP_F7; *inst |= NOT_rm; #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) - inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 31, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 31, TMP_REG1, 0); #else - inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 63 : 31, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 63 : 31, TMP_REG1, 0); #endif FAIL_IF(!inst); *inst |= SHR; @@ -1156,24 +1164,24 @@ } if (SLJIT_UNLIKELY(src & SLJIT_IMM)) { - EMIT_MOV(compiler, TMP_REGISTER, 0, SLJIT_IMM, srcw); - src = TMP_REGISTER; + EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw); + src = TMP_REG1; srcw = 0; } - inst = emit_x86_instruction(compiler, 2, TMP_REGISTER, 0, src, srcw); + inst = emit_x86_instruction(compiler, 2, TMP_REG1, 0, src, srcw); FAIL_IF(!inst); *inst++ = GROUP_0F; *inst = BSR_r_rm; #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) - if (dst <= TMP_REGISTER) + if (FAST_IS_REG(dst)) dst_r = dst; else { /* Find an unused temporary register. */ - if ((dst & 0xf) != SLJIT_SCRATCH_REG1 && (dst & 0xf0) != (SLJIT_SCRATCH_REG1 << 4)) + if ((dst & REG_MASK) != SLJIT_SCRATCH_REG1 && (dst & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_SCRATCH_REG1)) dst_r = SLJIT_SCRATCH_REG1; - else if ((dst & 0xf) != SLJIT_SCRATCH_REG2 && (dst & 0xf0) != (SLJIT_SCRATCH_REG2 << 4)) + else if ((dst & REG_MASK) != SLJIT_SCRATCH_REG2 && (dst & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_SCRATCH_REG2)) dst_r = SLJIT_SCRATCH_REG2; else dst_r = SLJIT_SCRATCH_REG3; @@ -1181,7 +1189,7 @@ } EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, 32 + 31); #else - dst_r = (dst <= TMP_REGISTER) ? dst : TMP_REG2; + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2; compiler->mode32 = 0; EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 64 + 63 : 32 + 31); compiler->mode32 = op_flags & SLJIT_INT_OP; @@ -1191,7 +1199,7 @@ get_cpu_features(); if (cpu_has_cmov) { - inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst++ = GROUP_0F; *inst = CMOVNE_r_rm; @@ -1204,7 +1212,7 @@ *inst++ = JE_i8; *inst++ = 2; *inst++ = MOV_r_rm; - *inst++ = MOD_REG | (reg_map[dst_r] << 3) | reg_map[TMP_REGISTER]; + *inst++ = MOD_REG | (reg_map[dst_r] << 3) | reg_map[TMP_REG1]; #else inst = (sljit_ub*)ensure_buf(compiler, 1 + 5); FAIL_IF(!inst); @@ -1212,9 +1220,9 @@ *inst++ = JE_i8; *inst++ = 3; - *inst++ = REX_W | (reg_map[dst_r] >= 8 ? REX_R : 0) | (reg_map[TMP_REGISTER] >= 8 ? REX_B : 0); + *inst++ = REX_W | (reg_map[dst_r] >= 8 ? REX_R : 0) | (reg_map[TMP_REG1] >= 8 ? REX_B : 0); *inst++ = MOV_r_rm; - *inst++ = MOD_REG | (reg_lmap[dst_r] << 3) | reg_lmap[TMP_REGISTER]; + *inst++ = MOD_REG | (reg_lmap[dst_r] << 3) | reg_lmap[TMP_REG1]; #endif } @@ -1271,7 +1279,7 @@ #endif if (op_flags & SLJIT_INT_OP) { - if (src <= TMP_REGISTER && src == dst) { + if (FAST_IS_REG(src) && src == dst) { if (!TYPE_CAST_NEEDED(op)) return SLJIT_SUCCESS; } @@ -1322,8 +1330,8 @@ #endif } - if (SLJIT_UNLIKELY(update) && (src & SLJIT_MEM) && !src_is_ereg && (src & 0xf) && (srcw != 0 || (src & 0xf0) != 0)) { - inst = emit_x86_instruction(compiler, 1, src & 0xf, 0, src, srcw); + if (SLJIT_UNLIKELY(update) && (src & SLJIT_MEM) && !src_is_ereg && (src & REG_MASK) && (srcw != 0 || (src & OFFS_REG_MASK) != 0)) { + inst = emit_x86_instruction(compiler, 1, src & REG_MASK, 0, src, srcw); FAIL_IF(!inst); *inst = LEA_r_m; src &= SLJIT_MEM | 0xf; @@ -1333,7 +1341,7 @@ #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) if (SLJIT_UNLIKELY(dst_is_ereg) && (!(op == SLJIT_MOV || op == SLJIT_MOV_UI || op == SLJIT_MOV_SI || op == SLJIT_MOV_P) || (src & SLJIT_MEM))) { SLJIT_ASSERT(dst == SLJIT_MEM1(SLJIT_LOCALS_REG)); - dst = TMP_REGISTER; + dst = TMP_REG1; } #endif @@ -1369,12 +1377,12 @@ } #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) - if (SLJIT_UNLIKELY(dst_is_ereg) && dst == TMP_REGISTER) - return emit_mov(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), dstw, TMP_REGISTER, 0); + if (SLJIT_UNLIKELY(dst_is_ereg) && dst == TMP_REG1) + return emit_mov(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), dstw, TMP_REG1, 0); #endif - if (SLJIT_UNLIKELY(update) && (dst & SLJIT_MEM) && (dst & 0xf) && (dstw != 0 || (dst & 0xf0) != 0)) { - inst = emit_x86_instruction(compiler, 1, dst & 0xf, 0, dst, dstw); + if (SLJIT_UNLIKELY(update) && (dst & SLJIT_MEM) && (dst & REG_MASK) && (dstw != 0 || (dst & OFFS_REG_MASK) != 0)) { + inst = emit_x86_instruction(compiler, 1, dst & REG_MASK, 0, dst, dstw); FAIL_IF(!inst); *inst = LEA_r_m; } @@ -1447,12 +1455,12 @@ sljit_ub* inst; if (dst == SLJIT_UNUSED) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); if (src2 & SLJIT_IMM) { - BINARY_IMM(op_imm, op_mr, src2w, TMP_REGISTER, 0); + BINARY_IMM(op_imm, op_mr, src2w, TMP_REG1, 0); } else { - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, src2, src2w); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w); FAIL_IF(!inst); *inst = op_rm; } @@ -1472,20 +1480,20 @@ BINARY_IMM(op_imm, op_mr, src2w, dst, dstw); } } - else if (dst <= TMP_REGISTER) { + else if (FAST_IS_REG(dst)) { inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w); FAIL_IF(!inst); *inst = op_rm; } - else if (src2 <= TMP_REGISTER) { + else if (FAST_IS_REG(src2)) { /* Special exception for sljit_emit_op_flags. */ inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw); FAIL_IF(!inst); *inst = op_mr; } else { - EMIT_MOV(compiler, TMP_REGISTER, 0, src2, src2w); - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, dst, dstw); + EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); FAIL_IF(!inst); *inst = op_mr; } @@ -1506,19 +1514,19 @@ BINARY_IMM(op_imm, op_mr, src1w, dst, dstw); } } - else if (dst <= TMP_REGISTER) { + else if (FAST_IS_REG(dst)) { inst = emit_x86_instruction(compiler, 1, dst, dstw, src1, src1w); FAIL_IF(!inst); *inst = op_rm; } - else if (src1 <= TMP_REGISTER) { + else if (FAST_IS_REG(src1)) { inst = emit_x86_instruction(compiler, 1, src1, src1w, dst, dstw); FAIL_IF(!inst); *inst = op_mr; } else { - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, dst, dstw); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); FAIL_IF(!inst); *inst = op_mr; } @@ -1526,7 +1534,7 @@ } /* General version. */ - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { EMIT_MOV(compiler, dst, 0, src1, src1w); if (src2 & SLJIT_IMM) { BINARY_IMM(op_imm, op_mr, src2w, dst, 0); @@ -1539,16 +1547,16 @@ } else { /* This version requires less memory writing. */ - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); if (src2 & SLJIT_IMM) { - BINARY_IMM(op_imm, op_mr, src2w, TMP_REGISTER, 0); + BINARY_IMM(op_imm, op_mr, src2w, TMP_REG1, 0); } else { - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, src2, src2w); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w); FAIL_IF(!inst); *inst = op_rm; } - EMIT_MOV(compiler, dst, dstw, TMP_REGISTER, 0); + EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); } return SLJIT_SUCCESS; @@ -1563,12 +1571,12 @@ sljit_ub* inst; if (dst == SLJIT_UNUSED) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); if (src2 & SLJIT_IMM) { - BINARY_IMM(op_imm, op_mr, src2w, TMP_REGISTER, 0); + BINARY_IMM(op_imm, op_mr, src2w, TMP_REG1, 0); } else { - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, src2, src2w); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w); FAIL_IF(!inst); *inst = op_rm; } @@ -1588,19 +1596,19 @@ BINARY_IMM(op_imm, op_mr, src2w, dst, dstw); } } - else if (dst <= TMP_REGISTER) { + else if (FAST_IS_REG(dst)) { inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w); FAIL_IF(!inst); *inst = op_rm; } - else if (src2 <= TMP_REGISTER) { + else if (FAST_IS_REG(src2)) { inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw); FAIL_IF(!inst); *inst = op_mr; } else { - EMIT_MOV(compiler, TMP_REGISTER, 0, src2, src2w); - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, dst, dstw); + EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw); FAIL_IF(!inst); *inst = op_mr; } @@ -1608,7 +1616,7 @@ } /* General version. */ - if (dst <= TMP_REGISTER && dst != src2) { + if (FAST_IS_REG(dst) && dst != src2) { EMIT_MOV(compiler, dst, 0, src1, src1w); if (src2 & SLJIT_IMM) { BINARY_IMM(op_imm, op_mr, src2w, dst, 0); @@ -1621,16 +1629,16 @@ } else { /* This version requires less memory writing. */ - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); if (src2 & SLJIT_IMM) { - BINARY_IMM(op_imm, op_mr, src2w, TMP_REGISTER, 0); + BINARY_IMM(op_imm, op_mr, src2w, TMP_REG1, 0); } else { - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, src2, src2w); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w); FAIL_IF(!inst); *inst = op_rm; } - EMIT_MOV(compiler, dst, dstw, TMP_REGISTER, 0); + EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); } return SLJIT_SUCCESS; @@ -1644,7 +1652,7 @@ sljit_ub* inst; sljit_si dst_r; - dst_r = (dst <= TMP_REGISTER) ? dst : TMP_REGISTER; + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; /* Register destination. */ if (dst_r == src1 && !(src2 & SLJIT_IMM)) { @@ -1752,7 +1760,7 @@ else { /* Neither argument is immediate. */ if (ADDRESSING_DEPENDS_ON(src2, dst_r)) - dst_r = TMP_REGISTER; + dst_r = TMP_REG1; EMIT_MOV(compiler, dst_r, 0, src1, src1w); inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w); FAIL_IF(!inst); @@ -1760,8 +1768,8 @@ *inst = IMUL_r_rm; } - if (dst_r == TMP_REGISTER) - EMIT_MOV(compiler, dst, dstw, TMP_REGISTER, 0); + if (dst_r == TMP_REG1) + EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); return SLJIT_SUCCESS; } @@ -1782,10 +1790,10 @@ return SLJIT_ERR_UNSUPPORTED; } - dst_r = (dst <= TMP_REGISTER) ? dst : TMP_REGISTER; + dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1; - if (src1 <= TMP_REGISTER) { - if (src2 <= TMP_REGISTER || src2 == TMP_REGISTER) { + if (FAST_IS_REG(src1)) { + if (FAST_IS_REG(src2)) { inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM2(src1, src2), 0); FAIL_IF(!inst); *inst = LEA_r_m; @@ -1803,7 +1811,7 @@ done = 1; } } - else if (src2 <= TMP_REGISTER) { + else if (FAST_IS_REG(src2)) { #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) if ((src1 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src1w))) { inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), (sljit_si)src1w); @@ -1818,8 +1826,8 @@ } if (done) { - if (dst_r == TMP_REGISTER) - return emit_mov(compiler, dst, dstw, TMP_REGISTER, 0); + if (dst_r == TMP_REG1) + return emit_mov(compiler, dst, dstw, TMP_REG1, 0); return SLJIT_SUCCESS; } return SLJIT_ERR_UNSUPPORTED; @@ -1840,7 +1848,7 @@ return SLJIT_SUCCESS; } - if (src1 <= TMP_REGISTER) { + if (FAST_IS_REG(src1)) { if (src2 & SLJIT_IMM) { BINARY_IMM(CMP, CMP_rm_r, src2w, src1, 0); } @@ -1852,7 +1860,7 @@ return SLJIT_SUCCESS; } - if (src2 <= TMP_REGISTER && !(src1 & SLJIT_IMM)) { + if (FAST_IS_REG(src2) && !(src1 & SLJIT_IMM)) { inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w); FAIL_IF(!inst); *inst = CMP_rm_r; @@ -1861,15 +1869,15 @@ if (src2 & SLJIT_IMM) { if (src1 & SLJIT_IMM) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); - src1 = TMP_REGISTER; + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); + src1 = TMP_REG1; src1w = 0; } BINARY_IMM(CMP, CMP_rm_r, src2w, src1, src1w); } else { - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, src2, src2w); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w); FAIL_IF(!inst); *inst = CMP_r_rm; } @@ -1900,7 +1908,7 @@ return SLJIT_SUCCESS; } - if (src1 <= TMP_REGISTER) { + if (FAST_IS_REG(src1)) { if (src2 & SLJIT_IMM) { #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) if (IS_HALFWORD(src2w) || compiler->mode32) { @@ -1928,7 +1936,7 @@ return SLJIT_SUCCESS; } - if (src2 <= TMP_REGISTER) { + if (FAST_IS_REG(src2)) { if (src1 & SLJIT_IMM) { #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) if (IS_HALFWORD(src1w) || compiler->mode32) { @@ -1956,28 +1964,28 @@ return SLJIT_SUCCESS; } - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); if (src2 & SLJIT_IMM) { #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) if (IS_HALFWORD(src2w) || compiler->mode32) { - inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0); FAIL_IF(!inst); *inst = GROUP_F7; } else { FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w)); - inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst = TEST_rm_r; } #else - inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0); FAIL_IF(!inst); *inst = GROUP_F7; #endif } else { - inst = emit_x86_instruction(compiler, 1, TMP_REGISTER, 0, src2, src2w); + inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w); FAIL_IF(!inst); *inst = TEST_rm_r; } @@ -2000,21 +2008,21 @@ return SLJIT_SUCCESS; } if (dst == SLJIT_UNUSED) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); - inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REGISTER, 0); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); + inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0); FAIL_IF(!inst); *inst |= mode; return SLJIT_SUCCESS; } if (dst == SLJIT_PREF_SHIFT_REG && src2 == SLJIT_PREF_SHIFT_REG) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); - inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); + inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst |= mode; - EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0); return SLJIT_SUCCESS; } - if (dst <= TMP_REGISTER) { + if (FAST_IS_REG(dst)) { EMIT_MOV(compiler, dst, 0, src1, src1w); inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, 0); FAIL_IF(!inst); @@ -2022,36 +2030,36 @@ return SLJIT_SUCCESS; } - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); - inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REGISTER, 0); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); + inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0); FAIL_IF(!inst); *inst |= mode; - EMIT_MOV(compiler, dst, dstw, TMP_REGISTER, 0); + EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); return SLJIT_SUCCESS; } if (dst == SLJIT_PREF_SHIFT_REG) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w); - inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst |= mode; - EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0); } - else if (dst <= TMP_REGISTER && dst != src2 && !ADDRESSING_DEPENDS_ON(src2, dst)) { + else if (FAST_IS_REG(dst) && dst != src2 && !ADDRESSING_DEPENDS_ON(src2, dst)) { if (src1 != dst) EMIT_MOV(compiler, dst, 0, src1, src1w); - EMIT_MOV(compiler, TMP_REGISTER, 0, SLJIT_PREF_SHIFT_REG, 0); + EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_PREF_SHIFT_REG, 0); EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w); inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, dst, 0); FAIL_IF(!inst); *inst |= mode; - EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0); + EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0); } else { /* This case is really difficult, since ecx itself may used for addressing, and we must ensure to work even in that case. */ - EMIT_MOV(compiler, TMP_REGISTER, 0, src1, src1w); + EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w); #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0); #else @@ -2059,7 +2067,7 @@ EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_sw), SLJIT_PREF_SHIFT_REG, 0); #endif EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w); - inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REGISTER, 0); + inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0); FAIL_IF(!inst); *inst |= mode; #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) @@ -2067,7 +2075,7 @@ #else EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), sizeof(sljit_sw)); #endif - EMIT_MOV(compiler, dst, dstw, TMP_REGISTER, 0); + EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0); } return SLJIT_SUCCESS; @@ -2098,12 +2106,12 @@ if (!set_flags) return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w); - if (!(dst <= TMP_REGISTER)) + if (!FAST_IS_REG(dst)) FAIL_IF(emit_cmp_binary(compiler, src1, src1w, SLJIT_IMM, 0)); FAIL_IF(emit_shift(compiler,mode, dst, dstw, src1, src1w, src2, src2w)); - if (dst <= TMP_REGISTER) + if (FAST_IS_REG(dst)) return emit_cmp_binary(compiler, dst, dstw, SLJIT_IMM, 0); return SLJIT_SUCCESS; } @@ -2263,7 +2271,9 @@ SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void) { -#if (defined SLJIT_SSE2 && SLJIT_SSE2) +#ifdef SLJIT_IS_FPU_AVAILABLE + return SLJIT_IS_FPU_AVAILABLE; +#elif (defined SLJIT_SSE2 && SLJIT_SSE2) #if (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2) if (cpu_has_sse2 == -1) get_cpu_features(); @@ -2329,7 +2339,7 @@ if (GET_OPCODE(op) == SLJIT_CMPD) { compiler->flags_saved = 0; - if (dst <= SLJIT_FLOAT_REG6) + if (FAST_IS_REG(dst)) dst_r = dst; else { dst_r = TMP_FREG; @@ -2339,15 +2349,15 @@ } if (op == SLJIT_MOVD) { - if (dst <= SLJIT_FLOAT_REG6) + if (FAST_IS_REG(dst)) return emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst, src, srcw); - if (src <= SLJIT_FLOAT_REG6) + if (FAST_IS_REG(src)) return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, src); FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src, srcw)); return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG); } - if (dst >= SLJIT_FLOAT_REG1 && dst <= SLJIT_FLOAT_REG6) { + if (SLOW_IS_REG(dst)) { dst_r = dst; if (dst != src) FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src, srcw)); @@ -2386,7 +2396,7 @@ compiler->mode32 = 1; #endif - if (dst <= SLJIT_FLOAT_REG6) { + if (FAST_IS_REG(dst)) { dst_r = dst; if (dst == src1) ; /* Do nothing here. */ @@ -2548,8 +2558,8 @@ #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL) if (src == SLJIT_SCRATCH_REG3) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src, 0); - src = TMP_REGISTER; + EMIT_MOV(compiler, TMP_REG1, 0, src, 0); + src = TMP_REG1; } if (src == SLJIT_MEM1(SLJIT_LOCALS_REG) && type >= SLJIT_CALL3) srcw += sizeof(sljit_sw); @@ -2557,8 +2567,8 @@ #endif #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && defined(_WIN64) if (src == SLJIT_SCRATCH_REG3) { - EMIT_MOV(compiler, TMP_REGISTER, 0, src, 0); - src = TMP_REGISTER; + EMIT_MOV(compiler, TMP_REG1, 0, src, 0); + src = TMP_REG1; } #endif FAIL_IF(call_with_args(compiler, type)); @@ -2626,22 +2636,22 @@ cond_set = get_jump_code(type) + 0x10; #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) - if (GET_OPCODE(op) == SLJIT_OR && !GET_ALL_FLAGS(op) && dst <= TMP_REGISTER && dst == src) { + if (GET_OPCODE(op) == SLJIT_OR && !GET_ALL_FLAGS(op) && FAST_IS_REG(dst) && dst == src) { inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + 3); FAIL_IF(!inst); INC_SIZE(4 + 3); /* Set low register to conditional flag. */ - *inst++ = (reg_map[TMP_REGISTER] <= 7) ? REX : REX_B; + *inst++ = (reg_map[TMP_REG1] <= 7) ? REX : REX_B; *inst++ = GROUP_0F; *inst++ = cond_set; - *inst++ = MOD_REG | reg_lmap[TMP_REGISTER]; - *inst++ = REX | (reg_map[TMP_REGISTER] <= 7 ? 0 : REX_R) | (reg_map[dst] <= 7 ? 0 : REX_B); + *inst++ = MOD_REG | reg_lmap[TMP_REG1]; + *inst++ = REX | (reg_map[TMP_REG1] <= 7 ? 0 : REX_R) | (reg_map[dst] <= 7 ? 0 : REX_B); *inst++ = OR_rm8_r8; - *inst++ = MOD_REG | (reg_lmap[TMP_REGISTER] << 3) | reg_lmap[dst]; + *inst++ = MOD_REG | (reg_lmap[TMP_REG1] << 3) | reg_lmap[dst]; return SLJIT_SUCCESS; } - reg = (op == SLJIT_MOV && dst <= TMP_REGISTER) ? dst : TMP_REGISTER; + reg = (op == SLJIT_MOV && FAST_IS_REG(dst)) ? dst : TMP_REG1; inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + 4); FAIL_IF(!inst); @@ -2656,19 +2666,19 @@ *inst++ = MOVZX_r_rm8; *inst = MOD_REG | (reg_lmap[reg] << 3) | reg_lmap[reg]; - if (reg != TMP_REGISTER) + if (reg != TMP_REG1) return SLJIT_SUCCESS; if (GET_OPCODE(op) < SLJIT_ADD) { compiler->mode32 = GET_OPCODE(op) != SLJIT_MOV; - return emit_mov(compiler, dst, dstw, TMP_REGISTER, 0); + return emit_mov(compiler, dst, dstw, TMP_REG1, 0); } #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG) compiler->skip_checks = 1; #endif - return sljit_emit_op2(compiler, op, dst, dstw, dst, dstw, TMP_REGISTER, 0); + return sljit_emit_op2(compiler, op, dst, dstw, dst, dstw, TMP_REG1, 0); #else /* SLJIT_CONFIG_X86_64 */ - if (GET_OPCODE(op) < SLJIT_ADD && dst <= TMP_REGISTER) { + if (GET_OPCODE(op) < SLJIT_ADD && FAST_IS_REG(dst)) { if (reg_map[dst] <= 4) { /* Low byte is accessible. */ inst = (sljit_ub*)ensure_buf(compiler, 1 + 3 + 3); @@ -2690,7 +2700,7 @@ get_cpu_features(); if (cpu_has_cmov) { - EMIT_MOV(compiler, TMP_REGISTER, 0, SLJIT_IMM, 1); + EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1); /* a xor reg, reg operation would overwrite the flags. */ EMIT_MOV(compiler, dst, 0, SLJIT_IMM, 0); @@ -2701,14 +2711,14 @@ *inst++ = GROUP_0F; /* cmovcc = setcc - 0x50. */ *inst++ = cond_set - 0x50; - *inst++ = MOD_REG | (reg_map[dst] << 3) | reg_map[TMP_REGISTER]; + *inst++ = MOD_REG | (reg_map[dst] << 3) | reg_map[TMP_REG1]; return SLJIT_SUCCESS; } inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1); FAIL_IF(!inst); INC_SIZE(1 + 3 + 3 + 1); - *inst++ = XCHG_EAX_r + reg_map[TMP_REGISTER]; + *inst++ = XCHG_EAX_r + reg_map[TMP_REG1]; /* Set al to conditional flag. */ *inst++ = GROUP_0F; *inst++ = cond_set; @@ -2717,24 +2727,24 @@ *inst++ = GROUP_0F; *inst++ = MOVZX_r_rm8; *inst++ = MOD_REG | (reg_map[dst] << 3) | 0 /* eax */; - *inst++ = XCHG_EAX_r + reg_map[TMP_REGISTER]; + *inst++ = XCHG_EAX_r + reg_map[TMP_REG1]; return SLJIT_SUCCESS; } - if (GET_OPCODE(op) == SLJIT_OR && !GET_ALL_FLAGS(op) && dst <= TMP_REGISTER && dst == src && reg_map[dst] <= 4) { + if (GET_OPCODE(op) == SLJIT_OR && !GET_ALL_FLAGS(op) && FAST_IS_REG(dst) && dst == src && reg_map[dst] <= 4) { SLJIT_COMPILE_ASSERT(reg_map[SLJIT_SCRATCH_REG1] == 0, scratch_reg1_must_be_eax); if (dst != SLJIT_SCRATCH_REG1) { inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 2 + 1); FAIL_IF(!inst); INC_SIZE(1 + 3 + 2 + 1); /* Set low register to conditional flag. */ - *inst++ = XCHG_EAX_r + reg_map[TMP_REGISTER]; + *inst++ = XCHG_EAX_r + reg_map[TMP_REG1]; *inst++ = GROUP_0F; *inst++ = cond_set; *inst++ = MOD_REG | 0 /* eax */; *inst++ = OR_rm8_r8; *inst++ = MOD_REG | (0 /* eax */ << 3) | reg_map[dst]; - *inst++ = XCHG_EAX_r + reg_map[TMP_REGISTER]; + *inst++ = XCHG_EAX_r + reg_map[TMP_REG1]; } else { inst = (sljit_ub*)ensure_buf(compiler, 1 + 2 + 3 + 2 + 2); @@ -2742,23 +2752,23 @@ INC_SIZE(2 + 3 + 2 + 2); /* Set low register to conditional flag. */ *inst++ = XCHG_r_rm; - *inst++ = MOD_REG | (1 /* ecx */ << 3) | reg_map[TMP_REGISTER]; + *inst++ = MOD_REG | (1 /* ecx */ << 3) | reg_map[TMP_REG1]; *inst++ = GROUP_0F; *inst++ = cond_set; *inst++ = MOD_REG | 1 /* ecx */; *inst++ = OR_rm8_r8; *inst++ = MOD_REG | (1 /* ecx */ << 3) | 0 /* eax */; *inst++ = XCHG_r_rm; - *inst++ = MOD_REG | (1 /* ecx */ << 3) | reg_map[TMP_REGISTER]; + *inst++ = MOD_REG | (1 /* ecx */ << 3) | reg_map[TMP_REG1]; } return SLJIT_SUCCESS; } - /* Set TMP_REGISTER to the bit. */ + /* Set TMP_REG1 to the bit. */ inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1); FAIL_IF(!inst); INC_SIZE(1 + 3 + 3 + 1); - *inst++ = XCHG_EAX_r + reg_map[TMP_REGISTER]; + *inst++ = XCHG_EAX_r + reg_map[TMP_REG1]; /* Set al to conditional flag. */ *inst++ = GROUP_0F; *inst++ = cond_set; @@ -2768,15 +2778,15 @@ *inst++ = MOVZX_r_rm8; *inst++ = MOD_REG | (0 << 3) /* eax */ | 0 /* eax */; - *inst++ = XCHG_EAX_r + reg_map[TMP_REGISTER]; + *inst++ = XCHG_EAX_r + reg_map[TMP_REG1]; if (GET_OPCODE(op) < SLJIT_ADD) - return emit_mov(compiler, dst, dstw, TMP_REGISTER, 0); + return emit_mov(compiler, dst, dstw, TMP_REG1, 0); #if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) || (defined SLJIT_DEBUG && SLJIT_DEBUG) compiler->skip_checks = 1; #endif - return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REGISTER, 0); + return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0); #endif /* SLJIT_CONFIG_X86_64 */ } @@ -2796,12 +2806,12 @@ #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) if (NOT_HALFWORD(offset)) { - FAIL_IF(emit_load_imm64(compiler, TMP_REGISTER, offset)); + FAIL_IF(emit_load_imm64(compiler, TMP_REG1, offset)); #if (defined SLJIT_DEBUG && SLJIT_DEBUG) - SLJIT_ASSERT(emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_LOCALS_REG, 0, TMP_REGISTER, 0) != SLJIT_ERR_UNSUPPORTED); + SLJIT_ASSERT(emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_LOCALS_REG, 0, TMP_REG1, 0) != SLJIT_ERR_UNSUPPORTED); return compiler->error; #else - return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_LOCALS_REG, 0, TMP_REGISTER, 0); + return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_LOCALS_REG, 0, TMP_REG1, 0); #endif } #endif @@ -2831,13 +2841,13 @@ #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) compiler->mode32 = 0; - reg = (dst <= TMP_REGISTER) ? dst : TMP_REGISTER; + reg = SLOW_IS_REG(dst) ? dst : TMP_REG1; if (emit_load_imm64(compiler, reg, init_value)) return NULL; #else if (dst == SLJIT_UNUSED) - dst = TMP_REGISTER; + dst = TMP_REG1; if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value)) return NULL; @@ -2850,8 +2860,8 @@ *inst++ = 1; #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) - if (reg == TMP_REGISTER && dst != SLJIT_UNUSED) - if (emit_mov(compiler, dst, dstw, TMP_REGISTER, 0)) + if (dst & SLJIT_MEM) + if (emit_mov(compiler, dst, dstw, TMP_REG1, 0)) return NULL; #endif diff -Nru r-base-3.1.0/src/extra/tre/tre-internal.h r-base-3.1.1/src/extra/tre/tre-internal.h --- r-base-3.1.0/src/extra/tre/tre-internal.h 2014-03-12 23:02:09.000000000 +0000 +++ r-base-3.1.1/src/extra/tre/tre-internal.h 2014-06-13 22:15:07.000000000 +0000 @@ -106,8 +106,8 @@ #endif /* !TRE_WCHAR */ -/* WIN32 opt-out is R addition - iswctype is missing "blank" */ -#if !defined(WIN32) && defined(TRE_WCHAR) && defined(HAVE_ISWCTYPE) && defined(HAVE_WCTYPE) +/* _WIN32 opt-out is R addition - iswctype is missing "blank" */ +#if !defined(_WIN32) && defined(TRE_WCHAR) && defined(HAVE_ISWCTYPE) && defined(HAVE_WCTYPE) #define TRE_USE_SYSTEM_WCTYPE 1 #endif diff -Nru r-base-3.1.0/src/extra/tre/xmalloc.c r-base-3.1.1/src/extra/tre/xmalloc.c --- r-base-3.1.0/src/extra/tre/xmalloc.c 2010-10-15 16:28:00.000000000 +0000 +++ r-base-3.1.1/src/extra/tre/xmalloc.c 2014-06-13 22:15:07.000000000 +0000 @@ -93,7 +93,7 @@ for (i = 0; i < (int)sizeof(ptr)*8 / TABLE_BITS; i++) { /* R change: unsigned long may be shorter than ptr */ -#ifdef WIN64 +#ifdef _WIN64 hash ^= (size_t)ptr >> i*8; #else hash ^= (unsigned long)ptr >> i*8; diff -Nru r-base-3.1.0/src/extra/tzone/localtime.c r-base-3.1.1/src/extra/tzone/localtime.c --- r-base-3.1.0/src/extra/tzone/localtime.c 2014-03-12 23:02:07.000000000 +0000 +++ r-base-3.1.1/src/extra/tzone/localtime.c 2014-06-13 22:15:06.000000000 +0000 @@ -53,7 +53,7 @@ #include #include // for open + modes -#ifndef WIN32 +#ifndef _WIN32 # include // for access, read, close #endif @@ -389,7 +389,11 @@ char buf[1000]; p = getenv("TZDIR"); if (p == NULL) { - snprintf(buf, 1000, "%s/share/zoneinfo", getenv("R_HOME")); + p = getenv("R_SHARE_DIR"); + if(p) + snprintf(buf, 1000, "%s/zoneinfo", p); + else + snprintf(buf, 1000, "%s/share/zoneinfo", getenv("R_HOME")); buf[999] = '\0'; p = buf; } diff -Nru r-base-3.1.0/src/extra/tzone/Make.zi r-base-3.1.1/src/extra/tzone/Make.zi --- r-base-3.1.0/src/extra/tzone/Make.zi 2014-03-17 23:15:05.000000000 +0000 +++ r-base-3.1.1/src/extra/tzone/Make.zi 2014-05-19 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ ## Makefile to be run on a Unix box with zic -VERSION = 2014a +VERSION = 2014c TZDIR = zoneinfo TZTMP = tz TARFILE = tzdata$(VERSION).tar.gz diff -Nru r-base-3.1.0/src/extra/tzone/Notes r-base-3.1.1/src/extra/tzone/Notes --- r-base-3.1.0/src/extra/tzone/Notes 2014-03-17 23:15:04.000000000 +0000 +++ r-base-3.1.1/src/extra/tzone/Notes 2014-06-20 22:15:04.000000000 +0000 @@ -23,11 +23,12 @@ To remake it, download the current version of tzdataXXXXx.tar.gz from http://www.iana.org/time-zones to this directory and run -make -f Make.zi VERSION=2014a +make -f Make.zi VERSION=2014e for the appropriate version. If zic is not on the path, use something like -make -f Make.zi VERSION=2014a ZIC=/usr/sbin/zic +make -f Make.zi VERSION=2014e ZIC=/usr/sbin/zic NB: it seems that this needs to be done on a system with 64-bit time_t -or the catalogs will be confined to 1902-2038. +or the catalogs will be confined to 1902-2038. And even that does not +to suffice on OS X, whose zic seems to be 32-bit. diff -Nru r-base-3.1.0/src/extra/tzone/strftime.c r-base-3.1.1/src/extra/tzone/strftime.c --- r-base-3.1.0/src/extra/tzone/strftime.c 2014-03-12 23:02:07.000000000 +0000 +++ r-base-3.1.1/src/extra/tzone/strftime.c 2014-06-13 22:15:06.000000000 +0000 @@ -214,7 +214,7 @@ case 'c': // In a C locale this is supposed to be // "%a %b %e %T %Y". It is not on Windows .... -#ifdef WIN32 +#ifdef _WIN32 pt = _fmt("%a %b %e %T %Y", t, pt, ptlim); #else pt = _fmt(orig("%c", t), t, pt, ptlim); @@ -306,7 +306,7 @@ stm tm = *t; char buf[22]; // <= 19 digs + sign + terminator int_fast64_t mkt = R_mktime(&tm); -#ifdef WIN32 +#ifdef _WIN32 // not ISO C99, so warns (void) snprintf(buf, 22, "%I64d", mkt); #else Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/extra/tzone/zoneinfo.zip and /tmp/cKZCsh2fJF/r-base-3.1.1/src/extra/tzone/zoneinfo.zip differ diff -Nru r-base-3.1.0/src/extra/xdr/rpc/types.h r-base-3.1.1/src/extra/xdr/rpc/types.h --- r-base-3.1.0/src/extra/xdr/rpc/types.h 2011-07-19 22:05:01.000000000 +0000 +++ r-base-3.1.1/src/extra/xdr/rpc/types.h 2014-06-13 22:15:08.000000000 +0000 @@ -59,10 +59,10 @@ # define NULL 0 #endif -#if !defined(WIN32) && !defined(macintosh) && !defined(__CYGWIN__) +#if !defined(_WIN32) && !defined(macintosh) && !defined(__CYGWIN__) #include // for malloc #endif -#if defined(WIN32) && defined(LEA_MALLOC) +#if defined(_WIN32) && defined(LEA_MALLOC) #include extern void *Rm_malloc(size_t n); extern void Rm_free(void * p); @@ -78,7 +78,7 @@ #include #endif /* macintosh */ #endif -#if !defined(WIN32) && !defined(macintosh) +#if !defined(_WIN32) && !defined(macintosh) #include #endif diff -Nru r-base-3.1.0/src/extra/xdr/xdr_mem.c r-base-3.1.1/src/extra/xdr/xdr_mem.c --- r-base-3.1.0/src/extra/xdr/xdr_mem.c 2011-07-22 22:05:02.000000000 +0000 +++ r-base-3.1.1/src/extra/xdr/xdr_mem.c 2014-06-13 22:15:08.000000000 +0000 @@ -8,8 +8,8 @@ typedef unsigned long uintptr_t; #endif -/* Local mod: assumes WIN32 is i386 and little-endian generic is 32-bit */ -#if defined(WIN32) || defined(__CYGWIN__) +/* Local mod: assumes _WIN32 is i386 and little-endian generic is 32-bit */ +#if defined(_WIN32) || defined(__CYGWIN__) static uint32_t ntohl(uint32_t x) { /* could write VC++ inline assembler, but not worth it for now */ #ifdef _MSC_VER diff -Nru r-base-3.1.0/src/extra/xdr/xdr_stdio.c r-base-3.1.1/src/extra/xdr/xdr_stdio.c --- r-base-3.1.0/src/extra/xdr/xdr_stdio.c 2011-07-22 22:05:02.000000000 +0000 +++ r-base-3.1.1/src/extra/xdr/xdr_stdio.c 2014-06-13 22:15:08.000000000 +0000 @@ -4,8 +4,8 @@ #include -/* Local mod: assumes WIN32 is i386 and little-endian generic is 32-bit */ -#if defined(WIN32) || defined(__CYGWIN__) +/* Local mod: assumes _WIN32 is i386 and little-endian generic is 32-bit */ +#if defined(_WIN32) || defined(__CYGWIN__) static uint32_t ntohl(uint32_t x) { /* could write VC++ inline assembler, but not worth it for now */ #ifdef _MSC_VER diff -Nru r-base-3.1.0/src/extra/xz/check/crc64_fast.c r-base-3.1.1/src/extra/xz/check/crc64_fast.c --- r-base-3.1.0/src/extra/xz/check/crc64_fast.c 2010-11-08 23:05:05.000000000 +0000 +++ r-base-3.1.1/src/extra/xz/check/crc64_fast.c 2014-05-27 22:15:04.000000000 +0000 @@ -25,8 +25,10 @@ #endif +// Used in package utils, so needs to be visible +#include // See the comments in crc32_fast.c. They aren't duplicated here. -extern LZMA_API(uint64_t) +extern attribute_visible LZMA_API(uint64_t) lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) { crc = ~crc; diff -Nru r-base-3.1.0/src/extra/xz/common/common.h r-base-3.1.1/src/extra/xz/common/common.h --- r-base-3.1.0/src/extra/xz/common/common.h 2010-11-08 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/extra/xz/common/common.h 2014-05-31 22:15:04.000000000 +0000 @@ -24,8 +24,6 @@ # define LZMA_API_EXPORT # endif // Don't use ifdef or defined() below. -#elif HAVE_VISIBILITY -# define LZMA_API_EXPORT __attribute__((__visibility__("default"))) #else # define LZMA_API_EXPORT #endif diff -Nru r-base-3.1.0/src/gnuwin32/console.c r-base-3.1.1/src/gnuwin32/console.c --- r-base-3.1.0/src/gnuwin32/console.c 2014-03-12 23:03:24.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/console.c 2014-05-22 22:15:05.000000000 +0000 @@ -360,7 +360,6 @@ p->clp = NULL; p->r = -1; p->overwrite = 0; - p->lazyupdate = 1; p->needredraw = 0; p->wipe_completion = 0; p->my0 = p->my1 = -1; @@ -1547,7 +1546,10 @@ xbufaddxs(p->lbuf, buf, 1); } if (strchr(s, '\n')) p->needredraw = 1; - if (!p->lazyupdate || (p->r >= 0)) + if (!p->lazyupdate) { + setfirstvisible(c, NUMLINES - ROWS); + REDRAW; + } else if (p->r >= 0) setfirstvisible(c, NUMLINES - ROWS); else { p->newfv = NUMLINES - ROWS; diff -Nru r-base-3.1.0/src/gnuwin32/COPYRIGHTS.win r-base-3.1.1/src/gnuwin32/COPYRIGHTS.win --- r-base-3.1.0/src/gnuwin32/COPYRIGHTS.win 2010-03-17 14:43:06.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/COPYRIGHTS.win 2014-06-26 22:15:03.000000000 +0000 @@ -133,3 +133,13 @@ src/gnuwin32/bitmap direcctory. The exact sources used for these libraries are available on request to R-windows@r-project.org (you will need to specify which binary installer version). + +A binay build may contain compiled sources from cairographics, +distributed under LGPL 2.1 (our choice) or MPL 1.1. The binary +distribution used is that at http://www.rforge.net/Cairo/files/ . + +A binary build may contain compiled components from ICU, whose license +can be viewed at +http://source.icu-project.org/repos/icu/icu/trunk/license.html: the +sources and binary libraries used are available at +http://www.stats.ox.ac.uk/pub/Rtools/ . diff -Nru r-base-3.1.0/src/gnuwin32/extra.c r-base-3.1.1/src/gnuwin32/extra.c --- r-base-3.1.0/src/gnuwin32/extra.c 2014-03-12 23:03:26.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/extra.c 2014-06-13 22:15:14.000000000 +0000 @@ -231,7 +231,7 @@ GetComputerNameW(name, &namelen); wcstoutf8(buf, name, 1000); SET_STRING_ELT(ans, 3, mkCharCE(buf, CE_UTF8)); -#ifdef WIN64 +#ifdef _WIN64 SET_STRING_ELT(ans, 4, mkChar("x86-64")); #else SET_STRING_ELT(ans, 4, mkChar("x86")); @@ -307,7 +307,7 @@ if (!R_FINITE(mem)) error(_("incorrect argument")); #ifdef LEA_MALLOC -#ifndef WIN64 +#ifndef _WIN64 if(mem >= 4096) error(_("don't be silly!: your machine has a 4Gb address limit")); #endif diff -Nru r-base-3.1.0/src/gnuwin32/fixed/h/config.h r-base-3.1.1/src/gnuwin32/fixed/h/config.h --- r-base-3.1.0/src/gnuwin32/fixed/h/config.h 2014-03-12 23:03:25.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/fixed/h/config.h 2014-06-13 22:15:14.000000000 +0000 @@ -988,7 +988,7 @@ #endif /* Define this to be the name of the CPU of your system. */ -#ifdef WIN64 +#ifdef _WIN64 #define R_CPU "x86_64" #else #define R_CPU "i386" @@ -1007,7 +1007,7 @@ #define R_OS "mingw32" /* Define this to be the canonical name (cpu-vendor-os) of your system. */ -#ifdef WIN64 +#ifdef _WIN64 #define R_PLATFORM "x86_64-w64-mingw32" #else #define R_PLATFORM "i386-w64-mingw32" @@ -1038,7 +1038,7 @@ #define SIZEOF_LONG 4 /* The size of `long double', as computed by sizeof. */ -#ifdef WIN64 +#ifdef _WIN64 #define SIZEOF_LONG_DOUBLE 16 #else #define SIZEOF_LONG_DOUBLE 12 diff -Nru r-base-3.1.0/src/gnuwin32/front-ends/RSetReg.c r-base-3.1.1/src/gnuwin32/front-ends/RSetReg.c --- r-base-3.1.0/src/gnuwin32/front-ends/RSetReg.c 2012-04-15 22:05:37.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/front-ends/RSetReg.c 2014-06-13 22:15:14.000000000 +0000 @@ -24,7 +24,7 @@ #define PRODUCER "R-core" -#ifdef WIN64 +#ifdef _WIN64 # define RK "R64" #else # define RK "R32" diff -Nru r-base-3.1.0/src/gnuwin32/front-ends/rterm.c r-base-3.1.1/src/gnuwin32/front-ends/rterm.c --- r-base-3.1.0/src/gnuwin32/front-ends/rterm.c 2012-06-23 22:05:05.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/front-ends/rterm.c 2014-06-13 22:15:14.000000000 +0000 @@ -77,7 +77,7 @@ gl_hist_init(R_HistorySize, 1); if (R_RestoreHistory) gl_loadhistory(R_HistoryFile); saveConsoleTitle(); -#ifdef WIN64 +#ifdef _WIN64 SetConsoleTitle("Rterm (64-bit)"); #else SetConsoleTitle("Rterm (32-bit)"); diff -Nru r-base-3.1.0/src/gnuwin32/installer/JRins.R r-base-3.1.1/src/gnuwin32/installer/JRins.R --- r-base-3.1.0/src/gnuwin32/installer/JRins.R 2014-03-12 23:03:26.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/installer/JRins.R 2014-05-08 22:15:06.000000000 +0000 @@ -28,7 +28,9 @@ Rver <- readLines("../../../VERSION")[1L] Rver <- sub("Under .*$", "Pre-release", Rver) + ## This is now over 2^16, so truncate SVN <- sub("Revision: ", "", readLines("../../../SVN-REVISION"))[1L] + SVN <- as.character(as.numeric(SVN) - 50000L) Rver0 <- paste(sub(" .*$", "", Rver), SVN, sep = ".") diff -Nru r-base-3.1.0/src/gnuwin32/Makefile r-base-3.1.1/src/gnuwin32/Makefile --- r-base-3.1.0/src/gnuwin32/Makefile 2013-11-19 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/Makefile 2014-06-26 22:15:03.000000000 +0000 @@ -67,7 +67,7 @@ R-DLLFLAGS=-mwindows ifdef USE_ICU -LIBEXTRAS+= -licuin38 -licuuc38 +LIBEXTRAS+= -L$(ICU_PATH)/lib$(R_ARCH) $(ICU_LIBS) endif R-DLLLIBS =$(OPENMP) -L. $(FLIBS) -lRblas -L../../$(IMPDIR) -lRzlib -lRgraphapp -lRiconv -lcomctl32 -lversion $(LIBEXTRAS) @@ -285,7 +285,7 @@ $(RM) ../../doc/html/index.html \ ../../doc/html/packages.html ../../doc/html/rwin.html \ ../../doc/html/rw-FAQ.html ../../doc/html/NEWS.html \ - ../../doc/NEWS.rds ../../NEWS ../../NEWS.pdf \ + ../../doc/NEWS.rds ../../doc/NEWS ../../doc/NEWS.pdf \ ../../doc/CHANGES.rds ../../doc/html/CHANGES.html $(RM) ../../etc/Makeconf ../../etc/Rconsole ../../etc/Rdevga \ ../../etc/Rprofile.site ../../etc/rgb.txt ../../etc/Rcmd_environ \ diff -Nru r-base-3.1.0/src/gnuwin32/MkRules.dist r-base-3.1.1/src/gnuwin32/MkRules.dist --- r-base-3.1.0/src/gnuwin32/MkRules.dist 2013-10-06 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/MkRules.dist 2014-06-26 22:15:03.000000000 +0000 @@ -64,10 +64,11 @@ ### END more detailed options -# set to use ICU (experimental) -# USE_ICU=YES +# set to use ICU +# USE_ICU = YES # path to parent of ICU headers -ICU_PATH=/sources/icu +ICU_PATH = /path/to/ICU +ICU_LIBS = -lsicuin -lsicuuc -lsicudt -lstdc++ # optional overrides for making bitmapdll: names of source directories # JPEGDIR = jpeg-9 @@ -92,6 +93,7 @@ MAKEINFO = makeinfo # for texinfo >= 5.0. Might also need -I/path/to/modules # MAKEINFO = /path/to/perl /path/to/texi2any +# or perhaps something like # additional optimization flags (use -mtune=native for a private build) EOPTS = -mtune=core2 diff -Nru r-base-3.1.0/src/gnuwin32/Rdll.hide r-base-3.1.1/src/gnuwin32/Rdll.hide --- r-base-3.1.0/src/gnuwin32/Rdll.hide 2014-03-12 23:03:25.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/Rdll.hide 2014-06-13 22:15:14.000000000 +0000 @@ -125,9 +125,6 @@ R_OpenSiteFile R_OpenSysInitFile R_OutputCon - R_PPStack - R_PPStackSize - R_PPStackTop R_Parse1Buffer R_Parse1File R_ParseBuffer @@ -229,7 +226,6 @@ R_newsock R_newunz R_newurl - R_num_math_threads R_nwarnings R_osDynSymbol R_possible_dispatch diff -Nru r-base-3.1.0/src/gnuwin32/rui.c r-base-3.1.1/src/gnuwin32/rui.c --- r-base-3.1.0/src/gnuwin32/rui.c 2013-04-16 22:05:07.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/rui.c 2014-06-13 22:15:14.000000000 +0000 @@ -1041,7 +1041,7 @@ if (RguiMDI & RW_MDI) { TRACERUI("Rgui"); RFrame = newwindow( -#ifdef WIN64 +#ifdef _WIN64 "RGui (64-bit)", #else "RGui (32-bit)", @@ -1056,7 +1056,7 @@ TRACERUI("Console done"); } else { TRACERUI("Console"); -#ifdef WIN64 +#ifdef _WIN64 if (!(RConsole = newconsole("R Console (64-bit)", flags ))) return 0; #else if (!(RConsole = newconsole("R Console (32-bit)", flags ))) return 0; diff -Nru r-base-3.1.0/src/gnuwin32/run.c r-base-3.1.1/src/gnuwin32/run.c --- r-base-3.1.0/src/gnuwin32/run.c 2014-01-05 23:05:33.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/run.c 2014-05-15 22:15:05.000000000 +0000 @@ -41,18 +41,19 @@ static char RunError[501] = ""; /* This might be given a command line (whole = 0) or just the - executable (whole = 0). In the later case the path may or may not + executable (whole = 1). In the later case the path may or may not be quoted */ static char *expandcmd(const char *cmd, int whole) { char c = '\0'; char *s, *p, *q = NULL, *f, *dest, *src; int d, ext, len = strlen(cmd)+1; - char buf[len], fl[len], fn[len]; + char buf[len], fl[len], fn[MAX_PATH]; /* make a copy as we manipulate in place */ strcpy(buf, cmd); + // This is the return value. if (!(s = (char *) malloc(MAX_PATH + strlen(cmd)))) { strcpy(RunError, "Insufficient memory (expandcmd)"); return NULL; @@ -62,7 +63,7 @@ /* find the command itself, possibly double-quoted */ if (whole) { d = 0; - } else { + } else { // command line for (q = p, d = 0; *q && ( d || !isspace(*q) ); q++) if (*q == '\"') d = d ? 0 : 1; if (d) { @@ -109,11 +110,11 @@ return NULL; } /* + NB: as of Windows 7 SearchPath does not return short names any more. + Paranoia : on my system switching to short names is not needed since SearchPath already returns 'short names'. However, this is not documented so I prefer to be explicit. - Problem is that we have removed \" from the executable since - SearchPath seems dislikes them */ GetShortPathName(fn, s, MAX_PATH); if (!whole) { diff -Nru r-base-3.1.0/src/gnuwin32/system.c r-base-3.1.1/src/gnuwin32/system.c --- r-base-3.1.0/src/gnuwin32/system.c 2014-03-12 23:03:25.000000000 +0000 +++ r-base-3.1.1/src/gnuwin32/system.c 2014-06-13 22:15:14.000000000 +0000 @@ -885,7 +885,7 @@ ms.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&ms); /* Win2k or later */ Virtual = ms.ullTotalVirtual; /* uint64 = DWORDLONG */ -#ifdef WIN64 +#ifdef _WIN64 R_max_memory = ms.ullTotalPhys; #else R_max_memory = min(Virtual - 512*Mega, ms.ullTotalPhys); diff -Nru r-base-3.1.0/src/include/config.h.in r-base-3.1.1/src/include/config.h.in --- r-base-3.1.0/src/include/config.h.in 2014-03-12 23:02:11.000000000 +0000 +++ r-base-3.1.1/src/include/config.h.in 2014-06-13 22:18:01.000000000 +0000 @@ -109,12 +109,12 @@ /* Define to 1 if you have the `cexp' function. */ #undef HAVE_CEXP -/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the +/* Define to 1 if you have the OS X function CFLocaleCopyCurrent in the CoreFoundation framework. (For intl) */ #undef HAVE_CFLOCALECOPYCURRENT -/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in - the CoreFoundation framework. (For intl) */ +/* Define to 1 if you have the OS X function CFPreferencesCopyAppValue in the + CoreFoundation framework. (For intl) */ #undef HAVE_CFPREFERENCESCOPYAPPVALUE /* Define to 1 if you have the `chdir' function. */ diff -Nru r-base-3.1.0/src/include/Defn.h r-base-3.1.1/src/include/Defn.h --- r-base-3.1.0/src/include/Defn.h 2014-03-12 23:02:11.000000000 +0000 +++ r-base-3.1.1/src/include/Defn.h 2014-05-29 22:15:03.000000000 +0000 @@ -258,6 +258,9 @@ /* seems this is now defined by MinGW to be 259, whereas FILENAME_MAX and MAX_PATH are 260. It is not clear that this really is in bytes, but might be chars for the Unicode interfaces. + + 260 is d:\ plus 256 chars plus nul. Some but not all API calls + allow filepaths of the form \\?\D:\very_long_path . */ # define PATH_MAX 260 # else @@ -1057,6 +1060,8 @@ SEXP mkFalse(void); SEXP mkPRIMSXP (int, int); SEXP mkPROMISE(SEXP, SEXP); +SEXP R_mkEVPROMISE(SEXP, SEXP); +SEXP R_mkEVPROMISE_NR(SEXP, SEXP); SEXP mkQUOTE(SEXP); SEXP mkSYMSXP(SEXP, SEXP); SEXP mkTrue(void); diff -Nru r-base-3.1.0/src/include/R_ext/Lapack.h r-base-3.1.1/src/include/R_ext/Lapack.h --- r-base-3.1.0/src/include/R_ext/Lapack.h 2014-03-12 23:02:10.000000000 +0000 +++ r-base-3.1.1/src/include/R_ext/Lapack.h 2014-06-06 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2003-13 The R Core Team. + * Copyright (C) 2003-14 The R Core Team. * Copyright (C) 2008 The R Foundation * * This program is free software; you can redistribute it and/or modify @@ -361,7 +361,7 @@ /* DGESVX - use the LU factorization to compute the solution to a */ /* real system of linear equations A * X = B, */ La_extern void -F77_NAME(dgesvx)(const int* fact, const char* trans, const int* n, +F77_NAME(dgesvx)(const char* fact, const char* trans, const int* n, const int* nrhs, double* a, const int* lda, double* af, const int* ldaf, int* ipiv, char *equed, double* r, double* c, diff -Nru r-base-3.1.0/src/include/R_ext/libextern.h r-base-3.1.1/src/include/R_ext/libextern.h --- r-base-3.1.0/src/include/R_ext/libextern.h 2012-08-14 22:05:06.000000000 +0000 +++ r-base-3.1.1/src/include/R_ext/libextern.h 2014-06-13 22:15:08.000000000 +0000 @@ -30,7 +30,7 @@ /* Don't try to include CYGWIN here: decorating some symbols breaks the auto-export that it relies on, even if R_DLL_BUILD were set. */ -#ifdef WIN32 /* WIN32 as does not depend on config.h */ +#ifdef _WIN32 /* _WIN32 as does not depend on config.h */ #define LibImport __declspec(dllimport) #define LibExport __declspec(dllexport) #else diff -Nru r-base-3.1.0/src/include/R_ext/MathThreads.h r-base-3.1.1/src/include/R_ext/MathThreads.h --- r-base-3.1.0/src/include/R_ext/MathThreads.h 2012-08-14 22:05:06.000000000 +0000 +++ r-base-3.1.1/src/include/R_ext/MathThreads.h 2014-06-13 22:15:08.000000000 +0000 @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2000, 2001 The R Core Team. + * Copyright (C) 2000-2014 The R Core Team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -19,6 +19,12 @@ /* Experimental: included by src/library/stats/src/distance.c + + Note that only uses R_num_math_threads: it is not clear + R_num_math_threads should be exposed at all. + + This is not used currently on Windows, where R_num_math_threads + used not to be exposed. */ #ifndef R_EXT_MATHTHREADS_H_ diff -Nru r-base-3.1.0/src/include/Rinternals.h r-base-3.1.1/src/include/Rinternals.h --- r-base-3.1.0/src/include/Rinternals.h 2014-03-12 23:02:11.000000000 +0000 +++ r-base-3.1.1/src/include/Rinternals.h 2014-04-18 22:15:02.000000000 +0000 @@ -486,6 +486,11 @@ #endif #define MAYBE_REFERENCED(x) (! NO_REFERENCES(x)) +/* Complex assignment support */ +/* temporary definition that will need to be refined to distinguish + getter from setter calls */ +#define IS_GETTER_CALL(call) (CADR(call) == R_TmpvalSymbol) + /* Accessor functions. Many are declared using () to avoid the macro definitions in the USE_RINTERNALS section. The function STRING_ELT is used as an argument to arrayAssign even diff -Nru r-base-3.1.0/src/include/Rmath.h0.in r-base-3.1.1/src/include/Rmath.h0.in --- r-base-3.1.0/src/include/Rmath.h0.in 2014-03-12 23:02:11.000000000 +0000 +++ r-base-3.1.1/src/include/Rmath.h0.in 2014-06-13 22:15:08.000000000 +0000 @@ -649,7 +649,7 @@ # define R_FINITE(x) R_finite(x) int R_finite(double); -# ifdef WIN32 /* not Win32 as no config information */ +# ifdef _WIN32 /* not Win32 as no config information */ # ifdef RMATH_DLL # define R_EXTERN extern __declspec(dllimport) # else diff -Nru r-base-3.1.0/src/library/base/man/as.Date.Rd r-base-3.1.1/src/library/base/man/as.Date.Rd --- r-base-3.1.0/src/library/base/man/as.Date.Rd 2014-01-05 23:05:26.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/as.Date.Rd 2014-07-01 22:15:04.000000000 +0000 @@ -150,7 +150,7 @@ as.Date(32768, origin = "1900-01-01") ## Excel is said to use 1900-01-01 as day 1 (Windows default) or ## 1904-01-01 as day 0 (Mac default), but this is complicated by Excel -## treating 1900 as a leap year. +## incorrectly treating 1900 as a leap year. ## So for dates (post-1901) from Windows Excel as.Date(35981, origin = "1899-12-30") # 1998-07-05 ## and Mac Excel @@ -158,9 +158,11 @@ ## (these values come from http://support.microsoft.com/kb/214330) ## Experiment shows that Matlab's origin is 719529 days before ours, +## (it takes the non-existent 0000-01-01 as day 1) ## so Matlab day 734373 can be imported as -as.Date(734373, origin = "1970-01-01") - 719529 -## (value from http://www.mathworks.com/help/techdoc/matlab_prog/bspgcx2-1.html) +as.Date(734373, origin = "1970-01-01") - 719529 # 2010-08-23 +## (value from +## http://www.mathworks.de/de/help/matlab/matlab_prog/represent-date-and-times-in-MATLAB.html) ## Time zone effect z <- ISOdate(2010, 04, 13, c(0,12)) # midnight and midday UTC diff -Nru r-base-3.1.0/src/library/base/man/as.POSIXlt.Rd r-base-3.1.1/src/library/base/man/as.POSIXlt.Rd --- r-base-3.1.0/src/library/base/man/as.POSIXlt.Rd 2014-03-12 23:02:57.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/as.POSIXlt.Rd 2014-06-25 22:15:05.000000000 +0000 @@ -42,7 +42,8 @@ \item{tz}{A time zone specification to be used for the conversion, \emph{if one is required}. System-specific (see \link{time zones}), but \code{""} is the current time zone, and \code{"GMT"} is UTC - (Universal Time, Coordinated).} + (Universal Time, Coordinated). Invalid values are most commonly + treated as UTC, on some platforms with a warning.} \item{\dots}{further arguments to be passed to or from other methods.} \item{format}{character string giving a date-time format as used by \code{\link{strptime}}.} @@ -96,7 +97,8 @@ happens in such cases is OS-specific: one should expect the first to be \code{NA}, but the second could be interpreted as either BST or GMT (and common OSes give both possible values). Note too (see - \code{\link{strftime}}), OS facilities may not format invalid times correctly. + \code{\link{strftime}}) that OS facilities may not format invalid + times correctly. } \value{ @@ -108,14 +110,14 @@ \note{ Some of the concepts used have to be extended backwards in time (the - usage is \emph{proleptic}). For example, the origin of time for the - \code{"POSIXct"} class, \sQuote{1970-01-01 00:00.00 UTC}, is before UTC - was defined. More importantly, conversion is done assuming the - Gregorian calendar which was introduced in 1582 and not used - universally until the 20th century. One of the re-interpretations - assumed by ISO 8601:2004 is that there was a year zero, even though - current year numbering (and zero) is a much later concept (525 AD for - year numbers from 1 AD). + usage is said to be \sQuote{proleptic}). For example, the origin of + time for the \code{"POSIXct"} class, \sQuote{1970-01-01 00:00.00 UTC}, + is before UTC was defined. More importantly, conversion is done + assuming the Gregorian calendar which was introduced in 1582 and not + used universally until the 20th century. One of the + re-interpretations assumed by ISO 8601:2004 is that there was a year + zero, even though current year numbering (and zero) is a much later + concept (525 AD for year numbers from 1 AD). If you want to extract specific aspects of a time (such as the day of the week) just convert it to class \code{"POSIXlt"} and extract the @@ -170,9 +172,13 @@ as.POSIXct((z+0.1)/1000, origin = "1960-01-01") options(op) +## Matlab 'serial day number' (days and fractional days) +z <- 7.343736909722223e5 # 2010-08-23 16:35:00 +as.POSIXct((z - 719529)*86400, origin = "1970-01-01", tz = "UTC") + as.POSIXlt(Sys.time(), "GMT") # the current time in UTC } -\dontrun{## These may not be correct names on your system +\donttest{## These may not be correct names on your system as.POSIXlt(Sys.time(), "America/New_York") # in New York as.POSIXlt(Sys.time(), "EST5EDT") # alternative. as.POSIXlt(Sys.time(), "EST" ) # somewhere in Eastern Canada diff -Nru r-base-3.1.0/src/library/base/man/base-internal.Rd r-base-3.1.1/src/library/base/man/base-internal.Rd --- r-base-3.1.0/src/library/base/man/base-internal.Rd 2014-01-05 23:05:26.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/base-internal.Rd 2014-04-17 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/base-internal.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{base-internal} @@ -33,6 +33,7 @@ \alias{.popath} \alias{.mapply} \alias{.detach} +\alias{.maskedMsg} \alias{.C_R_addTaskCallback} \alias{.C_R_getTaskCallbackNames} @@ -97,6 +98,8 @@ .mapply(FUN, dots, MoreArgs) .detach(pos) + +.maskedMsg(same, pkg, by) } \arguments{ \item{x}{object from which to extract elements.} @@ -138,6 +141,11 @@ strictly positive length, or all of zero length).} \item{MoreArgs}{a list of other arguments to \code{FUN}.} \item{pos}{an integer.} + + \item{same}{character vector of \emph{same} objects, masking others.} + \item{pkg}{character string naming the package which is masked from or by.} + \item{by}{logical indicating if the masking happens \emph{by} + \code{pkg}, or (\code{by = FALSE}) from \code{pkg}.} } \details{ The functions \code{.subset} and \code{.subset2} are essentially @@ -217,6 +225,9 @@ \code{.mapply} and \code{.detach} are \sQuote{bare-bones} versions for use in other \R packages. + \code{.maskedMsg} is a utility called both from \code{\link{attach}()} + and \code{\link{library}()} for consistency to produce the warning message. + Objects starting \code{.C_} and \code{.F_} are references to registered C and Fortran entry points. } diff -Nru r-base-3.1.0/src/library/base/man/body.Rd r-base-3.1.1/src/library/base/man/body.Rd --- r-base-3.1.0/src/library/base/man/body.Rd 2012-04-15 22:05:26.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/body.Rd 2014-05-08 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/body.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{body} @@ -17,7 +17,7 @@ \arguments{ \item{fun}{a function object, or see \sQuote{Details}.} \item{envir}{environment in which the function should be defined.} - \item{value}{an object, usually a language object: see section + \item{value}{an object, usually a \link{language object}: see section \sQuote{Value}.} } \details{ @@ -32,8 +32,9 @@ } \value{ \code{body} returns the body of the function specified. This is - normally a language object, most often a call to \code{\{}, but it can - also be an object (e.g. \code{pi}) to be the return value of the function. + normally a \link{language object}, most often a call to \code{\{}, but + it can also be an object (e.g. \code{pi}) to be the return value of + the function. The replacement form sets the body of a function to the object on the right hand side, and (potentially) resets the diff -Nru r-base-3.1.0/src/library/base/man/bquote.Rd r-base-3.1.1/src/library/base/man/bquote.Rd --- r-base-3.1.0/src/library/base/man/bquote.Rd 2012-04-15 22:05:27.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/bquote.Rd 2014-05-08 22:15:06.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/bquote.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2007 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{bquote} @@ -15,12 +15,12 @@ bquote(expr, where = parent.frame()) } \arguments{ - \item{expr}{A language object.} + \item{expr}{A \link{language object}.} \item{where}{An environment.} } \value{ - A language object. + A \link{language object}. } \seealso{ \code{\link{quote}}, \code{\link{substitute}} diff -Nru r-base-3.1.0/src/library/base/man/character.Rd r-base-3.1.1/src/library/base/man/character.Rd --- r-base-3.1.0/src/library/base/man/character.Rd 2012-12-05 14:37:58.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/character.Rd 2014-05-08 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/character.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{character} @@ -48,8 +48,9 @@ \code{as.character} attempts to coerce its argument to character type; like \code{\link{as.vector}} it strips attributes including names. - For lists it deparses the elements individually, except that it - extracts the first element of length-one character vectors. + For lists and pairlists (including \link{language objects} such as + calls) it deparses the elements individually, except that it extracts + the first element of length-one character vectors. \code{is.character} returns \code{TRUE} or \code{FALSE} depending on whether its argument is of character type or not. @@ -57,7 +58,7 @@ \note{ \code{as.character} breaks lines in language objects at 500 characters, and inserts newlines. Prior to 2.15.0 lines were - truncated (at about 70 characters before 1.3.1). + truncated. } \seealso{ \code{\link{paste}}, \code{\link{substr}} and \code{\link{strsplit}} @@ -68,7 +69,7 @@ \code{help.search(keyword = "character")} gives even more links. \code{\link{deparse}}, which is normally preferable to - \code{as.character} for language objects. + \code{as.character} for \link{language objects}. } \references{ Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) diff -Nru r-base-3.1.0/src/library/base/man/connections.Rd r-base-3.1.1/src/library/base/man/connections.Rd --- r-base-3.1.0/src/library/base/man/connections.Rd 2014-03-30 22:15:04.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/connections.Rd 2014-06-25 22:15:05.000000000 +0000 @@ -385,6 +385,11 @@ explicitly, e.g. by \code{writeChar("\ufeff", con, eos = NULL)} or \code{writeBin(as.raw(c(0xef, 0xbb, 0xff)), binary_con)} + Encoding names \code{"utf8"}, \code{"mac"} and \code{"macroman"} are + not portable, and not supported on all current \R platforms. + \code{"UTF-8"} is portable and \code{"macintosh"} is the official + (and most widely supported) name for \sQuote{Mac Roman}. + Requesting a conversion that is not supported is an error, reported when the connection is opened. Exactly what happens when the requested translation cannot be done for invalid input is in general @@ -559,7 +564,7 @@ readLines(Tfile) close(Tfile) -\donttest{## fifo example -- may fail even with OS support for fifos +\dontrun{## fifo example -- may hang even with OS support for fifos if(capabilities("fifo")) { zz <- fifo("foo-fifo", "w+") writeLines("abc", zz) @@ -593,7 +598,8 @@ cat(format(round(stats::rnorm(48), 4)), fill = 70, file = zz) close(zz) file.show("outfile", delete.file = TRUE) - +} +\dontrun{ ## example for a machine running a finger daemon con <- socketConnection(port = 79, blocking = TRUE) diff -Nru r-base-3.1.0/src/library/base/man/cut.Rd r-base-3.1.1/src/library/base/man/cut.Rd --- r-base-3.1.0/src/library/base/man/cut.Rd 2013-03-05 23:02:36.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/cut.Rd 2014-05-27 22:15:06.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/cut.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2012 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{cut} @@ -47,16 +47,17 @@ is a constant vector, equal-length intervals are created, one of which includes the single value.) - If a \code{labels} parameter is specified, its values are used - to name the factor levels. If none is specified, the factor - level labels are constructed as \code{"(b1, b2]"}, \code{"(b2, b3]"} - etc. for \code{right = TRUE} and as \code{"[b1, b2)"}, \ldots if - \code{right = FALSE}. - In this case, \code{dig.lab} indicates the minimum number of digits + If a \code{labels} parameter is specified, its values are used to name + the factor levels. If none is specified, the factor level labels are + constructed as \code{"(b1, b2]"}, \code{"(b2, b3]"} etc. for + \code{right = TRUE} and as \code{"[b1, b2)"}, \ldots if \code{right = + FALSE}. + In this case, \code{dig.lab} indicates the minimum number of digits should be used in formatting the numbers \code{b1}, \code{b2}, \ldots. A larger value (up to 12) will be used if needed to distinguish - between any pair of endpoints: if this fails labels such as - \code{"Range3"} will be used. + between any pair of endpoints: if this fails labels such as + \code{"Range3"} will be used. Formatting is done by + \code{\link{formatC}}. The default method will sort a numeric vector of \code{breaks}, but other methods are not required to and \code{labels} will correspond to diff -Nru r-base-3.1.0/src/library/base/man/Dates.Rd r-base-3.1.1/src/library/base/man/Dates.Rd --- r-base-3.1.0/src/library/base/man/Dates.Rd 2013-03-05 23:02:35.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/Dates.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -63,7 +63,7 @@ \code{\link{DateTimeClasses}} for date-time classes. } -\examples{\dontrun{ +\examples{\donttest{ (today <- Sys.Date()) format(today, "\%d \%b \%Y") # with month as a word (tenweeks <- seq(today, length.out=10, by="1 week")) # next ten weeks diff -Nru r-base-3.1.0/src/library/base/man/DateTimeClasses.Rd r-base-3.1.1/src/library/base/man/DateTimeClasses.Rd --- r-base-3.1.0/src/library/base/man/DateTimeClasses.Rd 2014-03-12 23:03:01.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/DateTimeClasses.Rd 2014-04-25 22:15:02.000000000 +0000 @@ -95,22 +95,23 @@ \item{\code{zone}}{(Optional.) The abbreviation for the time zone in force at that time: \code{""} if unknown (but \code{""} might also be used for UTC).} - \item{\code{gmtoff}}{(Optional.) The offset in minutes from GMT: + \item{\code{gmtoff}}{(Optional.) The offset in seconds from GMT: positive values are East of the meridian. Usually \code{NA} if unknown, but \code{0} could mean unknown.} } - (The last two components not present for times in UTC and are + (The last two components are not present for times in UTC and are platform-dependent: they are supported on platforms based on BSD or - \code{glibc}, including Linux and OS X, but are not necessarily set.). - Note that the internal list structure is somewhat hidden, as many - methods (including \code{\link{length}(x)}, \code{\link{print}()} and - \code{\link{str}}) apply to the abstract date-time vector, as for - \code{"POSIXct"}. The classes correspond to the POSIX/C99 constructs - of \sQuote{calendar time} (the \code{time_t} data type) and - \sQuote{local time} (or broken-down time, the \code{struct tm} data - type), from which they also inherit their names. The components of - \code{"POSIXlt"} are integer vectors, except \code{sec} and - \code{zone}. + \code{glibc} (including Linux and OS X) and those using the + \code{tzcode} implementation shipped with \R (including Windows). But + they are not necessarily set.). Note that the internal list structure + is somewhat hidden, as many methods (including + \code{\link{length}(x)}, \code{\link{print}()} and \code{\link{str}}) + apply to the abstract date-time vector, as for \code{"POSIXct"}. The + classes correspond to the POSIX/C99 constructs of \sQuote{calendar + time} (the \code{time_t} data type) and \sQuote{local time} (or + broken-down time, the \code{struct tm} data type), from which they + also inherit their names. The components of \code{"POSIXlt"} are + integer vectors, except \code{sec} and \code{zone}. \code{"POSIXct"} is more convenient for including in data frames, and \code{"POSIXlt"} is closer to human-readable forms. A virtual class @@ -192,9 +193,9 @@ to billions of years), but such times can only be interpreted with reference to a time zone. - % http://www.timeanddate.com/calendar/julian-gregorian-switch.html The - concept of time zones was first adopted in the nineteenth century, and - the Gregorian calendar was introduced in 1582 but not universally + % http://www.timeanddate.com/calendar/julian-gregorian-switch.html + The concept of time zones was first adopted in the nineteenth century, + and the Gregorian calendar was introduced in 1582 but not universally adopted until 1927. OS services almost invariably assume the Gregorian calendar and may assume that the time zone that was first enacted for the location was in force before that date. (The earliest diff -Nru r-base-3.1.0/src/library/base/man/dcf.Rd r-base-3.1.1/src/library/base/man/dcf.Rd --- r-base-3.1.0/src/library/base/man/dcf.Rd 2014-03-28 23:15:04.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/dcf.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/dcf.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{dcf} @@ -102,18 +102,28 @@ \references{ \url{http://www.debian.org/doc/debian-policy/ch-controlfields.html}. + Note that \R does not require encoding in UTF-8, which is a recent - Debian requirement. Nor is it using the Debian-specific sub-format + Debian requirement. Nor does it use the Debian-specific sub-format which allows comment lines starting with \samp{#}. } \seealso{ \code{\link{write.table}}. + + \code{\link{available.packages}}, which uses \code{read.dcf} to read + the indices of package repositories. } -\examples{\dontrun{ -## Create a reduced version of the 'CONTENTS' file in package 'splines' -x <- read.dcf(file = system.file("CONTENTS", package = "splines"), - fields = c("Entry", "Description")) +\examples{\donttest{ +## Create a reduced version of the DESCRIPTION file in package 'splines' +x <- read.dcf(file = system.file("DESCRIPTION", package = "splines"), + fields = c("Package", "Version", "Title")) write.dcf(x) + +## An online DCF file with multiple records +con <- url("http://cran.r-project.org/src/contrib/PACKAGES") +y <- read.dcf(con, all = TRUE) +close(con) +utils::str(y) }} \keyword{print} \keyword{file} diff -Nru r-base-3.1.0/src/library/base/man/deparseOpts.Rd r-base-3.1.1/src/library/base/man/deparseOpts.Rd --- r-base-3.1.0/src/library/base/man/deparseOpts.Rd 2012-04-15 22:05:26.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/deparseOpts.Rd 2014-06-10 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/deparseOpts.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2007 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{deparseOpts} @@ -46,9 +46,9 @@ definitions. } \item{\code{warnIncomplete}}{ - Some exotic objects such as \link{environment}s, - external pointers, etc. can not be deparsed properly. This option - causes a warning to be issued if the deparser recognizes one of these + Some exotic objects such as \link{environment}s, external + pointers, etc. can not be deparsed properly. This option causes a + warning to be issued if the deparser recognizes one of these situations. Also, the parser in \R < 2.7.0 would only accept strings of up to @@ -56,7 +56,9 @@ } \item{\code{keepNA}}{ Integer, real and character \code{NA}s are surrounded by coercion - where necessary to ensure that they are parsed to the same type. + functions where necessary to ensure that they are parsed to the + same type. Since e.g. \code{NA_real_} can be output in \R, this is + mainly used in connection with \code{S_compatible}. } \item{\code{all}}{ An abbreviated way to specify all of the options diff -Nru r-base-3.1.0/src/library/base/man/dput.Rd r-base-3.1.1/src/library/base/man/dput.Rd --- r-base-3.1.0/src/library/base/man/dput.Rd 2013-03-05 23:02:36.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/dput.Rd 2014-06-21 22:15:06.000000000 +0000 @@ -43,7 +43,9 @@ To display saved source rather than deparsing the internal representation include \code{"useSource"} in \code{control}. \R currently saves - source only for function definitions. + source only for function definitions. If you do not care about source + representation (e.g. for a data object) set \code{options(keep.source + = FALSE}) before calling \code{dget}. } \value{ For \code{dput}, the first argument invisibly. @@ -51,6 +53,12 @@ For \code{dget}, the object created. } \note{ + This is \bold{not} a good way to transfer objects between \R sessions. + \code{\link{dump}} is better, but the function \code{\link{save}} is + designed to be used for transporting \R data, and will work with \R + objects that \code{dput} does not handle correctly as well as being + much faster. + To avoid the risk of a source attribute out of sync with the actual function definition, the source attribute of a function will never be written as an attribute. diff -Nru r-base-3.1.0/src/library/base/man/dump.Rd r-base-3.1.1/src/library/base/man/dump.Rd --- r-base-3.1.0/src/library/base/man/dump.Rd 2013-03-05 23:02:35.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/dump.Rd 2014-05-08 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/dump.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{dump} @@ -83,7 +83,7 @@ Currently environments, external pointers, weak references and objects of type \code{S4} are not deparsed in a way that can be - \code{source}d. In addition, language objects are deparsed in a + \code{source}d. In addition, \link{language objects} are deparsed in a simple way whatever the value of \code{control}, and this includes not dumping their attributes (which will result in a warning). } diff -Nru r-base-3.1.0/src/library/base/man/duplicated.Rd r-base-3.1.1/src/library/base/man/duplicated.Rd --- r-base-3.1.0/src/library/base/man/duplicated.Rd 2013-10-31 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/duplicated.Rd 2014-05-19 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/duplicated.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{duplicated} @@ -116,7 +116,9 @@ each row. For a matrix or array, and when \code{MARGIN = 0}, a logical array with the same dimensions and dimnames. - \code{anyDuplicated()}: a non-negative integer vector of length one. + \code{anyDuplicated()}: an integer or real vector of length one with + value the 1-based index of the first duplicate if any, otherwise + \code{0}. } \section{Warning}{ Using this for lists is potentially slow, especially if the elements diff -Nru r-base-3.1.0/src/library/base/man/Encoding.Rd r-base-3.1.1/src/library/base/man/Encoding.Rd --- r-base-3.1.0/src/library/base/man/Encoding.Rd 2013-03-05 23:02:35.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/Encoding.Rd 2014-04-27 22:15:01.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/Encoding.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{Encoding} @@ -26,16 +26,17 @@ \item{value}{A character vector of positive length.} } \details{ - Character strings in \R can be declared to be in \code{"latin1"} or - \code{"UTF-8"} or \code{"bytes"}. These declarations can be read by - \code{Encoding}, which will return a character vector of values - \code{"latin1"}, \code{"UTF-8"} \code{"bytes"} or \code{"unknown"}, or - set, when \code{value} is recycled as needed and other values are - silently treated as \code{"unknown"}. ASCII strings will never be - marked with a declared encoding, since their representation is the - same in all supported encodings. Strings marked as \code{"bytes"} are - intended to be non-ASCII strings which should be manipulated as bytes, - and never converted to a character encoding. + Character strings in \R can be declared to be encoded in + \code{"latin1"} or \code{"UTF-8"} or as \code{"bytes"}. These + declarations can be read by \code{Encoding}, which will return a + character vector of values \code{"latin1"}, \code{"UTF-8"} + \code{"bytes"} or \code{"unknown"}, or set, when \code{value} is + recycled as needed and other values are silently treated as + \code{"unknown"}. ASCII strings will never be marked with a declared + encoding, since their representation is the same in all supported + encodings. Strings marked as \code{"bytes"} are intended to be + non-ASCII strings which should be manipulated as bytes, and never + converted to a character encoding. \code{enc2native} and \code{enc2utf8} convert elements of character vectors to the native encoding or UTF-8 respectively, taking any @@ -48,7 +49,7 @@ \code{\link{read.table}}, \code{\link{readLines}}, and \code{\link{parse}} have an \code{encoding} argument that is used to declare encodings, \code{\link{iconv}} declares encodings from its - \code{from} argument, and console input in suitable locales is also + \code{to} argument, and console input in suitable locales is also declared. \code{\link{intToUtf8}} declares its output as \code{"UTF-8"}, and output text connections (see \code{\link{textConnection}}) are marked if running in a @@ -83,6 +84,9 @@ } \value{ A character vector. + + For \code{enc2utf8} encodings are always marked: they are for + \code{enc2native} in UTF-8 and Latin-1 locales. } \examples{ ## x is intended to be in latin1 diff -Nru r-base-3.1.0/src/library/base/man/EnvVar.Rd r-base-3.1.1/src/library/base/man/EnvVar.Rd --- r-base-3.1.0/src/library/base/man/EnvVar.Rd 2014-02-14 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/EnvVar.Rd 2014-06-18 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/EnvVar.Rd % Part of the R package, http://www.R-project.org -% Copyright 2007-2013 R Core Team +% Copyright 2007-2014 R Core Team % Distributed under GPL 2 or later \name{EnvVar} @@ -71,7 +71,7 @@ \item{\env{R_BROWSER}:}{The path to the default browser. Used to set the default value of \code{\link{options}("browser")}.} \item{\env{R_COMPLETION}:}{Optional. If set to \code{FALSE}, - command-line completion is not used. (Not used by Mac OS GUI.)} + command-line completion is not used. (Not used by OS X GUI.)} \item{\env{R_DEFAULT_PACKAGES}:}{A comma-separated list of packages which are to be attached in every session. See \code{\link{options}}.} \item{\env{R_DOC_DIR}:}{The location of the \R \file{doc} diff -Nru r-base-3.1.0/src/library/base/man/formatc.Rd r-base-3.1.1/src/library/base/man/formatc.Rd --- r-base-3.1.0/src/library/base/man/formatc.Rd 2013-08-04 22:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/formatc.Rd 2014-06-10 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/formatc.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{formatC} @@ -147,12 +147,16 @@ and \code{small.mark}, special characters need escaping. In particular, to insert a single backslash, use \code{"\\\\\\\\"}. - In versions of \R before 2.13.0, the \code{big.mark} would be - reversed on insertion if it contained more than one character. + The C doubles used for \R numerical vectors have signed zeros, which + \code{formatC} may output as \code{-0}, \code{-0.000} \dots. } \note{ Prior to \R 3.0.2 this copied the class of \code{x} to the return value and could easily create invalid objects. + + The default for \code{decimal.mark} is not appropriate for use within + \code{\link{print}} methods: use \code{decimal.mark = + getOption("OutDec")} there. } \author{ \code{formatC} was originally written by Bill Dunlap for S-PLUS, later diff -Nru r-base-3.1.0/src/library/base/man/formatDL.Rd r-base-3.1.1/src/library/base/man/formatDL.Rd --- r-base-3.1.0/src/library/base/man/formatDL.Rd 2012-04-15 22:05:28.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/formatDL.Rd 2014-05-12 22:15:05.000000000 +0000 @@ -43,16 +43,12 @@ In table style, items with more than \code{indent - 3} characters are displayed on a line of their own. } -\examples{\dontrun{ -%% FIXME: This no longer works! (\dontrun{..} is *not* the solution) -## Use R to create the 'INDEX' for package 'splines' from its 'CONTENTS' -x <- read.dcf(file = system.file("CONTENTS", package = "splines"), - fields = c("Entry", "Description")) -x <- as.data.frame(x) -writeLines(formatDL(x$Entry, x$Description)) -## or equivalently: writeLines(formatDL(x)) -## Same information in tagged description list style: -writeLines(formatDL(x$Entry, x$Description, style = "list")) -## or equivalently: writeLines(formatDL(x, style = "list")) -}} +\examples{ +## Provide a nice summary of the numerical characteristics of the +## machine R is running on: +writeLines(formatDL(unlist(.Machine))) +## Inspect Sys.getenv() results in "list" style (by default, these are +## printed in "table" style): +writeLines(formatDL(Sys.getenv(), style = "list")) +} \keyword{print} diff -Nru r-base-3.1.0/src/library/base/man/format.Rd r-base-3.1.1/src/library/base/man/format.Rd --- r-base-3.1.0/src/library/base/man/format.Rd 2013-08-27 22:05:08.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/format.Rd 2014-06-10 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/format.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Copyright 2003-2013 The R Foundation % Distributed under GPL 2 or later @@ -33,40 +33,48 @@ } \arguments{ \item{x}{any \R object (conceptually); typically numeric.} + \item{trim}{logical; if \code{FALSE}, logical, numeric and complex values are right-justified to a common width: if \code{TRUE} the leading blanks for justification are suppressed.} + \item{digits}{how many significant digits are to be used for numeric and complex \code{x}. The default, \code{NULL}, uses \code{\link{getOption}("digits")}. This is a suggestion: enough decimal places will be used so that the smallest (in magnitude) number has this many significant digits, and also to satisfy \code{nsmall}. (For the interpretation for complex numbers see \code{\link{signif}}.)} + \item{nsmall}{the minimum number of digits to the right of the decimal point in formatting real/complex numbers in non-scientific formats. Allowed values are \code{0 <= nsmall <= 20}.} + \item{justify}{should a \emph{character} vector be left-justified (the default), right-justified, centred or left alone.} + \item{width}{\code{default} method: the \emph{minimum} field width or \code{NULL} or \code{0} for no restriction. \code{AsIs} method: the \emph{maximum} field width for non-character - objects. \code{NULL} corresponds to the default 12. + objects. \code{NULL} corresponds to the default \code{12}. } + \item{na.encode}{logical: should \code{NA} strings be encoded? Note - this only applies to elements of character vectors, not to numerical - or logical \code{NA}s, which are always encoded as \code{"NA"}.} + this only applies to elements of character vectors, not to numerical, + complex nor logical \code{NA}s, which are always encoded as \code{"NA"}.} % because Mr Gorjanc won't read, PR#12318 + \item{scientific}{Either a logical specifying whether elements of a real or complex vector should be encoded in scientific format, or an integer penalty (see \code{\link{options}("scipen")}). Missing values correspond to the current default penalty.} + \item{\dots}{further arguments passed to or from other methods.} \item{big.mark, big.interval, small.mark, small.interval, decimal.mark, zero.print, drop0trailing}{% - used for prettying (longish) decimal sequences, passed to - \code{\link{prettyNum}}: that help page explains the details.} + used for prettying (longish) numerical and complex sequences. + Passed to \code{\link{prettyNum}}: that help page explains the details.} } \details{ \code{format} is a generic function. Apart from the methods described @@ -113,6 +121,11 @@ Raw vectors are converted to their 2-digit hexadecimal representation by \code{\link{as.character}}. + + The internal code respects the option + \code{\link{getOption}("OutDec")} for the \sQuote{decimal mark}, so if + this is set to something other than \code{"."} then it takes precedence + over argument \code{decimal.mark}. } \value{ An object of similar structure to \code{x} containing character diff -Nru r-base-3.1.0/src/library/base/man/iconv.Rd r-base-3.1.1/src/library/base/man/iconv.Rd --- r-base-3.1.0/src/library/base/man/iconv.Rd 2014-04-04 22:15:03.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/iconv.Rd 2014-06-25 22:15:05.000000000 +0000 @@ -116,7 +116,8 @@ Encoding names \code{"utf8"}, \code{"mac"} and \code{"macroman"} are not portable. \code{"utf8"} is converted to \code{"UTF-8"} for - \code{from} (as from \R 2.8.0) and \code{to} (as from \R 3.0.3). + \code{from} (as from \R 2.8.0) and \code{to} (as from \R 3.0.3) by + \code{iconv}, but not for e.g. \code{fileEncoding} arguments. \code{"macintosh"} is the official (and most widely supported) name for \sQuote{Mac Roman} (\url{http://en.wikipedia.org/wiki/Mac_OS_Roman}). diff -Nru r-base-3.1.0/src/library/base/man/icuSetCollate.Rd r-base-3.1.1/src/library/base/man/icuSetCollate.Rd --- r-base-3.1.0/src/library/base/man/icuSetCollate.Rd 2014-01-05 23:05:26.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/icuSetCollate.Rd 2014-06-26 22:15:02.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/icuSetCollate.Rd % Part of the R package, http://www.R-project.org -% Copyright 2008-2013 R Core Team +% Copyright 2008-2014 R Core Team % Distributed under GPL 2 or later \name{icuSetCollate} @@ -62,8 +62,8 @@ \code{C} locale, unless \code{locale} is specified. } \note{ - ICU is used by default wherever it is available: - this include Mac OS >= 10.4 and many Linux installations. + ICU is used by default wherever it is available: this include OS X (as + from 10.4) and many Linux installations. It is optional on Windows. } \seealso{ \link{Comparison}, \code{\link{sort}} diff -Nru r-base-3.1.0/src/library/base/man/is.language.Rd r-base-3.1.1/src/library/base/man/is.language.Rd --- r-base-3.1.0/src/library/base/man/is.language.Rd 2012-04-15 22:05:28.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/is.language.Rd 2014-05-08 22:15:06.000000000 +0000 @@ -1,10 +1,12 @@ % File src/library/base/man/is.language.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2007 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{is.language} \alias{is.language} +\alias{language object} +\alias{language objects} \title{Is an Object a Language Object?} \usage{ is.language(x) diff -Nru r-base-3.1.0/src/library/base/man/ISOdatetime.Rd r-base-3.1.1/src/library/base/man/ISOdatetime.Rd --- r-base-3.1.0/src/library/base/man/ISOdatetime.Rd 2014-01-05 23:05:26.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/ISOdatetime.Rd 2014-04-20 22:15:06.000000000 +0000 @@ -19,7 +19,8 @@ \item{hour, min, sec}{numerical values for a time within a day. Fractional seconds are allowed.} \item{tz}{A \link{time zone} specification to be used for the conversion. - \code{""} is the current time zone and \code{"GMT"} is UTC.} + \code{""} is the current time zone and \code{"GMT"} is UTC. Invalid + values are most commonly treated as UTC, on some platforms with a warning.} } \details{ \code{ISOdatetime} and \code{ISOdate} are convenience wrappers for diff -Nru r-base-3.1.0/src/library/base/man/lapply.Rd r-base-3.1.1/src/library/base/man/lapply.Rd --- r-base-3.1.0/src/library/base/man/lapply.Rd 2014-03-12 23:03:01.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/lapply.Rd 2014-05-08 22:15:06.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/lapply.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{lapply} @@ -44,7 +44,7 @@ \item{FUN.VALUE}{a (generalized) vector; a template for the return value from FUN. See \sQuote{Details}.} \item{n}{integer: the number of replications.} - \item{expr}{the expression (language object, usually a call) + \item{expr}{the expression (a \link{language object}, usually a call) to evaluate repeatedly.} \item{x}{a list, typically returned from \code{lapply()}.} diff -Nru r-base-3.1.0/src/library/base/man/length.Rd r-base-3.1.1/src/library/base/man/length.Rd --- r-base-3.1.0/src/library/base/man/length.Rd 2014-01-05 23:05:26.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/length.Rd 2014-05-08 22:15:06.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/length.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \newcommand{\CRANpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} @@ -43,9 +43,9 @@ For vectors (including lists) and factors the length is the number of elements. For an environment it is the number of objects in the environment, and \code{NULL} has length 0. For expressions and - pairlists (including language objects and dotlists) it is the length - of the pairlist chain. All other objects (including functions) have - length one: note that for functions this differs from S. + pairlists (including \link{language objects} and dotlists) it is the + length of the pairlist chain. All other objects (including functions) + have length one: note that for functions this differs from S. The replacement form removes all the attributes of \code{x} except its names, which are adjusted (and if necessary extended by \code{""}). diff -Nru r-base-3.1.0/src/library/base/man/locales.Rd r-base-3.1.1/src/library/base/man/locales.Rd --- r-base-3.1.0/src/library/base/man/locales.Rd 2013-07-15 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/locales.Rd 2014-06-18 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/locales.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{locales} @@ -127,7 +127,7 @@ Sys.setlocale("LC_TIME", "de") # Solaris: details are OS-dependent Sys.setlocale("LC_TIME", "de_DE.utf8") # Modern Linux etc. Sys.setlocale("LC_TIME", "de_DE.UTF-8") # ditto -Sys.setlocale("LC_TIME", "de_DE") # Mac OS X, in UTF-8 +Sys.setlocale("LC_TIME", "de_DE") # OS X, in UTF-8 Sys.setlocale("LC_TIME", "German") # Windows } Sys.getlocale("LC_PAPER") # may or may not be set diff -Nru r-base-3.1.0/src/library/base/man/match.fun.Rd r-base-3.1.1/src/library/base/man/match.fun.Rd --- r-base-3.1.0/src/library/base/man/match.fun.Rd 2012-04-15 22:05:29.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/match.fun.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -63,9 +63,7 @@ match.fun("*") # Overwrite outer with a vector outer <- 1:5 -\dontrun{ -match.fun(outer, descend = FALSE) #-> Error: not a function -} +try(match.fun(outer, descend = FALSE)) #-> Error: not a function match.fun(outer) # finds it anyway is.function(match.fun("outer")) # as well } diff -Nru r-base-3.1.0/src/library/base/man/merge.Rd r-base-3.1.1/src/library/base/man/merge.Rd --- r-base-3.1.0/src/library/base/man/merge.Rd 2014-03-27 23:15:25.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/merge.Rd 2014-06-17 22:15:05.000000000 +0000 @@ -95,6 +95,10 @@ \note{ This is intended to work with data frames with vector-like columns: some aspects work with data frames containing matrices, but not all. + + Currently long vectors are not accepted for inputs, which are thus + restricted to less than 2^31 rows, and that restriction + also applies to the result. } \value{ diff -Nru r-base-3.1.0/src/library/base/man/ns-hooks.Rd r-base-3.1.1/src/library/base/man/ns-hooks.Rd --- r-base-3.1.0/src/library/base/man/ns-hooks.Rd 2013-11-06 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/ns-hooks.Rd 2014-05-21 22:15:04.000000000 +0000 @@ -59,6 +59,10 @@ \code{.onDetach} are looked for as internal objects in the namespace and should not be exported (whereas \code{.Last.lib} should be). + Note that packages are not detached nor namespaces unloaded at the end + of an \R session unless the user arranges to do so (e.g. \emph{via} + \code{\link{.Last}}). + Anything needed for the functioning of the namespace should be handled at load/unload times by the \code{.onLoad} and \code{.onUnload} hooks. For example, DLLs can be loaded (unless done diff -Nru r-base-3.1.0/src/library/base/man/options.Rd r-base-3.1.1/src/library/base/man/options.Rd --- r-base-3.1.0/src/library/base/man/options.Rd 2014-04-02 22:02:04.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/options.Rd 2014-06-10 22:15:04.000000000 +0000 @@ -179,9 +179,11 @@ \code{max.print} \emph{entries}.} \item{\code{OutDec}:}{character string containing a single-byte - character. The character to be used as the decimal point in output - conversions, that is in printing, plotting and \code{as.character} - but not deparsing.} + character. The preferred character to be used as the decimal + point in output conversions, that is in printing, plotting, + \code{\link{format}} and \code{\link{as.character}} but not when + deparsing nor by \code{\link{sprintf}} nor \code{\link{formatC}} + (which are sometimes used prior to printing.} \item{\code{pager}:}{the command used for displaying text files by \code{\link{file.show}}. diff -Nru r-base-3.1.0/src/library/base/man/order.Rd r-base-3.1.1/src/library/base/man/order.Rd --- r-base-3.1.0/src/library/base/man/order.Rd 2014-03-12 23:03:01.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/order.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -146,7 +146,7 @@ (o <- order(a, b, na.last = FALSE)); z[o, ] (o <- order(a, b, na.last = NA)); z[o, ] -\dontrun{ +\donttest{ ## speed examples for long vectors: x <- factor(sample(letters, 1e6, replace = TRUE)) system.time(o <- sort.list(x)) ## 0.4 secs diff -Nru r-base-3.1.0/src/library/base/man/outer.Rd r-base-3.1.1/src/library/base/man/outer.Rd --- r-base-3.1.0/src/library/base/man/outer.Rd 2013-03-05 23:02:36.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/outer.Rd 2014-05-03 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/outer.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2007 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{outer} @@ -30,17 +30,17 @@ will be extended by \code{\link{rep}} to length the products of the lengths of \code{X} and \code{Y} before \code{FUN} is called. - \code{FUN} is called with these two extended vectors as - arguments. Therefore, it must be a vectorized function (or the - name of one), expecting at - least two arguments. + \code{FUN} is called with these two extended vectors as arguments + (plus any arguments in \code{\dots}). It must be a vectorized + function (or the name of one) expecting at least two arguments and + returning a value with the same length as the first (and the second). Where they exist, the [dim]names of \code{X} and \code{Y} will be copied to the answer, and a dimension assigned which is the concatenation of the dimensions of \code{X} and \code{Y} (or lengths if dimensions do not exist). - \code{FUN = "*"} is handled internally as a special case, \emph{via} + \code{FUN = "*"} is handled as a special case \emph{via} \code{as.vector(X) \%*\% t(as.vector(Y))}, and is intended only for numeric vectors and arrays. diff -Nru r-base-3.1.0/src/library/base/man/Platform.Rd r-base-3.1.1/src/library/base/man/Platform.Rd --- r-base-3.1.0/src/library/base/man/Platform.Rd 2014-04-02 22:02:04.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/Platform.Rd 2014-06-02 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/Platform.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{.Platform} @@ -92,9 +92,9 @@ \examples{ ## Note: this can be done in a system-independent way -## by file.info()$isdir +## by file.info()$isdir: see utils::file_test if(.Platform$OS.type == "unix") { - system.test <- function(...) { system(paste("test", ...)) == 0 } + system.test <- function(...) system(paste("test", ...)) == 0L dir.exists <- function(dir) sapply(dir, function(d) system.test("-d", d)) dir.exists(c(R.home(), "/tmp", "~", "/NO")) # > T T T F diff -Nru r-base-3.1.0/src/library/base/man/print.default.Rd r-base-3.1.1/src/library/base/man/print.default.Rd --- r-base-3.1.0/src/library/base/man/print.default.Rd 2014-02-20 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/print.default.Rd 2014-05-08 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/print.default.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2012 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{print.default} @@ -39,7 +39,7 @@ uses \code{\link{getOption}("max.print")}; see that help page for more details.} \item{useSource}{logical, indicating whether to use source - references or copies rather than deparsing language objects. + references or copies rather than deparsing \link{language objects}. The default is to use the original source if it is available.} \item{\dots}{further arguments to be passed to or from other methods. They are ignored in this function.} @@ -63,7 +63,7 @@ Option \code{width} controls the printing of vectors, matrices and arrays, and option \code{deparse.cutoff} controls the printing of - language objects such as calls and formulae. + \link{language objects} such as calls and formulae. When the \pkg{methods} package is attached, \code{print} will call \code{\link{show}} for \R objects with formal classes if called diff -Nru r-base-3.1.0/src/library/base/man/proc.time.Rd r-base-3.1.1/src/library/base/man/proc.time.Rd --- r-base-3.1.0/src/library/base/man/proc.time.Rd 2014-01-05 23:05:27.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/proc.time.Rd 2014-05-26 22:15:12.000000000 +0000 @@ -60,7 +60,7 @@ \code{\link{gc.time}} for how much of the time was spent in garbage collection. } -\examples{\dontrun{ +\examples{\donttest{ ## a way to time an R expression: system.time is preferred ptm <- proc.time() for (i in 1:50) mad(stats::runif(500)) diff -Nru r-base-3.1.0/src/library/base/man/quit.Rd r-base-3.1.1/src/library/base/man/quit.Rd --- r-base-3.1.0/src/library/base/man/quit.Rd 2013-04-04 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/quit.Rd 2014-05-21 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/quit.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{quit} @@ -34,11 +34,11 @@ ask in interactive use but may be overridden by command-line arguments (which must be supplied in non-interactive use). - Immediately \emph{before} terminating, \code{.Last()} is executed if - the function \code{.Last} exists and \code{runLast} is true. If in - interactive use there are errors in the \code{.Last} function, - control will be returned to the command prompt, so do test the - function thoroughly. There is a system analogue, + Immediately \emph{before} normal termination, \code{.Last()} is + executed if the function \code{.Last} exists and \code{runLast} is + true. If in interactive use there are errors in the \code{.Last} + function, control will be returned to the command prompt, so do test + the function thoroughly. There is a system analogue, \code{.Last.sys()}, which is run after \code{.Last()} if \code{runLast} is true. @@ -52,16 +52,16 @@ session temporary directory and print any remaining warnings (e.g. from \code{.Last()} and device closure). - Some error statuses are used by \R itself. The default error + Some error status values are used by \R itself. The default error handler for non-interactive use effectively calls \code{q("no", 1, - FALSE)} and returns error code 1. Error status 2 is used for \R + FALSE)} and returns error status 1. Error status 2 is used for \R \sQuote{suicide}, that is a catastrophic failure, and other small numbers are used by specific ports for initialization failures. It is recommended that users choose statuses of 10 or more. Valid values of \code{status} are system-dependent, but \code{0:255} are normally valid. (Many OSes will report the last byte of the - value, that is report the number modulo 256. But not all.) + value, that is report the value modulo 256. But not all.) #ifdef windows % https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true % https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/if.mspx?mfr=true @@ -82,7 +82,7 @@ \note{ The \code{R.app} GUI on OS X has its own version of these functions with slightly different behaviour for the \code{save} argument (the - \sQuote{Startup} preferences for this action are taken into account). + GUI's \sQuote{Startup} preferences for this action are taken into account). } \seealso{ \code{\link{.First}} for setting things on startup. @@ -90,6 +90,7 @@ \examples{ \dontrun{## Unix-flavour example .Last <- function() { + graphics.off() # close devices before printing cat("Now sending PDF graphics to the printer:\n") system("lpr Rplots.pdf") cat("bye bye...\n") diff -Nru r-base-3.1.0/src/library/base/man/readLines.Rd r-base-3.1.1/src/library/base/man/readLines.Rd --- r-base-3.1.0/src/library/base/man/readLines.Rd 2014-03-12 23:03:02.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/readLines.Rd 2014-05-16 22:15:09.000000000 +0000 @@ -26,8 +26,7 @@ used to mark character strings as known to be in Latin-1 or UTF-8: it is not used to re-encode the input. To do the latter, specify the encoding as part of the connection \code{con} or - via \code{\link{options}(encoding=)}: see the example under - \code{\link{file}}. + via \code{\link{options}(encoding=)}: see the examples. #ifdef windows See also \sQuote{Details}. #endif @@ -95,7 +94,8 @@ \dontrun{ # read a 'Windows Unicode' file -A <- readLines(file("Unicode.txt", encoding = "UCS-2LE")) +A <- readLines(con <- file("Unicode.txt", encoding = "UCS-2LE")) +close(con) unique(Encoding(A)) # will most likely be UTF-8 }} \keyword{file} diff -Nru r-base-3.1.0/src/library/base/man/readRDS.Rd r-base-3.1.1/src/library/base/man/readRDS.Rd --- r-base-3.1.0/src/library/base/man/readRDS.Rd 2013-03-05 23:02:35.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/readRDS.Rd 2014-06-05 22:15:02.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/serialize.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{readRDS} @@ -18,11 +18,11 @@ } \arguments{ \item{object}{\R object to serialize.} - \item{file}{a \link{connection} or the name of the file where the R object + \item{file}{a \link{connection} or the name of the file where the \R object is saved to or read from.} \item{ascii}{a logical. If \code{TRUE}, an ASCII representation is - written; otherwise (default except for text-mode connections), a - binary one is used. See the comments in the help for \code{\link{save}}.} + written; otherwise a binary one is used. See the comments in the + help for \code{\link{save}}.} \item{version}{the workspace format version to use. \code{NULL} specifies the current default version (2). Versions prior to 2 are not supported, so this will only be relevant when there are later versions.} @@ -85,7 +85,7 @@ identical(women, women2) ## or examine the object via a connection, which will be opened as needed. con <- gzfile("women.rds") -str(readRDS(con)) +readRDS(con) close(con) ## Less convenient ways to restore the object diff -Nru r-base-3.1.0/src/library/base/man/reg.finalizer.Rd r-base-3.1.1/src/library/base/man/reg.finalizer.Rd --- r-base-3.1.0/src/library/base/man/reg.finalizer.Rd 2014-02-16 23:05:02.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/reg.finalizer.Rd 2014-05-21 22:15:04.000000000 +0000 @@ -5,6 +5,7 @@ \name{reg.finalizer} \alias{reg.finalizer} +\alias{finalizer} \title{Finalization of Objects} \description{ Registers an \R function to be called upon garbage collection of @@ -30,7 +31,7 @@ for objects that are never copied on assignment, hence the restriction to environments and external pointers. - Note that as \R's interpreter is not re-entrant and the finalizer may + Note that as \R's interpreter is not re-entrant, the finalizer may be run in the middle of a computation. So there are many functions which it is not safe to call from \code{f}: one example which caused trouble is \code{\link{options}}. As from \R 3.0.3 finalizers are diff -Nru r-base-3.1.0/src/library/base/man/sample.Rd r-base-3.1.1/src/library/base/man/sample.Rd --- r-base-3.1.0/src/library/base/man/sample.Rd 2014-01-05 23:05:26.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/sample.Rd 2014-04-23 22:15:04.000000000 +0000 @@ -55,9 +55,8 @@ weights for obtaining the elements of the vector being sampled. They need not sum to one, but they should be non-negative and not all zero. If \code{replace} is true, Walker's alias method (Ripley, 1987) is - used when there are more than 250 reasonably probable values: this - gives results incompatible with those from \R < 2.2.0, and there will - be a warning the first time this happens in a session. + used when there are more than 200 reasonably probable values: this + gives results incompatible with those from \R < 2.2.0. If \code{replace} is false, these probabilities are applied sequentially, that is the probability of choosing the next item is diff -Nru r-base-3.1.0/src/library/base/man/save.Rd r-base-3.1.1/src/library/base/man/save.Rd --- r-base-3.1.0/src/library/base/man/save.Rd 2014-03-12 23:02:57.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/save.Rd 2014-06-08 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/save.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{save} @@ -73,11 +73,15 @@ All \R platforms use the XDR (bigendian) representation of C ints and doubles in binary save-d files, and these are portable across all \R - platforms. (ASCII saves used to be useful for moving data between - platforms but are now mainly of historical interest. They can be more - compact than binary saves where compression is not used, but are - almost always slower to both read and write: binary saves compress - much better than ASCII ones.) + platforms. + + ASCII saves used to be useful for moving data between platforms but + are now mainly of historical interest. They can be more compact than + binary saves where compression is not used, but are almost always + slower to both read and write: binary saves compress much better than + ASCII ones. Further, ASCII saves may not restore double/complex + values exactly, and what value is restored may depend on the \R + platform. Default values for the \code{ascii}, \code{compress}, \code{safe} and \code{version} arguments can be modified with the @@ -85,16 +89,18 @@ \code{save.image}), see also the \sQuote{Examples} section. If a \code{"save.image.defaults"} option is set it is used in preference to \code{"save.defaults"} for function \code{save.image} (which allows - this to have different defaults). In addition, + this to have different defaults). In addition, \code{compression_level} can be part of the \code{"save.defaults"} option. - A connection that is not already open will be opened in mode \code{"wb"}. + A connection that is not already open will be opened in mode + \code{"wb"}. Supplying a connection which is open and not in binary + mode gives an error. } \section{Compression}{ Large files can be reduced considerably in size by compression. A - particular 46MB object was saved as 35MB without compression in 2 + particular 46MB \R object was saved as 35MB without compression in 2 seconds, 22MB with \command{gzip} compression in 8 secs, 19MB with \command{bzip2} compression in 13 secs and 9.4MB with \command{xz} compression in 40 secs. The load times were 1.3, 2.8, 5.5 and 5.7 @@ -134,7 +140,7 @@ Saved \R objects are binary files, even those saved with \code{ascii = TRUE}, so ensure that they are transferred without - conversion of end of line markers and of 8-bit characters. The lines + conversion of end-of-line markers and of 8-bit characters. The lines are delimited by LF on all platforms. Although the default version has not changed since \R 1.4.0, this @@ -143,7 +149,7 @@ unless use is made of later additions (for example, raw vectors, external pointers and some S4 objects). - On such \sQuote{later addition} was long vectors, introduced in \R + One such \sQuote{later addition} was long vectors, introduced in \R 3.0.0 and loadable only on 64-bit platforms. } \seealso{ diff -Nru r-base-3.1.0/src/library/base/man/sink.Rd r-base-3.1.1/src/library/base/man/sink.Rd --- r-base-3.1.0/src/library/base/man/sink.Rd 2013-03-05 23:02:36.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/sink.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -100,7 +100,7 @@ outer(i, i, "*") sink() unlink("sink-examp.txt") -\dontrun{ +\donttest{ ## capture all the output to a file. zz <- file("all.Rout", open = "wt") sink(zz) @@ -109,7 +109,7 @@ ## back to the console sink(type = "message") sink() -try(log("a")) +file.show("all.Rout") }} \keyword{file} \keyword{connection} diff -Nru r-base-3.1.0/src/library/base/man/solve.Rd r-base-3.1.1/src/library/base/man/solve.Rd --- r-base-3.1.0/src/library/base/man/solve.Rd 2014-03-12 23:03:01.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/solve.Rd 2014-05-08 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/solve.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{solve} @@ -44,7 +44,7 @@ \code{\link{qr.solve}} can handle non-square systems. } \source{ - The defult method is an interface to the LAPACK routines \code{DGESV} + The default method is an interface to the LAPACK routines \code{DGESV} and \code{ZGESV}. LAPACK is from \url{http://www.netlib.org/lapack}. diff -Nru r-base-3.1.0/src/library/base/man/Special.Rd r-base-3.1.1/src/library/base/man/Special.Rd --- r-base-3.1.0/src/library/base/man/Special.Rd 2013-03-05 23:02:35.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/Special.Rd 2014-06-05 22:15:02.000000000 +0000 @@ -76,7 +76,8 @@ \code{deriv}-th derivative of \eqn{\psi(x)}. \deqn{\code{digamma(x)} = \psi(x) = \frac{d}{dx}\ln\Gamma(x) = \frac{\Gamma'(x)}{\Gamma(x)}}{digamma(x) = \psi(x) = d/dx{ln \Gamma(x)} = \Gamma'(x) / \Gamma(x)} - This is often called the \sQuote{polygamma} function, e.g. in + \eqn{\psi} and its derivatives, the \code{psigamma()} functions, are + often called the \sQuote{polygamma} functions, e.g. in Abramowitz and Stegun (section 6.4.1, page 260); and higher derivatives (\code{deriv = 2:4}) have occasionally been called \sQuote{tetragamma}, \sQuote{pentagamma}, and \sQuote{hexagamma}. @@ -116,7 +117,9 @@ Wadsworth & Brooks/Cole. (For \code{gamma} and \code{lgamma}.) Abramowitz, M. and Stegun, I. A. (1972) - \emph{Handbook of Mathematical Functions.} New York: Dover. + \emph{Handbook of Mathematical Functions}. New York: Dover. + \url{http://en.wikipedia.org/wiki/Abramowitz_and_Stegun} provides + links to the full text which is in public domain.\cr Chapter 6: Gamma and Related Functions. } \seealso{ diff -Nru r-base-3.1.0/src/library/base/man/sprintf.Rd r-base-3.1.1/src/library/base/man/sprintf.Rd --- r-base-3.1.0/src/library/base/man/sprintf.Rd 2014-03-12 23:02:59.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/sprintf.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/sprintf.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{sprintf} @@ -121,7 +121,9 @@ \item{\code{+}}{Always print number with sign: by default only negative numbers are printed with a sign.} \item{a space}{Prefix a space if the first character is not a sign.} - \item{\code{0}}{For numbers, pad to the field width with leading zeros.} + \item{\code{0}}{For numbers, pad to the field width with leading + zeros. For characters, this zero-pads on some platforms and is + ignored on others.} \item{\code{#}}{specifies \dQuote{alternate output} for numbers, its action depending on the type: For \code{x} or \code{X}, \code{0x} or \code{0X} will be prefixed @@ -152,6 +154,9 @@ Field widths and precisions of \code{\%s} conversions are interpreted as bytes, not characters, as described in the C standard. + + The C doubles used for \R numerical vectors have signed zeros, which + \code{sprintf} may output as \code{-0}, \code{-0.000} \dots. } %% (for #) This is from Kernighan & Ritchie, p. 243: %% For \code{o}, the first digit will be zero. @@ -244,6 +249,10 @@ sprintf("min 10-char string '\%10s'", c("a", "ABC", "and an even longer one")) +\donttest{## Platform-dependent bad example from qdapTools 1.0.0: +## may pad with spaces or zeroes. +sprintf("\%09s", month.name)} + n <- 1:18 sprintf(paste0("e with \%2d digits = \%.", n, "g"), n, exp(1)) diff -Nru r-base-3.1.0/src/library/base/man/strptime.Rd r-base-3.1.1/src/library/base/man/strptime.Rd --- r-base-3.1.0/src/library/base/man/strptime.Rd 2014-03-12 23:03:01.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/strptime.Rd 2014-04-23 22:15:04.000000000 +0000 @@ -30,7 +30,9 @@ \code{"\link{POSIXlt}"} for \code{strftime}.} \item{tz}{A character string specifying the time zone to be used for the conversion. System-specific (see \code{\link{as.POSIXlt}}), but - \code{""} is the current time zone, and \code{"GMT"} is UTC.} + \code{""} is the current time zone, and \code{"GMT"} is UTC. + Invalid values are most commonly treated as UTC, on some platforms with + a warning.} \item{format}{A character string. The default for the \code{format} methods is \code{"\%Y-\%m-\%d \%H:\%M:\%S"} if any element has a time @@ -159,8 +161,10 @@ For input, only years \code{0:9999} are accepted.} \item{\code{\%z}}{Signed offset in hours and minutes - from UTC, so \code{-0800} is 8 hours behind UTC.} - \item{\code{\%Z}}{(Output only.) Time zone abbreviation as a + from UTC, so \code{-0800} is 8 hours behind UTC. Values up to + \code{+1400} are accepted as from \R 3.1.1: previous versions only + accepted up to \code{+1200}.} + \item{\code{\%Z}}{(Output only.) Time zone abbreviation as a character string (empty if not available). This may not be reliable when a time zone has changed abbreviations over the years.} } @@ -239,7 +243,7 @@ more characters. Some platforms support modifiers from POSIX 2008 (and others). On - Linux the format \code{"\%04Y"}) assures a minimum of four characters + Linux the format \code{"\%04Y"} assures a minimum of four characters and zero-padding. The internal code (as used on Windows and by default on OS X) uses zero-padding by default, and formats \code{\%_4Y} and \code{\%_Y} can be used for space padding and no @@ -295,7 +299,7 @@ In a C locale \code{\%c} is required to be \code{"\%a \%b \%e \%H:\%M:\%S \%Y"}. As Windows does not comply (and uses a date format not understood outside N. America), that format is - used on Windows in all locales. + used by \R on Windows in all locales. That \code{\%A \%a \%B \%b} on input match both full and abbreviated names caused problems in some locales prior to \R 3.0.3: e.g. in French on diff -Nru r-base-3.1.0/src/library/base/man/Sys.getpid.Rd r-base-3.1.1/src/library/base/man/Sys.getpid.Rd --- r-base-3.1.0/src/library/base/man/Sys.getpid.Rd 2012-04-15 22:05:28.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/Sys.getpid.Rd 2014-06-18 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/Sys.getpid.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2009 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{Sys.getpid} @@ -18,8 +18,8 @@ } \value{ An integer, often between 1 and 32767 under Unix-alikes (but for - example FreeBSD and Mac OS >= 10.5 uses IDs up to 99999) and a - positive integer up to 32767) under Windows. + example FreeBSD and OS X use IDs up to 99999) and a + positive integer (up to 32767) under Windows. } \examples{\donttest{ Sys.getpid() diff -Nru r-base-3.1.0/src/library/base/man/Sys.glob.Rd r-base-3.1.1/src/library/base/man/Sys.glob.Rd --- r-base-3.1.0/src/library/base/man/Sys.glob.Rd 2014-02-20 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/Sys.glob.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -120,7 +120,7 @@ \link{Quotes} for handling backslashes in character strings. } \examples{ -\dontrun{ +\donttest{ Sys.glob(file.path(R.home(), "library", "*", "R", "*.rdx")) }} \keyword{utilities} diff -Nru r-base-3.1.0/src/library/base/man/Sys.localeconv.Rd r-base-3.1.1/src/library/base/man/Sys.localeconv.Rd --- r-base-3.1.0/src/library/base/man/Sys.localeconv.Rd 2013-03-05 23:02:36.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/Sys.localeconv.Rd 2014-05-26 22:15:12.000000000 +0000 @@ -51,7 +51,7 @@ ## "127" "127" ## Now try your default locale (which might be "C"). -\dontrun{old <- Sys.getlocale() +\donttest{old <- Sys.getlocale() ## The category may not be set: ## the following may do so, but it might not be supported. Sys.setlocale("LC_MONETARY", locale = "") diff -Nru r-base-3.1.0/src/library/base/man/system.Rd r-base-3.1.1/src/library/base/man/system.Rd --- r-base-3.1.0/src/library/base/man/system.Rd 2014-01-05 23:05:26.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/system.Rd 2014-06-18 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/base/man/system.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{system} @@ -140,7 +140,7 @@ For GUIs, what happens to output sent to \file{stdout} or \file{stderr} if \code{intern = FALSE} is interface-specific, and it is unsafe to assume that such messages will appear on a GUI console - (they do on the Mac OS X console, but not on some others). + (they do on the OS X GUI's console, but not on some others). } #endif diff -Nru r-base-3.1.0/src/library/base/man/textconnections.Rd r-base-3.1.1/src/library/base/man/textconnections.Rd --- r-base-3.1.0/src/library/base/man/textconnections.Rd 2013-03-05 23:02:35.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/textconnections.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -116,7 +116,7 @@ close(zz) foo -\dontrun{# capture R output: use part of example from help(lm) +\donttest{# capture R output: use part of example from help(lm) zz <- textConnection("foo", "w") ctl <- c(4.17, 5.58, 5.18, 6.11, 4.5, 4.61, 5.17, 4.53, 5.33, 5.14) trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69) diff -Nru r-base-3.1.0/src/library/base/man/timezones.Rd r-base-3.1.1/src/library/base/man/timezones.Rd --- r-base-3.1.0/src/library/base/man/timezones.Rd 2014-03-12 23:03:01.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/timezones.Rd 2014-06-06 22:15:03.000000000 +0000 @@ -51,7 +51,8 @@ If \env{TZ} is set but empty or invalid, most platforms default to \samp{UTC}, the time zone colloquially known as \samp{GMT} (see - \url{http://en.wikipedia.org/wiki/Coordinated_Universal_Time}). + \url{http://en.wikipedia.org/wiki/Coordinated_Universal_Time}). (Some + but not all platforms will give a warning for invalid timezones.) Time zones did not come into use until the second half of the nineteenth century and were not widely adopted until the twentieth, @@ -68,12 +69,13 @@ 1902 (so used local \sQuote{mean time} based on longitude) but for some places there had been time-zone changes before then. 64-bit representations are becoming common; unfortunately on some 64-bit OSes - the database information is only available for the range 1901--2038. + (notably OS X) the database information is only available for the + range 1901--2038, and incompletely for the end years. } \value{ \code{Sys.timezone} returns an OS-specific character string, possibly - \code{NA} or an empty string (which on some OSes means \samp{UTC}).. + \code{NA} or an empty string (which on some OSes means \samp{UTC}). For the default \code{location = TRUE} this will be a location such as \code{"Europe/London"} if one can be ascertained. For \code{location = FALSE} this may be an abbreviation such as \code{"EST"} or @@ -97,7 +99,7 @@ city) e.g. \code{Europe/London}, \code{America/Los_Angeles}, \code{Pacific/Easter}. Some traditional designations are also allowed such as \code{EST5EDT} or \code{GB}. (Beware that some of these - designations may not be what you think: in particular \code{EST} is a + designations may not be what you expect: in particular \code{EST} is a time zone used in Canada \emph{without} daylight saving time, and not \code{EST5EDT} nor (Australian) Eastern Standard Time.) The designation can also be an optional colon prepended to the path to a @@ -129,11 +131,12 @@ #ifdef unix Where \R was configured with option \option{--with-internal-tzcode} - (the default on OS X and Windows: recommended on Solaris), the - database at \code{file.path(R.home("share"), "zoneinfo")} is used by - default: file \file{VERSION} in that directory states the version. - Environment variable \env{TZDIR} can be used to point to a different - \file{zoneinfo} directory. + (the default on OS X: recommended on Solaris), the database at + \code{file.path(R.home("share"), "zoneinfo")} is used by default: file + \file{VERSION} in that directory states the version. Environment + variable \env{TZDIR} can be used to point to a different + \file{zoneinfo} directory (this is also supported by some OSes, + e.g. Linux). #endif #ifdef windows @@ -160,6 +163,14 @@ Contrary to some expectations (but consistent with names such as \samp{PST8PDT}), negative offsets are times ahead of (east of) UTC, positive offsets are times behind (west of) UTC. + + Immediately prior to the advent of legislated time zones, people used + time based on their longitude, known as \sQuote{Local Mean Time} and + abbreviated as \samp{LMT} in the databases. Often this was codified + by a name such as \sQuote{Copenhagen Mean Time} for a period before + the switch to standard time zones (such as \samp{GMT+5}). For + example, Paris codified its LMT as \sQuote{Paris Mean Time} in 1891, + switched to \samp{GMT+0} in 1911 and to \samp{GMT-1} in 1945. } \note{ @@ -175,7 +186,7 @@ Incorrect results will never be an \R issue, so please ensure that you have the courtesy not to blame \R for them. } -% Unlike Tony Plate. +% Unlike Tony Plate and John Pfuntner \seealso{ \code{\link{Sys.time}}, \code{\link{as.POSIXlt}}. diff -Nru r-base-3.1.0/src/library/base/man/utf8Conversion.Rd r-base-3.1.1/src/library/base/man/utf8Conversion.Rd --- r-base-3.1.0/src/library/base/man/utf8Conversion.Rd 2014-02-18 23:05:02.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/utf8Conversion.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -42,7 +42,7 @@ \code{NA} inputs are mapped to \code{NA} output. } -\examples{\dontrun{ +\examples{\donttest{ ## will only display in some locales and fonts intToUtf8(0x03B2L) # Greek beta }} diff -Nru r-base-3.1.0/src/library/base/man/vector.Rd r-base-3.1.1/src/library/base/man/vector.Rd --- r-base-3.1.0/src/library/base/man/vector.Rd 2013-06-23 22:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/vector.Rd 2014-05-26 22:15:11.000000000 +0000 @@ -125,9 +125,8 @@ } \examples{ df <- data.frame(x = 1:3, y = 5:7) -\dontrun{## Error: - as.vector(data.frame(x = 1:3, y = 5:7), mode = "numeric") -} +## Error: +try(as.vector(data.frame(x = 1:3, y = 5:7), mode = "numeric")) x <- c(a = 1, b = 2) is.vector(x) diff -Nru r-base-3.1.0/src/library/base/man/windows/shell.Rd r-base-3.1.1/src/library/base/man/windows/shell.Rd --- r-base-3.1.0/src/library/base/man/windows/shell.Rd 2013-07-29 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/windows/shell.Rd 2014-05-15 22:15:04.000000000 +0000 @@ -1,10 +1,9 @@ % File src/library/base/man/windows/shell.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{shell} -\Rdversion{1.1} \alias{shell} \title{Invoke a System Command, using a Shell} @@ -19,8 +18,8 @@ \code{NULL} (no shell). If missing, a suitable shell is chosen: see \sQuote{Details}.} \item{flag}{the switch to run a command under the shell. If the shell - is \code{bash} or \code{tcsh} or \code{sh} the default is changed to - \code{"-c"}.} + is identified as \code{bash} or \code{tcsh} or \code{sh} the default + is changed to \code{"-c"}.} \item{intern}{a logical, indicates whether to make the output of the command an \R object.} \item{wait}{should the \R interpreter wait for the command to finish? @@ -59,11 +58,14 @@ \details{ If no \code{shell} is specified, the environment variables \env{R_SHELL}, \env{SHELL} and \env{COMSPEC} are tried in turn: - \env{COMSPEC} should always succeed. Using \code{shell = NULL} - invokes the command \code{cmd} directly, in which case an extension - of \file{.exe} is assumed. It is possible to use batch files - directly if their extension is given: Windows (rather than \R) then - chooses a shell. + \env{COMSPEC} should always succeed. Note that future versions of \R + will not consult \env{SHELL}, so set \env{R_SHELL} if you want to + override \env{COMSPEC}. + + Using \code{shell = NULL} invokes the command \code{cmd} directly, in + which case an extension of \file{.exe} is assumed. It is possible to + use batch files directly if their extension is given: Windows (rather + than \R) then chooses a shell. See \code{\link{system}} for fuller details: \code{shell} is a more user-friendly wrapper for \code{system}. To make use of Windows diff -Nru r-base-3.1.0/src/library/base/man/with.Rd r-base-3.1.1/src/library/base/man/with.Rd --- r-base-3.1.0/src/library/base/man/with.Rd 2012-12-05 14:37:58.000000000 +0000 +++ r-base-3.1.1/src/library/base/man/with.Rd 2014-07-04 22:15:03.000000000 +0000 @@ -12,7 +12,7 @@ \title{Evaluate an Expression in a Data Environment} \description{ Evaluate an \R expression in an environment constructed from data, - possibly modifying the original data. + possibly modifying (a copy of) the original data. } \usage{ with(data, expr, \dots) @@ -38,10 +38,10 @@ \code{within} is similar, except that it examines the environment after the evaluation of \code{expr} and makes the corresponding - modifications to \code{data} (this may fail in the data frame case if - objects are created which cannot be stored in a data frame), and - returns it. \code{within} can be used as an alternative to - \code{transform}. + modifications to a copy of \code{data} (this may fail in the data + frame case if objects are created which cannot be stored in a data + frame), and returns it. \code{within} can be used as an alternative + to \code{transform}. } \value{ For \code{with}, the value of the evaluated \code{expr}. For @@ -54,7 +54,7 @@ \examples{ require(stats); require(graphics) #examples from glm: -\dontrun{ +\donttest{ library(MASS) with(anorexia, { anorex.1 <- glm(Postwt ~ Prewt + Treat + offset(Prewt), @@ -64,11 +64,11 @@ } - aq <- within(airquality, { # Notice that multiple vars can be changed lOzone <- log(Ozone) Month <- factor(month.abb[Month]) cTemp <- round((Temp - 32) * 5/9, 1) # From Fahrenheit to Celsius + S.cT <- Solar.R / cTemp # using the newly created variable rm(Day, Temp) }) head(aq) diff -Nru r-base-3.1.0/src/library/base/R/attach.R r-base-3.1.1/src/library/base/R/attach.R --- r-base-3.1.0/src/library/base/R/attach.R 2014-01-05 23:05:24.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/attach.R 2014-04-10 22:15:03.000000000 +0000 @@ -16,9 +16,25 @@ # A copy of the GNU General Public License is available at # http://www.r-project.org/Licenses/ +## also used by library() : +.maskedMsg <- function(same, pkg, by) { + objs <- strwrap(paste(same, collapse=", "), indent = 4L, exdent = 4L) + txt <- if(by) { + ngettext(length(same), + "The following object is masked _by_ %s:\n\n%s\n", + "The following objects are masked _by_ %s:\n\n%s\n") + } else { + ngettext(length(same), + "The following object is masked from %s:\n\n%s\n", + "The following objects are masked from %s:\n\n%s\n") + } + sprintf(txt, pkg, paste(objs, collapse="\n")) +} + attach <- function(what, pos = 2L, name = deparse(substitute(what)), warn.conflicts = TRUE) { + ## FIXME: ./library.R 's library() has *very* similar checkConflicts(), keep in sync checkConflicts <- function(env) { dont.mind <- c("last.dump", "last.warning", ".Last.value", @@ -33,12 +49,10 @@ } } ob <- objects(db.pos, all.names = TRUE) - if(.isMethodsDispatchOn()) { - ## : this is wrong-headed: see library(). - these <- objects(db.pos, all.names = TRUE) - these <- these[substr(these, 1L, 6L) == ".__M__"] - gen <- gsub(".__M__(.*):([^:]+)", "\\1", these) - from <- gsub(".__M__(.*):([^:]+)", "\\2", these) + if(.isMethodsDispatchOn()) { ## {see note in library() about this} + these <- ob[substr(ob, 1L, 6L) == ".__T__"] + gen <- gsub(".__T__(.*):([^:]+)", "\\1", these) + from <- gsub(".__T__(.*):([^:]+)", "\\2", these) gen <- gen[from != ".GlobalEnv"] ob <- ob[!(ob %in% gen)] } @@ -52,29 +66,15 @@ if(length(Classobjs)) same <- same[-Classobjs] ## report only objects which are both functions or ## both non-functions. - is_fn1 <- sapply(same, function(x) - exists(x, where = i, mode = "function", - inherits = FALSE)) - is_fn2 <- sapply(same, function(x) - exists(x, where = db.pos, mode = "function", - inherits = FALSE)) - same <- same[is_fn1 == is_fn2] + same.isFn <- function(where) + vapply(same, exists, NA, + where = where, mode = "function", inherits = FALSE) + same <- same[same.isFn(i) == same.isFn(db.pos)] if(length(same)) { - objs <- strwrap(paste(same, collapse=", "), - indent = 4L, exdent = 4L) - pkg <- - if (sum(sp == sp[i]) > 1L) { - sprintf("%s (position %d)", sp[i], i) - } else { - sp[i] - } - msg <- sprintf(ngettext(length(same), - "The following object is masked %s %s:\n\n%s\n", - "The following objects are masked %s %s:\n\n%s\n"), - if (i < db.pos) "_by_" else "from", - pkg, paste(objs, collapse="\n")) - cat(msg) - } + pkg <- if (sum(sp == sp[i]) > 1L) # 'pos = *' needs no translation + sprintf("%s (pos = %d)", sp[i], i) else sp[i] + message(.maskedMsg(same, pkg, by = i < db.pos), domain=NA) + } } } } @@ -200,8 +200,8 @@ pattern) { if (!missing(name)) { - nameValue <- try(name, silent = TRUE) - if(identical(class(nameValue), "try-error")) { + pos <- tryCatch(name, error = function(e)e) + if(inherits(pos, "error")) { name <- substitute(name) if (!is.character(name)) name <- deparse(name) @@ -209,8 +209,6 @@ domain = NA) pos <- name } - else - pos <- nameValue } all.names <- .Internal(ls(envir, all.names)) if (!missing(pattern)) { diff -Nru r-base-3.1.0/src/library/base/R/cut.R r-base-3.1.1/src/library/base/R/cut.R --- r-base-3.1.0/src/library/base/R/cut.R 2014-03-12 23:02:56.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/cut.R 2014-06-13 22:15:12.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/base/R/cut.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2013 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ dx <- diff(rx <- range(x, na.rm = TRUE)) if(dx == 0) { dx <- abs(rx[1L]) - breaks <- seq.int(rx[1L] - dx/1000, rx[2L] + dx/1000, + breaks <- seq.int(rx[1L] - dx/1000, rx[2L] + dx/1000, length.out = nb) } else { breaks <- seq.int(rx[1L], rx[2L], length.out = nb) @@ -41,7 +41,8 @@ codes.only <- FALSE if (is.null(labels)) {#- try to construct nice ones .. for(dig in dig.lab:max(12L, dig.lab)) { - ch.br <- formatC(breaks, digits = dig, width = 1L) + ## 0+ avoids printing signed zeros as "-0" + ch.br <- formatC(0+breaks, digits = dig, width = 1L) if(ok <- all(ch.br[-1L] != ch.br[-nb])) break } labels <- diff -Nru r-base-3.1.0/src/library/base/R/dataframe.R r-base-3.1.1/src/library/base/R/dataframe.R --- r-base-3.1.0/src/library/base/R/dataframe.R 2014-03-21 23:15:10.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/dataframe.R 2014-06-18 22:15:05.000000000 +0000 @@ -1139,7 +1139,11 @@ if (!is.null(a)) return(a) a <- x[[name, exact=FALSE]] - if (!is.null(a)) warning("Name partially matched in data frame") + if (!is.null(a) && getOption("warnPartialMatchDollar", default=FALSE)) { + names <- names(x) + warning(gettextf("Partial match of '%s' to '%s' in data frame", + name, names[pmatch(name, names)])) + } return(a) } diff -Nru r-base-3.1.0/src/library/base/R/datetime.R r-base-3.1.1/src/library/base/R/datetime.R --- r-base-3.1.0/src/library/base/R/datetime.R 2014-03-12 23:02:56.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/datetime.R 2014-06-20 22:15:05.000000000 +0000 @@ -298,7 +298,7 @@ stop(gettextf("'%s' not defined for \"POSIXt\" objects", .Generic), domain = NA) if(inherits(e1, "POSIXlt") || is.character(e1)) e1 <- as.POSIXct(e1) - if(inherits(e2, "POSIXlt") || is.character(e1)) e2 <- as.POSIXct(e2) + if(inherits(e2, "POSIXlt") || is.character(e2)) e2 <- as.POSIXct(e2) check_tzones(e1, e2) NextMethod(.Generic) } diff -Nru r-base-3.1.0/src/library/base/R/dcf.R r-base-3.1.1/src/library/base/R/dcf.R --- r-base-3.1.0/src/library/base/R/dcf.R 2012-08-05 22:05:11.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/dcf.R 2014-05-17 22:15:05.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/base/R/dcf.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2012 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -65,7 +65,10 @@ out } - on.exit(Sys.setlocale("LC_CTYPE", Sys.getlocale("LC_CTYPE")), add = TRUE) + ## This needs to be done in an 8-bit locale, + ## both for the regexps and strtrim(). + ctype <- Sys.getlocale("LC_CTYPE") + on.exit(Sys.setlocale("LC_CTYPE", ctype), add = TRUE) Sys.setlocale("LC_CTYPE", "C") lines <- readLines(file) diff -Nru r-base-3.1.0/src/library/base/R/files.R r-base-3.1.1/src/library/base/R/files.R --- r-base-3.1.0/src/library/base/R/files.R 2014-03-12 23:02:55.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/files.R 2014-06-02 22:15:04.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/base/R/files.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2013 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -128,10 +128,11 @@ okay[okay] <- file.create(to[okay]) if(any(okay)) { okay[okay] <- file.append(to[okay], from[okay]) - if(copy.mode) - Sys.chmod(to[okay], file.info(from[okay])$mode, TRUE) - if(copy.date) - Sys.setFileTime(to[okay], file.info(from[okay])$mtime) + if(copy.mode || copy.date) { # file.info call can be slow + fi <- file.info(from[okay]) + if(copy.mode) Sys.chmod(to[okay], fi$mode, TRUE) + if(copy.date) Sys.setFileTime(to[okay], fi$mtime) + } } } okay diff -Nru r-base-3.1.0/src/library/base/R/format.R r-base-3.1.1/src/library/base/R/format.R --- r-base-3.1.0/src/library/base/R/format.R 2013-10-22 22:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/format.R 2014-06-10 22:15:03.000000000 +0000 @@ -47,7 +47,7 @@ NULL = "NULL", character = .Internal(format(x, trim, digits, nsmall, width, adj, na.encode, scientific)), - call=, expression=, "function"=, "(" = deparse(x), + call =, expression =, "function" =, "(" = deparse(x), raw = as.character(x), { ## else: logical, numeric, complex, .. : diff -Nru r-base-3.1.0/src/library/base/R/library.R r-base-3.1.1/src/library/base/R/library.R --- r-base-3.1.0/src/library/base/R/library.R 2014-03-12 23:02:56.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/library.R 2014-04-10 22:15:03.000000000 +0000 @@ -153,10 +153,11 @@ else { ## A package will have created a generic ## only if it has created a formal method. - length(objects(env, pattern="^\\.__[MT]", all.names=TRUE)) == 0L + length(objects(env, pattern="^\\.__T", all.names=TRUE)) == 0L } } + ## FIXME: ./attach.R 's attach() has *very* similar checkConflicts(), keep in sync checkConflicts <- function(package, pkgname, pkgpath, nogenerics, env) { dont.mind <- c("last.dump", "last.warning", ".Last.value", @@ -173,7 +174,7 @@ ## down into the loop and test against specific other package name ## but subtle conflicts like that are likely to be found elsewhere these <- ob[substr(ob, 1L, 6L) == ".__T__"] - gen <- gsub(".__T__(.*):([^:]+)", "\\1", these) + gen <- gsub(".__T__(.*):([^:]+)", "\\1", these) from <- gsub(".__T__(.*):([^:]+)", "\\2", these) gen <- gen[from != package] ob <- ob[!(ob %in% gen)] @@ -212,15 +213,8 @@ sQuote(package)), domain = NA) } - - objs <- strwrap(paste(same, collapse=", "), - indent = 4L, exdent = 4L) - msg <- sprintf(ngettext(length(same), - "The following object is masked %s %s:\n\n%s\n", - "The following objects are masked %s %s:\n\n%s\n"), - if (i < lib.pos) "_by_" else "from", - sQuote(sp[i]), paste(objs, collapse="\n")) - packageStartupMessage(msg) + msg <- .maskedMsg(same, pkg = sQuote(sp[i]), by = i < lib.pos) + packageStartupMessage(msg, domain = NA) } } } diff -Nru r-base-3.1.0/src/library/base/R/load.R r-base-3.1.1/src/library/base/R/load.R --- r-base-3.1.0/src/library/base/R/load.R 2014-03-12 23:02:55.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/load.R 2014-04-23 22:15:03.000000000 +0000 @@ -68,10 +68,10 @@ if (!is.null(version) && version < 2) warning("Use of save versions prior to 2 is deprecated", domain = NA) - if(missing(list) && !length(list(...))) + names <- as.character(substitute(list(...)))[-1L] + if(missing(list) && !length(names)) warning("nothing specified to be save()d") - names <- as.character( substitute(list(...)))[-1L] - list <- c(list, names) + list <- c(list, names) if (!is.null(version) && version == 1) .Internal(save(list, file, ascii, version, envir, eval.promises)) else { diff -Nru r-base-3.1.0/src/library/base/R/merge.R r-base-3.1.1/src/library/base/R/merge.R --- r-base-3.1.0/src/library/base/R/merge.R 2014-03-12 23:02:55.000000000 +0000 +++ r-base-3.1.1/src/library/base/R/merge.R 2014-06-17 22:15:05.000000000 +0000 @@ -58,6 +58,7 @@ } nx <- nrow(x <- as.data.frame(x)); ny <- nrow(y <- as.data.frame(y)) + if (nx >= 2^31 || ny >= 2^31) stop("long vectors are not supported") by.x <- fix.by(by.x, x) by.y <- fix.by(by.y, y) if((l.b <- length(by.x)) != length(by.y)) @@ -95,6 +96,8 @@ bx <- x[, by.x]; if(is.factor(bx)) bx <- as.character(bx) by <- y[, by.y]; if(is.factor(by)) by <- as.character(by) } else { + if (!is.null(incomparables)) + stop("'incomparables' is supported only for merging on a single column") ## Do these together for consistency in as.character. ## Use same set of names. bx <- x[, by.x, drop=FALSE]; by <- y[, by.y, drop=FALSE] diff -Nru r-base-3.1.0/src/library/datasets/man/BOD.Rd r-base-3.1.1/src/library/datasets/man/BOD.Rd --- r-base-3.1.0/src/library/datasets/man/BOD.Rd 2012-04-15 22:05:20.000000000 +0000 +++ r-base-3.1.1/src/library/datasets/man/BOD.Rd 2014-05-12 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/datasets/man/BOD.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2010 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{BOD} @@ -16,10 +16,10 @@ \format{ This data frame contains the following columns: \describe{ - \item{Time}{ + \item{\code{Time}}{ A numeric vector giving the time of the measurement (days). } - \item{demand}{ + \item{\code{demand}}{ A numeric vector giving the biochemical oxygen demand (mg/l). } } diff -Nru r-base-3.1.0/src/library/datasets/man/chickwts.Rd r-base-3.1.1/src/library/datasets/man/chickwts.Rd --- r-base-3.1.0/src/library/datasets/man/chickwts.Rd 2013-03-05 23:02:31.000000000 +0000 +++ r-base-3.1.1/src/library/datasets/man/chickwts.Rd 2014-05-12 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/datasets/man/chickwts.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2007 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{chickwts} @@ -13,10 +13,10 @@ } \usage{chickwts} \format{ - A data frame with 71 observations on 2 variables. + A data frame with 71 observations on the following 2 variables. \describe{ - \item{weight}{a numeric variable giving the chick weight.} - \item{feed}{a factor giving the feed type.} + \item{\code{weight}}{a numeric variable giving the chick weight.} + \item{\code{feed}}{a factor giving the feed type.} } } \source{ diff -Nru r-base-3.1.0/src/library/datasets/man/longley.Rd r-base-3.1.1/src/library/datasets/man/longley.Rd --- r-base-3.1.0/src/library/datasets/man/longley.Rd 2014-01-05 23:05:22.000000000 +0000 +++ r-base-3.1.1/src/library/datasets/man/longley.Rd 2014-05-12 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/datasets/man/longley.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{longley} @@ -16,14 +16,14 @@ A data frame with 7 economical variables, observed yearly from 1947 to 1962 (\eqn{n=16}). \describe{ - \item{GNP.deflator:}{GNP implicit price deflator (\eqn{1954=100})} - \item{GNP:}{Gross National Product.} - \item{Unemployed:}{number of unemployed.} - \item{Armed.Forces:}{number of people in the armed forces.} - \item{Population:}{\sQuote{noninstitutionalized} population + \item{\code{GNP.deflator}}{GNP implicit price deflator (\eqn{1954=100})} + \item{\code{GNP}}{Gross National Product.} + \item{\code{Unemployed}}{number of unemployed.} + \item{\code{Armed.Forces}}{number of people in the armed forces.} + \item{\code{Population}}{\sQuote{noninstitutionalized} population \eqn{\ge} 14 years of age.} - \item{Year:}{the year (time).} - \item{Employed:}{number of people employed.} + \item{\code{Year}}{the year (time).} + \item{\code{Employed}}{number of people employed.} } The regression \code{lm(Employed ~ .)} is known to be highly diff -Nru r-base-3.1.0/src/library/datasets/man/morley.Rd r-base-3.1.1/src/library/datasets/man/morley.Rd --- r-base-3.1.0/src/library/datasets/man/morley.Rd 2014-01-05 23:05:22.000000000 +0000 +++ r-base-3.1.1/src/library/datasets/man/morley.Rd 2014-05-12 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/datasets/man/morley.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \newcommand{\CRANpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} @@ -20,7 +20,7 @@ morley } \format{ - A data frame contains the following components: + A data frame with 100 observations on the following 3 variables. \describe{ \item{\code{Expt}}{The experiment number, from 1 to 5.} \item{\code{Run}}{The run number within each experiment.} diff -Nru r-base-3.1.0/src/library/datasets/man/nottem.Rd r-base-3.1.1/src/library/datasets/man/nottem.Rd --- r-base-3.1.0/src/library/datasets/man/nottem.Rd 2012-12-05 14:37:56.000000000 +0000 +++ r-base-3.1.1/src/library/datasets/man/nottem.Rd 2014-05-26 22:15:09.000000000 +0000 @@ -20,7 +20,7 @@ Butterworths. Series R. } \examples{ -\dontrun{require(stats); require(graphics) +\donttest{require(stats); require(graphics) nott <- window(nottem, end = c(1936,12)) fit <- arima(nott, order = c(1,0,0), list(order = c(2,1,0), period = 12)) nott.fore <- predict(fit, n.ahead = 36) diff -Nru r-base-3.1.0/src/library/datasets/man/Puromycin.Rd r-base-3.1.1/src/library/datasets/man/Puromycin.Rd --- r-base-3.1.0/src/library/datasets/man/Puromycin.Rd 2013-03-05 23:02:31.000000000 +0000 +++ r-base-3.1.1/src/library/datasets/man/Puromycin.Rd 2014-05-12 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/datasets/man/Puromycin.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2010 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{Puromycin} @@ -16,13 +16,13 @@ \format{ This data frame contains the following columns: \describe{ - \item{conc}{ + \item{\code{conc}}{ a numeric vector of substrate concentrations (ppm) } - \item{rate}{ + \item{\code{rate}}{ a numeric vector of instantaneous reaction rates (counts/min/min) } - \item{state}{ + \item{\code{state}}{ a factor with levels \code{treated} \code{untreated} diff -Nru r-base-3.1.0/src/library/datasets/man/randu.Rd r-base-3.1.1/src/library/datasets/man/randu.Rd --- r-base-3.1.0/src/library/datasets/man/randu.Rd 2012-04-15 22:05:20.000000000 +0000 +++ r-base-3.1.1/src/library/datasets/man/randu.Rd 2014-05-26 22:15:09.000000000 +0000 @@ -32,7 +32,7 @@ David Donoho } \examples{ -\dontrun{## We could re-generate the dataset by the following R code +\donttest{## We could re-generate the dataset by the following R code seed <- as.double(1) RANDU <- function() { seed <<- ((2^16 + 3) * seed) \%\% (2^31) diff -Nru r-base-3.1.0/src/library/graphics/man/axis.POSIXct.Rd r-base-3.1.1/src/library/graphics/man/axis.POSIXct.Rd --- r-base-3.1.0/src/library/graphics/man/axis.POSIXct.Rd 2014-03-12 23:02:50.000000000 +0000 +++ r-base-3.1.1/src/library/graphics/man/axis.POSIXct.Rd 2014-04-23 22:15:03.000000000 +0000 @@ -42,7 +42,7 @@ The way the date-times are rendered (especially month names) is controlled by the locale setting of category \code{"LC_TIME"} (see - \code{\link{Sys.setlocale}}. + \code{\link{Sys.setlocale}}). } \value{ The locations on the axis scale at which tick marks were drawn. diff -Nru r-base-3.1.0/src/library/graphics/man/contour.Rd r-base-3.1.1/src/library/graphics/man/contour.Rd --- r-base-3.1.0/src/library/graphics/man/contour.Rd 2014-01-05 23:05:21.000000000 +0000 +++ r-base-3.1.1/src/library/graphics/man/contour.Rd 2014-05-21 22:15:04.000000000 +0000 @@ -124,8 +124,10 @@ image(x, x, z) contour(x, x, z, col = "pink", add = TRUE, method = "edge", vfont = c("sans serif", "plain")) -contour(x, x, z, ylim = c(1, 6), method = "simple", labcex = 1) -contour(x, x, z, ylim = c(-6, 6), nlev = 20, lty = 2, method = "simple") +contour(x, x, z, ylim = c(1, 6), method = "simple", labcex = 1, + xlab = quote(x[1]), ylab = quote(x[2])) +contour(x, x, z, ylim = c(-6, 6), nlev = 20, lty = 2, method = "simple", + main = "20 levels; \"simple\" labelling method") par(op) ## Persian Rug Art: @@ -150,16 +152,13 @@ abline(h = 200*0:4, v = 200*0:4, col = "lightgray", lty = 2, lwd = 0.1) ## contourLines produces the same contour lines as contour -line.list <- contourLines(x, y, volcano) plot(x = 0, y = 0, type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "") u <- par("usr") rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red") -contour(x, y, volcano, col = tcol[2], lty = "solid", add = TRUE, - vfont = c("sans serif", "plain")) -templines <- function(clines) { - lines(clines[[2]], clines[[3]]) -} -invisible(lapply(line.list, templines)) +contour(x, y, volcano, col = tcol[1], lty = "solid", add = TRUE, + vfont = c("sans serif", "plain")) +line.list <- contourLines(x, y, volcano) +invisible(lapply(line.list, lines, lwd=3, col=adjustcolor(2, .3))) par(opar) } \keyword{hplot} diff -Nru r-base-3.1.0/src/library/graphics/man/points.Rd r-base-3.1.1/src/library/graphics/man/points.Rd --- r-base-3.1.0/src/library/graphics/man/points.Rd 2014-02-20 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/graphics/man/points.Rd 2014-06-18 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/graphics/man/points.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{points} @@ -139,7 +139,7 @@ If the symbol font (\code{\link{par}(font = 5)}) is used, numerical values should be used for \code{pch}: the range is \code{c(32:126, 160:254)} in all locales (but \code{240} is not - defined (used for \sQuote{apple} on Mac OS) and \code{160}, Euro, may + defined (used for \sQuote{apple} on OS X) and \code{160}, Euro, may not be present). } \note{ diff -Nru r-base-3.1.0/src/library/grDevices/man/chull.Rd r-base-3.1.1/src/library/grDevices/man/chull.Rd --- r-base-3.1.0/src/library/grDevices/man/chull.Rd 2013-03-12 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/man/chull.Rd 2014-05-14 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/grDevices/man/chull.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{chull} @@ -19,8 +19,10 @@ set of points specified. } \details{ - \code{\link{xy.coords}} is used to interpret the - specification of the points. The algorithm is that given by Eddy (1977). + \code{\link{xy.coords}} is used to interpret the specification of the + points. Infinite, missing and \code{NaN} values are not allowed. + + The algorithm is that given by Eddy (1977). } \value{ An integer vector giving the indices of the unique points lying on the diff -Nru r-base-3.1.0/src/library/grDevices/man/dev2bitmap.Rd r-base-3.1.1/src/library/grDevices/man/dev2bitmap.Rd --- r-base-3.1.0/src/library/grDevices/man/dev2bitmap.Rd 2013-03-05 23:02:38.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/man/dev2bitmap.Rd 2014-05-12 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/grDevices/man/dev2bitmap.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2012 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{dev2bitmap} @@ -54,22 +54,18 @@ The types available will depend on the version of \code{ghostscript}, but are likely to include - \code{"pcxmono"}, \code{"pcxgray"}, \code{"pcx16"}, \code{"pcx256"}, - \code{"pcx24b"}, \code{"pcxcmyk"}, \code{"pbm"}, \code{"pbmraw"}, - \code{"pgm"}, \code{"pgmraw"}, \code{"pgnm"}, \code{"pgnmraw"}, - \code{"pnm"}, \code{"pnmraw"}, \code{"ppm"}, \code{"ppmraw"}, - \code{"pkm"}, \code{"pkmraw"}, \code{"tiffcrle"}, \code{"tiffg3"}, - \code{"tiffg32d"}, \code{"tiffg4"}, \code{"tifflzw"}, + \code{"jpeg"}, \code{"jpegcmyk"}, \code{"jpeggray"}, + \code{"tiffcrle"}, \code{"tiffg3"}, + \code{"tiffg32d"}, \code{"tiffg4"}, \code{"tiffgray"}, \code{"tifflzw"}, \code{"tiffpack"}, \code{"tiff12nc"}, \code{"tiff24nc"}, \code{"tiff32nc"} - \code{"psmono"}, \code{"psgray"}, \code{"psrgb"}, \code{"bit"}, - \code{"bitrgb"}, \code{"bitcmyk"}, \code{"pngmono"}, \code{"pnggray"}, - \code{"pngalpha"}, \code{"png16"}, \code{"png256"}, \code{"png16m"}, - \code{"png48"}, \code{"jpeg"}, \code{"jpeggray"}, \code{"pdfwrite"}. + \code{"png16"}, \code{"png16m"}, \code{"png256"}, \code{"png48"}, + \code{"pngmono"}, \code{"pnggray"}, \code{"pngalpha"}, + \code{"bmp16"}, \code{"bmp16m"} \code{"bmp256"}, \code{"bmp32b"}, + \code{"bmpgray"}, \code{"bmpmono"}. The default type, \code{"png16m"}, supports 24-bit colour and - anti-aliasing. Versions of \R prior to 2.7.0 defaulted to - \code{"png256"}, which uses a palette of 256 colours and could be a - more compact representation. Monochrome graphs can use + anti-aliasing. Type \code{"png256"} uses a palette of 256 colours and + could give a more compact representation. Monochrome graphs can use \code{"pngmono"}, or \code{"pnggray"} if anti-aliasing is desired. Plots with a transparent background and varying degrees of transparency should use \code{"pngalpha"}. @@ -83,7 +79,7 @@ \code{Rplots\%03d.png} can be used: this is interpreted by Ghostscript. For \code{dev2bitmap} if just one of \code{width} and \code{height} is - specified, the other is chosen to preserve aspect ratio of the + specified, the other is chosen to preserve the aspect ratio of the device being copied. The main reason to prefer \code{method = "pdf"} over the default would be to allow semi-transparent colours to be used. diff -Nru r-base-3.1.0/src/library/grDevices/man/dev.Rd r-base-3.1.1/src/library/grDevices/man/dev.Rd --- r-base-3.1.0/src/library/grDevices/man/dev.Rd 2013-03-05 23:02:38.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/man/dev.Rd 2014-05-20 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/grDevices/man/dev.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2009 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{dev} @@ -23,13 +23,16 @@ dev.prev(which = dev.cur()) dev.off(which = dev.cur()) dev.set(which = dev.next()) -dev.new(\dots) +dev.new(\dots, noRStudioGD = FALSE) graphics.off() } \arguments{ \item{which}{An integer specifying a device number.} \item{\dots}{arguments to be passed to the device selected.} + \item{noRStudioGD}{Do not use the RStudio graphics device even if + specified as the default device: it does not accept arguments such + as \code{width} and \code{height}.} } \details{ Only one device is the \sQuote{active} device: this is the device in diff -Nru r-base-3.1.0/src/library/grDevices/man/embedFonts.Rd r-base-3.1.1/src/library/grDevices/man/embedFonts.Rd --- r-base-3.1.0/src/library/grDevices/man/embedFonts.Rd 2013-03-05 23:02:38.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/man/embedFonts.Rd 2014-06-13 22:15:12.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/grDevices/man/embedFonts.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2012 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{embedFonts} @@ -12,12 +12,13 @@ embed all fonts in the file. } \usage{ -embedFonts(file, format, outfile = file, fontpaths = "", +embedFonts(file, format, outfile = file, fontpaths = character(), options = "") } \arguments{ \item{file}{a character string giving the name of the original file.} - \item{format}{either \code{"pswrite"} or \code{"pdfwrite"}. + \item{format}{the format for the new file (with fonts embedded) given as + the name of a ghostscript output device. If not specified, it is guessed from the suffix of \code{file}.} \item{outfile}{the name of the new file (with fonts embedded).} \item{fontpaths}{a character vector giving directories that @@ -45,6 +46,13 @@ of the environment variable \env{GSC} is used, otherwise commands \code{"gswi64c.exe"} then \code{"gswin32c.exe"} are tried. + The \code{format} is by default \code{"pswrite"}, when the original + file has a \code{.ps} or \code{.eps} suffix, or \code{"pdfwrite"} when + the original file has a \code{.pdf} suffix. In recent versions of + ghostscript, the \code{"pswrite"} format has been deprecated, so you + may have to provide an explicit format: \code{"ps2write"} and + \code{"eps2write"} (from version 9.14) should be available. + Note that Ghostscript may do font substitution, so the font embedded may differ from that specified in the original file. diff -Nru r-base-3.1.0/src/library/grDevices/man/getGraphicsEvent.Rd r-base-3.1.1/src/library/grDevices/man/getGraphicsEvent.Rd --- r-base-3.1.0/src/library/grDevices/man/getGraphicsEvent.Rd 2014-03-12 23:03:08.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/man/getGraphicsEvent.Rd 2014-05-26 22:15:12.000000000 +0000 @@ -108,7 +108,9 @@ } \author{Duncan Murdoch} \examples{ -\donttest{ +# This currently only works on the Windows +# and X11(type = "Xlib") screen devices... +\dontrun{ savepar <- par(ask = FALSE) dragplot <- function(..., xlim = NULL, ylim = NULL, xaxs = "r", yaxs = "r") { plot(..., xlim = xlim, ylim = ylim, xaxs = xaxs, yaxs = yaxs) @@ -163,8 +165,6 @@ } dragplot(rnorm(1000), rnorm(1000)) -# This currently only works on the Windows -# and X11(type = "Xlib") screen devices... getGraphicsEvent() par(savepar) } diff -Nru r-base-3.1.0/src/library/grDevices/man/pdf.Rd r-base-3.1.1/src/library/grDevices/man/pdf.Rd --- r-base-3.1.0/src/library/grDevices/man/pdf.Rd 2013-09-24 22:05:06.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/man/pdf.Rd 2014-05-26 22:15:12.000000000 +0000 @@ -301,7 +301,7 @@ \url{http://cran.r-project.org/doc/Rnews/Rnews_2006-2.pdf}. } \examples{ -\dontrun{ +\donttest{ ## Test function for encodings TestChars <- function(encoding = "ISOLatin1", ...) { diff -Nru r-base-3.1.0/src/library/grDevices/man/rgb.Rd r-base-3.1.1/src/library/grDevices/man/rgb.Rd --- r-base-3.1.0/src/library/grDevices/man/rgb.Rd 2013-06-23 22:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/man/rgb.Rd 2014-06-12 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/grDevices/man/rgb.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \newcommand{\CRANpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} @@ -54,6 +54,9 @@ Most other graphics devices plot semi-transparent colors as fully transparent, usually with a warning when first encountered. + + \code{NA} values are not allowed for any of \code{red}, \code{blue}, + \code{green} or \code{alpha}. } \value{ A character vector with elements of 7 or 9 characters, \code{"#"} diff -Nru r-base-3.1.0/src/library/grDevices/R/calc.R r-base-3.1.1/src/library/grDevices/R/calc.R --- r-base-3.1.0/src/library/grDevices/R/calc.R 2014-01-05 23:05:27.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/R/calc.R 2014-05-14 22:15:04.000000000 +0000 @@ -78,6 +78,7 @@ { X <- xy.coords(x, y, recycle = TRUE) x <- cbind(X$x, X$y) + if(any(!is.finite(x))) stop("finite coordinates are needed") if(nrow(x) == 0) return(integer()) if(nrow(x) == 1) return(1L) res <- .Call(C_chull, x) diff -Nru r-base-3.1.0/src/library/grDevices/R/device.R r-base-3.1.1/src/library/grDevices/R/device.R --- r-base-3.1.0/src/library/grDevices/R/device.R 2014-01-05 23:05:27.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/R/device.R 2014-05-20 22:15:04.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/grDevices/R/device.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2013 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -276,11 +276,27 @@ invisible() } -dev.new <- function(...) +dev.new <- function(..., noRStudioGD = FALSE) { dev <- getOption("device") if(!is.character(dev) && !is.function(dev)) stop("invalid setting for 'getOption(\"device\")'") + if(is.character(dev) && noRStudioGD && dev == "RStudioGD") { + ## copied from zzz.R + if(!nzchar(defdev <- Sys.getenv("R_DEFAULT_DEVICE"))) defdev <- pdf + dev <- if(interactive()) { + if(nzchar(intdev <- Sys.getenv("R_INTERACTIVE_DEVICE"))) intdev + else { + dsp <- Sys.getenv("DISPLAY") + if(.Platform$OS.type == "windows") windows + else if (.Platform$GUI == "AQUA" || + ((!nzchar(dsp) || grepl("^/tmp/launch-", dsp)) + && .Call(C_makeQuartzDefault))) quartz + else if (nzchar(dsp) && .Platform$GUI %in% c("X11", "Tk")) X11 + else defdev + } + } else defdev + } if(is.character(dev)) { ## this is documented to be searched for from workspace, ## then in graphics namespace. diff -Nru r-base-3.1.0/src/library/grDevices/R/gevents.R r-base-3.1.1/src/library/grDevices/R/gevents.R --- r-base-3.1.0/src/library/grDevices/R/gevents.R 2013-03-05 23:02:37.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/R/gevents.R 2014-06-25 22:15:06.000000000 +0000 @@ -21,14 +21,19 @@ setGraphicsEventEnv(which, as.environment(list(...))) setGraphicsEventEnv <- function(which=dev.cur(), env) { + which <- as.integer(which) + stopifnot(length(which) == 1) result <- getGraphicsEventEnv(which) env$which <- which .External2(C_setGraphicsEventEnv, which, env) invisible(result) } -getGraphicsEventEnv <- function(which=dev.cur()) +getGraphicsEventEnv <- function(which=dev.cur()) { + which <- as.integer(which) + stopifnot(length(which) == 1) .External2(C_getGraphicsEventEnv, which) +} getGraphicsEvent <- function(prompt = "Waiting for input", onMouseDown = NULL, onMouseMove = NULL, onMouseUp = NULL, diff -Nru r-base-3.1.0/src/library/grDevices/R/postscript.R r-base-3.1.1/src/library/grDevices/R/postscript.R --- r-base-3.1.0/src/library/grDevices/R/postscript.R 2014-03-12 23:03:06.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/R/postscript.R 2014-05-12 22:15:05.000000000 +0000 @@ -951,36 +951,23 @@ embedFonts <- function(file, # The ps or pdf file to convert format, # Default guessed from file suffix outfile = file, # By default overwrite file - fontpaths = "", + fontpaths = character(), options = "" # Additional options to ghostscript ) { if(!is.character(file) || length(file) != 1L || !nzchar(file)) stop("'file' must be a non-empty character string") + gsexe <- tools::find_gs_cmd() + if(!nzchar(gsexe)) stop("GhostScript was not found") + if(.Platform$OS.type == "windows") gsexe <- shortPathName(gsexe) suffix <- gsub(".+[.]", "", file) - if (missing(format)) { + if (missing(format)) format <- switch(suffix, ps = , eps = "pswrite", pdf = "pdfwrite") - } - if (!is.character(format)) { + if (!is.character(format)) stop("Invalid output format") - } - gsexe <- Sys.getenv("R_GSCMD") - if(.Platform$OS.type == "windows" && !nzchar(gsexe)) - gsexe <- Sys.getenv("GSC") - if(is.null(gsexe) || !nzchar(gsexe)) { - gsexe <- switch(.Platform$OS.type, - unix = "gs", - windows = { - poss <- Sys.which(c("gswin64c.exe", "gswin32c.exe")) - poss <- poss[nzchar(poss)] - if(length(poss)) poss else "gswin32c.exe" - }) - } else if(.Platform$OS.type == "windows" && - length(grep(" ", gsexe, fixed=TRUE))) - gsexe <- shortPathName(gsexe) tmpfile <- tempfile("Rembed") if (length(fontpaths)) fontpaths <- diff -Nru r-base-3.1.0/src/library/grDevices/R/unix/dev2bitmap.R r-base-3.1.1/src/library/grDevices/R/unix/dev2bitmap.R --- r-base-3.1.0/src/library/grDevices/R/unix/dev2bitmap.R 2014-03-12 23:03:06.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/R/unix/dev2bitmap.R 2014-05-12 22:15:05.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/grDevices/R/unix/dev2bitmap.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2013 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # A copy of the GNU General Public License is available at # http://www.r-project.org/Licenses/ -dev2bitmap <- function(file, type="png16m", height = 7, width = 7, res = 72, +dev2bitmap <- function(file, type = "png16m", height = 7, width = 7, res = 72, units = "in", pointsize, ..., method = c("postscript", "pdf"), taa = NA, gaa = NA) { @@ -27,27 +27,9 @@ units <- match.arg(units, c("in", "px", "cm", "mm")) height <- switch(units, "in"=1, "cm"=1/2.54, "mm"=1/25.4, "px"=1/res) * height width <- switch(units, "in"=1, "cm"=1/2.54, "mm"=1/25.4, "px"=1/res) * width - ## consider using tools::find_gs_cmd() here - gsexe <- Sys.getenv("R_GSCMD") - if(is.null(gsexe) || !nzchar(gsexe)) { - gsexe <- "gs" - rc <- system(paste(shQuote(gsexe), "-help > /dev/null")) - if(rc != 0) stop("sorry, 'gs' cannot be found") - } - gshelp <- system(paste(gsexe, "-help"), intern = TRUE) - st <- grep("^Available", gshelp) - en <- grep("^Search", gshelp) - if(!length(st) || !length(en)) - warning("unrecognized format of gs -help") - else { - gsdevs <- gshelp[(st+1):(en-1)] - devs <- c(strsplit(gsdevs, " "), recursive = TRUE) - if(match(type, devs, 0) == 0) - stop(gettextf("device '%s' is not available\n", type), - gettextf("Available devices are %s", - paste(gsdevs, collapse = "\n")), - domain = NA) - } + gsexe <- tools::find_gs_cmd() + if(!nzchar(gsexe)) stop("GhostScript was not found") + check_gs_type(gsexe, type) if(missing(pointsize)) pointsize <- 1.5*min(width, height) tmp <- tempfile("Rbit") on.exit(unlink(tmp)) @@ -88,27 +70,9 @@ units <- match.arg(units, c("in", "px", "cm", "mm")) height <- switch(units, "in"=1, "cm"=1/2.54, "mm"=1/25.4, "px"=1/res) * height width <- switch(units, "in"=1, "cm"=1/2.54, "mm"=1/25.4, "px"=1/res) * width - ## consider using tools::find_gs_cmd() here - gsexe <- Sys.getenv("R_GSCMD") - if(is.null(gsexe) || !nzchar(gsexe)) { - gsexe <- "gs" - rc <- system(paste(gsexe, "-help > /dev/null")) - if(rc != 0) stop("sorry, 'gs' cannot be found") - } - gshelp <- system(paste(gsexe, "-help"), intern = TRUE) - st <- grep("^Available", gshelp) - en <- grep("^Search", gshelp) - if(!length(st) || !length(en)) - warning("unrecognized format of gs -help") - else { - gsdevs <- gshelp[(st+1):(en-1)] - devs <- c(strsplit(gsdevs, " "), recursive = TRUE) - if(match(type, devs, 0) == 0) - stop(gettextf("device '%s' is not available\n", type), - gettextf("Available devices are %s", - paste(gsdevs, collapse = "\n")), - domain = NA) - } + gsexe <- tools::find_gs_cmd() + if(!nzchar(gsexe)) stop("GhostScript was not found") + check_gs_type(gsexe, type) if(missing(pointsize)) pointsize <- 1.5*min(width, height) extra <- "" if (!is.na(taa)) extra <- paste0(" -dTextAlphaBits=", taa) @@ -124,3 +88,26 @@ pointsize = pointsize, paper = "special", horizontal = FALSE, ...) invisible() } + + +## unexported +check_gs_type <- function(gsexe, type) +{ + gshelp <- system(paste(gsexe, "-help"), intern = TRUE) + st <- grep("^Available", gshelp) + en <- grep("^Search", gshelp) + if(!length(st) || !length(en)) + warning("unrecognized format of gs -help") + else { + gsdevs <- gshelp[(st+1L):(en-1L)] + devs <- c(strsplit(gsdevs, " "), recursive = TRUE) + if(match(type, devs, 0L) == 0L) { + op <- options(warning.length = 8000L) + on.exit(options(op)) + stop(gettextf("device '%s' is not available\n", type), + gettextf("Available devices are:\n%s", + paste(gsdevs, collapse = "\n")), + domain = NA) + } + } +} diff -Nru r-base-3.1.0/src/library/grDevices/R/windows/dev2bitmap.R r-base-3.1.1/src/library/grDevices/R/windows/dev2bitmap.R --- r-base-3.1.0/src/library/grDevices/R/windows/dev2bitmap.R 2014-03-12 23:03:06.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/R/windows/dev2bitmap.R 2014-05-12 22:15:05.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/grDevices/R/windows/dev2bitmap.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2013 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # A copy of the GNU General Public License is available at # http://www.r-project.org/Licenses/ -dev2bitmap <- function(file, type="png16m", height = 7, width = 7, res = 72, +dev2bitmap <- function(file, type = "png16m", height = 7, width = 7, res = 72, units = "in", pointsize, ..., method = c("postscript", "pdf"), taa = NA, gaa = NA) { @@ -27,29 +27,9 @@ units <- match.arg(units, c("in", "px", "cm", "mm")) height <- switch(units, "in"=1, "cm"=1/2.54, "mm"=1/25.4, "px"=1/res) * height width <- switch(units, "in"=1, "cm"=1/2.54, "mm"=1/25.4, "px"=1/res) * width - ## consider using tools::find_gs_cmd() here - gsexe <- Sys.getenv("R_GSCMD") - if(!nzchar(gsexe)) gsexe <- Sys.getenv("GSC") - if(is.null(gsexe) || !nzchar(gsexe)) { - poss <- Sys.which(c("gswin64c.exe", "gswin32c.exe")) - poss <- poss[nzchar(poss)] - gsexe <- if(length(poss)) poss else "gswin32c.exe" - } else if(grepl(" ", gsexe, fixed = TRUE)) - gsexe <- shortPathName(gsexe) - gshelp <- system(paste(gsexe, "-help"), intern = TRUE, invisible = TRUE) - st <- grep("^Available", gshelp) - en <- grep("^Search", gshelp) - if(!length(st) || !length(en)) - warning("unrecognized format of gs -help") - else { - gsdevs <- gshelp[(st+1):(en-1)] - devs <- c(strsplit(gsdevs, " "), recursive = TRUE) - if(match(type, devs, 0) == 0) - stop(gettextf("device '%s' is not available\n", type), - gettextf("Available devices are %s", - paste(gsdevs, collapse = "\n")), - domain = NA) - } + gsexe <- tools::find_gs_cmd() + if(!nzchar(gsexe)) stop("GhostScript was not found") + check_gs_type(gsexe, type) if(missing(pointsize)) pointsize <- 1.5*min(width, height) tmp <- tempfile("Rbit") on.exit(unlink(tmp)) @@ -90,29 +70,9 @@ units <- match.arg(units, c("in", "px", "cm", "mm")) height <- switch(units, "in"=1, "cm"=1/2.54, "mm"=1/25.4, "px"=1/res) * height width <- switch(units, "in"=1, "cm"=1/2.54, "mm"=1/25.4, "px"=1/res) * width - ## consider using tools::find_gs_cmd() here - gsexe <- Sys.getenv("R_GSCMD") - if(!nzchar(gsexe)) gsexe <- Sys.getenv("GSC") - if(is.null(gsexe) || !nzchar(gsexe)) { - poss <- Sys.which(c("gswin64c.exe", "gswin32c.exe")) - poss <- poss[nzchar(poss)] - gsexe <- if(length(poss)) poss else "gswin32c.exe" - } else if(grepl(" ", gsexe, fixed = TRUE)) - gsexe <- shortPathName(gsexe) - gshelp <- system(paste(gsexe, "-help"), intern = TRUE, invisible = TRUE) - st <- grep("^Available", gshelp) - en <- grep("^Search", gshelp) - if(!length(st) || !length(en)) - warning("unrecognized format of gs -help") - else { - gsdevs <- gshelp[(st+1):(en-1)] - devs <- c(strsplit(gsdevs, " "), recursive = TRUE) - if(match(type, devs, 0) == 0) - stop(gettextf("device '%s' is not available\n", type), - gettextf("Available devices are %s", - paste(gsdevs, collapse = "\n")), - domain = NA) - } + gsexe <- tools::find_gs_cmd() + if(!nzchar(gsexe)) stop("GhostScript was not found") + check_gs_type(gsexe, type) if(missing(pointsize)) pointsize <- 1.5*min(width, height) extra <- "" if (!is.na(taa)) extra <- paste0(" -dTextAlphaBits=", taa) @@ -129,3 +89,26 @@ print.it = TRUE, command = cmd, ...) invisible() } + + +## unexported +check_gs_type <- function(gsexe, type) +{ + gshelp <- system(paste(gsexe, "-help"), intern = TRUE, invisible = TRUE) + st <- grep("^Available", gshelp) + en <- grep("^Search", gshelp) + if(!length(st) || !length(en)) + warning("unrecognized format of gs -help") + else { + gsdevs <- gshelp[(st+1L):(en-1L)] + devs <- c(strsplit(gsdevs, " "), recursive = TRUE) + if(match(type, devs, 0L) == 0L) { + op <- options(warning.length = 8000L) + on.exit(options(op)) + stop(gettextf("device '%s' is not available\n", type), + gettextf("Available devices are:\n%s", + paste(gsdevs, collapse = "\n")), + domain = NA) + } + } +} diff -Nru r-base-3.1.0/src/library/grDevices/R/windows/png.R r-base-3.1.1/src/library/grDevices/R/windows/png.R --- r-base-3.1.0/src/library/grDevices/R/windows/png.R 2014-03-12 23:03:06.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/R/windows/png.R 2014-04-23 22:15:04.000000000 +0000 @@ -39,7 +39,7 @@ width = 480, height = 480, units = "px", pointsize = 12, bg = "white", res = NA, family = "sans", restoreConsole = TRUE, type = c("windows", "cairo", "cairo-png"), - antialias = c("default", "none", "cleartype", "grey", "subpixel")) + antialias = c("default", "none", "cleartype", "gray", "subpixel")) { if(!checkIntFormat(filename)) stop("invalid 'filename'") g <- .geometry(width, height, units, res) @@ -77,7 +77,7 @@ width = 480, height = 480, units = "px", pointsize = 12, bg = "white", res = NA, family = "sans", restoreConsole = TRUE, type = c("windows", "cairo"), - antialias = c("default", "none", "cleartype", "grey", "subpixel")) + antialias = c("default", "none", "cleartype", "gray", "subpixel")) { if(!checkIntFormat(filename)) stop("invalid 'filename'") g <- .geometry(width, height, units, res) @@ -109,7 +109,7 @@ width = 480, height = 480, units = "px", pointsize = 12, quality = 75, bg = "white", res = NA, family = "sans", restoreConsole = TRUE, type = c("windows", "cairo"), - antialias = c("default", "none", "cleartype", "grey", "subpixel")) + antialias = c("default", "none", "cleartype", "gray", "subpixel")) { if(!checkIntFormat(filename)) stop("invalid 'filename'") g <- .geometry(width, height, units, res) @@ -143,7 +143,7 @@ "lzw+p", "zip+p"), bg = "white", res = NA, family = "sans", restoreConsole = TRUE, type = c("windows", "cairo"), - antialias = c("default", "none", "cleartype", "grey", "subpixel")) + antialias = c("default", "none", "cleartype", "gray", "subpixel")) { if(!checkIntFormat(filename)) stop("invalid 'filename'") g <- .geometry(width, height, units, res) diff -Nru r-base-3.1.0/src/library/grDevices/R/xyz.coords.R r-base-3.1.1/src/library/grDevices/R/xyz.coords.R --- r-base-3.1.0/src/library/grDevices/R/xyz.coords.R 2013-03-05 23:02:37.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/R/xyz.coords.R 2014-06-19 22:15:04.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/grDevices/R/xyz.coords.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2012 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ ## Both xy.coords() and xyz.coords() --- should be kept in sync! xy.coords <- - function(x, y=NULL, xlab=NULL, ylab=NULL, log=NULL, recycle = FALSE) + function(x, y = NULL, xlab = NULL, ylab = NULL, log = NULL, recycle = FALSE) { if(is.null(y)) { ylab <- xlab @@ -27,8 +27,8 @@ if (inherits(x, "formula") && length(x) == 3) { ylab <- deparse(x[[2L]]) xlab <- deparse(x[[3L]]) - y <- eval(x[[2L]], environment(x), parent.frame()) - x <- eval(x[[3L]], environment(x), parent.frame()) + y <- eval(x[[2L]], environment(x)) + x <- eval(x[[3L]], environment(x)) } else stop("invalid first argument") } diff -Nru r-base-3.1.0/src/library/grDevices/src/colors.c r-base-3.1.1/src/library/grDevices/src/colors.c --- r-base-3.1.0/src/library/grDevices/src/colors.c 2014-01-05 23:05:27.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/src/colors.c 2014-06-12 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1997-2013 The R Core Team + * Copyright (C) 1997-2014 The R Core Team * Copyright (C) 2003 The R Foundation * * This program is free software; you can redistribute it and/or modify @@ -65,6 +65,8 @@ static unsigned int ScaleColor(double x) { + if (ISNA(x)) + error(_("color intensity %s, not in [0,1]"), "NA"); if (!R_FINITE(x) || x < 0.0 || x > 1.0) error(_("color intensity %g, not in [0,1]"), x); return (unsigned int)(255*x + 0.5); @@ -72,13 +74,17 @@ static unsigned int CheckColor(int x) { - if (x == NA_INTEGER || x < 0 || x > 255) + if (x == NA_INTEGER) + error(_("color intensity %s, not in 0:255"), "NA"); + if (x < 0 || x > 255) error(_("color intensity %d, not in 0:255"), x); return (unsigned int)x; } static unsigned int ScaleAlpha(double x) { + if (ISNA(x)) + error(_("alpha level %s, not in [0,1]"), "NA"); if (!R_FINITE(x) || x < 0.0 || x > 1.0) error(_("alpha level %g, not in [0,1]"), x); return (unsigned int)(255*x + 0.5); @@ -86,7 +92,9 @@ static unsigned int CheckAlpha(int x) { - if (x == NA_INTEGER || x < 0 || x > 255) + if (x == NA_INTEGER) + error(_("alpha level %s, not in 0:255"), "NA"); + if (x < 0 || x > 255) error(_("alpha level %d, not in 0:255"), x); return (unsigned int)x; } @@ -428,7 +436,7 @@ else if(max_1) { if(isNull(a)) { _R_set_c_RGB(ScaleColor(REAL(r)[i%nr]), - ScaleColor(REAL(g)[i%ng]), + ScaleColor(REAL(g)[i%ng]), ScaleColor(REAL(b)[i%nb])); } else { _R_set_c_RGBA(ScaleColor(REAL(r)[i%nr]), @@ -440,7 +448,7 @@ else { /* maxColorVal not in {1, 255} */ if(isNull(a)) { _R_set_c_RGB(ScaleColor(REAL(r)[i%nr] / mV), - ScaleColor(REAL(g)[i%ng] / mV), + ScaleColor(REAL(g)[i%ng] / mV), ScaleColor(REAL(b)[i%nb] / mV)); } else { _R_set_c_RGBA(ScaleColor(REAL(r)[i%nr] / mV), diff -Nru r-base-3.1.0/src/library/grDevices/src/grDevices.h r-base-3.1.1/src/library/grDevices/src/grDevices.h --- r-base-3.1.0/src/library/grDevices/src/grDevices.h 2013-03-05 23:02:37.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/src/grDevices.h 2014-06-13 22:15:12.000000000 +0000 @@ -40,7 +40,7 @@ SEXP Type1FontInUse(SEXP, SEXP); SEXP CIDFontInUse(SEXP, SEXP); -#ifndef WIN32 +#ifndef _WIN32 SEXP Quartz(SEXP); SEXP makeQuartzDefault(); @@ -63,7 +63,7 @@ double, double, double, int, int, const char*, SEXP, int, int, const char *, int, int, Rboolean, Rboolean); -#ifdef WIN32 +#ifdef _WIN32 SEXP devga(SEXP); SEXP savePlot(SEXP); SEXP bringToTop(SEXP, SEXP); diff -Nru r-base-3.1.0/src/library/grDevices/src/init.c r-base-3.1.1/src/library/grDevices/src/init.c --- r-base-3.1.0/src/library/grDevices/src/init.c 2013-04-09 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/src/init.c 2014-06-13 22:15:12.000000000 +0000 @@ -28,7 +28,7 @@ #include "grDevices.h" #include -#ifndef WIN32 +#ifndef _WIN32 /* This really belongs with the X11 module, but it is about devices */ static SEXP cairoProps(SEXP in) { @@ -71,7 +71,7 @@ CALLDEF(palette, 1), CALLDEF(palette2, 1), -#ifndef WIN32 +#ifndef _WIN32 CALLDEF(makeQuartzDefault, 0), CALLDEF(cairoProps, 1), #else @@ -109,7 +109,7 @@ EXTDEF(setGraphicsEventEnv, 2), EXTDEF(devAskNewPage, 1), -#ifdef WIN32 +#ifdef _WIN32 EXTDEF(savePlot, 4), EXTDEF(devga, 21), #else diff -Nru r-base-3.1.0/src/library/grDevices/src/stubs.c r-base-3.1.1/src/library/grDevices/src/stubs.c --- r-base-3.1.0/src/library/grDevices/src/stubs.c 2013-03-05 23:02:37.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/src/stubs.c 2014-06-13 22:15:12.000000000 +0000 @@ -22,7 +22,7 @@ #include #include "grDevices.h" -#ifndef WIN32 +#ifndef _WIN32 SEXP do_X11(SEXP call, SEXP op, SEXP args, SEXP env); SEXP do_saveplot(SEXP call, SEXP op, SEXP args, SEXP env); @@ -67,7 +67,7 @@ return do_setGraphicsEventEnv(call, op, CDR(args), env); } -#ifdef WIN32 +#ifdef _WIN32 SEXP bringtotop(SEXP sdev, SEXP sstay); SEXP msgwindow(SEXP sdev, SEXP stype); diff -Nru r-base-3.1.0/src/library/grDevices/tests/ps-tests.Rout.save r-base-3.1.1/src/library/grDevices/tests/ps-tests.Rout.save --- r-base-3.1.0/src/library/grDevices/tests/ps-tests.Rout.save 2014-04-05 22:15:06.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/tests/ps-tests.Rout.save 2014-07-07 22:15:05.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -95,4 +95,4 @@ > > proc.time() user system elapsed - 0.358 0.011 0.366 + 0.463 0.021 0.481 diff -Nru r-base-3.1.0/src/library/grDevices/tests/xfig-tests.Rout.save r-base-3.1.1/src/library/grDevices/tests/xfig-tests.Rout.save --- r-base-3.1.0/src/library/grDevices/tests/xfig-tests.Rout.save 2014-04-05 22:15:06.000000000 +0000 +++ r-base-3.1.1/src/library/grDevices/tests/xfig-tests.Rout.save 2014-07-07 22:15:05.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -102,4 +102,4 @@ > > proc.time() user system elapsed - 0.125 0.012 0.133 + 0.244 0.021 0.263 diff -Nru r-base-3.1.0/src/library/grid/inst/doc/changes.txt r-base-3.1.1/src/library/grid/inst/doc/changes.txt --- r-base-3.1.0/src/library/grid/inst/doc/changes.txt 2014-03-12 23:02:28.000000000 +0000 +++ r-base-3.1.1/src/library/grid/inst/doc/changes.txt 2014-06-04 22:15:06.000000000 +0000 @@ -1,4 +1,15 @@ +Changes from grid_3.1.* to grid_3.2.0: +------------------------------------- + +1. Fixed evaluation of "pure null" units (by making evaluation recursive). + Previously, for example, a unit list with a unit list as its first + component would evaluate to NA. This typically only affects layouts + in grid. + + Problem reported by Baptiste Auguie. + + Changes from grid_3.0.* to grid_3.1.0: ------------------------------------- Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/displaylist.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/displaylist.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/frame.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/frame.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/grid.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/grid.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/grobs.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/grobs.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/interactive.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/interactive.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/locndimn.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/locndimn.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/moveline.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/moveline.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/nonfinite.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/nonfinite.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/plotexample.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/plotexample.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/rotated.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/rotated.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/saveload.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/saveload.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/sharing.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/sharing.pdf differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/grid/inst/doc/viewports.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/grid/inst/doc/viewports.pdf differ diff -Nru r-base-3.1.0/src/library/grid/man/grid.cap.Rd r-base-3.1.1/src/library/grid/man/grid.cap.Rd --- r-base-3.1.0/src/library/grid/man/grid.cap.Rd 2012-04-15 22:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/grid/man/grid.cap.Rd 2014-05-20 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/grid/man/grid.cap.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{grid.cap} @@ -19,7 +19,7 @@ This function is only implemented for on-screen graphics devices. } \value{ - A matrix of R colour names. + A matrix of R colour names, or \code{NULL} if not available. } \author{ Paul Murrell @@ -30,14 +30,15 @@ \code{\link{dev.capabilities}} to see if it is supported. } \examples{ -\dontrun{ -dev.new(width=.5, height=.5) +\donttest{ +dev.new(width=0.5, height=0.5) grid.rect() grid.text("hi") cap <- grid.cap() dev.off() -grid.raster(cap, width=.5, height=.5, interpolate=FALSE) +if(!is.null(cap)) + grid.raster(cap, width=0.5, height=0.5, interpolate=FALSE) } } \keyword{ dplot } diff -Nru r-base-3.1.0/src/library/grid/src/unit.c r-base-3.1.1/src/library/grid/src/unit.c --- r-base-3.1.0/src/library/grid/src/unit.c 2014-03-12 23:02:27.000000000 +0000 +++ r-base-3.1.1/src/library/grid/src/unit.c 2014-06-04 22:15:06.000000000 +0000 @@ -218,23 +218,23 @@ if (isUnitArithmetic(unit)) { int i; if (addOp(unit)) { - result = unitValue(arg1(unit), index) + - unitValue(arg2(unit), index); + result = pureNullUnitValue(arg1(unit), index) + + pureNullUnitValue(arg2(unit), index); } else if (minusOp(unit)) { - result = unitValue(arg1(unit), index) - - unitValue(arg2(unit), index); + result = pureNullUnitValue(arg1(unit), index) - + pureNullUnitValue(arg2(unit), index); } else if (timesOp(unit)) { result = REAL(arg1(unit))[index] * - unitValue(arg2(unit), index); + pureNullUnitValue(arg2(unit), index); } else if (minFunc(unit)) { int n = unitLength(arg1(unit)); double temp = DBL_MAX; - result = unitValue(arg1(unit), 0); + result = pureNullUnitValue(arg1(unit), 0); for (i=1; i result) result = temp; } @@ -253,7 +253,7 @@ int n = unitLength(arg1(unit)); result = 0.0; for (i=0; i > proc.time() user system elapsed - 0.197 0.009 0.203 + 0.278 0.019 0.289 diff -Nru r-base-3.1.0/src/library/methods/man/stdRefClass.Rd r-base-3.1.1/src/library/methods/man/stdRefClass.Rd --- r-base-3.1.0/src/library/methods/man/stdRefClass.Rd 2012-08-19 22:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/methods/man/stdRefClass.Rd 2014-04-25 22:15:02.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/methods/man/stdRefClass.Rd % Part of the R package, http://www.R-project.org -% Copyright 2010-2 R Core Team +% Copyright 2010-2014 R Core Team % Distributed under GPL 2 or later \name{envRefClass-class} @@ -30,7 +30,7 @@ from subclasses defined by a call to \code{\link{setRefClass}}. The documentation below is technical background describing the implementation, but applications should use the interface documented under \code{\link{setRefClass}}, -in particular the \code{\$} operator and field accessor functions as +in particular the \code{$} operator and field accessor functions as described there. } @@ -42,7 +42,7 @@ class}, which must implement a set of methods and provide some further information used by \code{\link{setRefClass}}. -The required methods are for operators \code{\$} and \code{\$<-} to +The required methods are for operators \code{$} and \code{$<-} to get and set a field in an object, and for \code{\link{initialize}} to initialize objects. @@ -60,8 +60,8 @@ as Java or C++ using reference semantics for classes. Usually, the \R user will be able to invoke class methods on the -class, using the \code{\$} operator. The basic reference class -method for \code{\$} needs to make this possible. Essentially, the +class, using the \code{$} operator. The basic reference class +method for \code{$} needs to make this possible. Essentially, the operator must return an \R function corresponding to the object and the class method name. Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/parallel/inst/doc/parallel.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/parallel/inst/doc/parallel.pdf differ diff -Nru r-base-3.1.0/src/library/parallel/man/makeCluster.Rd r-base-3.1.1/src/library/parallel/man/makeCluster.Rd --- r-base-3.1.0/src/library/parallel/man/makeCluster.Rd 2014-01-05 23:05:06.000000000 +0000 +++ r-base-3.1.1/src/library/parallel/man/makeCluster.Rd 2014-05-13 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/parallel/man/makePSOCKcluster.Rd % Part of the R package, http://www.R-project.org -% Copyright 2003-2013 R Core Team +% Copyright 2003-2014 R Core Team % Distributed under GPL 2 or later \newcommand{\CRANpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} @@ -72,17 +72,18 @@ \item{\code{outfile}}{Where to direct the \code{\link{stdout}} and \code{\link{stderr}} connection output from the workers. \code{""} indicates no redirection (which may only be useful for - workers on the local machines). + workers on the local machine). Defaults to \file{/dev/null} (\file{nul:} on Windows). The other possibility is a file path on the worker's host. Files will be opened in append mode, as all workers log to the same file.} \item{\code{homogeneous}}{Logical. Are all the hosts running - identical setups, so \command{Rscript} can be launched using its - full path on the master? Otherwise it has to be in the default - path on the other hosts.} - \item{\code{rscript}}{The path to \command{Rscript} on the workers. - Defaults to the full path on the master.} + identical setups, so \command{Rscript} can be launched using + the same path on each? Otherwise \command{Rscript} has to be in + the default path on the workers.} + \item{\code{rscript}}{The path to \command{Rscript} on the workers, + used if \code{homogeneous} is true. Defaults to the full path on + the master.} \item{\code{renice}}{A numerical \sQuote{niceness} to set for the worker processes, e.g.{} \code{15} for a low priority. OS-dependent: see \code{\link{psnice}} for details.} @@ -94,11 +95,11 @@ run manually.} \item{\code{methods}}{Logical. If true (default) the workers will load the \pkg{methods} package: not loading it saves ca 30\% of the - startup time of the cluster.} + startup CPU time of the cluster.} \item{\code{useXDR}}{Logical. If true (default) serialization will use XDR: where large amounts of data are to be transferred and all the nodes are little-endian, communication may be - substantially fast if this is set to false.} + substantially faster if this is set to false.} } Function \code{makeForkCluster} creates a socket cluster by forking diff -Nru r-base-3.1.0/src/library/parallel/man/unix/mcfork.Rd r-base-3.1.1/src/library/parallel/man/unix/mcfork.Rd --- r-base-3.1.0/src/library/parallel/man/unix/mcfork.Rd 2014-03-12 23:02:31.000000000 +0000 +++ r-base-3.1.1/src/library/parallel/man/unix/mcfork.Rd 2014-05-20 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/parallel/man/unix/mcfork.Rd % Part of the R package, http://www.R-project.org -% Copyright 2009-2013 R Core Team +% Copyright 2009-2014 R Core Team % Distributed under GPL 2 or later \newcommand{\CRANpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} @@ -26,7 +26,7 @@ \arguments{ \item{estranged}{logical, if \code{TRUE} then the new process has no ties to the parent process, will not show in the list of - children and will not be killed on exit} + children and will not be killed on exit.} \item{exit.code}{process exit code. By convention \code{0L} signifies a clean exit, \code{1L} an error.} \item{send}{if not \code{NULL} send this data before exiting @@ -109,12 +109,12 @@ % The results here involve a random PID. \examples{\donttest{ ## This will work when run as an example, but not when pasted in. -p <- mcfork() +p <- parallel:::mcfork() if (inherits(p, "masterProcess")) { cat("I'm a child! ", Sys.getpid(), "\n") - mcexit(,"I was a child") + parallel:::mcexit(,"I was a child") } cat("I'm the master\n") -unserialize(readChildren(1.5)) +unserialize(parallel:::readChildren(1.5)) }} \keyword{interface} diff -Nru r-base-3.1.0/src/library/parallel/R/unix/mcmapply.R r-base-3.1.1/src/library/parallel/R/unix/mcmapply.R --- r-base-3.1.0/src/library/parallel/R/unix/mcmapply.R 2013-03-05 23:02:21.000000000 +0000 +++ r-base-3.1.1/src/library/parallel/R/unix/mcmapply.R 2014-05-29 22:15:04.000000000 +0000 @@ -29,7 +29,7 @@ n <- max(lens) if(n && min(lens) == 0L) stop("Zero-length inputs cannot be mixed with those of non-zero length") - answer <- if(n <= mc.cores) .mapply(FUN, dots, MoreArgs) + answer <- if(n < 2L) .mapply(FUN, dots, MoreArgs) else { ## recycle shorter vectors X <- if (!all(lens == n)) diff -Nru r-base-3.1.0/src/library/parallel/src/fork.c r-base-3.1.1/src/library/parallel/src/fork.c --- r-base-3.1.0/src/library/parallel/src/fork.c 2014-03-15 23:15:02.000000000 +0000 +++ r-base-3.1.1/src/library/parallel/src/fork.c 2014-05-27 22:15:04.000000000 +0000 @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -#include /* for affinity function checks */ +#include /* for affinity function checks and sigaction */ #endif #include "parallel.h" @@ -184,11 +184,59 @@ on signal makes this automatic as opposed to requiring a poll. */ +#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION) && defined(HAVE_WORKING_SIGACTION) && defined(HAVE_SIGEMPTYSET) +/* if we can, we use SIGINFO to get the PID of the child to avoid + picking up children spawned by other packages */ +static void parent_sig_handler(int sig, siginfo_t *info, void *context) { + /* clean up when a child terminates */ + if (sig == SIGCHLD) { + if (info && info->si_pid > 0) { + pid_t pid = info->si_pid; + child_info_t *ci = children; + while (ci) { + if (ci->pid == pid) { + /* one of ours - pick up the status - this is almost like clean_zombies() except targetted at one PID */ + int wstat; + if ((waitpid(pid, &wstat, WNOHANG) == pid) && (WIFEXITED(wstat) || WIFSIGNALED(wstat))) { +#ifdef MC_DEBUG + if (WIFEXITED(wstat)) + Dprintf("child %d terminated with %d\n", pid, WEXITSTATUS(wstat)); + else + Dprintf("child %d terminated by signal %d\n", pid, WTERMSIG(wstat)); +#endif + if (ci->pfd > 0) { close(ci->pfd); ci->pfd = -1; } + if (ci->sifd > 0) { close(ci->sifd); ci->sifd = -1; } + ci->pid = 0; + } + break; + } + ci = ci->next; + } + } else /* no way to tell the source - pick up everything */ + clean_zombies(); + } +} + +static void setup_sig_handler() { + struct sigaction sa; + sa.sa_sigaction = parent_sig_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_SIGINFO | SA_RESTART; + sigaction(SIGCHLD, &sa, NULL); +} +#else +/* sigaction is not viable, so use the "dumb" way + to clean up anything that comes our way */ +static void setup_sig_handler() { + signal(SIGCHLD, parent_sig_handler); +} + static void parent_sig_handler(int sig) { /* clean up when a child terminates */ if (sig == SIGCHLD) clean_zombies(); } +#endif /* from Defn.h */ extern Rboolean R_isForkedChild; @@ -215,7 +263,7 @@ } /* make sure we get SIGCHLD to clean up the child process */ - signal(SIGCHLD, parent_sig_handler); + setup_sig_handler(); pid = fork(); if (pid == -1) { diff -Nru r-base-3.1.0/src/library/parallel/src/init.c r-base-3.1.1/src/library/parallel/src/init.c --- r-base-3.1.0/src/library/parallel/src/init.c 2014-03-12 23:02:31.000000000 +0000 +++ r-base-3.1.1/src/library/parallel/src/init.c 2014-06-13 22:15:08.000000000 +0000 @@ -24,7 +24,7 @@ static const R_CallMethodDef callMethods[] = { {"nextStream", (DL_FUNC) &nextStream, 1}, {"nextSubStream", (DL_FUNC) &nextSubStream, 1}, -#ifndef WIN32 +#ifndef _WIN32 {"mc_children", (DL_FUNC) &mc_children, 0}, {"mc_close_fds", (DL_FUNC) &mc_close_fds, 1}, {"mc_close_stderr", (DL_FUNC) &mc_close_stderr, 1}, diff -Nru r-base-3.1.0/src/library/parallel/src/parallel.h r-base-3.1.1/src/library/parallel/src/parallel.h --- r-base-3.1.0/src/library/parallel/src/parallel.h 2014-03-27 23:15:19.000000000 +0000 +++ r-base-3.1.1/src/library/parallel/src/parallel.h 2014-06-13 22:15:08.000000000 +0000 @@ -31,7 +31,7 @@ SEXP nextStream(SEXP); SEXP nextSubStream(SEXP); -#ifndef WIN32 +#ifndef _WIN32 SEXP mc_children(void); SEXP mc_close_fds(SEXP); SEXP mc_close_stderr(SEXP); diff -Nru r-base-3.1.0/src/library/parallel/tests/multicore2.Rout.save r-base-3.1.1/src/library/parallel/tests/multicore2.Rout.save --- r-base-3.1.0/src/library/parallel/tests/multicore2.Rout.save 2014-04-05 22:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/parallel/tests/multicore2.Rout.save 2014-07-07 22:15:04.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -43,4 +43,4 @@ > > proc.time() user system elapsed - 0.302 0.029 0.229 + 0.320 0.032 0.351 diff -Nru r-base-3.1.0/src/library/parallel/tests/snow2.Rout.save r-base-3.1.1/src/library/parallel/tests/snow2.Rout.save --- r-base-3.1.0/src/library/parallel/tests/snow2.Rout.save 2014-04-05 22:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/parallel/tests/snow2.Rout.save 2014-07-07 22:15:04.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -48,4 +48,4 @@ > > proc.time() user system elapsed - 0.119 0.018 0.503 + 0.236 0.024 0.816 Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/Recommended/MASS_7.3-31.tar.gz and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/Recommended/MASS_7.3-31.tar.gz differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/Recommended/MASS_7.3-33.tar.gz and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/Recommended/MASS_7.3-33.tar.gz differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/Recommended/MASS.tgz and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/Recommended/MASS.tgz differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/Recommended/Matrix_1.1-3.tar.gz and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/Recommended/Matrix_1.1-3.tar.gz differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/Recommended/Matrix_1.1-4.tar.gz and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/Recommended/Matrix_1.1-4.tar.gz differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/Recommended/Matrix.tgz and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/Recommended/Matrix.tgz differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/Recommended/mgcv_1.7-29.tar.gz and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/Recommended/mgcv_1.7-29.tar.gz differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/Recommended/mgcv_1.8-0.tar.gz and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/Recommended/mgcv_1.8-0.tar.gz differ Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/Recommended/mgcv.tgz and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/Recommended/mgcv.tgz differ diff -Nru r-base-3.1.0/src/library/stats/man/Beta.Rd r-base-3.1.1/src/library/stats/man/Beta.Rd --- r-base-3.1.0/src/library/stats/man/Beta.Rd 2014-03-24 23:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Beta.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -29,7 +29,7 @@ \item{p}{vector of probabilities.} \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} - \item{shape1, shape2}{positive parameters of the Beta distribution.} + \item{shape1, shape2}{non-negative parameters of the Beta distribution.} \item{ncp}{non-centrality parameter.} \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} \item{lower.tail}{logical; if TRUE (default), probabilities are @@ -45,6 +45,10 @@ by continuity (as limits). \cr The mean is \eqn{a/(a+b)} and the variance is \eqn{ab/((a+b)^2 (a+b+1))}. + These moments and all distributional properties can be defined as + limits (leading to point masses at 0, 1/2, or 1) when \eqn{a} or + \eqn{b} are zero or infinite, and the corresponding + \code{[dpqr]beta()} functions are defined correspondingly. \code{pbeta} is closely related to the incomplete beta function. As defined by Abramowitz and Stegun 6.6.1 @@ -66,14 +70,14 @@ generates random deviates. Invalid arguments will result in return value \code{NaN}, with a warning. - + The length of the result is determined by \code{n} for \code{rbeta}, and is the maximum of the lengths of the - numerical parameters for the other functions. - - The numerical parameters other than \code{n} are recycled to the + numerical arguments for the other functions. + + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \note{ Supplying \code{ncp = 0} uses the algorithm for the non-central @@ -149,5 +153,39 @@ x <- seq(0, 1, length = 21) dbeta(x, 1, 1) pbeta(x, 1, 1) + +## Visualization, including limit cases: +pl.beta <- function(a,b, asp = if(isLim) 1, ylim = if(isLim) c(0,1.1)) { + if(isLim <- a == 0 || b == 0 || a == Inf || b == Inf) { + eps <- 1e-10 + x <- c(0, eps, (1:7)/16, 1/2+c(-eps,0,eps), (9:15)/16, 1-eps, 1) + } else { + x <- seq(0, 1, length = 1025) + } + fx <- cbind(dbeta(x, a,b), pbeta(x, a,b), qbeta(x, a,b)) + f <- fx; f[fx == Inf] <- 1e100 + matplot(x, f, ylab="", type="l", ylim=ylim, asp=asp, + main = sprintf("[dpq]beta(x, a=\%g, b=\%g)", a,b)) + abline(0,1, col="gray", lty=3) + abline(h = 0:1, col="gray", lty=3) + legend("top", paste0(c("d","p","q"), "beta(x, a,b)"), + col=1:3, lty=1:3, bty = "n") + invisible(cbind(x, fx)) +} +pl.beta(3,1) + +pl.beta(2, 4) +pl.beta(3, 7) +pl.beta(3, 7, asp=1) + +pl.beta(0, 0) ## point masses at {0, 1} + +pl.beta(0, 2) ## point mass at 0 ; the same as +pl.beta(1, Inf) + +pl.beta(Inf, 2) ## point mass at 1 ; the same as +pl.beta(3, 0) + +pl.beta(Inf, Inf)# point mass at 1/2 } \keyword{distribution} diff -Nru r-base-3.1.0/src/library/stats/man/Binomial.Rd r-base-3.1.1/src/library/stats/man/Binomial.Rd --- r-base-3.1.0/src/library/stats/man/Binomial.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Binomial.Rd 2014-05-27 22:15:06.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/stats/man/Binomial.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{Binomial} @@ -14,6 +14,9 @@ Density, distribution function, quantile function and random generation for the binomial distribution with parameters \code{size} and \code{prob}. + + This is conventionally interpreted as the number of \sQuote{successes} + in \code{size} trials. } \usage{ dbinom(x, size, prob, log = FALSE) @@ -41,11 +44,11 @@ The length of the result is determined by \code{n} for \code{rbinom}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ The binomial distribution with \code{size} \eqn{= n} and @@ -58,6 +61,7 @@ If an element of \code{x} is not integer, the result of \code{dbinom} is zero, with a warning. + \eqn{p(x)} is computed using Loader's algorithm, see the reference below. The quantile is defined as the smallest value \eqn{x} such that diff -Nru r-base-3.1.0/src/library/stats/man/Cauchy.Rd r-base-3.1.1/src/library/stats/man/Cauchy.Rd --- r-base-3.1.0/src/library/stats/man/Cauchy.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Cauchy.Rd 2014-05-27 22:15:06.000000000 +0000 @@ -39,11 +39,11 @@ The length of the result is determined by \code{n} for \code{rcauchy}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ If \code{location} or \code{scale} are not specified, they assume diff -Nru r-base-3.1.0/src/library/stats/man/Chisquare.Rd r-base-3.1.1/src/library/stats/man/Chisquare.Rd --- r-base-3.1.0/src/library/stats/man/Chisquare.Rd 2014-03-14 23:15:04.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Chisquare.Rd 2014-05-27 22:15:06.000000000 +0000 @@ -42,11 +42,11 @@ The length of the result is determined by \code{n} for \code{rchisq}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ The chi-squared distribution with \code{df}\eqn{= n \ge 0} @@ -139,7 +139,7 @@ Z0 <- rchisq(100, df = 0, ncp = 2.) graphics::stem(Z0) -\dontrun{## visual testing +\donttest{## visual testing ## do P-P plots for 1000 points at various degrees of freedom L <- 1.2; n <- 1000; pp <- ppoints(n) op <- par(mfrow = c(3,3), mar = c(3,3,1,1)+.1, mgp = c(1.5,.6,0), diff -Nru r-base-3.1.0/src/library/stats/man/Exponential.Rd r-base-3.1.1/src/library/stats/man/Exponential.Rd --- r-base-3.1.0/src/library/stats/man/Exponential.Rd 2013-03-05 23:02:25.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Exponential.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -39,11 +39,11 @@ The length of the result is determined by \code{n} for \code{rexp}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ If \code{rate} is not specified, it assumes the default value of diff -Nru r-base-3.1.0/src/library/stats/man/family.Rd r-base-3.1.1/src/library/stats/man/family.Rd --- r-base-3.1.0/src/library/stats/man/family.Rd 2014-03-24 23:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/family.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/stats/man/family.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \newcommand{\sspace}{\ifelse{latex}{\out{~}}{ }} @@ -81,6 +81,19 @@ \code{family} is a generic function with methods for classes \code{"glm"} and \code{"lm"} (the latter returning \code{gaussian()}). + + For the \code{binomial} and \code{quasibinomial} families the response + can be specified in one of three ways: + \enumerate{ + \item As a factor: \sQuote{success} is interpreted as the factor not + having the first level (and hence usually of having the second level). + \item As a numerical vector with values between \code{0} and + \code{1}, interpreted as the proportion of successful cases (with the + total number of cases given by the \code{weights}). + \item As a two-column integer matrix: the first column gives the + number of successes and the second the number of failures. + } + The \code{quasibinomial} and \code{quasipoisson} families differ from the \code{binomial} and \code{poisson} families only in that the dispersion parameter is not fixed at one, so they can model diff -Nru r-base-3.1.0/src/library/stats/man/Fdist.Rd r-base-3.1.1/src/library/stats/man/Fdist.Rd --- r-base-3.1.0/src/library/stats/man/Fdist.Rd 2013-03-05 23:02:25.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Fdist.Rd 2014-05-27 22:15:06.000000000 +0000 @@ -42,11 +42,11 @@ The length of the result is determined by \code{n} for \code{rf}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ The F distribution with \code{df1 =} \eqn{n_1}{n1} and \code{df2 =} diff -Nru r-base-3.1.0/src/library/stats/man/GammaDist.Rd r-base-3.1.1/src/library/stats/man/GammaDist.Rd --- r-base-3.1.0/src/library/stats/man/GammaDist.Rd 2013-03-05 23:02:25.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/GammaDist.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -49,11 +49,11 @@ The length of the result is determined by \code{n} for \code{rgamma}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ If \code{scale} is omitted, it assumes the default value of \code{1}. diff -Nru r-base-3.1.0/src/library/stats/man/Geometric.Rd r-base-3.1.1/src/library/stats/man/Geometric.Rd --- r-base-3.1.0/src/library/stats/man/Geometric.Rd 2013-03-05 23:02:25.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Geometric.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -52,11 +52,11 @@ The length of the result is determined by \code{n} for \code{rgeom}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \source{ \code{dgeom} computes via \code{dbinom}, using code contributed by diff -Nru r-base-3.1.0/src/library/stats/man/glm.Rd r-base-3.1.1/src/library/stats/man/glm.Rd --- r-base-3.1.0/src/library/stats/man/glm.Rd 2014-03-24 23:15:06.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/glm.Rd 2014-05-26 22:15:06.000000000 +0000 @@ -339,7 +339,7 @@ anova(glm.D93) \donttest{summary(glm.D93)} -\dontrun{## an example with offsets from Venables & Ripley (2002, p.189) +\donttest{## an example with offsets from Venables & Ripley (2002, p.189) utils::data(anorexia, package = "MASS") anorex.1 <- glm(Postwt ~ Prewt + Treat + offset(Prewt), diff -Nru r-base-3.1.0/src/library/stats/man/Hypergeometric.Rd r-base-3.1.1/src/library/stats/man/Hypergeometric.Rd --- r-base-3.1.0/src/library/stats/man/Hypergeometric.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Hypergeometric.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -44,11 +44,11 @@ The length of the result is determined by \code{n} for \code{rhyper}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ The hypergeometric distribution is used for sampling \emph{without} diff -Nru r-base-3.1.0/src/library/stats/man/kmeans.Rd r-base-3.1.1/src/library/stats/man/kmeans.Rd --- r-base-3.1.0/src/library/stats/man/kmeans.Rd 2014-03-24 23:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/kmeans.Rd 2014-04-23 22:15:02.000000000 +0000 @@ -32,7 +32,7 @@ \item{nstart}{if \code{centers} is a number, how many random sets should be chosen?} \item{algorithm}{character: may be abbreviated. Note that - \code{"Lloyd"} and \code{"Forgy"} and alternative names for one + \code{"Lloyd"} and \code{"Forgy"} are alternative names for one algorithm.} \item{object}{an \R object of class \code{"kmeans"}, typically the result \code{ob} of \code{ob <- kmeans(..)}.} diff -Nru r-base-3.1.0/src/library/stats/man/lag.plot.Rd r-base-3.1.1/src/library/stats/man/lag.plot.Rd --- r-base-3.1.0/src/library/stats/man/lag.plot.Rd 2013-03-05 23:02:25.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/lag.plot.Rd 2014-05-26 22:15:07.000000000 +0000 @@ -73,10 +73,9 @@ ## Multivariate (but non-stationary! ...) lag.plot(freeny.x, lags = 3) -\dontrun{ -no lines for long series : + +## no lines for long series : lag.plot(sqrt(sunspots), set = c(1:4, 9:12), pch = ".", col = "gold") } -} \keyword{hplot} \keyword{ts} diff -Nru r-base-3.1.0/src/library/stats/man/lag.Rd r-base-3.1.1/src/library/stats/man/lag.Rd --- r-base-3.1.0/src/library/stats/man/lag.Rd 2012-04-15 22:05:08.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/lag.Rd 2014-04-20 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/stats/man/lag.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2007 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{lag} @@ -10,7 +10,10 @@ \description{ Compute a lagged version of a time series, shifting the time base back by a given number of observations. -} + + \code{lag} is a generic function; this page documents its default + method. + } \usage{ lag(x, \dots) @@ -21,14 +24,12 @@ \item{k}{The number of lags (in units of observations).} \item{\dots}{further arguments to be passed to or from methods.} } -\details{ - Vector or matrix arguments \code{x} are coerced to time series. - - \code{lag} is a generic function; this page documents its default - method. +\details{ + Vector or matrix arguments \code{x} are given a \code{tsp} attribute + \emph{via} \code{\link{hasTsp}}. } \value{ - A time series object. + A time series object with the same class as \code{x}. } \note{ diff -Nru r-base-3.1.0/src/library/stats/man/lmfit.Rd r-base-3.1.1/src/library/stats/man/lmfit.Rd --- r-base-3.1.0/src/library/stats/man/lmfit.Rd 2014-03-12 23:02:39.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/lmfit.Rd 2014-05-26 22:15:06.000000000 +0000 @@ -93,7 +93,7 @@ stopifnot(id(unname(lm.$coef), lm..$coef), id(unname(lmw$coef), lm.w$coef)) } -\dontrun{ +\donttest{ if(require("microbenchmark")) { mb <- microbenchmark(lm(y~X), lm.fit(X,y), .lm.fit(X,y)) print(mb) diff -Nru r-base-3.1.0/src/library/stats/man/Logistic.Rd r-base-3.1.1/src/library/stats/man/Logistic.Rd --- r-base-3.1.0/src/library/stats/man/Logistic.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Logistic.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -42,11 +42,11 @@ The length of the result is determined by \code{n} for \code{rlogis}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ If \code{location} or \code{scale} are omitted, they assume the diff -Nru r-base-3.1.0/src/library/stats/man/Lognormal.Rd r-base-3.1.1/src/library/stats/man/Lognormal.Rd --- r-base-3.1.0/src/library/stats/man/Lognormal.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Lognormal.Rd 2014-06-16 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/stats/man/Lognormal.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{Lognormal} @@ -40,11 +40,13 @@ The length of the result is determined by \code{n} for \code{rlnorm}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. + + \code{sdlog <= 0} is an error and returns \code{NaN}. } \source{ \code{dlnorm} is calculated from the definition (in \sQuote{Details}). diff -Nru r-base-3.1.0/src/library/stats/man/NegBinomial.Rd r-base-3.1.1/src/library/stats/man/NegBinomial.Rd --- r-base-3.1.0/src/library/stats/man/NegBinomial.Rd 2013-08-05 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/NegBinomial.Rd 2014-06-19 22:15:04.000000000 +0000 @@ -25,7 +25,7 @@ \item{x}{vector of (non-negative integer) quantiles.} \item{q}{vector of quantiles.} \item{p}{vector of probabilities.} - \item{n}{number of observations. If \code{length(n) > 1}, the length + \item{n}{number of observations. If \code{length(n) > 1}, the length is taken to be the number required.} \item{size}{target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). @@ -50,7 +50,7 @@ A negative binomial distribution can also arise as a mixture of Poisson distributions with mean distributed as a gamma distribution - (see\code{\link{pgamma}}) with scale parameter \code{(1 - prob)/prob} + (see \code{\link{pgamma}}) with scale parameter \code{(1 - prob)/prob} and shape parameter \code{size}. (This definition allows non-integer values of \code{size}.) @@ -62,10 +62,11 @@ If an element of \code{x} is not integer, the result of \code{dnbinom} is zero, with a warning. - The case \code{size == 0} is the distribution concentrated at zero. This - is the limiting distribution for \code{size} approaching zero, even if - \code{mu} rather than \code{prob} is held constant. Notice though, that - the mean of the limit distribution is 0, whatever the value of \code{mu}. + The case \code{size == 0} is the distribution concentrated at zero. + This is the limiting distribution for \code{size} approaching zero, + even if \code{mu} rather than \code{prob} is held constant. Notice + though, that the mean of the limit distribution is 0, whatever the + value of \code{mu}. The quantile is defined as the smallest value \eqn{x} such that \eqn{F(x) \ge p}, where \eqn{F} is the distribution function. @@ -78,14 +79,14 @@ Invalid \code{size} or \code{prob} will result in return value \code{NaN}, with a warning. - + The length of the result is determined by \code{n} for \code{rnbinom}, and is the maximum of the lengths of the - numerical parameters for the other functions. - - The numerical parameters other than \code{n} are recycled to the + numerical arguments for the other functions. + + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \source{ \code{dnbinom} computes via binomial probabilities, using code diff -Nru r-base-3.1.0/src/library/stats/man/nls.Rd r-base-3.1.1/src/library/stats/man/nls.Rd --- r-base-3.1.0/src/library/stats/man/nls.Rd 2014-01-05 23:05:13.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/nls.Rd 2014-05-26 22:15:07.000000000 +0000 @@ -257,10 +257,8 @@ y <- 2*x + 3 # perfect fit yeps <- y + rnorm(length(y), sd = 0.01) # added noise nls(yeps ~ a + b*x, start = list(a = 0.12345, b = 0.54321)) -\dontrun{ ## terminates in an error, because convergence cannot be confirmed: -nls(y ~ a + b*x, start = list(a = 0.12345, b = 0.54321)) -} +try(nls(y ~ a + b*x, start = list(a = 0.12345, b = 0.54321))) ## the nls() internal cheap guess for starting values can be sufficient: diff -Nru r-base-3.1.0/src/library/stats/man/Normal.Rd r-base-3.1.1/src/library/stats/man/Normal.Rd --- r-base-3.1.0/src/library/stats/man/Normal.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Normal.Rd 2014-06-19 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/stats/man/Normal.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{Normal} @@ -46,11 +46,15 @@ The length of the result is determined by \code{n} for \code{rnorm}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. + + For \code{sd = 0} this gives the limit as \code{sd} decreases to 0, a + point mass at \code{mu}. + \code{sd < 0} is an error and returns \code{NaN}. } \details{ If \code{mean} or \code{sd} are not specified they assume the default @@ -64,9 +68,6 @@ } where \eqn{\mu} is the mean of the distribution and \eqn{\sigma} the standard deviation. - - \code{qnorm} is based on Wichura's algorithm AS 241 which provides - precise results up to about 16 digits. } \seealso{ \link{Distributions} for other standard distributions, including @@ -86,6 +87,8 @@ Algorithm AS 241: The percentage points of the normal distribution. \emph{Applied Statistics}, \bold{37}, 477--484. + which provides precise results up to about 16 digits. + For \code{rnorm}, see \link{RNG} for how to select the algorithm and for references to the supplied methods. } diff -Nru r-base-3.1.0/src/library/stats/man/plot.ts.Rd r-base-3.1.1/src/library/stats/man/plot.ts.Rd --- r-base-3.1.0/src/library/stats/man/plot.ts.Rd 2012-12-05 14:37:55.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/plot.ts.Rd 2014-05-26 22:15:07.000000000 +0000 @@ -79,13 +79,8 @@ plot(z, plot.type = "single", lty = 1:3, col = 4:2) ## A phase plot: -plot(nhtemp, c(nhtemp[-1], NA), cex = .8, col = "blue", - main = "Lag plot of New Haven temperatures") -## a clearer way to do this would be -\dontrun{ plot(nhtemp, lag(nhtemp, 1), cex = .8, col = "blue", main = "Lag plot of New Haven temperatures") -} ## xy.lines and xy.labels are FALSE for large series: plot(lag(sunspots, 1), sunspots, pch = ".") diff -Nru r-base-3.1.0/src/library/stats/man/Poisson.Rd r-base-3.1.1/src/library/stats/man/Poisson.Rd --- r-base-3.1.0/src/library/stats/man/Poisson.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Poisson.Rd 2014-05-27 22:15:06.000000000 +0000 @@ -40,11 +40,11 @@ The length of the result is determined by \code{n} for \code{rpois}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ The Poisson distribution has density diff -Nru r-base-3.1.0/src/library/stats/man/se.contrast.Rd r-base-3.1.1/src/library/stats/man/se.contrast.Rd --- r-base-3.1.0/src/library/stats/man/se.contrast.Rd 2012-12-05 14:37:55.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/se.contrast.Rd 2014-05-26 22:15:07.000000000 +0000 @@ -107,7 +107,7 @@ cont <- cbind(A = cont1, BC = cont2) colSums(cont*Yield) # values of the contrasts se.contrast(fit, as.matrix(cont)) -\dontrun{# comparison with lme +\donttest{# comparison with lme library(nlme) fit2 <- lme(Yield ~ A + B*C, random = ~1 | Block, data = aovdat) summary(fit2)$tTable # same estimates, similar (but smaller) se's. diff -Nru r-base-3.1.0/src/library/stats/man/SignRank.Rd r-base-3.1.1/src/library/stats/man/SignRank.Rd --- r-base-3.1.0/src/library/stats/man/SignRank.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/SignRank.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -40,11 +40,11 @@ The length of the result is determined by \code{nn} for \code{rsignrank}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{nn} are recycled to the + The numerical arguments other than \code{nn} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ This distribution is obtained as follows. Let \code{x} be a sample of diff -Nru r-base-3.1.0/src/library/stats/man/smooth.spline.Rd r-base-3.1.1/src/library/stats/man/smooth.spline.Rd --- r-base-3.1.0/src/library/stats/man/smooth.spline.Rd 2014-03-12 23:02:39.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/smooth.spline.Rd 2014-05-14 22:15:03.000000000 +0000 @@ -5,14 +5,15 @@ \name{smooth.spline} \alias{smooth.spline} +\alias{.nknots.smspl} %\alias{print.smooth.spline}% is not exported \title{Fit a Smoothing Spline} \description{ Fits a cubic smoothing spline to the supplied data. } \usage{ -smooth.spline(x, y = NULL, w = NULL, df, spar = NULL, - cv = FALSE, all.knots = FALSE, nknots = NULL, +smooth.spline(x, y = NULL, w = NULL, df, spar = NULL, cv = FALSE, + all.knots = FALSE, nknots = .nknots.smspl, keep.data = TRUE, df.offset = 0, penalty = 1, control.spar = list(), tol = 1e-6 * IQR(x)) } @@ -38,9 +39,11 @@ knots. If \code{FALSE} (default), a subset of \code{x[]} is used, specifically \code{x[j]} where the \code{nknots} indices are evenly spaced in \code{1:n}, see also the next argument \code{nknots}.} - \item{nknots}{integer giving the number of knots to use when - \code{all.knots = FALSE}. By default for \eqn{n > 49} this is less - than \eqn{n}, the number of unique \code{x} values.} + \item{nknots}{integer or \code{\link{function}} giving the number of + knots to use when \code{all.knots = FALSE}. If a function (as by + default), the number of knots is \code{nknots(nx)}. By default for + \eqn{n_x > 49}{nx > 49} this is less than \eqn{n_x}{nx}, the number + of unique \code{x} values, see the Note.} \item{keep.data}{logical specifying if the input data should be kept in the result. If \code{TRUE} (as per default), fitted values and residuals are available from the result.} @@ -70,12 +73,12 @@ } Note that \code{spar} is only searched for in the interval \eqn{[low, high]}. - } + } - \item{tol}{A tolerance for same-ness of the \code{x} values. The - values are binned into bins of size \code{tol} and values which - fall into the same bin are regarded as the same. - Must be strictly positive (and finite).} + \item{tol}{a tolerance for same-ness or uniqueness of the \code{x} + values. The values are binned into bins of size \code{tol} and + values which fall into the same bin are regarded as the same. Must + be strictly positive (and finite).} } \details{ Neither \code{x} nor \code{y} are allowed to containing missing or @@ -136,12 +139,17 @@ of duplicated points. \code{cv = TRUE} is best avoided in that case. } \note{ - The default \code{all.knots = FALSE} and \code{nknots = NULL} entails - using only \eqn{O(n^{0.2})} - knots instead of \eqn{n} for \eqn{n > 49}. This cuts speed and memory - requirements, but not drastically anymore since \R version 1.5.1 where - it is only \eqn{O(n_k) + O(n)}{O(nk) + O(n)} where \eqn{n_k}{nk} is - the number of knots. + The number of unique \code{x} values, \eqn{\mathtt{nx} = n_x}{nx} are + determined by the \code{tol} argument, equivalently to \preformatted{% + nx <- length(x) - sum(duplicated( round((x - mean(x)) / tol) ))} + + The default \code{all.knots = FALSE} and \code{nknots = .nknots.smspl}, + entails using only \eqn{O({n_x}^{0.2})}{O(nx ^ 0.2)} + knots instead of \eqn{n_x}{nx} for \eqn{n_x > 49}{nx > 49}. This cuts + speed and memory requirements, but not drastically anymore since \R + version 1.5.1 where it is only \eqn{O(n_k) + O(n)}{O(nk) + O(n)} where + \eqn{n_k}{nk} is the number of knots. + In this case where not all unique \code{x} values are used as knots, the result is not a smoothing spline in the strict sense, but very close unless a small smoothing parameter (or large @@ -244,6 +252,20 @@ stopifnot(all.equal(cars$dist, fitted(cars.spl) + residuals(cars.spl))) +## Visualize the behavior of .nknots.smspl() +nKnots <- Vectorize(.nknots.smspl) ; c.. <- adjustcolor("gray20",.5) +curve(nKnots, 1, 250, n=250) +abline(0,1, lty=2, col=c..); text(90,90,"y = x", col=c.., adj=-.25) +abline(h=100,lty=2); abline(v=200, lty=2) + +n <- c(1:799, seq(800, 3490, by=10), seq(3500, 10000, by = 50)) +plot(n, nKnots(n), type="l", main = "Vectorize(.nknots.smspl) (n)") +abline(0,1, lty=2, col=c..); text(180,180,"y = x", col=c..) +n0 <- c(50, 200, 800, 3200); c0 <- adjustcolor("blue3", .5) +lines(n0, nKnots(n0), type="h", col=c0) +axis(1, at=n0, line=-2, col.ticks=c0, col=NA, col.axis=c0) +axis(4, at=.nknots.smspl(10000), line=-.5, col=c..,col.axis=c.., las=1) + ##-- artificial example y18 <- c(1:3, 5, 4, 7:3, 2*(2:5), rep(10, 4)) xx <- seq(1, length(y18), len = 201) diff -Nru r-base-3.1.0/src/library/stats/man/TDist.Rd r-base-3.1.1/src/library/stats/man/TDist.Rd --- r-base-3.1.0/src/library/stats/man/TDist.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/TDist.Rd 2014-05-27 22:15:06.000000000 +0000 @@ -46,11 +46,11 @@ The length of the result is determined by \code{n} for \code{rt}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \note{ Supplying \code{ncp = 0} uses the algorithm for the non-central diff -Nru r-base-3.1.0/src/library/stats/man/termplot.Rd r-base-3.1.1/src/library/stats/man/termplot.Rd --- r-base-3.1.0/src/library/stats/man/termplot.Rd 2013-08-02 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/termplot.Rd 2014-07-09 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/stats/man/termplot.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \newcommand{\CRANpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} @@ -34,7 +34,7 @@ \item{rug}{add \link{rug}plots (jittered 1-d histograms) to the axes?} \item{terms}{which terms to plot (default \code{NULL} means all terms); a vector passed to - \code{\link{predict}(.., term = "terms", terms = *)}.} + \code{\link{predict}(.., type = "terms", terms = *)}.} \item{se}{plot pointwise standard errors?} \item{xlabs}{vector of labels for the x axes} \item{ylabs}{vector of labels for the y axes} @@ -62,8 +62,8 @@ \item{plot}{if set to \code{FALSE} plots are not produced: instead a list is returned containing the data that would have been plotted.} \item{transform.x}{logical vector; if an element (recycled as necessary) - is \code{TRUE}, partial residuals for the corresponding term are - plotted against transformed values. + is \code{TRUE}, partial residuals for the corresponding term are + plotted against transformed values. The model response is then a straight line, allowing a ready comparison against the data or against the curve obtained from \code{smooth-panel.smooth}.} @@ -71,7 +71,7 @@ } \details{ The \code{model} object must have a \code{predict} method that accepts - \code{type = terms}, e.g., \code{\link{glm}} in the \pkg{stats} package, + \code{type = "terms"}, e.g., \code{\link{glm}} in the \pkg{stats} package, \code{\link[survival]{coxph}} and \code{\link[survival]{survreg}} in the \CRANpkg{survival} package. @@ -121,9 +121,9 @@ if (require(MASS)) { hills.lm <- lm(log(time) ~ log(climb)+log(dist), data=hills) - termplot(hills.lm, partial.resid = TRUE, smooth = panel.smooth, + termplot(hills.lm, partial.resid = TRUE, smooth = panel.smooth, terms = "log(dist)", main = "Original") - termplot(hills.lm, transform.x = TRUE, partial.resid = TRUE, + termplot(hills.lm, transform.x = TRUE, partial.resid = TRUE, terms = "log(dist)", main = "Transformed", smooth=panel.smooth) } diff -Nru r-base-3.1.0/src/library/stats/man/tsdiag.Rd r-base-3.1.1/src/library/stats/man/tsdiag.Rd --- r-base-3.1.0/src/library/stats/man/tsdiag.Rd 2012-12-05 14:37:55.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/tsdiag.Rd 2014-05-26 22:15:07.000000000 +0000 @@ -39,7 +39,7 @@ } \examples{ -\dontrun{require(graphics) +\donttest{require(graphics) fit <- arima(lh, c(1,0,0)) tsdiag(fit) diff -Nru r-base-3.1.0/src/library/stats/man/tsp.Rd r-base-3.1.1/src/library/stats/man/tsp.Rd --- r-base-3.1.0/src/library/stats/man/tsp.Rd 2013-03-05 23:02:25.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/tsp.Rd 2014-04-20 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/stats/man/tsp.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2007 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{tsp} @@ -14,25 +14,31 @@ hasTsp(x) } \arguments{ - \item{x}{a vector or matrix or univariate or multivariate time-series.} - \item{value}{a numeric vector of length 3 or \code{NULL}.} + \item{x}{a vector or matrix or univariate or multivariate time-series.} + \item{value}{a numeric vector of length 3 or \code{NULL}.} } \description{ - \code{tsp} returns the \code{tsp} attribute (or \code{NULL}). - It is included for compatibility with S version 2. \code{tsp<-} - sets the \code{tsp} attribute. \code{hasTsp} ensures \code{x} has a - \code{tsp} attribute, by adding one if needed. + \code{tsp} returns the \code{tsp} attribute (or \code{NULL}). + It is included for compatibility with S version 2. \code{tsp<-} + sets the \code{tsp} attribute. \code{hasTsp} ensures \code{x} has a + \code{tsp} attribute, by adding one if needed. } \details{ - The \code{tsp} attribute was previously described here as - \code{c(start(x), end(x), frequency(x))}, but this is incorrect. - It gives the start time \emph{in time units}, the end time and - the frequency. + The \code{tsp} attribute gives the start time \emph{in time units}, + the end time and the frequency (the number of observations per unit of + time, e.g. 12 for a monthly series). - Assignments are checked for consistency. + Assignments are checked for consistency. - Assigning \code{NULL} which removes the \code{tsp} attribute - \emph{and} any \code{"ts"} (or \code{"mts"}) class of \code{x}. + Assigning \code{NULL} which removes the \code{tsp} attribute + \emph{and} any \code{"ts"} (or \code{"mts"}) class of \code{x}. +} +\value{ + An object which differs from \code{x} only in the \code{tsp} attribute + (unless \code{NULL} is assigned). + + \code{hasTsp} adds, if needed, an attribute with a start time and + frequency of 1 and end time \code{\link{NROW}(x)}. } \references{ Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) @@ -40,6 +46,6 @@ Wadsworth & Brooks/Cole. } \seealso{ - \code{\link{ts}}, \code{\link{time}}, \code{\link{start}}. + \code{\link{ts}}, \code{\link{time}}, \code{\link{start}}. } \keyword{ts} diff -Nru r-base-3.1.0/src/library/stats/man/ts.Rd r-base-3.1.1/src/library/stats/man/ts.Rd --- r-base-3.1.0/src/library/stats/man/ts.Rd 2013-08-24 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/ts.Rd 2014-05-26 22:15:06.000000000 +0000 @@ -126,11 +126,7 @@ plot(z, plot.type = "single", lty = 1:3) ## A phase plot: -plot(nhtemp, c(nhtemp[-1], NA), cex = .8, col = "blue", - main = "Lag plot of New Haven temperatures") -## a clearer way to do this would be -\dontrun{ plot(nhtemp, lag(nhtemp, 1), cex = .8, col = "blue", main = "Lag plot of New Haven temperatures") -}} +} \keyword{ts} diff -Nru r-base-3.1.0/src/library/stats/man/Tukey.Rd r-base-3.1.1/src/library/stats/man/Tukey.Rd --- r-base-3.1.0/src/library/stats/man/Tukey.Rd 2013-03-05 23:02:25.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Tukey.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -39,8 +39,8 @@ inverse, the quantile function. The length of the result is the maximum of the lengths of the - numerical parameters. The other numerical parameters are recycled - to that length. Only the first elements of the logical parameters + numerical arguments. The other numerical arguments are recycled + to that length. Only the first elements of the logical arguments are used. } \note{ diff -Nru r-base-3.1.0/src/library/stats/man/Uniform.Rd r-base-3.1.1/src/library/stats/man/Uniform.Rd --- r-base-3.1.0/src/library/stats/man/Uniform.Rd 2013-02-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Uniform.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -57,11 +57,11 @@ The length of the result is determined by \code{n} for \code{runif}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \note{The characteristics of output from pseudo-random number generators (such as precision and periodicity) vary widely. See diff -Nru r-base-3.1.0/src/library/stats/man/Weibull.Rd r-base-3.1.1/src/library/stats/man/Weibull.Rd --- r-base-3.1.0/src/library/stats/man/Weibull.Rd 2014-01-27 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Weibull.Rd 2014-05-27 22:15:06.000000000 +0000 @@ -41,11 +41,11 @@ The length of the result is determined by \code{n} for \code{rweibull}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{n} are recycled to the + The numerical arguments other than \code{n} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ The Weibull distribution with \code{shape} parameter \eqn{a} and diff -Nru r-base-3.1.0/src/library/stats/man/Wilcoxon.Rd r-base-3.1.1/src/library/stats/man/Wilcoxon.Rd --- r-base-3.1.0/src/library/stats/man/Wilcoxon.Rd 2013-03-05 23:02:25.000000000 +0000 +++ r-base-3.1.1/src/library/stats/man/Wilcoxon.Rd 2014-05-27 22:15:05.000000000 +0000 @@ -40,11 +40,11 @@ The length of the result is determined by \code{nn} for \code{rwilcox}, and is the maximum of the lengths of the - numerical parameters for the other functions. + numerical arguments for the other functions. - The numerical parameters other than \code{nn} are recycled to the + The numerical arguments other than \code{nn} are recycled to the length of the result. Only the first elements of the logical - parameters are used. + arguments are used. } \details{ This distribution is obtained as follows. Let \code{x} and \code{y} diff -Nru r-base-3.1.0/src/library/stats/NAMESPACE r-base-3.1.1/src/library/stats/NAMESPACE --- r-base-3.1.0/src/library/stats/NAMESPACE 2014-03-12 23:02:40.000000000 +0000 +++ r-base-3.1.1/src/library/stats/NAMESPACE 2014-05-14 22:15:03.000000000 +0000 @@ -6,7 +6,8 @@ importFrom(utils, str) -export(.checkMFClasses, .getXlevels, .MFclass, acf, acf2AR, add.scope, +export(.checkMFClasses, .getXlevels, .MFclass, .nknots.smspl, + acf, acf2AR, add.scope, add1, addmargins, aggregate,aggregate.ts, AIC, alias, anova, aov, approx, approxfun, ar, ar.burg, ar.mle, ar.ols, ar.yw, arima, arima.sim, arima0, arima0.diag, ARMAacf, ARMAtoMA, diff -Nru r-base-3.1.0/src/library/stats/R/lm.R r-base-3.1.1/src/library/stats/R/lm.R --- r-base-3.1.0/src/library/stats/R/lm.R 2014-03-26 23:02:03.000000000 +0000 +++ r-base-3.1.1/src/library/stats/R/lm.R 2014-06-19 22:15:04.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/stats/R/lm.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2013 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -541,7 +541,7 @@ fcall[names(nargs)] <- nargs env <- environment(formula$terms) if (is.null(env)) env <- parent.frame() - eval(fcall, env, parent.frame()) + eval(fcall, env) # 2-arg form as env is an environment } else formula$model } diff -Nru r-base-3.1.0/src/library/stats/R/models.R r-base-3.1.1/src/library/stats/R/models.R --- r-base-3.1.0/src/library/stats/R/models.R 2014-03-12 23:02:35.000000000 +0000 +++ r-base-3.1.1/src/library/stats/R/models.R 2014-06-19 22:15:04.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/stats/R/models.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2013 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -357,7 +357,7 @@ fcall[[1L]] <- quote(stats::model.frame) env <- environment(formula$terms) if (is.null(env)) env <- parent.frame() - return(eval(fcall, env, parent.frame())) + return(eval(fcall, env)) # 2-arg form as env is an environment } if(missing(formula)) { if(!missing(data) && inherits(data, "data.frame") && diff -Nru r-base-3.1.0/src/library/stats/R/smspline.R r-base-3.1.1/src/library/stats/R/smspline.R --- r-base-3.1.0/src/library/stats/R/smspline.R 2013-03-05 23:02:23.000000000 +0000 +++ r-base-3.1.1/src/library/stats/R/smspline.R 2014-05-14 22:15:03.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/stats/R/smspline.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2012 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,8 +16,7 @@ # A copy of the GNU General Public License is available at # http://www.r-project.org/Licenses/ -## Namespace-hidden but at least available to programmeRs: -n.knots <- function(n) { +.nknots.smspl <- function(n) { ## Number of inner knots if(n < 50L) n else trunc({ @@ -31,10 +30,14 @@ else 200 + (n-3200)^0.2 }) } +n.knots <- function(n) { + message(".nknots.smspl() is now exported; use it instead of n.knots()") + .nknots.smspl(n) +} smooth.spline <- function(x, y = NULL, w = NULL, df, spar = NULL, cv = FALSE, - all.knots = FALSE, nknots = NULL, keep.data = TRUE, + all.knots = FALSE, nknots = .nknots.smspl, keep.data = TRUE, df.offset = 0, penalty = 1, control.spar = list(), tol = 1e-6 * IQR(x)) { @@ -56,7 +59,7 @@ n <- length(x) if(is.na(n)) stop("invalid number of points") w <- - if(is.null(w)) rep(1, n) + if(is.null(w)) rep_len(1, n) else { if(n != length(w)) stop("lengths of 'x' and 'w' must match") if(any(w < 0)) stop("all weights should be non-negative") @@ -99,19 +102,20 @@ r.ux <- ux[nx] - ux[1L] xbar <- (ux - ux[1L])/r.ux # scaled to [0,1] if(all.knots) { - if(!is.null(nknots)) + if(!missing(nknots) && !is.null(nknots)) warning("'all.knots' is TRUE; 'nknots' specification is disregarded") nknots <- nx - } else { - ## was knot <- sknotl(xbar, nknots) - if(is.null(nknots)) - nknots <- n.knots(nx) - else if(!is.numeric(nknots)) - stop("'nknots' must be numeric (in {1,..,n})") - else if(nknots < 1) - stop("'nknots' must be at least 1") - else if(nknots > nx) - stop("cannot use more inner knots than unique 'x' values") + } else if(is.null(nknots))# <- for back compatibility + nknots <- .nknots.smspl(nx) + else { + if(is.function(nknots)) + nknots <- nknots(nx) + else if(!is.numeric(nknots)) + stop("'nknots' must be numeric (in {1,..,n})") + if(nknots < 1) + stop("'nknots' must be at least 1") + else if(nknots > nx) + stop("cannot use more inner knots than unique 'x' values") } knot <- c(rep(xbar[1 ], 3), if(all.knots) xbar else xbar[seq.int(1, nx, length.out = nknots)], @@ -140,8 +144,7 @@ dofoff <- df } else warning("you must supply 1 < df <= n, n = #{unique x} = ", nx) } - iparms <- setNames(as.integer(c(icrit,ispar, contr.sp$maxit)), - c("icrit", "ispar", "iter")) + iparms <- c(icrit=icrit, ispar=ispar, iter=as.integer(contr.sp$maxit)) keep.stuff <- FALSE ## << to become an argument in the future ans.names <- c("coef","ty","lev","spar","parms","crit","iparms","ier", diff -Nru r-base-3.1.0/src/library/stats/src/deriv.c r-base-3.1.1/src/library/stats/src/deriv.c --- r-base-3.1.0/src/library/stats/src/deriv.c 2014-03-22 23:15:04.000000000 +0000 +++ r-base-3.1.1/src/library/stats/src/deriv.c 2014-06-25 22:15:05.000000000 +0000 @@ -456,28 +456,28 @@ ans = simplify(DivideSymbol, PP(D(CADR(expr), var)), PP_S(SqrtSymbol, - PP_S(MinusSymbol, Constant(1.), - PP_S(PowerSymbol,CADR(expr),Constant(2.))), + PP_S(MinusSymbol, PP(Constant(1.)), + PP_S(PowerSymbol,CADR(expr),PP(Constant(2.)))), R_MissingArg)); - UNPROTECT(4); + UNPROTECT(6); } else if (CAR(expr) == AcosSymbol) { ans = simplify(MinusSymbol, PP_S(DivideSymbol, PP(D(CADR(expr), var)), PP_S(SqrtSymbol, - PP_S(MinusSymbol,Constant(1.), + PP_S(MinusSymbol,PP(Constant(1.)), PP_S(PowerSymbol, - CADR(expr),Constant(2.))), + CADR(expr),PP(Constant(2.)))), R_MissingArg)), R_MissingArg); - UNPROTECT(5); + UNPROTECT(7); } else if (CAR(expr) == AtanSymbol) { ans = simplify(DivideSymbol, PP(D(CADR(expr), var)), - PP_S(PlusSymbol,Constant(1.), - PP_S(PowerSymbol, CADR(expr),Constant(2.)))); - UNPROTECT(3); + PP_S(PlusSymbol,PP(Constant(1.)), + PP_S(PowerSymbol, CADR(expr),PP(Constant(2.))))); + UNPROTECT(5); } else if (CAR(expr) == LGammaSymbol) { ans = simplify(TimesSymbol, @@ -502,31 +502,31 @@ else if (CAR(expr) == TriGammaSymbol) { ans = simplify(TimesSymbol, PP(D(CADR(expr), var)), - PP_S(PsiSymbol, CADR(expr), ScalarInteger(2))); - UNPROTECT(2); + PP_S(PsiSymbol, CADR(expr), PP(ScalarInteger(2)))); + UNPROTECT(3); } else if (CAR(expr) == PsiSymbol) { if (length(expr) == 2){ ans = simplify(TimesSymbol, PP(D(CADR(expr), var)), - PP_S(PsiSymbol, CADR(expr), ScalarInteger(1))); - UNPROTECT(2); + PP_S(PsiSymbol, CADR(expr), PP(ScalarInteger(1)))); + UNPROTECT(3); } else if (TYPEOF(CADDR(expr)) == INTSXP || TYPEOF(CADDR(expr)) == REALSXP) { ans = simplify(TimesSymbol, PP(D(CADR(expr), var)), PP_S(PsiSymbol, CADR(expr), - ScalarInteger(asInteger(CADDR(expr))+1))); - UNPROTECT(2); + PP(ScalarInteger(asInteger(CADDR(expr))+1)))); + UNPROTECT(3); } else { ans = simplify(TimesSymbol, PP(D(CADR(expr), var)), PP_S(PsiSymbol, CADR(expr), simplify(PlusSymbol, CADDR(expr), - ScalarInteger(1)))); - UNPROTECT(2); + PP(ScalarInteger(1))))); + UNPROTECT(3); } } diff -Nru r-base-3.1.0/src/library/stats/src/model.c r-base-3.1.1/src/library/stats/src/model.c --- r-base-3.1.0/src/library/stats/src/model.c 2014-03-25 23:15:07.000000000 +0000 +++ r-base-3.1.1/src/library/stats/src/model.c 2014-05-19 22:15:03.000000000 +0000 @@ -1726,7 +1726,9 @@ a = CDR(a); nvar = length(varlist) - 1; - nwords = (int)((nvar - 1) / WORDSIZE + 1); + /* in allocating words need to allow for intercept term */ + nwords = (int)(nvar/ WORDSIZE + 1); +// printf("nvar = %d, nwords = %d\n", nvar, nwords); /* Step 2: Recode the model terms in binary form */ /* and at the same time, expand the model formula. */ @@ -1802,9 +1804,9 @@ PROTECT(pattern = allocVector(VECSXP, nterm)); PROTECT(sCounts = allocVector(INTSXP, nterm)); counts = INTEGER(sCounts); - for (call = formula, n = 0; call != R_NilValue; call = CDR(call)) { + for (call = formula, n = 0; call != R_NilValue; call = CDR(call), n++) { SET_VECTOR_ELT(pattern, n, CAR(call)); - counts[n++] = BitCount(CAR(call)); + counts[n] = BitCount(CAR(call)); } for (n = 0; n < nterm; n++) if(counts[n] > bitmax) bitmax = counts[n]; diff -Nru r-base-3.1.0/src/library/stats/src/nls.c r-base-3.1.1/src/library/stats/src/nls.c --- r-base-3.1.0/src/library/stats/src/nls.c 2014-01-05 23:05:11.000000000 +0000 +++ r-base-3.1.1/src/library/stats/src/nls.c 2014-07-03 22:15:09.000000000 +0000 @@ -5,7 +5,7 @@ * Copyright 1999-2001 Douglas M. Bates * Saikat DebRoy * - * Copyright 2005--2013 The R Core Team + * Copyright 2005--2014 The R Core Team * Copyright 2006 The R Foundation * * This program is free software; you can redistribute it and/or modify @@ -318,6 +318,9 @@ error(_("variable '%s' is integer, not numeric"), name); if(!isReal(temp)) error(_("variable '%s' is not numeric"), name); + if (MAYBE_SHARED(temp)) /* We'll be modifying the variable, so need to make sure it's unique PR#15849 */ + defineVar(install(name), temp = duplicate(temp), rho); + MARK_NOT_MUTABLE(temp); SET_VECTOR_ELT(pars, i, temp); lengthTheta += LENGTH(VECTOR_ELT(pars, i)); } diff -Nru r-base-3.1.0/src/library/stats/src/pacf.c r-base-3.1.1/src/library/stats/src/pacf.c --- r-base-3.1.0/src/library/stats/src/pacf.c 2013-03-05 23:02:23.000000000 +0000 +++ r-base-3.1.1/src/library/stats/src/pacf.c 2014-06-13 22:15:10.000000000 +0000 @@ -359,7 +359,7 @@ } } -#ifdef WIN32 +#ifdef _WIN32 extern double atanh(double); #endif diff -Nru r-base-3.1.0/src/library/stats/tests/glm.Rout.save r-base-3.1.1/src/library/stats/tests/glm.Rout.save --- r-base-3.1.0/src/library/stats/tests/glm.Rout.save 2014-04-05 22:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/stats/tests/glm.Rout.save 2014-07-07 22:15:04.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -29,4 +29,4 @@ > > proc.time() user system elapsed - 0.104 0.006 0.106 + 0.136 0.016 0.144 diff -Nru r-base-3.1.0/src/library/stats/tests/ks-test.Rout.save r-base-3.1.1/src/library/stats/tests/ks-test.Rout.save --- r-base-3.1.0/src/library/stats/tests/ks-test.Rout.save 2014-04-05 22:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/stats/tests/ks-test.Rout.save 2014-07-07 22:15:04.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -114,4 +114,4 @@ > > proc.time() user system elapsed - 0.104 0.012 0.112 + 0.206 0.020 0.227 diff -Nru r-base-3.1.0/src/library/stats/tests/nls.Rout.save r-base-3.1.1/src/library/stats/tests/nls.Rout.save --- r-base-3.1.0/src/library/stats/tests/nls.Rout.save 2014-04-05 22:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/stats/tests/nls.Rout.save 2014-07-07 22:15:04.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -697,4 +697,4 @@ > > proc.time() user system elapsed - 1.219 0.012 1.230 + 1.677 0.017 1.694 diff -Nru r-base-3.1.0/src/library/stats/tests/simulate.Rout.save r-base-3.1.1/src/library/stats/tests/simulate.Rout.save --- r-base-3.1.0/src/library/stats/tests/simulate.Rout.save 2014-04-05 22:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/stats/tests/simulate.Rout.save 2014-07-07 22:15:04.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -406,4 +406,4 @@ > > proc.time() user system elapsed - 0.172 0.016 0.185 + 0.234 0.017 0.244 diff -Nru r-base-3.1.0/src/library/tools/man/buildVignette.Rd r-base-3.1.1/src/library/tools/man/buildVignette.Rd --- r-base-3.1.0/src/library/tools/man/buildVignette.Rd 2014-03-12 23:02:48.000000000 +0000 +++ r-base-3.1.1/src/library/tools/man/buildVignette.Rd 2014-04-22 22:15:03.000000000 +0000 @@ -4,13 +4,15 @@ \description{ Run \code{\link{Sweave}} (or other custom weave function) \code{\link{texi2dvi}}, and/or \code{\link{Stangle}} - (or other custom tangle function) on one vignette. + (or other custom tangle function) on one vignette. + + This is the workhorse of \command{R CMD Sweave}. } \usage{ buildVignette(file, dir = ".", weave = TRUE, latex = TRUE, tangle = TRUE, - quiet = TRUE, clean = TRUE, engine = NULL, buildPkg = NULL, ...) + quiet = TRUE, clean = TRUE, keep = character(), + engine = NULL, buildPkg = NULL, ...) } -%- maybe also 'usage' for other objects documented here. \arguments{ \item{file}{character; the vignette source file} \item{dir}{character; the working directory in which the intermediate and @@ -19,35 +21,42 @@ \item{latex}{logical; \link{texi2pdf} be run if weaving produces a \file{.tex} file?} \item{tangle}{logical; should tangle be run?} \item{quiet}{logical; run in quiet mode?} - \item{clean}{logical; whether to remove intermediate files. See details below.} - \item{engine}{\code{NULL} or character; name of vignette engine to use. Overrides - any \code{\\VignetteEngine\{\}} markup in the vignette.} + \item{clean}{logical; whether to remove some newly created, often + intermediate, files. See details below.} + \item{keep}{a list of file names to keep in any case when cleaning. Note + that \dQuote{target} files are kept anyway.} + \item{engine}{\code{NULL} or character; name of vignette engine to + use. Overrides any \code{\\VignetteEngine\{\}} markup in the vignette.} \item{buildPkg}{\code{NULL} or character; an optional package in which to find the vignette engine} \item{...}{Additional arguments passed to weave and tangle.} } \details{ -This function determines the vignette engine for the vignette (default \code{utils::Sweave}), -then weaves and/or tangles the vignette using that engine. Finally, if \code{clean} is \code{TRUE}, -newly created intermediate files will be deleted. If \code{clean} is \code{NA}, newly created -\file{.tex} files will not be deleted even if a \file{.pdf} file has been produced from them. + This function determines the vignette engine for the vignette (default + \code{utils::Sweave}), then weaves and/or tangles the vignette using + that engine. Finally, if \code{clean} is \code{TRUE}, newly created + intermediate files (non \dQuote{targets}, where these depend on the engine, + etc, and not any in \code{keep}) will be deleted. If \code{clean} is + \code{NA}, and \code{weave} is true, newly created intermediate output + files (e.g., \file{.tex}) will not be deleted even if a \file{.pdf} + file has been produced from them. -If \code{buildPkg} is specified, it will be loaded before the vignette is processed, and will -be used as the default package -in the search for a vignette engine, but an explicitly specified package in the vignette source -(e.g. using \code{\\VignetteEngine\{utils::Sweave\}} to specify the \code{Sweave} -engine in the \pkg{utils} package) will override it. In contrast, -if the \code{engine} argument is given, it will override the -vignette source. + If \code{buildPkg} is specified, it will be loaded before the vignette + is processed, and will be used as the default package in the search + for a vignette engine, but an explicitly specified package in the + vignette source (e.g. using \code{\\VignetteEngine\{utils::Sweave\}} + to specify the \code{Sweave} engine in the \pkg{utils} package) will + override it. In contrast, if the \code{engine} argument is given, it + will override the vignette source. } \value{ -A character vector naming the files that have been produced. + A character vector naming the files that have been produced. } \author{ -Henrik Bengtsson and Duncan Murdoch + Henrik Bengtsson and Duncan Murdoch } \seealso{ -\code{\link{buildVignettes}} for building all vignettes in a package. + \code{\link{buildVignettes}} for building all vignettes in a package. } \keyword{documentation} diff -Nru r-base-3.1.0/src/library/tools/man/buildVignettes.Rd r-base-3.1.1/src/library/tools/man/buildVignettes.Rd --- r-base-3.1.0/src/library/tools/man/buildVignettes.Rd 2014-03-12 23:02:48.000000000 +0000 +++ r-base-3.1.1/src/library/tools/man/buildVignettes.Rd 2014-05-08 22:15:05.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/tools/man/buildVignettes.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{buildVignettes} @@ -39,17 +39,17 @@ \item{subdirs}{a character vector of subdirectories of \code{dir} in which to look for vignettes. The first which exists is used. Defaults to \code{"doc"} if \code{package} is supplied, otherwise \code{"vignettes"}.} - \item{output}{logical. If \code{TRUE}, the output filename - for each vignette in the result.} - \item{source}{logical. If \code{TRUE}, include the tangled output filename - for each vignette in the result.} + \item{output}{logical indicating if the output filenames for each + vignette should be returned (in component \code{outputs}).} + \item{source}{logical indicating if the \emph{tangled} output + filenames for each vignette should be returned (in component \code{sources}).} \item{check}{logical. If \code{TRUE}, check whether all files that have vignette-like filenames have an identifiable vignette engine. This may be a false positive if a file is not a vignette but has a filename matching a pattern defined by one of the vignette engines.} } \details{ - \code{buildVignettes} is used by \code{R CMD build} and \code{R CMD + \code{buildVignettes} is used by \command{R CMD build} and \command{R CMD check} to (re-)build vignette PDFs from their sources. } \value{ @@ -60,5 +60,9 @@ \code{pkgVignettes} returns an object of class \code{"pkgVignettes"} if a vignette directory is found, otherwise \code{NULL}. } +\examples{ +gVigns <- pkgVignettes("grid") +\donttest{str(gVigns)}% because it contains paths +} \keyword{utilities} \keyword{documentation} diff -Nru r-base-3.1.0/src/library/tools/man/compactPDF.Rd r-base-3.1.1/src/library/tools/man/compactPDF.Rd --- r-base-3.1.0/src/library/tools/man/compactPDF.Rd 2014-03-12 23:02:48.000000000 +0000 +++ r-base-3.1.1/src/library/tools/man/compactPDF.Rd 2014-06-18 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/tools/man/compactPDF.Rd % Part of the R package, http://www.R-project.org -% Copyright 2011-2013 R Core Team +% Copyright 2011-2014 R Core Team % Distributed under GPL 2 or later \name{compactPDF} @@ -48,7 +48,7 @@ \details{ This by default makes use of \command{qpdf}, available from \url{http://qpdf.sourceforge.net/} (including as a Windows binary) and - included with the CRAN Mac OS X distribution of \R. If \code{gs_cmd} + included with the CRAN OS X distribution of \R. If \code{gs_cmd} is non-empty and \code{gs_quality != "none"}, GhostScript will used first, then \command{qpdf} if it is available. If \code{gs_quality != "none"} and \code{gs_cmd} is \code{""}, an attempt will be made to find a diff -Nru r-base-3.1.0/src/library/tools/man/md5sum.Rd r-base-3.1.1/src/library/tools/man/md5sum.Rd --- r-base-3.1.0/src/library/tools/man/md5sum.Rd 2014-01-05 23:05:19.000000000 +0000 +++ r-base-3.1.1/src/library/tools/man/md5sum.Rd 2014-05-12 22:15:04.000000000 +0000 @@ -1,28 +1,43 @@ % File src/library/tools/man/md5sum.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{md5sum} \alias{md5sum} \title{Compute MD5 Checksums} \description{ - Compute the 32-byte MD5 checksums of one or more files. + Compute the 32-byte MD5 hashes of one or more files. } \usage{ md5sum(files) } \arguments{ - \item{files}{character. The paths of file(s) to be check-summed.} + \item{files}{character. The paths of file(s) whose contents are to be hashed.} } -\value{ - A character vector of the same length as \code{files}, with names - equal to \code{files}. The elements - will be \code{NA} for non-existent or unreadable files, otherwise - a 32-character string of hexadecimal digits. +\details{ + A MD5 \sQuote{hash} or \sQuote{checksum} or \sQuote{message digest} is + a 128-bit summary of the file contents represented by 32 hexadecimal + digits. Files with different MD5 sums are different: only very + exceptionally (and usually with the intent to deceive) are those with + the same sums different. On Windows all files are read in binary mode (as the \code{md5sum} - utilities there do): on other OSes the files are read in the default way. + utilities there do): on other OSes the files are read in the default + mode (almost always text mode where there is more than one). + + MD5 sums are used as a check that \R packages have been unpacked + correctly and not subsequently modified. +} +\value{ + A character vector of the same length as \code{files}, with names + equal to \code{files}. The elements will be \code{NA} for non-existent + or unreadable files, otherwise a 32-character string of hexadecimal + digits. +} +\source{ + The underlying C code was written by Ulrich Drepper and extracted from + a 2001 release of \code{glibc}. } \seealso{ \code{\link{checkMD5sums}} diff -Nru r-base-3.1.0/src/library/tools/man/writePACKAGES.Rd r-base-3.1.1/src/library/tools/man/writePACKAGES.Rd --- r-base-3.1.0/src/library/tools/man/writePACKAGES.Rd 2014-03-12 23:02:48.000000000 +0000 +++ r-base-3.1.1/src/library/tools/man/writePACKAGES.Rd 2014-06-18 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/tools/man/writePACKAGES.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{write_PACKAGES} @@ -36,10 +36,10 @@ are used. } \item{type}{ - Type of packages: currently source \file{.tar.gz} archives, and Mac - or Windows binary (\file{.tgz} or \file{.zip}, respectively) - packages are supported. Defaults to \code{"win.binary"} on Windows - and to \code{"source"} otherwise. + Type of packages: currently source \file{.tar.\{gz,bz2,xz\}} archives, + and OS X or Windows binary (\file{.tgz} or \file{.zip}, + respectively) packages are supported. Defaults to + \code{"win.binary"} on Windows and to \code{"source"} otherwise. } \item{verbose}{logical. Should packages be listed as they are processed?} diff -Nru r-base-3.1.0/src/library/tools/R/admin.R r-base-3.1.1/src/library/tools/R/admin.R --- r-base-3.1.0/src/library/tools/R/admin.R 2014-03-12 23:02:47.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/admin.R 2014-04-28 22:15:03.000000000 +0000 @@ -805,7 +805,7 @@ encoding = encoding, built_file = built_file) nm <- as.character(names(db)) # Might be NULL saveRDS(structure(nm, - first = nchar(file.path(mandir, "")) + 1L), + first = nchar(file.path(mandir)) + 2L), pathsFile) names(db) <- sub("\\.[Rr]d$", "", basename(nm)) makeLazyLoadDB(db, file.path(manOutDir, basename(outDir))) diff -Nru r-base-3.1.0/src/library/tools/R/build.R r-base-3.1.1/src/library/tools/R/build.R --- r-base-3.1.0/src/library/tools/R/build.R 2014-03-17 23:15:06.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/build.R 2014-06-19 22:15:04.000000000 +0000 @@ -3,8 +3,6 @@ # # Copyright (C) 1995-2013 The R Core Team # -# NB: also copyright date in Usage. -# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or @@ -219,13 +217,13 @@ libdir <- tempfile("Rinst") - ensure_installed <- function() { + ensure_installed <- function() if (!pkgInstalled) { messageLog(Log, "installing the package to build vignettes") pkgInstalled <<- temp_install_pkg(pkgdir, libdir) } - } + pkgInstalled <- build_Rd_db(pkgdir, libdir, desc) if (file.exists("INDEX")) update_Rd_index("INDEX", "man", Log) @@ -237,8 +235,13 @@ } if (vignettes && parse_description_field(desc, "BuildVignettes", TRUE)) { - if (nchar(parse_description_field(desc, "VignetteBuilder", ""))) - ensure_installed() +## this is not a logical field +## if (nchar(parse_description_field(desc, "VignetteBuilder", ""))) +## ensure_installed() + ## PR#15775: check VignetteBuilder packages are installed + ## This is a bit wasteful: we do not need them in this process + loadVignetteBuilder(pkgdir, TRUE) + ## Look for vignette sources vigns <- pkgVignettes(dir = '.', check = TRUE) if (!is.null(vigns) && length(vigns$docs)) { @@ -491,7 +494,7 @@ # Strip the pkgdir off the names names(db) <- substring(names(db), - nchar(file.path(pkgdir, "man", "")) + 1L) + nchar(file.path(pkgdir, "man")) + 2L) containsSexprs <- which(sapply(db, function(Rd) getDynamicFlags(Rd)["\\Sexpr"])) diff -Nru r-base-3.1.0/src/library/tools/R/check.R r-base-3.1.1/src/library/tools/R/check.R --- r-base-3.1.0/src/library/tools/R/check.R 2014-03-28 23:15:03.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/check.R 2014-06-11 22:15:04.000000000 +0000 @@ -2849,7 +2849,7 @@ ## since so many people use 'R CMD' in Makefiles, oPATH <- Sys.getenv("PATH") Sys.setenv(PATH = paste(R.home("bin"), oPATH, - sep = .Platform$path.sep)) + sep = .Platform$path.sep)) on.exit(Sys.setenv(PATH = oPATH)) ## And too many inst/doc/Makefile are not safe for ## parallel makes @@ -2865,16 +2865,27 @@ status <- R_runR(Rcmd, R_opts2, jitstr, stdout = outfile, stderr = outfile) t2 <- proc.time() + out <- readLines(outfile, warn = FALSE) + if(R_check_suppress_RandR_message) + out <- grep('^Xlib: *extension "RANDR" missing on display', + out, invert = TRUE, value = TRUE, + useBytes = TRUE) + warns <- grep("^Warning: file .* is not portable", + out, value = TRUE, useBytes = TRUE) if (status) { noteLog(Log) - out <- readLines(outfile, warn = FALSE) - if (R_check_suppress_RandR_message) - out <- grep('^Xlib: *extension "RANDR" missing on display', out, - invert = TRUE, value = TRUE, useBytes = TRUE) out <- utils::tail(out, 25) printLog0(Log, paste(c("Error in re-building vignettes:", " ...", out, "", ""), collapse = "\n")) + } else if(nw <- length(warns)) { + noteLog(Log) + msg <- ngettext(nw, + "Warning in re-building vignettes:\n", + "Warnings in re-building vignettes:\n", + domain = NA) + wrapLog(msg) + printLog0(Log, .format_lines_with_indent(warns), "\n") } else { ## clean up if (config_val_to_logical(Sys.getenv("_R_CHECK_CLEAN_VIGN_TEST_", "true"))) @@ -3032,7 +3043,8 @@ for(fp in c("foreign/tests/datefactor.dta", "msProcess/inst/data[12]/.*.txt", "WMBrukerParser/inst/Examples/C3ValidationExtractSmall/RobotRun1/2-100kDa/0_B1/1/1SLin/fid", - "bayesLife/inst/ex-data/bayesLife.output/predictions/traj_country104.rda" # file 5.16 + "bayesLife/inst/ex-data/bayesLife.output/predictions/traj_country104.rda", # file 5.16 + "alm/inst/vign/cache/signposts1_c96f55a749822dd089b636087766def2.rdb" # Sparc Solaris, file 5.16 ) ) known <- known | grepl(fp, pexecs) execs <- execs[!known] @@ -3249,10 +3261,31 @@ warn_re <- c(warn_re, ": warning: .* \\[-Wreturn-type-c-linkage\\]") + ## gcc and clang warnings about sequencing + + ## gcc warnings + warn_re <- c(warn_re, + ": warning: pointer of type .* used in arithmetic", + ": warning: .* \\[-Wformat-contains-nul\\]", + ": warning: .* \\[-Wformat-zero-length\\]", + ": warning: .* \\[-Wpointer-to-int-cast\\]", + ": warning: .* \\[-Wsequence-point\\]") + + ## clang warnings + warn_re <- c(warn_re, + ": warning: .* GNU extension", + ": warning: .* \\[-Wdeprecated-register\\]", + ": warning: .* \\[-Wformat-extra-args\\]", # also gcc + ": warning: .* \\[-Wformat-security\\]", + ": warning: .* \\[-Wheader-guard\\]", + ": warning: .* \\[-Wpointer-arith\\]", + ": warning: .* \\[-Wunsequenced\\]") + warn_re <- paste0("(", paste(warn_re, collapse = "|"), ")") lines <- grep(warn_re, lines, value = TRUE, useBytes = TRUE) + ## Ignore install-time readLines() warnings about ## files with incomplete final lines. Most of these ## come from .install_package_indices(), and should be @@ -3362,9 +3395,28 @@ lines <- grep("Warning: ignoring .First.lib()", lines, fixed = TRUE, invert = TRUE, value = TRUE) + lines <- unique(lines) + + note_re <- + "warning: control may reach end of non-void function" + + notes <- grep(note_re, lines0, value = TRUE, useBytes = TRUE) + notes <- unique(notes) + if (length(lines)) { warningLog(Log, "Found the following significant warnings:") printLog0(Log, .format_lines_with_indent(lines), "\n") + if(length(notes)) { + printLog(Log, + "Found the following additional warnings:\n") + printLog0(Log, .format_lines_with_indent(notes), + "\n") + } + printLog0(Log, sprintf("See %s for details.\n", + sQuote(outfile))) + } else if(length(notes)) { + noteLog(Log, "Found the following warnings:") + printLog0(Log, .format_lines_with_indent(notes), "\n") printLog0(Log, sprintf("See %s for details.\n", sQuote(outfile))) } else resultLog(Log, "OK") @@ -3668,7 +3720,7 @@ srcfiles <- dir(".", all.files = TRUE) fi <- file.info(srcfiles) srcfiles <- srcfiles[!fi$isdir] - srcfiles <- grep("(\\.([cfmCM]|cc|cpp|f90|f95|mm|h|o|so)$|^Makevars|-win\\.def$)", + srcfiles <- grep("(\\.([cfmCM]|cc|cpp|f90|f95|mm|h|o|so)$|^Makevars|-win\\.def|^install\\.libs\\.R$)", srcfiles, invert = TRUE, value = TRUE) if (length(srcfiles)) { @@ -4607,12 +4659,12 @@ CRAN_check_results <- function() { - rds <- gzcon(url(sprintf("%s/%s", - getOption("repos")["CRAN"], + ## This allows for partial local mirrors, or to + ## look at a more-freqently-updated mirror + CRAN_repos <- Sys.getenv("R_CRAN_WEB", getOption("repos")["CRAN"]) + rds <- gzcon(url(sprintf("%s/%s", CRAN_repos, "web/checks/check_results.rds"), open = "rb")) - ## We could make the location of the local CRAN web/checks rsync - ## settable via some env var. results <- readRDS(rds) close(rds) @@ -4622,12 +4674,10 @@ CRAN_check_details <- function() { - rds <- gzcon(url(sprintf("%s/%s", - getOption("repos")["CRAN"], + CRAN_repos <- Sys.getenv("R_CRAN_WEB", getOption("repos")["CRAN"]) + rds <- gzcon(url(sprintf("%s/%s", CRAN_repos, "web/checks/check_details.rds"), open = "rb")) - ## We could make the location of the local CRAN web/checks rsync - ## settable via some env var. details <- readRDS(rds) close(rds) @@ -4637,12 +4687,10 @@ CRAN_memtest_notes <- function() { - rds <- gzcon(url(sprintf("%s/%s", - getOption("repos")["CRAN"], + CRAN_repos <- Sys.getenv("R_CRAN_WEB", getOption("repos")["CRAN"]) + rds <- gzcon(url(sprintf("%s/%s", CRAN_repos, "web/checks/memtest_notes.rds"), open = "rb")) - ## We could make the location of the local CRAN web/checks rsync - ## settable via some env var. mtnotes <- readRDS(rds) close(rds) diff -Nru r-base-3.1.0/src/library/tools/R/checktools.R r-base-3.1.1/src/library/tools/R/checktools.R --- r-base-3.1.0/src/library/tools/R/checktools.R 2014-03-26 23:02:03.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/checktools.R 2014-04-26 22:15:03.000000000 +0000 @@ -599,7 +599,7 @@ re <- sprintf("^\\* using options? (%s)(.*)(%s)$", lqa, rqa) flags <- if(length(pos <- grep(re, header, perl = TRUE, useBytes = TRUE))) { - sub(re, "\\1", header[pos[1L]], + sub(re, "\\2", header[pos[1L]], perl = TRUE, useBytes = TRUE) } else "" } else return() diff -Nru r-base-3.1.0/src/library/tools/R/dynamicHelp.R r-base-3.1.1/src/library/tools/R/dynamicHelp.R --- r-base-3.1.0/src/library/tools/R/dynamicHelp.R 2013-08-30 22:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/dynamicHelp.R 2014-06-18 22:15:04.000000000 +0000 @@ -180,7 +180,15 @@ "xml" = "text/xml", # in RCurl "text/plain") } - + + charsetSetting <- function(pkg) { + encoding <-read.dcf(system.file("DESCRIPTION", package=pkg), "Encoding") + if (is.na(encoding)) + "" + else + paste0("; charset=", encoding) + } + sQuote <- function(text) paste0("‘", text, "’") mono <- function(text) @@ -199,8 +207,8 @@ else if(path == "/NEWS") return(list(file = file.path(R.home("doc"), "html", "NEWS.html"))) else if(grepl("^/NEWS[.][[:digit:]]$", path)) - return(list(file = file.path(R.home(), sub("/", "", path)), - "content-type" = "text/plain")) + return(list(file = file.path(R.home("doc"), sub("/", "", path)), + "content-type" = "text/plain; encoding=utf-8")) else if(!grepl("^/(doc|library|session)/", path)) return(error_page(paste("Only NEWS and URLs under", mono("/doc"), "and", mono("/library"), "are allowed"))) @@ -407,7 +415,7 @@ return( list(payload = paste(formatted, collapse="\n")) ) else return( list(file = system.file("NEWS", package = pkg), - "content-type" = "text/plain") ) + "content-type" = paste0("text/plain", charsetSetting(pkg) ) ) ) } else if (grepl(figureRegexp, path)) { pkg <- sub(figureRegexp, "\\1", path) fig <- sub(figureRegexp, "\\3", path) @@ -426,7 +434,7 @@ if(grepl(descRegexp, path)) { pkg <- sub(descRegexp, "\\1", path) file <- system.file("DESCRIPTION", package = pkg) - return(list(file = file, "content-type" = "text/plain")) + return(list(file = file, "content-type" = paste0("text/plain", charsetSetting(pkg)))) } else return(error_page(gettextf("Only help files, %s, %s and files under %s and %s in a package can be viewed", mono("NEWS"), mono("DESCRIPTION"), mono("doc/"), mono("demo/")))) diff -Nru r-base-3.1.0/src/library/tools/R/install.R r-base-3.1.1/src/library/tools/R/install.R --- r-base-3.1.0/src/library/tools/R/install.R 2014-03-12 23:02:47.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/install.R 2014-04-23 22:15:03.000000000 +0000 @@ -333,8 +333,7 @@ if (res) errmsg(sprintf("packaging into %s failed", sQuote(filename))) message("packaged installation of ", - sQuote(pkg_name), " as ", - sQuote(paste0(filename, ".gz")), + sQuote(pkg_name), " as ", sQuote(filename), domain = NA) setwd(owd) } diff -Nru r-base-3.1.0/src/library/tools/R/packages.R r-base-3.1.1/src/library/tools/R/packages.R --- r-base-3.1.0/src/library/tools/R/packages.R 2014-01-05 23:05:18.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/packages.R 2014-05-12 22:15:04.000000000 +0000 @@ -148,7 +148,8 @@ temp <- tryCatch(read.dcf(p, fields = fields)[1L, ], error = identity) if(!inherits(temp, "error")) { - if(is.na(temp["NeedsCompilation"])) { + if("NeedsCompilation" %in% fields && + is.na(temp["NeedsCompilation"])) { l <- utils::untar(files[i], list = TRUE) temp["NeedsCompilation"] <- if(any(l == file.path(packages[i], "src/"))) "yes" else "no" diff -Nru r-base-3.1.0/src/library/tools/R/QC.R r-base-3.1.1/src/library/tools/R/QC.R --- r-base-3.1.0/src/library/tools/R/QC.R 2014-03-24 23:15:06.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/QC.R 2014-06-14 22:15:03.000000000 +0000 @@ -1125,6 +1125,51 @@ names(db) <- .Rd_get_names_from_Rd_db(db) + .get_var_names_from_item_tags <- function(s, nice = TRUE) { + if(!length(s)) return(character()) + + nms <- character() + ## Handle trailing colons and leading/trailing white space. + s <- sub("^ *", "", sub("( *:)? *$", "", s)) + ## Handle \samp entries: need to match until the first unescaped + ## rbrace. + re <- "\\\\samp\\{(([^\\}]|[\\].)*)\\}( *, *)?" + m <- gregexpr(re, s) + if(any(unlist(m) > -1)) { + nms <- sub(re, "\\1", unlist(regmatches(s, m))) + ## Unescape Rd escapes. + nms <- gsub("\\\\([{}%])", "\\1", nms) + regmatches(s, m) <- "" + } + ## Handle \code entries, assuming that they can be taken literally + ## (no escaping or quoting to obtain valid R syntax). + re <- "\\\\code\\{([^}]*)\\}( *, *)?" + m <- gregexpr(re, s) + add <- regmatches(s, m) + lens <- sapply(add, length) + add <- sub(re, "\\1", unlist(add)) + ## The old code base simply dropped the \code markup via + ## gsub("\\\\code\\{(.*)\\}:?", "\\1", s) + ## unescaped underscores and stripped whitespace. + ## Let us be nice about such whitespace inside a single \code (by + ## default), as this should always render ok in the manual, but not + ## about escaped underscores e.g., + ## ElemStatLearn/man/marketing.Rd: Dual\_Income + ## and comma-separated lists inside + ## \code, e.g., + ## prefmod/man/trdel.Rd: \code{V1,V2,V3,V4,V5,V6,V7,V8,V9,V10} + ## as these will not render correctly. + if(nice) { + ind <- rep.int(lens == 1L, lens) + add[ind] <- tools:::.strip_whitespace(add[ind]) + } + nms <- c(nms, add) + regmatches(s, m) <- "" + ## Handle rest. + nms <- c(nms, unlist(strsplit(s, " *, *"))) + nms + } + .get_data_frame_var_names <- function(x) { ## Make sure that there is exactly one format section: ## using .Rd_get_section() would get the first one. @@ -1143,16 +1188,9 @@ ## Should this allow for several \describe blocks? x <- .Rd_get_section(x, "describe") ## Get the \item tags inside \describe. - txt <- .Rd_get_item_tags(x) - if(!length(txt)) return(character()) - txt <- gsub("(.*):$", "\\1", as.character(txt)) - txt <- gsub("\\\\code\\{(.*)\\}:?", "\\1", txt) - ## Argh. Of course, variable names can have a '_', which needs - ## to be escaped if not in \code{}, and the prompt() default is - ## not to put variable names inside \code{}. - txt <- gsub("\\\\_", "_", txt) - txt <- unlist(strsplit(txt, ", *")) - .strip_whitespace(txt) + x <- .Rd_get_item_tags(x) + ## And extract the variable names from these. + .get_var_names_from_item_tags(x) } Rd_var_names <- lapply(db, .get_data_frame_var_names) @@ -2814,6 +2852,8 @@ lsuggests <- .get_requires_with_version_from_package_db(db, "Suggests") ## NB: no one checks version for 'Enhances'. lenhances <- .get_requires_with_version_from_package_db(db, "Enhances") + ## VignetteBuilder packages are needed to ascertain what is a vignette. + VB <- .get_requires_from_package_db(db, "VignetteBuilder") depends <- sapply(ldepends, `[[`, 1L) imports <- sapply(limports, `[[`, 1L) @@ -2884,6 +2924,18 @@ if(length(m)) bad_depends$suggests_but_not_installed <- m } + if (length(VB)) { + ## These need both to be declared and installed + ## If people explicitly state 'utils' they ought really to + ## declare it, but skip for now. + bad <- VB[! VB %in% c(package_name, "utils", depends, imports, suggests)] + if(length(bad)) + bad_depends$required_for_checking_but_not_declared <- bad + bad2 <- VB[! VB %in% c(package_name, installed)] + bad2 <- setdiff(bad2, bad) + if(length(bad2)) + bad_depends$required_for_checking_but_not_installed <- bad2 + } } ## FIXME: is this still needed now we do dependency analysis? ## Are all vignette dependencies at least suggested or equal to @@ -2996,6 +3048,16 @@ c(sprintf("Package which this enhances but not available for checking: %s", sQuote(bad)), "") }, + if(length(bad <- x$required_for_checking_but_not_declared) > 1L) { + c(.pretty_format2("VignetteBuilder packages not declared:", bad), "") + } else if(length(bad)) { + c(sprintf("VignetteBuilder package not declared: %s", sQuote(bad)), "") + }, + if(length(bad <- x$required_for_checking_but_not_installed) > 1L) { + c(.pretty_format2("VignetteBuilder packages required for checking but not installed:", bad), "") + } else if(length(bad)) { + c(sprintf("VignetteBuilder package required for checking but installed: %s", sQuote(bad)), "") + }, if(length(bad <- x$missing_vignette_depends)) { c(if(length(bad) > 1L) { c("Vignette dependencies not required:", .pretty_format(bad)) @@ -6498,6 +6560,66 @@ if(length(repositories)) out$repositories <- repositories + ## Does this have Suggests or Enhances not in mainstream + ## repositories? + + suggests_or_enhances <- + setdiff(unique(c(.extract_dependency_package_names(meta["Suggests"]), + .extract_dependency_package_names(meta["Enhances"]))), + c(.get_standard_package_names()$base, db[, "Package"])) + if(length(suggests_or_enhances)) { + out$suggests_or_enhances_not_in_mainstream_repositories <- + suggests_or_enhances + if(!is.na(aurls <- meta["Additional_repositories"])) { + aurls <- unique(unlist(strsplit(aurls, ", *"))) + adb <- + tryCatch(utils::available.packages(utils::contrib.url(aurls, + "source"), + filters = + c("R_version", + "duplicates"))) + if(inherits(adb, "error")) { + out$additional_repositories_analysis_failed_with <- + conditionMessage(adb) + } else { + pos <- match(suggests_or_enhances, rownames(adb), nomatch = + 0L) + ind <- (pos > 0L) + tab <- matrix(character(), nrow = 0L, ncol = 3L) + if(any(ind)) + tab <- rbind(tab, + cbind(suggests_or_enhances[ind], + "yes", + adb[pos[ind], "Repository"])) + ind <- !ind + if(any(ind)) + tab <- rbind(tab, + cbind(suggests_or_enhances[ind], + "no", + "")) + ## Map Repository fields to URLs, and determine unused + ## URLs. + ## Note that available.packages() possibly adds Path + ## information in the Repository field, so matching + ## given contrib URLs to these fields is not trivial. + unused <- character() + for(u in aurls) { + cu <- utils::contrib.url(u, "source") + ind <- substring(tab[, 3L], 1, nchar(cu)) == cu + if(any(ind)) { + tab[ind, 3L] <- u + } else { + unused <- c(unused, u) + } + } + if(length(unused)) + tab <- rbind(tab, cbind("", "", unused)) + dimnames(tab) <- NULL + out$additional_repositories_analysis_results <- tab + } + } + } + uses <- character() BUGS <- character() for (field in c("Depends", "Imports", "Suggests")) { @@ -6522,6 +6644,27 @@ vds <- readRDS(vds)[, "File"] } + ## Check for missing build/{partial.rdb,pkgname.pdf} + ## copy code from build.R + Rdb <- .build_Rd_db(dir, stages = NULL, + os = c("unix", "windows"), step = 1) + if(length(Rdb)) { + names(Rdb) <- + substring(names(Rdb), nchar(file.path(dir, "man")) + 2L) + containsBuildSexprs <- + any(sapply(Rdb, function(Rd) any(getDynamicFlags(Rd)["build"]))) + if(containsBuildSexprs && + !file.exists(file.path(dir, "build", "partial.rdb"))) + out$missing_manual_rdb <- TRUE + needRefMan <- + any(sapply(Rdb, function(Rd) any(getDynamicFlags(Rd)[c("install", "render")]))) + if(needRefMan && + !file.exists(file.path(dir, "build", + paste0( meta[["Package"]], ".pdf")))) + out$missing_manual_pdf <- TRUE + } + + ## Check for vignette source (only) in old-style 'inst/doc' rather ## than 'vignettes'. vign_dir <- file.path(dir, "vignettes") @@ -6693,7 +6836,7 @@ "FOSS licence with BuildVignettes: false" }, if(length(y <- x$fields)) { - c("Possibly mis-spelled fields in DESCRIPTION:", + c("Unknown, possibly mis-spelled, fields in DESCRIPTION:", sprintf(" %s", paste(sQuote(y), collapse = " "))) }, if(length(y <- x$overrides)) { @@ -6725,6 +6868,24 @@ "package which may restrict use:", strwrap(paste(y, collapse = ", "), indent = 2L, exdent = 4L)) }, + if(length(y <- + x$suggests_or_enhances_not_in_mainstream_repositories)) { + c("Suggests or Enhances not in mainstream repositories:", + strwrap(paste(y, collapse = ", "), + indent = 2L, exdent = 4L), + if(length(y <- + x$additional_repositories_analysis_failed_with)) { + c("Using Additional_repositories specification failed with:", + paste(" ", y)) + } else if(length(y <- + x$additional_repositories_analysis_results)) { + c("Availability using Additional_repositories specification:", + sprintf(" %s %s %s", + format(y[, 1L], justify = "left"), + format(y[, 2L], justify = "right"), + format(y[, 3L], justify = "left"))) + }) + }, if (length(y <- x$uses)) { paste(if(length(y) > 1L) "Uses the superseded packages:" else @@ -6750,6 +6911,12 @@ }, if(length(y <- x$missing_vignette_index)) { "Package has a VignetteBuilder field but no prebuilt vignette index." + }, + if(length(y <- x$missing_manual_rdb)) { + "Package has help file(s) containing build-stage \\Sexpr{} expresssons but no build/partial.rdb." + }, + if(length(y <- x$missing_manual_pdf)) { + "Package has help file(s) containing install/render-stage \\Sexpr{} expresssons but no prebuilt PDF manual." } ) } diff -Nru r-base-3.1.0/src/library/tools/R/Rd2ex.R r-base-3.1.1/src/library/tools/R/Rd2ex.R --- r-base-3.1.0/src/library/tools/R/Rd2ex.R 2014-03-12 23:02:47.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/Rd2ex.R 2014-05-20 22:15:04.000000000 +0000 @@ -83,12 +83,14 @@ writeLines("", con) render(x[[1L]], paste0(if (commentDontrun) "##D ", prefix)) } else render(x[[1L]], prefix) - for(i in 2:length(x)) render(x[[i]], paste0(if (commentDontrun) "##D ", prefix)) + if(length(x) >= 2L) + for(i in 2:length(x)) + render(x[[i]], paste0(if (commentDontrun) "##D ", prefix)) last <- x[[length(x)]] if (!grepl("\n$", last[length(last)], perl = TRUE)) writeLines("", con) if (commentDontrun) - of1("## End(Not run)") + of1("## End(Not run)") } } else if (tag == "\\donttest") { of1("## No test: ") diff -Nru r-base-3.1.0/src/library/tools/R/Rd2pdf.R r-base-3.1.1/src/library/tools/R/Rd2pdf.R --- r-base-3.1.0/src/library/tools/R/Rd2pdf.R 2014-03-12 23:02:47.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/Rd2pdf.R 2014-05-20 22:15:04.000000000 +0000 @@ -677,9 +677,10 @@ " -o, --output=FILE write output to FILE", " --force overwrite output file if it exists", " --title=NAME use NAME as the title of the document", - " --no-index don't index output", - " --no-description don't typeset the description of a package", + " --no-index do not index output", + " --no-description do not typeset the description of a package", " --internals typeset 'internal' documentation (usually skipped)", + " --build_dir=DIR use DIR as the working directory", "", "The output papersize is set by the environment variable R_PAPERSIZE.", "The PDF previewer is set by the environment variable R_PDFVIEWER.", diff -Nru r-base-3.1.0/src/library/tools/R/RdConv2.R r-base-3.1.1/src/library/tools/R/RdConv2.R --- r-base-3.1.0/src/library/tools/R/RdConv2.R 2014-03-12 23:02:47.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/RdConv2.R 2014-06-29 22:02:05.000000000 +0000 @@ -490,7 +490,7 @@ ## Some people have \docType{ package } and similar. docTypes[i] <- sub("^ *", "", sub(" *$", "", docType[[1L]])) if (! docTypes[i] %in% - c("data", "package", "methods", "class")) + c("data", "package", "methods", "class", "import")) warnRd(dt[i], Rdfile, "docType ", sQuote(docTypes[i]), " is unrecognized") } diff -Nru r-base-3.1.0/src/library/tools/R/Rd.R r-base-3.1.1/src/library/tools/R/Rd.R --- r-base-3.1.0/src/library/tools/R/Rd.R 2014-03-12 23:02:47.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/Rd.R 2014-04-28 22:15:04.000000000 +0000 @@ -344,7 +344,7 @@ stages = "build", built_file = built_file) if(length(db)) { - first <- nchar(file.path(dir, "man", "")) + 1L + first <- nchar(file.path(dir, "man")) + 2L names(db) <- substring(names(db), first) } } diff -Nru r-base-3.1.0/src/library/tools/R/utils.R r-base-3.1.1/src/library/tools/R/utils.R --- r-base-3.1.0/src/library/tools/R/utils.R 2014-04-02 22:02:03.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/utils.R 2014-05-17 22:15:05.000000000 +0000 @@ -442,8 +442,10 @@ ### ** .BioC_version_associated_with_R_version -.BioC_version_associated_with_R_version <- +..BioC_version_associated_with_R_version <- function() numeric_version(Sys.getenv("R_BIOC_VERSION", "2.14")) +.BioC_version_associated_with_R_version <- + ..BioC_version_associated_with_R_version() ## Things are more complicated from R-2.15.x with still two BioC ## releases a year, so we do need to set this manually. @@ -791,7 +793,8 @@ .get_requires_from_package_db <- function(db, - category = c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances")) + category = c("Depends", "Imports", "LinkingTo", "VignetteBuilder", + "Suggests", "Enhances")) { category <- match.arg(category) if(category %in% names(db)) { @@ -810,7 +813,8 @@ .get_requires_with_version_from_package_db <- function(db, - category = c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances")) + category = c("Depends", "Imports", "LinkingTo", "VignetteBuilder", + "Suggests", "Enhances")) { category <- match.arg(category) if(category %in% names(db)) { @@ -1503,7 +1507,7 @@ "http://www.bioconductor.org")), x, fixed = TRUE) sub("%v", - as.character(.BioC_version_associated_with_R_version), + as.character(..BioC_version_associated_with_R_version()), x, fixed = TRUE) } diff -Nru r-base-3.1.0/src/library/tools/R/Vignettes.R r-base-3.1.1/src/library/tools/R/Vignettes.R --- r-base-3.1.0/src/library/tools/R/Vignettes.R 2014-03-12 23:02:47.000000000 +0000 +++ r-base-3.1.1/src/library/tools/R/Vignettes.R 2014-05-15 22:15:04.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/tools/R/Vignettes.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2013 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ # Locates the vignette weave, tangle and texi2pdf product(s) based on the # vignette name. All such products must have the name as their filename # prefix (i.e. "^"). -# For weave, final = TRUE will look for .pdf and .pdf, whereas +# For weave, final = TRUE will look for .pdf and .html, whereas # with final = FALSE it also looks for .tex (if .pdf is also # found, it will be returned). For tangle, main = TRUE will look .R, # whereas main = FALSE will look for *.R. @@ -44,29 +44,25 @@ function(name, by = c("weave", "tangle", "texi2pdf"), final = FALSE, main = TRUE, dir = ".", engine, ...) { - stopifnot(length(name) == 1L) + stopifnot(length(name) == 1L, file_test("-d", dir)) by <- match.arg(by) - stopifnot(file_test("-d", dir)) + exts <- ## (lower case here): + switch(by, + "weave" = if (final) c("pdf", "html") else c("pdf", "html", "tex"), + "tangle" = c("r", "s"), + "texi2pdf" = "pdf") - if (by == "weave") { - if (final) - exts <- c("pdf", "html") - else - exts <- c("pdf", "html", "tex") - } else if (by == "tangle") { - exts <- c("r", "s") - } else if (by == "texi2pdf") { - exts <- "pdf" - } exts <- c(exts, toupper(exts)) pattern1 <- sprintf("^%s[.](%s)$", name, paste(exts, collapse = "|")) - output0 <- list.files(path = dir, all.files = FALSE, full.names = FALSE, no..=TRUE) + output0 <- list.files(path = dir, all.files = FALSE, full.names = FALSE, + no.. = TRUE) output0 <- output0[file_test("-f", file.path(dir, output0))] output <- grep(pattern1, output0, value = TRUE) - # If main is FALSE, we want to find all other files with related names. We make sure - # that the main file is in position 1. - # FIXME: we should check a timestamp or something to see that these were produced by tangling - # for the "name" vignette, they aren't just coincidentally similar names. + # If main is FALSE, we want to find all other files with related + # names. We make sure that the main file is in position 1. + # FIXME: we should check a timestamp or something to see that + # these were produced by tangling for the "name" vignette, + # they aren't just coincidentally similar names. if (!main) { pattern2 <- sprintf("^%s.*[.](%s)$", name, paste(exts, collapse = "|")) output2 <- grep(pattern2, output0, value = TRUE) @@ -113,16 +109,13 @@ domain = NA) } + ## return : if (length(output) > 0L) { if (dir == ".") - output <- basename(output) + basename(output) else - output <- file.path(dir, output) - } else { - output <- NULL - } - - output + file.path(dir, output) + } ## else NULL } @@ -382,28 +375,24 @@ docs <- names <- engines <- patterns <- character() allFiles <- list.files(docdir, all.files = FALSE, full.names = TRUE) - matchedPattern <- rep(FALSE, length(allFiles)) + matchedPattern <- rep.int(FALSE, length(allFiles)) msg <- character() if (length(allFiles) > 0L) { for (name in names(engineList)) { engine <- engineList[[name]] - patternsT <- engine$pattern - for (pattern in patternsT) { + for (pattern in engine$pattern) { idxs <- grep(pattern, allFiles) - docsT <- allFiles[idxs] matchedPattern[idxs] <- TRUE - keep <- logical(length(docsT)) - for (i in seq_along(docsT)) - keep[i] <- engineMatches(name, getVignetteEngine(docsT[i])) - idxs <- idxs[keep] - nidxs <- length(idxs) - if (nidxs > 0L) { + keep <- vapply(allFiles[idxs], function(.d.) + engineMatches(name, getVignetteEngine(.d.)), NA) + if (any(keep)) { + idxs <- idxs[keep] if (is.function(engine$weave)) { docsT <- allFiles[idxs] docs <- c(docs, docsT) names <- c(names, gsub(pattern, "", basename(docsT))) - engines <- c(engines, rep(name, times = nidxs)) - patterns <- c(patterns, rep(pattern, times = nidxs)) + engines <- c(engines, rep.int(name, length(idxs))) + patterns <- c(patterns, rep.int(pattern, length(idxs))) } matchedPattern <- matchedPattern[-idxs] allFiles <- allFiles[-idxs] @@ -421,13 +410,12 @@ } # Assert - stopifnot(length(names) == length(docs)) - stopifnot(length(engines) == length(docs)) - stopifnot(length(patterns) == length(docs)) - stopifnot(!any(duplicated(docs))) + stopifnot(length(names) == length(docs), + length(engines) == length(docs), + length(patterns) == length(docs), !anyDuplicated(docs)) z <- list(docs=docs, names=names, engines=engines, patterns=patterns, - dir=docdir, pkgdir=dir, msg = msg) + dir = docdir, pkgdir = dir, msg = msg) if (output) { outputs <- character(length(docs)) @@ -460,24 +448,25 @@ ### ### Run a weave and pdflatex on all vignettes of a package and try to ### remove all temporary files that were created. - buildVignettes <- -function(package, dir, lib.loc = NULL, quiet = TRUE, clean = TRUE, tangle = FALSE) + function(package, dir, lib.loc = NULL, quiet = TRUE, clean = TRUE, + tangle = FALSE) { - vigns <- pkgVignettes(package = package, dir = dir, lib.loc = lib.loc, check = TRUE) + vigns <- pkgVignettes(package = package, dir = dir, lib.loc = lib.loc, + check = TRUE) if(is.null(vigns)) return(invisible()) if(length(vigns$msg)) warning(paste(vigns$msg, collapse = "\n"), domain = NA) - ## Assert that duplicated vignette names do not exist, e.g. + ## Check that duplicated vignette names do not exist, e.g. ## 'vig' and 'vig' from 'vig.Rnw' and 'vig.Snw'. dups <- duplicated(vigns$names) if (any(dups)) { names <- unique(vigns$names[dups]) docs <- sort(basename(vigns$docs[vigns$names %in% names])) stop(gettextf("Detected vignette source files (%s) with shared names (%s) and therefore risking overwriting each others output files", - paste(sQuote(docs), collapse=", "), - paste(sQuote(names), collapse=", ")), + paste(sQuote(docs), collapse = ", "), + paste(sQuote(names), collapse = ", ")), domain = NA) } @@ -509,8 +498,7 @@ sourceList <- list() startdir <- getwd() for(i in seq_along(vigns$docs)) { - file <- vigns$docs[i] - file <- basename(file) + file <- basename(vigns$docs[i]) name <- vigns$names[i] engine <- vignetteEngine(vigns$engine[i]) @@ -569,11 +557,11 @@ newer <- file_test("-nt", f, ".build.timestamp") ## some packages, e.g. SOAR, create directories unlink(f[newer], recursive = TRUE) + f <- setdiff(list.files(all.files = TRUE, no.. = TRUE), + c(keep, origfiles)) + f <- f[file_test("-f", f)] + file.remove(f) } - f <- setdiff(list.files(all.files = TRUE, no.. = TRUE), - c(keep, origfiles)) - f <- f[file_test("-f", f)] - file.remove(f) } # Assert @@ -592,15 +580,14 @@ ### ### Run a weave and/or tangle on one vignette and try to ### remove all temporary files that were created. - +### Also called from 'R CMD Sweave' via .Sweave() in ../../utils/R/Sweave.R buildVignette <- function(file, dir = ".", weave = TRUE, latex = TRUE, tangle = TRUE, - quiet = TRUE, clean = TRUE, engine = NULL, buildPkg = NULL, ...) + quiet = TRUE, clean = TRUE, keep = character(), + engine = NULL, buildPkg = NULL, ...) { - if (!file_test("-f", file)) stop(gettextf("file '%s' not found", file), domain = NA) - if (!file_test("-d", dir)) stop(gettextf("directory '%s' does not exist", dir), domain = NA) @@ -628,12 +615,11 @@ # Set output directory temporarily file <- file_path_as_absolute(file) - olddir <- getwd() + olddir <- setwd(dir) if (!is.null(olddir)) on.exit(setwd(olddir)) - setwd(dir) - # Record existing files - origfiles <- list.files(all.files = TRUE) + ## # Record existing files + ## origfiles <- list.files(all.files = TRUE) if (is.na(clean) || clean) { file.create(".build.timestamp") } @@ -662,9 +648,9 @@ find_vignette_product(name, by = "tangle", main = FALSE, engine = engine) } # else NULL - # Cleanup - keep <- c(sources, final) - if (is.na(clean)) { # Use NA to signal we want .tex files kept. + ## Cleanup newly created files unless those in 'keep' + keep <- c(sources, final, keep) + if (is.na(clean)) { # Use NA to signal we want .tex (or .md) files kept. keep <- c(keep, output) clean <- TRUE } @@ -674,10 +660,11 @@ ## some packages create directories unlink(f[newer], recursive = TRUE) } - f <- setdiff(list.files(all.files = TRUE, no.. = TRUE), c(keep, origfiles)) - f <- f[file_test("-f", f)] - file.remove(f) - + ### huh? 2nd round of cleaning even if clean is FALSE ?? + ## f <- setdiff(list.files(all.files = TRUE, no.. = TRUE), c(keep, origfiles)) + ## f <- f[file_test("-f", f)] + ## file.remove(f) + ## #} unique(keep) } @@ -685,18 +672,18 @@ getVignetteEncoding <- function(file, ...) { - # Look for inputen[cx] first, then %\SweaveUTF8. Complain about + # Look for inputen[cx] first, then %\SweaveUTF8. Complain about # inconsistencies. - + lines <- readLines(file, warn = FALSE) result1 <- .getVignetteEncoding(lines, ...) - + poss <- grep("^[[:space:]]*%+[[:space:]]*\\\\SweaveUTF8[[:space:]]*$", lines, useBytes = TRUE) if (length(poss)) { result <- "UTF-8" if (!(result1 %in% c("", "non-ASCII", "UTF-8"))) - stop("Inconsistent encoding specifications: ", result1, " with %\\SweaveUTF8") - } else + stop(gettextf("Inconsistent encoding specifications: %s with %%\\SweaveUTF8", result1), domain = NA) + } else result <- result1 result } @@ -1176,7 +1163,7 @@ pkgs <- .get_package_metadata(pkgdir)["VignetteBuilder"] if (is.na(pkgs)) pkgs <- NULL - else if (length(pkgs) > 0L) { + else if (length(pkgs)) { pkgs <- unlist(strsplit(pkgs, ",")) pkgs <- gsub('[[:space:]]', '', pkgs) } diff -Nru r-base-3.1.0/src/library/tools/src/Rmd5.c r-base-3.1.1/src/library/tools/src/Rmd5.c --- r-base-3.1.0/src/library/tools/src/Rmd5.c 2013-07-05 22:05:05.000000000 +0000 +++ r-base-3.1.1/src/library/tools/src/Rmd5.c 2014-06-13 22:15:11.000000000 +0000 @@ -38,7 +38,7 @@ PROTECT(ans = allocVector(STRSXP, nfiles)); for(i = 0; i < nfiles; i++) { path = translateChar(STRING_ELT(files, i)); -#ifdef WIN32 +#ifdef _WIN32 fp = fopen(path, "rb"); #else fp = fopen(path, "r"); diff -Nru r-base-3.1.0/src/library/tools/src/signals.c r-base-3.1.1/src/library/tools/src/signals.c --- r-base-3.1.0/src/library/tools/src/signals.c 2013-04-17 22:05:05.000000000 +0000 +++ r-base-3.1.1/src/library/tools/src/signals.c 2014-06-13 22:15:11.000000000 +0000 @@ -25,7 +25,7 @@ #include "tools.h" #include // C99 -#ifdef WIN32 +#ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #endif @@ -39,12 +39,12 @@ PROTECT(sres = allocVector(LGLSXP, ns)); pid = INTEGER(sspid); res = INTEGER(sres); -#if !defined(WIN32) && !defined(HAVE_KILL) +#if !defined(_WIN32) && !defined(HAVE_KILL) warning(_("pskill() is not supported on this platform")); #endif if(signal != NA_INTEGER) { for (int i = 0; i < ns; i++) { -#ifdef WIN32 +#ifdef _WIN32 HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid[i]); if (hProc) { TerminateProcess(hProc, 1); @@ -92,7 +92,7 @@ UNPROTECT(2); return sres; } -#elif defined(WIN32) +#elif defined(_WIN32) SEXP ps_priority(SEXP spid, SEXP svalue) { SEXP sspid, sres; Binary files /tmp/SEN5fQ6Sdv/r-base-3.1.0/src/library/utils/inst/doc/Sweave.pdf and /tmp/cKZCsh2fJF/r-base-3.1.1/src/library/utils/inst/doc/Sweave.pdf differ diff -Nru r-base-3.1.0/src/library/utils/man/apropos.Rd r-base-3.1.1/src/library/utils/man/apropos.Rd --- r-base-3.1.0/src/library/utils/man/apropos.Rd 2012-12-05 14:37:55.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/apropos.Rd 2014-05-26 22:15:08.000000000 +0000 @@ -79,7 +79,7 @@ # need a DOUBLE backslash '\\\\' (in case you don't see it anymore) apropos("\\\\[") -\dontrun{# everything % not diff-able +\donttest{# everything % not diff-able length(apropos(".")) # those starting with 'pr' diff -Nru r-base-3.1.0/src/library/utils/man/available.packages.Rd r-base-3.1.1/src/library/utils/man/available.packages.Rd --- r-base-3.1.0/src/library/utils/man/available.packages.Rd 2014-01-05 23:05:17.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/available.packages.Rd 2014-05-03 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/utils/man/available.packages.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{available.packages} @@ -62,21 +62,21 @@ The built-in filters are \describe{ - \item{\code{"R_version"}}{exclude packages whose \R version + \item{\code{"R_version"}}{Exclude packages whose \R version requirements are not met} - \item{\code{"OS_type"}}{exclude packages whose OS requirement is + \item{\code{"OS_type"}}{Exclude packages whose OS requirement is incompatible with this version of \R: that is exclude Windows-only packages on a Unix-alike platform and \emph{vice versa}.} - \item{\code{"subarch"}}{for binary packages, exclude those with + \item{\code{"subarch"}}{For binary packages, exclude those with compiled code that is not available for the current sub-architecture, e.g. exclude packages only compiled for 32-bit Windows on a 64-bit Windows \R.} - \item{\code{"duplicates"}}{only report the latest version where more + \item{\code{"duplicates"}}{Only report the latest version where more than one version is available, and only report the first-named repository (in \code{contriburl}) with the latest version if that is in more than one repository.} - \item{\code{"license/FOSS"}}{include only packages for which + \item{\code{"license/FOSS"}}{Include only packages for which installation can proceed solely based on packages which can be verified as Free or Open Source Software (FOSS, e.g., \url{http://en.wikipedia.org/wiki/FOSS}) employing the available @@ -86,13 +86,16 @@ Note that this does depend on the repository supplying license information. } - \item{\code{"license/restricts_use"}}{include only packages for + \item{\code{"license/restricts_use"}}{Include only packages for which installation can proceed solely based on packages which are guaranteed not to restrict use. } - \item{\code{"CRAN"}}{use CRAN versions in preference to versions + \item{\code{"CRAN"}}{Use CRAN versions in preference to versions from other repositories (even if these have a higher version - number).} + number). This needs to be applied \emph{before} the default + \code{"duplicates"} filter, so cannot be used with + \code{add = TRUE}. + } } If all the filters are from this set they can be specified as a character vector; otherwise \code{filters} should be a list with @@ -128,10 +131,15 @@ set up a repository. } \examples{\dontrun{ -## restrict install.packages() (etc) to known-to-be-FOSS packages +## Restrict install.packages() (etc) to known-to-be-FOSS packages options(available_packages_filters = c("R_version", "OS_type", "subarch", "duplicates", "license/FOSS")) ## or options(available_packages_filters = list(add = TRUE, "license/FOSS")) + +## Give priority to released versions on CRAN, rather than development +## versions on Omegahat, R-Forge etc. +options(available_packages_filters = + c("R_version", "OS_type", "subarch", "CRAN", "duplicates")) }} \keyword{utilities} diff -Nru r-base-3.1.0/src/library/utils/man/browseVignettes.Rd r-base-3.1.1/src/library/utils/man/browseVignettes.Rd --- r-base-3.1.0/src/library/utils/man/browseVignettes.Rd 2013-03-05 23:02:27.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/browseVignettes.Rd 2014-05-26 22:15:08.000000000 +0000 @@ -37,7 +37,7 @@ \seealso{ \code{\link{browseURL}}, \code{\link{vignette}} } -\examples{\dontrun{ +\examples{\donttest{ ## List vignettes from all *attached* packages browseVignettes(all = FALSE) diff -Nru r-base-3.1.0/src/library/utils/man/debugger.Rd r-base-3.1.1/src/library/utils/man/debugger.Rd --- r-base-3.1.0/src/library/utils/man/debugger.Rd 2013-03-05 23:02:27.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/debugger.Rd 2014-06-13 22:15:11.000000000 +0000 @@ -109,7 +109,7 @@ Selection: 0 ## A possible setting for non-interactive sessions -options(error = quote({dump.frames(to.file = TRUE); q()})) +options(error = quote({dump.frames(to.file = TRUE); q(status = 1)})) }} \keyword{utilities} \keyword{error} diff -Nru r-base-3.1.0/src/library/utils/man/example.Rd r-base-3.1.1/src/library/utils/man/example.Rd --- r-base-3.1.0/src/library/utils/man/example.Rd 2013-05-25 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/example.Rd 2014-05-12 22:15:04.000000000 +0000 @@ -42,7 +42,7 @@ number generator state is saved, then initialized to a specified state, the example is run and the (saved) state is restored. \code{setRNG = TRUE} sets the same state as - \code{R CMD \link{check}} does for + \command{R CMD \link{check}} does for running a package's examples. This is currently equivalent to \code{setRNG = \{RNGkind("default", "default"); set.seed(1)\}}.} \item{ask}{logical (or \code{"default"}) indicating if diff -Nru r-base-3.1.0/src/library/utils/man/help.Rd r-base-3.1.1/src/library/utils/man/help.Rd --- r-base-3.1.0/src/library/utils/man/help.Rd 2014-03-12 23:02:44.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/help.Rd 2014-06-24 22:15:10.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/utils/man/help.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2013 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{help} @@ -28,8 +28,8 @@ See \sQuote{Details} for what happens if this is omitted. } \item{package}{a name or character vector giving the packages to look - into for documentation, or \code{NULL}. By default, all packages in - the search path are used. To avoid a name being deparsed use e.g. + into for documentation, or \code{NULL}. By default, all packages + whose namespaces are loaded are used. To avoid a name being deparsed use e.g. \code{(pkg_ref)} (see the examples).} \item{lib.loc}{a character vector of directory names of \R libraries, or \code{NULL}. The default value of \code{NULL} corresponds to all @@ -59,7 +59,7 @@ see the section on \sQuote{Offline help}. } #ifdef unix - The \sQuote{factory-fresh} default is text help except from the Mac OS + The \sQuote{factory-fresh} default is text help except from the OS X GUI, which uses HTML help displayed in its own browser window. #endif #ifdef windows @@ -99,7 +99,7 @@ \code{\link{getOption}("menu.graphics")} is true, the default.) Note that HTML help does not make use of \code{lib.loc}: it will - always look first in the attached packages and then along + always look first in the loaded packages and then along \code{.libPaths()}. } diff -Nru r-base-3.1.0/src/library/utils/man/help.search.Rd r-base-3.1.1/src/library/utils/man/help.search.Rd --- r-base-3.1.0/src/library/utils/man/help.search.Rd 2014-03-12 23:02:44.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/help.search.Rd 2014-05-26 22:15:08.000000000 +0000 @@ -150,7 +150,7 @@ ??utils::help # All the topics matching "help" in the utils package -\dontrun{ +\donttest{ help.search("print") # All help pages with topics or title # matching 'print' help.search(apropos = "print") # The same diff -Nru r-base-3.1.0/src/library/utils/man/install.packages.Rd r-base-3.1.1/src/library/utils/man/install.packages.Rd --- r-base-3.1.0/src/library/utils/man/install.packages.Rd 2014-02-19 23:05:04.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/install.packages.Rd 2014-06-17 22:15:05.000000000 +0000 @@ -26,19 +26,23 @@ \item{pkgs}{character vector of the names of packages whose current versions should be downloaded from the repositories. - If \code{repos = NULL}, a character vector of file paths of + If \code{repos = NULL}, a character vector of #ifdef windows - \file{.zip} files containing binary builds of packages. Source - directories or \file{.tar.gz} archives may also be installed, but - some packages need suitable tools installed (see the - \sQuote{Details} section). + file paths of \file{.zip} files containing binary builds of + packages. (\code{http://} and \code{file://} URLs are also accepted + and the files will be downloaded and installed from local copies.) + Source directories or file paths or URLs of archives be + specified with \code{type = "source"}, but some packages need + suitable tools installed (see the \sQuote{Details} section). #endif #ifdef unix - \file{.tar.gz} files. These can be source archives or binary - package archive files (as created by \command{R CMD build --binary}). - On a CRAN build of \R for OS X these can be \file{.tgz} files - containing binary package archives. - Tilde-expansion will be done on the file paths. + file paths. These can be source directories or archives + or binary package archive files (as created by \command{R CMD build + --binary}). (\code{http://} and \code{file://} URLs are also + accepted and the files will be downloaded and installed from local + copies.) On a CRAN build of \R for OS X these can be \file{.tgz} + files containing binary package archives. + Tilde-expansion will be done on file paths. #endif If this is missing or a zero-length character vector, a listbox of @@ -56,15 +60,15 @@ \code{"http://cran.us.r-project.org"}. For more details on supported URL schemes see \code{\link{url}}. - Can be \code{NULL} to install from local files - (with extension \file{.tar.gz} for source packages). + Can be \code{NULL} to install from local files, directories or URLs: + this will be inferred by extension from \code{pkgs} if of length one. } \item{contriburl}{ URL(s) of the contrib sections of the repositories. Use this argument if your repository mirror is incomplete, e.g., because you burned only the \file{contrib} section on a CD, or only have - binary packages. Overrides argument \code{repos}. As with - \code{repos}, can also be \code{NULL} to install from local files. + binary packages. Overrides argument \code{repos}. Can also be + \code{NULL} to install from local files. } \item{method}{ download method, see \code{\link{download.file}}. @@ -107,22 +111,23 @@ \item{type}{character, indicating the type of package to download and install. - Possible values are (currently) \code{"source"}, \code{"mac.binary"} - and \code{"win.binary"}: the binary types can be listed and - downloaded but not installed on other platforms. + Possible values are (currently) \code{"source"}, + \code{"mac.binary"}, \code{"mac.binary.mavericks"} and + \code{"win.binary"}: the binary types can be listed and downloaded + but not installed on other platforms. The default is the appropriate binary type on Windows and on the - CRAN binary OS X distribution, otherwise \code{"source"}. For - the platforms where binary packages are the default, an alternative - is \code{"both"} which means \sQuote{try binary if available, - otherwise try source}. (This will only choose the binary package if - its version number is no older than the source version. In - interactive use it will ask before attempting to install source + CRAN binary OS X distributions, otherwise \code{"source"}. For the + platforms where binary packages are the default, an alternative is + \code{"both"} which means \sQuote{try binary if available and + current, otherwise try source}. (This will only choose the binary + package if its version number is no older than the source version. + In interactive use it will ask before attempting to install source packages.) } \item{configure.args}{ - (not used on Windows) a character vector or a named list. If a - character vector with no names is supplied, the elements are + (Used only for source installs.) A character vector or a named list. + If a character vector with no names is supplied, the elements are concatenated into a single string (separated by a space) and used as the value for the \option{--configure-args} flag in the call to \command{R CMD INSTALL}. If the character vector has names these @@ -138,9 +143,9 @@ value for \option{--configure-args}. } \item{configure.vars}{ - (not used on Windows) analogous to \code{configure.args} for flag - \option{--configure-vars}, which is used to set environment variables - for the \command{configure} run. + (Used only for source installs.) Analogous to \code{configure.args} + for flag \option{--configure-vars}, which is used to set environment + variables for the \command{configure} run. } \item{clean}{a logical value indicating whether to specify to add the \option{--clean} flag to the call to @@ -188,8 +193,8 @@ \details{ \R packages are primarily distributed as \emph{source} packages, but \emph{binary} packages (a packaging up of the installed package) are - also supported, and the type most commonly used on Windows and from - the CRAN distribution for OS X. This function can install either + also supported, and the type most commonly used on Windows and by + the CRAN distributions for OS X. This function can install either type where supported, either by downloading a file from a repository or from a local file. The default type is given by \code{\link{getOption}("pkgType")}: this defaults to \code{"source"} @@ -303,9 +308,10 @@ bundle, e.g. an \code{R-devel} RPM. \code{install.packages} will give an error if called with \code{type = "source"} on such a system. - Some binary distributions of \R can be installed on a machine without the - tools needed to install packages: the remedy is to do a complete - install of \R which should bring in all those tools as dependencies. + Some binary Linux distributions of \R can be installed on a machine + without the tools needed to install packages: a possible remedy is to + do a complete install of \R which should bring in all those tools as + dependencies. } #endif #ifdef windows diff -Nru r-base-3.1.0/src/library/utils/man/news.Rd r-base-3.1.1/src/library/utils/man/news.Rd --- r-base-3.1.0/src/library/utils/man/news.Rd 2013-03-05 23:02:27.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/news.Rd 2014-04-10 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/utils/man/news.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{news} @@ -29,7 +29,7 @@ } \details{ If \code{package} is \code{"R"} (default), a news db is built with the - news since the 2.10.0 release of R (corresponding to R's top-level + news since the 3.0.0 release of R (corresponding to R's top-level \file{NEWS} file). Otherwise, if the given add-on package can be found in the given libraries, it is attempted to read its news in structured form from files \file{inst/NEWS.Rd}, \file{NEWS} or @@ -102,11 +102,11 @@ vv <- capture.output(db) # without an error } \donttest{% <- is not sensibly diff-ed against previous versions -## Bug fixes with PR number in 2.11.0. -news(Version == "2.11.0" & grepl("^BUG", Category) & grepl("PR#", Text), +## Bug fixes with PR number in 3.0.1. +news(Version == "3.0.1" & grepl("^BUG", Category) & grepl("PR#", Text), db = db) ## Which categories have been in use? % R-core maybe should standardize a bit more sort(table(db[, "Category"]), decreasing = TRUE) -## Entries with version >= 2.10.1 (including "2.10.1 patched"): -table(news(Version >= "2.10.1", db = db)$Version) +## Entries with version >= 3.0.0 (including "3.0.0 patched"): +table(news(Version >= "3.0.0", db = db)$Version) }} diff -Nru r-base-3.1.0/src/library/utils/man/package.skeleton.Rd r-base-3.1.1/src/library/utils/man/package.skeleton.Rd --- r-base-3.1.0/src/library/utils/man/package.skeleton.Rd 2014-03-12 23:02:43.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/package.skeleton.Rd 2014-06-29 22:02:04.000000000 +0000 @@ -46,6 +46,10 @@ Stubs of help files are generated for functions, data objects, and S4 classes and methods, using the \code{\link{prompt}}, \code{\link{promptClass}}, and \code{\link{promptMethods}} functions. + If an object from another package is intended to be imported and + re-exported without changes, the \code{\link{promptImport}} function + should be used after \code{package.skeleton} + to generate a simple help file linking to the original one. The package sources are placed in subdirectory \code{name} of \code{path}. If \code{code_files} is supplied, these files are diff -Nru r-base-3.1.0/src/library/utils/man/prompt.Rd r-base-3.1.1/src/library/utils/man/prompt.Rd --- r-base-3.1.0/src/library/utils/man/prompt.Rd 2012-04-15 22:05:11.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/prompt.Rd 2014-06-29 22:02:04.000000000 +0000 @@ -8,6 +8,7 @@ \alias{prompt} \alias{prompt.default} \alias{prompt.data.frame} +\alias{promptImport} \description{ Facilitate the constructing of files documenting \R objects. } @@ -18,6 +19,9 @@ force.function = FALSE, \dots) \method{prompt}{data.frame}(object, filename = NULL, name = NULL, \dots) + +promptImport(object, filename = NULL, name = NULL, + importedFrom = NULL, importPage = name, ...) } \arguments{ \item{object}{an \R object, typically a function for the default @@ -30,6 +34,11 @@ \item{force.function}{a logical. If \code{TRUE}, treat \code{object} as function in any case.} \item{\dots}{further arguments passed to or from other methods.} + \item{importedFrom}{a character string naming the package from + which \code{object} was imported. Defaults to the environment + of \code{object} if \code{object} is a function.} + \item{importPage}{a character string naming the help page + in the package from which \code{object} was imported.} } \value{ If \code{filename} is \code{NA}, a list-style representation of the @@ -52,6 +61,15 @@ When \code{prompt} is used in \code{\link{for}} loops or scripts, the explicit \code{name} specification will be useful. + + The \code{importPage} argument for \code{promptImport} needs to give + the base of the name of the + help file of the original help page. For example, + the \code{\link{approx}} function is documented in \file{approxfun.Rd} + in the \pkg{stats} package, so if it were imported and re-exported + it should have \code{importPage = "approxfun"}. + Objects that are imported from other packages are not + normally documented unless re-exported. } \note{ The documentation file produced by \code{prompt.data.frame} does not diff -Nru r-base-3.1.0/src/library/utils/man/read.DIF.Rd r-base-3.1.1/src/library/utils/man/read.DIF.Rd --- r-base-3.1.0/src/library/utils/man/read.DIF.Rd 2013-03-05 23:02:27.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/read.DIF.Rd 2014-05-16 22:15:08.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/utils/man/read.DIF.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{read.DIF} @@ -12,13 +12,12 @@ } \usage{ read.DIF(file, header = FALSE, - dec = ".", row.names, col.names, - as.is = !stringsAsFactors, - na.strings = "NA", colClasses = NA, nrows = -1, - skip = 0, check.names = TRUE, - blank.lines.skip = TRUE, - stringsAsFactors = default.stringsAsFactors(), - transpose = FALSE) + dec = ".", numerals = c("allow.loss", "warn.loss", "no.loss"), + row.names, col.names, as.is = !stringsAsFactors, + na.strings = "NA", colClasses = NA, nrows = -1, + skip = 0, check.names = TRUE, blank.lines.skip = TRUE, + stringsAsFactors = default.stringsAsFactors(), + transpose = FALSE) } \arguments{ \item{file}{the name of the file which the data are to be read from, @@ -37,6 +36,9 @@ \item{dec}{the character used in the file for decimal points.} + \item{numerals}{string indicating how to convert numbers whose conversion + to double precision would lose accuracy, see \code{\link{type.convert}}.} + \item{row.names}{a vector of row names. This can be a vector giving the actual row names, or a single number giving the column of the table which contains the row names, or character string giving the @@ -152,7 +154,7 @@ its WinFX system, which may or may not be compatible. } \examples{ -## read.DIF() needs transpose = TRUE for file exported from Excel +## read.DIF() may need transpose = TRUE for a file exported from Excel udir <- system.file("misc", package = "utils") dd <- read.DIF(file.path(udir, "exDIF.dif"), header = TRUE, transpose = TRUE) dc <- read.csv(file.path(udir, "exDIF.csv"), header = TRUE) diff -Nru r-base-3.1.0/src/library/utils/man/read.fortran.Rd r-base-3.1.1/src/library/utils/man/read.fortran.Rd --- r-base-3.1.0/src/library/utils/man/read.fortran.Rd 2013-03-05 23:02:27.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/read.fortran.Rd 2014-05-16 22:15:08.000000000 +0000 @@ -1,22 +1,22 @@ % File src/library/utils/man/read.fortran.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{read.fortran} \alias{read.fortran} -\title{Read Fixed-Format Data} +\title{Read Fixed-Format Data in a Fortran-like Style} \description{ -Read fixed-format data files using Fortran-style format specifications. + Read fixed-format data files using Fortran-style format specifications. } \usage{ read.fortran(file, format, ..., as.is = TRUE, colClasses = NA) } \arguments{ - \item{file}{File or \link{connection} to read from} + \item{file}{File or \link{connection} to read from.} \item{format}{Character vector or list of vectors. See \sQuote{Details} below.} - \item{\dots}{Other arguments for \code{\link{read.fwf}}} + \item{\dots}{Other arguments for \code{\link{read.fwf}}.} \item{as.is}{Keep characters as characters?} \item{colClasses}{Variable classes to override defaults. See \code{\link{read.table}} for details.} diff -Nru r-base-3.1.0/src/library/utils/man/read.fwf.Rd r-base-3.1.1/src/library/utils/man/read.fwf.Rd --- r-base-3.1.0/src/library/utils/man/read.fwf.Rd 2013-03-05 23:02:27.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/read.fwf.Rd 2014-05-20 22:15:03.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/utils/man/read.fwf.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{read.fwf} @@ -39,7 +39,7 @@ to no limit.} \item{buffersize}{Maximum number of lines to read at one time} \item{\dots}{further arguments to be passed to - \code{\link{read.table}}. Useful further arguments include + \code{\link{read.table}}. Useful such arguments include \code{as.is}, \code{na.strings}, \code{colClasses} and \code{strip.white}.} } % PR#8083 mentions strip.white @@ -60,11 +60,19 @@ Reducing the \code{buffersize} argument may reduce memory use when reading large files with long lines. Increasing \code{buffersize} may result in faster processing when enough memory is available. + + Note that \code{read.fwf} (not \code{read.table}) reads the supplied + file, so the latter's arguments such as \code{encoding} and + \code{fileEncoding} will not be useful. } \author{ - Brian Ripley for \R version: original \code{Perl} by Kurt Hornik. + Brian Ripley for \R version: originally in \code{Perl} by Kurt Hornik. +} +\seealso{ + \code{\link{scan}} and \code{\link{read.table}}. + + \code{\link{read.fortran}} for another style of fixed-format files. } -\seealso{\code{\link{scan}} and \code{\link{read.table}}.} \examples{ ff <- tempfile() cat(file = ff, "123456", "987654", sep = "\n") diff -Nru r-base-3.1.0/src/library/utils/man/read.table.Rd r-base-3.1.1/src/library/utils/man/read.table.Rd --- r-base-3.1.0/src/library/utils/man/read.table.Rd 2014-03-12 23:02:44.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/read.table.Rd 2014-05-10 22:15:03.000000000 +0000 @@ -16,8 +16,8 @@ } \usage{ read.table(file, header = FALSE, sep = "", quote = "\"'", - dec = ".", row.names, col.names, - as.is = !stringsAsFactors, + dec = ".", numerals = c("allow.loss", "warn.loss", "no.loss"), + row.names, col.names, as.is = !stringsAsFactors, na.strings = "NA", colClasses = NA, nrows = -1, skip = 0, check.names = TRUE, fill = !blank.lines.skip, strip.white = FALSE, blank.lines.skip = TRUE, @@ -79,6 +79,9 @@ \item{dec}{the character used in the file for decimal points.} + \item{numerals}{string indicating how to convert numbers whose conversion + to double precision would lose accuracy, see \code{\link{type.convert}}.} + \item{row.names}{a vector of row names. This can be a vector giving the actual row names, or a single number giving the column of the table which contains the row names, or character string giving the @@ -198,7 +201,7 @@ } \item{skipNul}{logical: should nuls be skipped?} - + \item{\dots}{Further arguments to be passed to \code{read.table}.} } @@ -293,10 +296,10 @@ the column of row names (if any). There are two approaches for reading input that is not in the local - encoding. If the input is known to be UTF-8 or Latin1, use the - \code{encoding} argument to declare that. If the input is in some - other encoding, then it may be translated on input. The \code{fileEncoding} - argument achieves this by setting up a connection to do the re-encoding + encoding. If the input is known to be UTF-8 or Latin1, use the + \code{encoding} argument to declare that. If the input is in some + other encoding, then it may be translated on input. The \code{fileEncoding} + argument achieves this by setting up a connection to do the re-encoding into the current locale. Note that on Windows or other systems not running in a UTF-8 locale, this may not be possible. } diff -Nru r-base-3.1.0/src/library/utils/man/RShowDoc.Rd r-base-3.1.1/src/library/utils/man/RShowDoc.Rd --- r-base-3.1.0/src/library/utils/man/RShowDoc.Rd 2013-03-05 23:02:27.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/RShowDoc.Rd 2014-05-26 22:15:08.000000000 +0000 @@ -39,7 +39,7 @@ \value{ A invisible character string given the path to the file found. } -\examples{\dontrun{ +\examples{\donttest{ RShowDoc("R-lang") RShowDoc("FAQ", type = "html") RShowDoc("frame", package = "grid") diff -Nru r-base-3.1.0/src/library/utils/man/type.convert.Rd r-base-3.1.1/src/library/utils/man/type.convert.Rd --- r-base-3.1.0/src/library/utils/man/type.convert.Rd 2014-04-05 22:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/type.convert.Rd 2014-05-10 22:15:03.000000000 +0000 @@ -11,7 +11,8 @@ factor as appropriate. } \usage{ -type.convert(x, na.strings = "NA", as.is = FALSE, dec = ".") +type.convert(x, na.strings = "NA", as.is = FALSE, dec = ".", + numerals = c("allow.loss", "warn.loss", "no.loss")) } \arguments{ \item{x}{a character vector.} @@ -19,10 +20,24 @@ \item{na.strings}{a vector of strings which are to be interpreted as \code{\link{NA}} values. Blank fields are also considered to be missing values in logical, integer, numeric or complex vectors.} - \item{as.is}{logical. See \sQuote{Details}.} - \item{dec}{the character to be assumed for decimal points.} + \item{numerals}{string indicating how to convert numbers whose + conversion to double precision would lose accuracy, typically when + \code{x} has more digits than can be stored in a \code{\link{double}}. + \describe{ + \item{\code{numerals = "allow.loss"}, default:}{the conversion + happens with some accuracy loss. This has been the only + behavior of \R versions 3.0.3 and earlier.} + \item{\code{numerals = "warn.loss"}:}{a \code{\link{warning}} + about accuracy loss is signalled and the conversion happens as + with \code{numerals = "allow.loss"}.} + \item{\code{numerals = "no.loss"}:}{\code{x} is \emph{not} + converted to a number, but to a \code{\link{factor}} or left as + character, depending on \code{as.is}. This has been the only + behavior of \R version 3.1.0.} + } + } } \details{ This is principally a helper function for \code{\link{read.table}}. diff -Nru r-base-3.1.0/src/library/utils/man/untar.Rd r-base-3.1.1/src/library/utils/man/untar.Rd --- r-base-3.1.0/src/library/utils/man/untar.Rd 2014-01-05 23:05:16.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/untar.Rd 2014-06-18 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/utils/man/untar.Rd % Part of the R package, http://www.R-project.org -% Copyright 2009-2013 R Core Team +% Copyright 2009-2014 R Core Team % Distributed under GPL 2 or later \name{untar} @@ -67,14 +67,14 @@ Modern GNU flavours of \command{tar} will support compressed archives, and since 1.15 are able to detect the type of compression automatically: version 1.20 added support for \command{lzma} and - version 1.22 for \command{xz} compression using LZMA2. Mac OS 10.6 - and later (and FreeBSD and some other OSes) have a \command{tar} also - known as \command{bsdtar} from the \samp{libarchive} project used by - Mac OS 10.6 and later which can also detect \command{gzip} and - \command{bzip2} compression automatically. For other flavours of - \command{tar}, environment variable \env{R_GZIPCMD} gives the command - to decompress \command{gzip} and \command{compress} files, and - \command{R_BZIPCMD} for \command{bzip2} files. + version 1.22 for \command{xz} compression using LZMA2. OS X 10.6 and + later (and FreeBSD and some other OSes) have a \command{tar} (also + known as \command{bsdtar}) from the \samp{libarchive} project which + can also detect \command{gzip} and \command{bzip2} compression + automatically. For other flavours of \command{tar}, environment + variable \env{R_GZIPCMD} gives the command to decompress + \command{gzip} and \command{compress} files, and \command{R_BZIPCMD} + for \command{bzip2} files. Arguments \code{compressed}, \code{extras} and \code{verbose} are only used when an external \command{tar} is used. diff -Nru r-base-3.1.0/src/library/utils/man/windows/readRegistry.Rd r-base-3.1.1/src/library/utils/man/windows/readRegistry.Rd --- r-base-3.1.0/src/library/utils/man/windows/readRegistry.Rd 2013-08-13 22:05:05.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/windows/readRegistry.Rd 2014-05-26 22:15:07.000000000 +0000 @@ -47,15 +47,15 @@ } \examples{\donttest{ ## only in HLM if set in an admin-mode install. -readRegistry("SOFTWARE\\\\R-core", maxdepth = 3) +try(readRegistry("SOFTWARE\\\\R-core", maxdepth = 3)) gmt <- file.path("SOFTWARE", "Microsoft", "Windows NT", "CurrentVersion", "Time Zones", "GMT Standard Time", fsep = "\\\\") -readRegistry(gmt, "HLM") - +readRegistry(gmt, "HLM")} +\dontrun{ ## on a 64-bit R need this to find 32-bit JAGS -readRegistry("SOFTWARE\\\\JAGS-1.0.3", maxdepth = 3, view = "32") +readRegistry("SOFTWARE\\\\JAGS", maxdepth = 3, view = "32") ## See if there is a 64-bit user install readRegistry("SOFTWARE\\\\R-core\\\\R64", "HCU", maxdepth = 2) diff -Nru r-base-3.1.0/src/library/utils/man/windows/shortPathName.Rd r-base-3.1.1/src/library/utils/man/windows/shortPathName.Rd --- r-base-3.1.0/src/library/utils/man/windows/shortPathName.Rd 2013-08-13 22:05:05.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/windows/shortPathName.Rd 2014-05-12 22:15:04.000000000 +0000 @@ -1,15 +1,14 @@ % File src/library/utils/man/windows/shortPathName.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2008 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \name{shortPathName} \alias{shortPathName} \title{Express File Paths in Short Form} \description{ - Convert file paths to the short (DOS) form, with 8+3 path components - and no spaces. This is an interface to the Windows API call - \code{GetShortPathName}. + Convert file paths to the short form. This is an interface to the + Windows API call \code{GetShortPathName}. } \usage{ shortPathName(path) @@ -17,9 +16,16 @@ \arguments{ \item{path}{character vector of file paths.} } +% http://msdn.microsoft.com/en-gb/library/windows/desktop/aa364989%28v=vs.85%29.aspx +\details{ + For most file systems, the short form is the \sQuote{DOS} form with + 8+3 path components and no spaces, and this used to be guaranteed. + But some file systems on recent versions of Windows do not have short + path names when the long-name path will be returned instead. +} \value{ - A character vector. The path separator will be \code{\\}. If the - file does not exist, the supplied path will be returned with slashes + A character vector. The path separator will be \code{\\}. If a + file path does not exist, the supplied path will be returned with slashes replaced by backslashes. } \note{ diff -Nru r-base-3.1.0/src/library/utils/man/write.table.Rd r-base-3.1.1/src/library/utils/man/write.table.Rd --- r-base-3.1.0/src/library/utils/man/write.table.Rd 2013-03-05 23:02:27.000000000 +0000 +++ r-base-3.1.1/src/library/utils/man/write.table.Rd 2014-06-18 22:15:04.000000000 +0000 @@ -1,6 +1,6 @@ % File src/library/utils/man/write.table.Rd % Part of the R package, http://www.R-project.org -% Copyright 1995-2011 R Core Team +% Copyright 1995-2014 R Core Team % Distributed under GPL 2 or later \newcommand{\CRANpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} @@ -138,13 +138,13 @@ CSV files do not record an encoding, and this causes problems if they are not ASCII for many other applications. Windows Excel 2007/10 will open files (e.g. by the file association mechanism) correctly if they - are ASCII or UTF-16 (use \code{fileEncoding = "UTF-16LE"}) or perhaps in - the current Windows codepage (e.g. \code{"CP1252"}), but the + are ASCII or UTF-16 (use \code{fileEncoding = "UTF-16LE"}) or perhaps + in the current Windows codepage (e.g. \code{"CP1252"}), but the \sQuote{Text Import Wizard} (from the \sQuote{Data} tab) allows far more choice of encodings. Excel:mac 2004/8 can \emph{import} only - Macintosh (which seems to mean MacRoman), Windows (perhaps Latin-1) - and \sQuote{PC-8} files. OpenOffice 3.x asks for the character set - when opening the file. + \sQuote{Macintosh} (which seems to mean Mac Roman), \sQuote{Windows} + (perhaps Latin-1) and \sQuote{PC-8} files. OpenOffice 3.x asks for + the character set when opening the file. There is an IETF RFC4180 (\url{http://tools.ietf.org/html/rfc4180}) for CSV files, which mandates comma as the separator and CRLF line @@ -183,7 +183,7 @@ write.csv(x, file = "foo.csv", row.names = FALSE) read.csv("foo.csv") -## To write a file in MacRoman for simple use in Mac Excel 2004/8 +## To write a file in Mac Roman for simple use in Mac Excel 2004/8 write.csv(x, file = "foo.csv", fileEncoding = "macroman") ## or for Windows Excel 2007/10 write.csv(x, file = "foo.csv", fileEncoding = "UTF-16LE") diff -Nru r-base-3.1.0/src/library/utils/NAMESPACE r-base-3.1.1/src/library/utils/NAMESPACE --- r-base-3.1.0/src/library/utils/NAMESPACE 2014-03-12 23:02:45.000000000 +0000 +++ r-base-3.1.1/src/library/utils/NAMESPACE 2014-06-29 22:02:04.000000000 +0000 @@ -28,7 +28,7 @@ new.packages, news, object.size, old.packages, package.skeleton, packageDescription, packageName, packageVersion, packageStatus, page, person, personList, pico, - process.events, prompt, promptData, promptPackage, + process.events, prompt, promptData, promptImport, promptPackage, rc.getOption, rc.options, rc.settings, rc.status, readCitationFile, read.DIF, read.csv, read.csv2, read.delim, read.delim2, read.fwf, read.fortran, read.socket, read.table, diff -Nru r-base-3.1.0/src/library/utils/R/citation.R r-base-3.1.1/src/library/utils/R/citation.R --- r-base-3.1.0/src/library/utils/R/citation.R 2014-03-17 23:15:05.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/citation.R 2014-05-23 22:15:03.000000000 +0000 @@ -30,6 +30,9 @@ args <- list(given = given, family = family, middle = middle, email = email, role = role, comment = comment, first = first, last = last) + if(all(sapply(args, is.null))) { + return(structure(list(), class = "person")) + } args <- lapply(args, .listify) args_length <- sapply(args, length) if(!all(args_length_ok <- args_length %in% c(1L, max(args_length)))) @@ -116,6 +119,9 @@ ## Canonicalize 0-length character arguments to NULL. if(any(ind <- (sapply(rval, length) == 0L))) rval[ind] <- vector("list", length = sum(ind)) + ## Give nothing if there is nothing. + if(all(sapply(rval, is.null))) + rval <- NULL return(rval) } @@ -128,12 +134,15 @@ middle = middle[[i]], email = email[[i]], role = role[[i]], comment = comment[[i]], first = first[[i]], last = last[[i]]))) - class(rval) <- "person" ## ## Should we check that for each person there is at least one ## non-NULL entry? ## + ## Yes! + rval <- rval[!sapply(rval, is.null)] + + class(rval) <- "person" rval } @@ -173,7 +182,7 @@ print.person <- function(x, ...) { - print(format(x, ...)) + if(length(x)) print(format(x, ...)) invisible(x) } @@ -264,6 +273,8 @@ x <- as.character(x) + if(!length(x)) return(person()) + ## Need to split the strings into individual person components. ## We used to split at ',' and 'and', but of course these could be ## contained in roles or comments as well. @@ -303,6 +314,8 @@ regmatches(x, gregexpr(pattern, y), invert = TRUE)) x <- x[!sapply(x, .is_not_nonempty_text)] + if(!length(x)) return(person()) + ## Step C. as_person1 <- function(x) { comment <- if(grepl("\\(.*\\)", x)) @@ -366,6 +379,8 @@ ... ) { + if(!length(x)) return(character()) + args <- c("given", "family", "email", "role", "comment") include <- sapply(include, match.arg, args) @@ -595,6 +610,8 @@ citation.bibtex.max = getOption("citation.bibtex.max", 1), sort = FALSE, ...) { + if(!length(x)) return(character()) + style <- .bibentry_match_format_style(style) if(sort) x <- sort(x, .bibstyle = .bibstyle) diff -Nru r-base-3.1.0/src/library/utils/R/findLineNum.R r-base-3.1.1/src/library/utils/R/findLineNum.R --- r-base-3.1.0/src/library/utils/R/findLineNum.R 2013-03-05 23:02:26.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/findLineNum.R 2014-05-22 22:15:04.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/utils/R/fineLineNum.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 2009-2012 Duncan Murdoch and the R Core Team +# Copyright (C) 2009-2014 Duncan Murdoch and the R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -74,7 +74,7 @@ perfectMatch <- identical(.normalizePath(fnsrc$filename, fnsrc$wd), targetfilename) if (perfectMatch || (nameonly && !is.null(fnsrc$filename) && basename(fnsrc$filename) == basename(targetfilename))) { - if (!is.na(srcfile$timestamp) && fnsrc$timestamp != srcfile$timestamp) + if (!is.na(srcfile$timestamp) && !is.null(fnsrc$timestamp) && fnsrc$timestamp != srcfile$timestamp) timediff <- fnsrc$timestamp - srcfile$timestamp else timediff <- 0 diff -Nru r-base-3.1.0/src/library/utils/R/help.R r-base-3.1.1/src/library/utils/R/help.R --- r-base-3.1.0/src/library/utils/R/help.R 2013-03-05 23:02:26.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/help.R 2014-06-25 22:15:05.000000000 +0000 @@ -23,13 +23,13 @@ help_type = getOption("help_type")) { types <- c("text", "html", "pdf") - if(!missing(package)) + if(!missing(package)) # Don't check for NULL; may be nonstandard eval if(is.name(y <- substitute(package))) package <- as.character(y) ## If no topic was given ... if(missing(topic)) { - if(!missing(package)) { # "Help" on package. + if(!is.null(package)) { # "Help" on package. help_type <- if(!length(help_type)) "text" else match.arg(tolower(help_type), types) ## Carter Butts and others misuse 'help(package=)' in startup @@ -48,7 +48,7 @@ } else return(library(help = package, lib.loc = lib.loc, character.only = TRUE)) } - if(!missing(lib.loc)) # text "Help" on library. + if(!is.null(lib.loc)) # text "Help" on library. return(library(lib.loc = lib.loc)) ## ultimate default is to give help on help() topic <- "help"; package <- "utils"; lib.loc <- .Library @@ -71,13 +71,14 @@ help_type <- if(!length(help_type)) "text" else match.arg(tolower(help_type), types) - + paths <- index.search(topic, - find.package(package, lib.loc, verbose = verbose)) + find.package(if (is.null(package)) loadedNamespaces() else package, + lib.loc, verbose = verbose)) tried_all_packages <- FALSE if(!length(paths) && is.logical(try.all.packages) && !is.na(try.all.packages) - && try.all.packages && missing(package) && missing(lib.loc)) { + && try.all.packages && is.null(package) && is.null(lib.loc)) { ## Try all the remaining packages. for(lib in .libPaths()) { packages <- .packages(TRUE, lib) diff -Nru r-base-3.1.0/src/library/utils/R/linkhtml.R r-base-3.1.1/src/library/utils/R/linkhtml.R --- r-base-3.1.0/src/library/utils/R/linkhtml.R 2013-03-05 23:02:26.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/linkhtml.R 2014-05-26 22:15:07.000000000 +0000 @@ -113,15 +113,15 @@ writeLines(paste0("", nm, ""), out) writeLines("

    \n", out) } - cat('

    \n', file = out) for (a in nm) { if(use_alpha) - cat("\n", sep = "", file = out) + cat("\n", sep = "", file = out) for (i in pg[first == a]) { title <- packageDescription(i, lib.loc = lib, fields = "Title", encoding = "UTF-8") if (is.na(title)) title <- "-- Title is missing --" - cat('\n', + cat('\n', '\n", file = out, sep = "") diff -Nru r-base-3.1.0/src/library/utils/R/mirrorAdmin.R r-base-3.1.1/src/library/utils/R/mirrorAdmin.R --- r-base-3.1.0/src/library/utils/R/mirrorAdmin.R 2013-03-05 23:02:26.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/mirrorAdmin.R 2014-05-23 22:15:03.000000000 +0000 @@ -16,12 +16,12 @@ # A copy of the GNU General Public License is available at # http://www.r-project.org/Licenses/ -mirror2html <- function(mirrors = NULL, file="mirrors.html", - head = "mirrors-head.html", - foot = "mirrors-foot.html") +mirror2html <- +function(mirrors = NULL, file = "mirrors.html", + head = "mirrors-head.html", foot = "mirrors-foot.html") { if(is.null(mirrors)){ - mirrors <- getCRANmirrors(all=FALSE, local.only=TRUE) + mirrors <- getCRANmirrors(all = FALSE, local.only = TRUE) } mirrors$Host <- gsub("&", "&", mirrors$Host) z <- NULL @@ -31,11 +31,11 @@ m <- mirrors[mirrors$Country == country,] z <- c(z, paste0("
    ", country, "
    "), "
    ", - sprintf("
    ', i, "", title, "
    ", + sprintf("
    ", country)) for(k in seq_len(nrow(m))) { z <- c(z, "", - "\n", @@ -50,19 +50,14 @@ invisible(z) } -checkCRAN <- function(method) +checkCRAN <- +function(method) { - master <- available.packages(contrib.url("http://cran.R-project.org"), - method=method) + master <- available.packages(contrib.url("http://CRAN.R-project.org"), + method = method) m <- getCRANmirrors() z <- list() for(url in as.character(m$URL)) - z[[url]] = available.packages(contrib.url(url), method=method) + z[[url]] <- available.packages(contrib.url(url), method = method) lapply(z, function(a) all.equal(a, master)) } - - - - - - diff -Nru r-base-3.1.0/src/library/utils/R/packages2.R r-base-3.1.1/src/library/utils/R/packages2.R --- r-base-3.1.0/src/library/utils/R/packages2.R 2014-03-12 23:02:41.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/packages2.R 2014-06-17 22:15:04.000000000 +0000 @@ -140,7 +140,7 @@ get_package_name <- function(pkg) { ## Since the pkg argument can be the name of a file rather than ## a regular package name, we have to clean that up. - gsub("_\\.(zip|tar\\.gz)", "", + gsub("_[.](zip|tar[.]gz|tar[.]bzip2|tar[.]xz)", "", gsub(.standard_regexps()$valid_package_version, "", basename(pkg))) } @@ -149,13 +149,12 @@ { if(.Platform$OS.type == "windows") return(character()) - pkg <- get_package_name(pkg) - if(length(pkgs) == 1L && length(configure.args) && length(names(configure.args)) == 0L) return(paste0("--configure-args=", shQuote(paste(configure.args, collapse = " ")))) + pkg <- get_package_name(pkg) if (length(configure.args) && length(names(configure.args)) && pkg %in% names(configure.args)) config <- paste0("--configure-args=", @@ -170,13 +169,12 @@ { if(.Platform$OS.type == "windows") return(character()) - pkg <- get_package_name(pkg) - if(length(pkgs) == 1L && length(configure.vars) && length(names(configure.vars)) == 0L) return(paste0("--configure-vars=", shQuote(paste(configure.vars, collapse = " ")))) + pkg <- get_package_name(pkg) if (length(configure.vars) && length(names(configure.vars)) && pkg %in% names(configure.vars)) config <- paste0("--configure-vars=", @@ -257,6 +255,7 @@ ##' returns "no" for "no", otherwise 'ans', a string msg <- gettext(msg) if(.Platform$OS.type == "windows") { + flush.console() # so warning is seen ans <- winDialog("yesno", sprintf(msg, sQuote(userdir))) if(ans != "YES") "no" else ans } else { @@ -281,17 +280,45 @@ lib <- normalizePath(lib) - ## check if we should infer repos=NULL + ## check if we should infer repos = NULL if(length(pkgs) == 1L && missing(repos) && missing(contriburl)) { - if((type == "source" && length(grep("\\.tar.gz$", pkgs))) || - (type %in% "win.binary" && length(grep("\\.zip$", pkgs))) || + if((type == "source" && + any(grepl("[.]tar[.](gz|bz2|xz)$", pkgs))) || + (type %in% "win.binary" && length(grep("[.]zip$", pkgs))) || (substr(type, 1L, 10L) == "mac.binary" - && length(grep("\\.tgz$", pkgs)))) { + && length(grep("[.]tgz$", pkgs)))) { repos <- NULL - message("inferring 'repos = NULL' from the file name") + message("inferring 'repos = NULL' from 'pkgs'") } } + if(is.null(repos) & missing(contriburl)) { + tmpd <- destdir + nonlocalrepos <- any(web <- grepl("^(http|https|ftp)://", pkgs)) + if(is.null(destdir) && nonlocalrepos) { + tmpd <- file.path(tempdir(), "downloaded_packages") + if (!file.exists(tmpd) && !dir.create(tmpd)) + stop(gettextf("unable to create temporary directory %s", + sQuote(tmpd)), + domain = NA) + } + if(nonlocalrepos) { + urls <- pkgs[web] + for (p in unique(urls)) { + this <- pkgs == p + destfile <- file.path(tmpd, basename(p)) + res <- try(download.file(p, destfile, method, mode="wb", ...)) + if(!inherits(res, "try-error") && res == 0L) + pkgs[this] <- destfile + else { + ## There will be enough notification from the try() + pkgs[this] <- NA + } + } + } + } + + # for testing .Platform$pkgType <- "mac.binary.leopard" ## Look at type == "both" if (type == "both") { @@ -554,25 +581,25 @@ ## install from local source tarball(s) update <- cbind(path.expand(pkgs), lib) # for side-effect of recycling to same length - for(i in seq_len(nrow(update))) { - args <- c(args0, - get_install_opts(update[i, 1L]), - "-l", shQuote(update[i, 2L]), - getConfigureArgs(update[i, 1L]), - getConfigureVars(update[i, 1L]), - shQuote(update[i, 1L])) - status <- system2(cmd0, args, env = env, - stdout = output, stderr = output) - if(status > 0L) - warning(gettextf("installation of package %s had non-zero exit status", - sQuote(update[i, 1L])), - domain = NA) - else if(verbose) { - cmd <- paste(c(cmd0, args), collapse = " ") - message(sprintf("%d): succeeded '%s'", i, cmd), - domain = NA) - } - } + for(i in seq_len(nrow(update))) { + if (is.na(update[i, 1L])) next + args <- c(args0, + get_install_opts(update[i, 1L]), + "-l", shQuote(update[i, 2L]), + getConfigureArgs(update[i, 1L]), + getConfigureVars(update[i, 1L]), + shQuote(update[i, 1L])) + status <- system2(cmd0, args, env = env, + stdout = output, stderr = output) + if(status > 0L) + warning(gettextf("installation of package %s had non-zero exit status", + sQuote(update[i, 1L])), + domain = NA) + else if(verbose) { + cmd <- paste(c(cmd0, args), collapse = " ") + message(sprintf("%d): succeeded '%s'", i, cmd), domain = NA) + } + } return(invisible()) } @@ -676,7 +703,7 @@ if(status > 0L) { ## Try to figure out which pkgs <- update[, 1L] - tss <- sub("\\.ts$", "", dir(".", pattern = "\\.ts$")) + tss <- sub("[.]ts$", "", dir(".", pattern = "[.]ts$")) failed <- pkgs[!pkgs %in% tss] for (pkg in failed) system(paste0("cat ", pkg, ".out")) warning(gettextf("installation of one or more packages failed,\n probably %s", diff -Nru r-base-3.1.0/src/library/utils/R/packages.R r-base-3.1.1/src/library/utils/R/packages.R --- r-base-3.1.0/src/library/utils/R/packages.R 2014-02-12 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/packages.R 2014-05-15 22:15:04.000000000 +0000 @@ -275,10 +275,12 @@ dups <- packages[duplicated(packages)] drop <- integer() CRAN <- getOption("repos")["CRAN"] + ## do nothing if there is no CRAN repos on the list + if(is.na(CRAN)) return(db) for(d in dups) { pos <- which(packages == d) - drop <- c(drop, pos[substring(db[pos, "Repository"], 1, - nchar(CRAN)) != CRAN]) + ind <- substring(db[pos, "Repository"], 1, nchar(CRAN)) != CRAN + if(!all(ind)) drop <- c(drop, pos[ind]) } if(length(drop)) db[-drop, , drop = FALSE] else db } @@ -863,8 +865,8 @@ { if(is.na(a)) return(-1L) if(is.na(b)) return(1L) - a <- as.integer(strsplit(a, "[\\.-]")[[1L]]) - b <- as.integer(strsplit(b, "[\\.-]")[[1L]]) + a <- as.integer(strsplit(a, "[.-]")[[1L]]) + b <- as.integer(strsplit(b, "[.-]")[[1L]]) for(k in seq_along(a)) if(k <= length(b)) { if(a[k] > b[k]) return(1) else if(a[k] < b[k]) return(-1L) diff -Nru r-base-3.1.0/src/library/utils/R/prompt.R r-base-3.1.1/src/library/utils/R/prompt.R --- r-base-3.1.0/src/library/utils/R/prompt.R 2013-03-05 23:02:26.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/prompt.R 2014-06-29 22:02:04.000000000 +0000 @@ -226,6 +226,16 @@ ## Construct the format. if(is.data.frame(x)) { + + make_item_tag <- function(s) { + ## For syntactic names, use \code; otherwise, use \samp. + if(grepl("^([[:alpha:]]|[.][[:alpha:]._])[[:alnum:]._]*$", s)) { + paste0("\\code{", s, "}") + } else { + paste0("\\samp{", gsub("([%{}])", "\\\\\\1", s), "}") + } + } + fmt <- c("\\format{", paste(" A data frame with", nrow(x), @@ -238,7 +248,7 @@ xi <- x[[i]] fmt <- c(fmt, - paste0(" \\item{\\code{", i, "}}{", + paste0(" \\item{", make_item_tag(i), "}{", if(inherits(xi, "ordered")) { paste("an", data.class(xi), "factor with levels", @@ -279,7 +289,7 @@ description = c("\\description{", "%% ~~ A concise (1-5 lines) description of the dataset. ~~", "}"), - usage = paste0("\\usage{data(", name, ")}"), + usage = paste0("\\usage{data(\"", name, "\")}"), format = fmt, details = c("\\details{", paste("%% ~~ If necessary, more details than the", @@ -412,3 +422,58 @@ invisible(filename) } + +promptImport <- function(object, filename = NULL, name = NULL, importedFrom = NULL, + importPage = name, ...) +{ + if(missing(name)) + name <- + if(is.character(object)) + object + else { + name <- substitute(object) + if(is.name(name)) + as.character(name) + else if (is.language(name) && length(name) == 3 && identical(name[[1]], as.name("::"))) + as.character(name[[3]]) + else + stop("cannot determine a usable name") + } + if(is.null(filename)) + filename <- paste0(name, ".Rd") + + x <- if(!missing(object)) + object + else { + ## Better than get(); works when called in fun : + x <- get(name, envir = parent.frame()) + } + + if(is.null(importedFrom)) { + if (is.function(x)) + importedFrom <- getNamespaceName(environment(x)) + else + stop("cannot determine import name") + } + + Rdtxt <- + list(name = paste0("\\name{", name, "}"), + aliases = paste0("\\alias{", name, "}"), + docType = "\\docType{import}", + title = paste0("\\title{Import from package \\pkg{", importedFrom, "}}"), + description = c("\\description{", + paste0("The \\code{", name, "} object is imported from package \\pkg{", importedFrom, "}."), + paste0("Help is available here: \\code{\\link[", importedFrom, ":", importPage, "]{", + importedFrom, "::", importPage, "}}."), + "}")) + + if(is.na(filename)) return(Rdtxt) + + cat(unlist(Rdtxt), file = filename, sep = "\n") + + message(gettextf("Created file named %s.", sQuote(filename)), + "\n", + gettext("Edit the file and move it to the appropriate directory."), + domain = NA) +} + diff -Nru r-base-3.1.0/src/library/utils/R/question.R r-base-3.1.1/src/library/utils/R/question.R --- r-base-3.1.0/src/library/utils/R/question.R 2014-03-12 23:02:41.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/question.R 2014-06-24 22:15:10.000000000 +0000 @@ -80,6 +80,8 @@ return(.helpForCall(topicExpr, parent.frame(), FALSE)) e2 } + if (type == "package") + package <- topic h <- .tryHelp(topicName(type, topic), package = package) if(is.null(h)) { if(is.language(topicExpr)) diff -Nru r-base-3.1.0/src/library/utils/R/read.DIF.R r-base-3.1.1/src/library/utils/R/read.DIF.R --- r-base-3.1.0/src/library/utils/R/read.DIF.R 2014-03-12 23:02:41.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/read.DIF.R 2014-05-10 22:15:03.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/utils/R/read.DIF.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2013 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,6 +17,7 @@ # http://www.r-project.org/Licenses/ read.DIF <- function(file, header = FALSE, dec = ".", + numerals = c("allow.loss", "warn.loss", "no.loss"), row.names, col.names, as.is = !stringsAsFactors, na.strings = "NA", colClasses = NA, nrows = -1, skip = 0, @@ -213,7 +214,7 @@ else data[[i]] } else type.convert(data[[i]], as.is = as.is[i], dec = dec, - na.strings = character(0L)) + na.strings = character(0L), numerals=numerals) } ## as na.strings have already been converted to else if (colClasses[i] == "factor") as.factor(data[[i]]) diff -Nru r-base-3.1.0/src/library/utils/R/readtable.R r-base-3.1.1/src/library/utils/R/readtable.R --- r-base-3.1.0/src/library/utils/R/readtable.R 2014-03-12 23:02:42.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/readtable.R 2014-05-10 22:15:03.000000000 +0000 @@ -32,12 +32,15 @@ type.convert <- -function(x, na.strings = "NA", as.is = FALSE, dec = ".") - .External2(C_typeconvert, x, na.strings, as.is, dec) +function(x, na.strings = "NA", as.is = FALSE, dec = ".", + numerals = c("allow.loss", "warn.loss", "no.loss")) + .External2(C_typeconvert, x, na.strings, as.is, dec, + match.arg(numerals)) read.table <- function(file, header = FALSE, sep = "", quote = "\"'", dec = ".", + numerals = c("allow.loss", "warn.loss", "no.loss"), row.names, col.names, as.is = !stringsAsFactors, na.strings = "NA", colClasses = NA, nrows = -1, skip = 0, @@ -64,6 +67,7 @@ on.exit(close(file)) } pbEncoding <- if (encoding %in% c("", "bytes", "UTF-8")) encoding else "bytes" + numerals <- match.arg(numerals) if(skip > 0L) readLines(file, skip) ## read a few lines to determine header, no of cols. @@ -207,8 +211,8 @@ for (i in (1L:cols)[do]) { data[[i]] <- if (is.na(colClasses[i])) - type.convert(data[[i]], as.is = as.is[i], dec = dec, - na.strings = character(0L)) + type.convert(data[[i]], as.is = as.is[i], dec=dec, + numerals=numerals, na.strings = character(0L)) ## as na.strings have already been converted to else if (colClasses[i] == "factor") as.factor(data[[i]]) else if (colClasses[i] == "Date") as.Date(data[[i]]) diff -Nru r-base-3.1.0/src/library/utils/R/SweaveDrivers.R r-base-3.1.1/src/library/utils/R/SweaveDrivers.R --- r-base-3.1.0/src/library/utils/R/SweaveDrivers.R 2014-03-12 23:02:42.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/SweaveDrivers.R 2014-04-26 22:15:02.000000000 +0000 @@ -26,8 +26,8 @@ } ## We definitely do not want '.' in here, to avoid misidentification -## of file extensions. -.SweaveValidFilenameRegexp <- "^[[:alnum:]#+-_]+$" +## of file extensions. Note that - is used literally here. +.SweaveValidFilenameRegexp <- "^[[:alnum:]/#+_-]+$" RweaveLatexSetup <- function(file, syntax, output = NULL, quiet = FALSE, debug = FALSE, @@ -177,7 +177,7 @@ if (!is.null(options$label)) object$chunkout[[chunkprefix]] <- chunkout if(!grepl(.SweaveValidFilenameRegexp, chunkout)) - warning("file name ", sQuote(chunkout), " is not portable", + warning("file stem ", sQuote(chunkout), " is not portable", call. = FALSE, domain = NA) } } else chunkout <- object$output @@ -259,7 +259,7 @@ if (length(devs)) { if(!grepl(.SweaveValidFilenameRegexp, chunkprefix)) - warning("file name ", sQuote(chunkprefix), " is not portable", + warning("file stem ", sQuote(chunkprefix), " is not portable", call. = FALSE, domain = NA) if (options$figs.only) devs[[1L]](name = chunkprefix, @@ -456,7 +456,13 @@ cmdloc + attr(cmdloc, "match.length") - 1L) cmd <- sub(object$syntax$docexpr, "\\1", cmd) if (object$options$eval) { - val <- as.character(eval(parse(text = cmd), envir = .GlobalEnv)) + val <- tryCatch(as.character(eval(parse(text = cmd), envir = .GlobalEnv)), + error = function(e) { + filenum <- attr(chunk, "srcFilenum")[pos[1L]] + filename <- attr(chunk, "srcFilenames")[filenum] + location <- paste0(basename(filename), ":", attr(chunk, "srclines")[pos[1L]]) + stop("at ",location, ", ", conditionMessage(e), call. = FALSE) + }) ## protect against character(), because sub() will fail if (length(val) == 0L) val <- "" } @@ -712,7 +718,7 @@ if (options$split) { if(!grepl(.SweaveValidFilenameRegexp, chunkprefix)) - warning("file name ", sQuote(chunkprefix), " is not portable", + warning("file stem ", sQuote(chunkprefix), " is not portable", call. = FALSE, domain = NA) outfile <- paste(chunkprefix, options$engine, sep = ".") if (!object$quiet) cat(options$chunknr, ":", outfile,"\n") diff -Nru r-base-3.1.0/src/library/utils/R/Sweave.R r-base-3.1.1/src/library/utils/R/Sweave.R --- r-base-3.1.0/src/library/utils/R/Sweave.R 2014-03-12 23:02:41.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/Sweave.R 2014-05-26 22:15:07.000000000 +0000 @@ -1,7 +1,7 @@ # File src/library/utils/R/Sweave.R # Part of the R package, http://www.R-project.org # -# Copyright (C) 1995-2012 The R Core Team +# Copyright (C) 1995-2014 The R Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ ### re-encodes the output back to 'encoding': the Rtangle driver ### leaves it in the encoding of the current locale and records what ### that is in a comment. The "UTF-8" encoding is preserved on -### both input and output in RweaveLatex, but is handled like +### both input and output in RweaveLatex, but is handled like ### other encodings in Rtangle. ### ### SweaveReadFile first looks for a call to one of the LaTeX packages @@ -202,9 +202,11 @@ stop(gettextf("no Sweave file with name %s found", sQuote(file[1L])), domain = NA) else if (length(f) > 1L) - stop(paste(gettextf("%d Sweave files for basename %s found", - length(f), sQuote(file[1L])), - paste(":\n ", f, collapse="")), + stop(paste(sprintf(ngettext(length(f), "%d Sweave file for basename %s found", + "%d Sweave files for basename %s found", + + domain = "R-utils"), + length(f), sQuote(file[1L])), paste(":\n ", f, collapse = "")), domain = NA) } @@ -228,7 +230,7 @@ " declares an encoding that Sweave does not know about", domain = NA, call. = FALSE) } - if (enc == "UTF-8") + if (enc == "UTF-8") Encoding(text) <- enc else { if (nzchar(enc)) text <- iconv(text, enc, "") else enc <- "ASCII" @@ -289,15 +291,16 @@ ###********************************************************** +## NB: } should not be escaped in [] . SweaveSyntaxNoweb <- list(doc = "^@", code = "^<<(.*)>>=.*", coderef = "^<<(.*)>>.*", - docopt = "^[[:space:]]*\\\\SweaveOpts\\{([^\\}]*)\\}", - docexpr = "\\\\Sexpr\\{([^\\}]*)\\}", + docopt = "^[[:space:]]*\\\\SweaveOpts\\{([^}]*)\\}", + docexpr = "\\\\Sexpr\\{([^}]*)\\}", extension = "\\.[rsRS]?nw$", - syntaxname = "^[[:space:]]*\\\\SweaveSyntax\\{([^\\}]*)\\}", - input = "^[[:space:]]*\\\\SweaveInput\\{([^\\}]*)\\}", + syntaxname = "^[[:space:]]*\\\\SweaveSyntax\\{([^}]*)\\}", + input = "^[[:space:]]*\\\\SweaveInput\\{([^}]*)\\}", trans = list( doc = "@", code = "<<\\1>>=", @@ -313,8 +316,8 @@ SweaveSyntaxLatex <- SweaveSyntaxNoweb SweaveSyntaxLatex$doc <- "^[[:space:]]*\\\\end\\{Scode\\}" -SweaveSyntaxLatex$code <- "^[[:space:]]*\\\\begin\\{Scode\\}\\{?([^\\}]*)\\}?.*" -SweaveSyntaxLatex$coderef <- "^[[:space:]]*\\\\Scoderef\\{([^\\}]*)\\}.*" +SweaveSyntaxLatex$code <- "^[[:space:]]*\\\\begin\\{Scode\\}\\{?([^}]*)\\}?.*" +SweaveSyntaxLatex$coderef <- "^[[:space:]]*\\\\Scoderef\\{([^}]*)\\}.*" SweaveSyntaxLatex$extension <- "\\.[rsRS]tex$" SweaveSyntaxLatex$trans$doc <- "\\\\end{Scode}" @@ -425,7 +428,7 @@ Usage <- function() { cat("Usage: R CMD Sweave [options] file", "", - "A front-end for Sweave and other vignette engines", + "A front-end for Sweave and other vignette engines, via buildVignette()", "", "Options:", " -h, --help print this help message and exit", @@ -433,6 +436,10 @@ " --driver=name use named Sweave driver", " --engine=pkg::engine use named vignette engine", " --encoding=enc default encoding 'enc' for file", + " --clean corresponds to --clean=default", + " --clean= remove some of the created files:", + ' "default" removes those the same initial name;', + ' "keepOuts" keeps e.g. *.tex even when PDF is produced', " --options= comma-separated list of Sweave/engine options", " --pdf convert to PDF document", " --compact= try to compact PDF document:", @@ -454,6 +461,7 @@ engine <- NULL toPDF <- FALSE compact <- Sys.getenv("_R_SWEAVE_COMPACT_PDF_", "no") + clean <- FALSE ## default! while(length(args)) { a <- args[1L] if (a %in% c("-h", "--help")) { @@ -465,7 +473,7 @@ R.version[["major"]], ".", R.version[["minor"]], " (r", R.version[["svn rev"]], ")\n", sep = "") cat("", - "Copyright (C) 2006-2013 The R Core Team.", + "Copyright (C) 2006-2014 The R Core Team.", "This is free software; see the GNU General Public License version 2", "or later for copying conditions. There is NO warranty.", sep = "\n") @@ -476,6 +484,15 @@ engine <- substr(a, 10, 1000) } else if (substr(a, 1, 11) == "--encoding=") { encoding <- substr(a, 12, 1000) + } else if (a == "--clean") { + clean <- TRUE + } else if (substr(a, 1, 8) == "--clean=") { + clean. <- substr(a, 9, 1000) + clean <- switch(clean., + "default" = TRUE, + "keepOuts" = NA, + message(gettextf("Warning: unknown option '--clean='%s", + clean.), domain = NA)) } else if (substr(a, 1, 10) == "--options=") { options <- substr(a, 11, 1000) } else if (a == "--pdf") { @@ -494,7 +511,7 @@ Usage() do_exit(1L) } - args <- list(file=file, tangle=FALSE, latex=toPDF, engine=engine) + args <- list(file=file, tangle=FALSE, latex=toPDF, engine=engine, clean=clean) if(nzchar(driver)) args <- c(args, driver) args <- c(args, encoding = encoding) if(nzchar(options)) { @@ -503,7 +520,7 @@ } output <- do.call(tools::buildVignette, args) message("Output file: ", output) - if (toPDF && compact != "no" + if (toPDF && compact != "no" && length(output) == 1 && grepl(".pdf$", output, ignore.case=TRUE)) { ## ## Same code as used for --compact-vignettes in @@ -596,7 +613,7 @@ Usage() do_exit(1L) } - args <- list(file=file, tangle=TRUE, weave=FALSE, engine=engine, + args <- list(file=file, tangle=TRUE, weave=FALSE, engine=engine, encoding=encoding) if(nzchar(options)) { opts <- eval(parse(text = paste("list(", options, ")"))) diff -Nru r-base-3.1.0/src/library/utils/R/unix/mac.install.R r-base-3.1.1/src/library/utils/R/unix/mac.install.R --- r-base-3.1.0/src/library/utils/R/unix/mac.install.R 2014-01-03 23:05:06.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/unix/mac.install.R 2014-06-13 22:15:11.000000000 +0000 @@ -143,8 +143,10 @@ ## there is no guarantee we have got the package name right: ## foo.zip might contain package bar or Foo or FOO or .... ## but we can't tell without trying to unpack it. - for(i in seq_along(pkgs)) + for(i in seq_along(pkgs)) { + if(is.na(pkgs[i])) next unpackPkg(pkgs[i], pkgnames[i], lib, lock = lock) + } return(invisible()) } tmpd <- destdir diff -Nru r-base-3.1.0/src/library/utils/R/windows/install.packages.R r-base-3.1.1/src/library/utils/R/windows/install.packages.R --- r-base-3.1.0/src/library/utils/R/windows/install.packages.R 2014-01-03 23:05:06.000000000 +0000 +++ r-base-3.1.1/src/library/utils/R/windows/install.packages.R 2014-06-13 22:15:11.000000000 +0000 @@ -227,8 +227,10 @@ } if(is.null(contriburl)) { - for(i in seq_along(pkgs)) + for(i in seq_along(pkgs)) { + if(is.na(pkgs[i])) next unpackPkgZip(pkgs[i], pkgnames[i], lib, libs_only, lock, quiet) + } return(invisible()) } tmpd <- destdir diff -Nru r-base-3.1.0/src/library/utils/src/init.c r-base-3.1.1/src/library/utils/src/init.c --- r-base-3.1.0/src/library/utils/src/init.c 2014-03-12 23:02:42.000000000 +0000 +++ r-base-3.1.1/src/library/utils/src/init.c 2014-05-10 22:15:03.000000000 +0000 @@ -79,7 +79,7 @@ EXTDEF(countfields, 6), EXTDEF(readtablehead, 7), - EXTDEF(typeconvert, 4), + EXTDEF(typeconvert, 5), EXTDEF(writetable, 11), EXTDEF(addhistory, 1), diff -Nru r-base-3.1.0/src/library/utils/src/io.c r-base-3.1.1/src/library/utils/src/io.c --- r-base-3.1.0/src/library/utils/src/io.c 2014-03-12 23:02:42.000000000 +0000 +++ r-base-3.1.1/src/library/utils/src/io.c 2014-05-15 22:15:04.000000000 +0000 @@ -168,24 +168,24 @@ return (int) res; } -/* src/main/utils.h */ -extern double R_strtod5(const char *str, char **endptr, char dec, +// ../../../main/util.c +extern double R_strtod5(const char *str, char **endptr, char dec, Rboolean NA, Rboolean exact); static double -Strtod (const char *nptr, char **endptr, Rboolean NA, LocalData *d) +Strtod (const char *nptr, char **endptr, Rboolean NA, LocalData *d, int i_exact) { - return R_strtod5(nptr, endptr, d->decchar, NA, TRUE); + return R_strtod5(nptr, endptr, d->decchar, NA, i_exact); } static Rcomplex -strtoc(const char *nptr, char **endptr, Rboolean NA, LocalData *d) +strtoc(const char *nptr, char **endptr, Rboolean NA, LocalData *d, int i_exact) { Rcomplex z; double x, y; char *s, *endp; - x = Strtod(nptr, &endp, NA, d); + x = Strtod(nptr, &endp, NA, d, i_exact); if (isBlankString(endp)) { z.r = x; z.i = 0; } else if (*endp == 'i') { @@ -193,7 +193,7 @@ endp++; } else { s = endp; - y = Strtod(s, &endp, NA, d); + y = Strtod(s, &endp, NA, d, i_exact); if (*endp == 'i') { z.r = x; z.i = y; endp++; @@ -364,9 +364,9 @@ if(!data.con->canread) { data.con->close(data.con); error(_("cannot read from this connection")); - } + } } else { - if(!data.con->canread) + if(!data.con->canread) error(_("cannot read from this connection")); } for (i = 0; i < nskip; i++) /* MBCS-safe */ @@ -499,19 +499,21 @@ * * The typeInfo struct should be initialized with all fields TRUE. */ -static void ruleout_types(const char *s, Typecvt_Info *typeInfo, LocalData *data) +static void ruleout_types(const char *s, Typecvt_Info *typeInfo, LocalData *data, + Rboolean exact) { int res; char *endp; if (typeInfo->islogical) { - if (strcmp(s, "F") == 0 || strcmp(s, "FALSE") == 0 - || strcmp(s, "T") == 0 || strcmp(s, "TRUE") == 0) { + if (strcmp(s, "F") == 0 || strcmp(s, "T") == 0 || + strcmp(s, "FALSE") == 0 || strcmp(s, "TRUE") == 0) { typeInfo->isinteger = FALSE; typeInfo->isreal = FALSE; typeInfo->iscomplex = FALSE; + return; // short cut } else { - typeInfo->islogical = TRUE; + typeInfo->islogical = FALSE; } } @@ -522,20 +524,20 @@ } if (typeInfo->isreal) { - Strtod(s, &endp, TRUE, data); + Strtod(s, &endp, TRUE, data, exact); if (!isBlankString(endp)) typeInfo->isreal = FALSE; } if (typeInfo->iscomplex) { - strtoc(s, &endp, TRUE, data); + strtoc(s, &endp, TRUE, data, exact); if (!isBlankString(endp)) typeInfo->iscomplex = FALSE; } } -/* type.convert(char, na.strings, as.is, dec) */ +/* type.convert(char, na.strings, as.is, dec, numerals) */ /* This is a horrible hack which is used in read.table to take a character variable, if possible to convert it to a logical, @@ -546,10 +548,10 @@ SEXP typeconvert(SEXP call, SEXP op, SEXP args, SEXP env) { - SEXP cvec, a, dup, levs, dims, names, dec; + SEXP cvec, a, dup, levs, dims, names, dec, numerals; SEXP rval = R_NilValue; /* -Wall */ - int i, j, len, asIs; - Rboolean done = FALSE; + int i, j, len, asIs, i_exact; + Rboolean done = FALSE, exact; char *endp; const char *tmp = NULL; LocalData data = {NULL, 0, 0, '.', NULL, NO_COMCHAR, 0, NULL, FALSE, @@ -574,7 +576,6 @@ if (asIs == NA_LOGICAL) asIs = 0; dec = CADDDR(args); - if (isString(dec) || isNull(dec)) { if (length(dec) == 0) data.decchar = '.'; @@ -582,6 +583,26 @@ data.decchar = translateChar(STRING_ELT(dec, 0))[0]; } + numerals = CAD4R(args); // string, one of c("allow.loss", "warn.loss", "no.loss") + if (isString(numerals)) { + tmp = CHAR(STRING_ELT(numerals, 0)); + if(strcmp(tmp, "allow.loss") == 0) { + i_exact = FALSE; + exact = FALSE; + } else if(strcmp(tmp, "warn.loss") == 0) { + i_exact = NA_INTEGER; + exact = FALSE; + } else if(strcmp(tmp, "no.loss") == 0) { + i_exact = TRUE; + exact = TRUE; + } else // should never happen + error(_("invalid 'numerals' string: \"%s\""), tmp); + + } else { // (currently never happens): use default + i_exact = FALSE; + exact = FALSE; + } + cvec = CAR(args); len = length(cvec); @@ -593,15 +614,15 @@ else PROTECT(names = getAttrib(cvec, R_NamesSymbol)); - /* Use the first non-NA to screen */ + /* Find the first non-NA entry (empty => NA) */ for (i = 0; i < len; i++) { tmp = CHAR(STRING_ELT(cvec, i)); if (!(STRING_ELT(cvec, i) == NA_STRING || strlen(tmp) == 0 || isNAstring(tmp, 1, &data) || isBlankString(tmp))) break; } - if (i < len) { /* not all entries are NA */ - ruleout_types(tmp, &typeInfo, &data); + if (i < len) { // Found non-NA entry; use it to screen: + ruleout_types(tmp, &typeInfo, &data, exact); } if (typeInfo.islogical) { @@ -618,7 +639,7 @@ LOGICAL(rval)[i] = 1; else { typeInfo.islogical = FALSE; - ruleout_types(tmp, &typeInfo, &data); + ruleout_types(tmp, &typeInfo, &data, exact); break; } } @@ -637,7 +658,7 @@ INTEGER(rval)[i] = Strtoi(tmp, 10); if (INTEGER(rval)[i] == NA_INTEGER) { typeInfo.isinteger = FALSE; - ruleout_types(tmp, &typeInfo, &data); + ruleout_types(tmp, &typeInfo, &data, exact); break; } } @@ -653,10 +674,10 @@ || isNAstring(tmp, 1, &data) || isBlankString(tmp)) REAL(rval)[i] = NA_REAL; else { - REAL(rval)[i] = Strtod(tmp, &endp, FALSE, &data); + REAL(rval)[i] = Strtod(tmp, &endp, FALSE, &data, i_exact); if (!isBlankString(endp)) { typeInfo.isreal = FALSE; - ruleout_types(tmp, &typeInfo, &data); + ruleout_types(tmp, &typeInfo, &data, exact); break; } } @@ -672,11 +693,11 @@ || isNAstring(tmp, 1, &data) || isBlankString(tmp)) COMPLEX(rval)[i].r = COMPLEX(rval)[i].i = NA_REAL; else { - COMPLEX(rval)[i] = strtoc(tmp, &endp, FALSE, &data); + COMPLEX(rval)[i] = strtoc(tmp, &endp, FALSE, &data, i_exact); if (!isBlankString(endp)) { typeInfo.iscomplex = FALSE; /* this is not needed, unless other cases are added */ - ruleout_types(tmp, &typeInfo, &data); + ruleout_types(tmp, &typeInfo, &data, exact); break; } } @@ -764,7 +785,7 @@ while (Rspace((int)*bufp)) bufp++; first = LENGTH(choices) + 1; if (isdigit((int)*bufp)) { - first = Strtod(buffer, NULL, TRUE, &data); + first = Strtod(buffer, NULL, TRUE, &data, /*exact*/FALSE); } else { for (j = 0; j < LENGTH(choices); j++) { if (streql(translateChar(STRING_ELT(choices, j)), buffer)) { @@ -848,7 +869,7 @@ PROTECT(ans = allocVector(STRSXP, nlines)); for(nread = 0; nread < nlines; ) { nbuf = 0; empty = TRUE; skip = FALSE; firstnonwhite = TRUE; - if (data.ttyflag) + if (data.ttyflag) snprintf(ConsolePrompt, CONSOLE_PROMPT_SIZE, "%d: ", nread); /* want to interpret comments here, not in scanchar */ while((c = scanchar(TRUE, &data)) != R_EOF) { @@ -1090,7 +1111,8 @@ for(int j = 0; j < nc; j++) { xj = VECTOR_ELT(x, j); if(LENGTH(xj) != nr) - error(_("corrupt data frame -- length of column %d does not not match nrows"), j+1); + error(_("corrupt data frame -- length of column %d does not not match nrows"), + j+1); if(inherits(xj, "factor")) { levels[j] = getAttrib(xj, R_LevelsSymbol); } else levels[j] = R_NilValue; @@ -1115,12 +1137,13 @@ quote_col[j], qmethod, &strBuf, cdec); else if(TYPEOF(xj) == REALSXP) - tmp = EncodeElement2(levels[j], + tmp = EncodeElement2(levels[j], (int) (REAL(xj)[i] - 1), quote_col[j], qmethod, &strBuf, cdec); else - error(_("column %s claims to be a factor but does not have numeric codes"), j+1); + error(_("column %s claims to be a factor but does not have numeric codes"), + j+1); } else { tmp = EncodeElement2(xj, i, quote_col[j], qmethod, &strBuf, cdec); diff -Nru r-base-3.1.0/src/library/utils/src/windows/dataentry.c r-base-3.1.1/src/library/utils/src/windows/dataentry.c --- r-base-3.1.0/src/library/utils/src/windows/dataentry.c 2014-03-12 23:02:42.000000000 +0000 +++ r-base-3.1.1/src/library/utils/src/windows/dataentry.c 2014-04-15 22:15:03.000000000 +0000 @@ -279,7 +279,7 @@ /* start up the window, more initializing in here */ if (initwin(DE, G_("Data Editor"))) - error(G_("invalid device")); + error("unable to start data editor"); R_de_up = TRUE; /* set up a context which will close the window if there is an error */ @@ -1888,7 +1888,7 @@ /* start up the window, more initializing in here */ if (initwin(DE, CHAR(STRING_ELT(stitle, 0)))) - error(G_("invalid device")); + error("unable to start data viewer"); /* set up a context which will close the window if there is an error */ begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv, diff -Nru r-base-3.1.0/src/library/utils/vignettes/Sweave.Rnw r-base-3.1.1/src/library/utils/vignettes/Sweave.Rnw --- r-base-3.1.0/src/library/utils/vignettes/Sweave.Rnw 2014-03-12 23:02:42.000000000 +0000 +++ r-base-3.1.1/src/library/utils/vignettes/Sweave.Rnw 2014-04-26 22:15:02.000000000 +0000 @@ -236,6 +236,10 @@ \texttt{Rtangle} (provided the \texttt{annotate} option is true, as it is by default), and as part of the file names for files generated by figure chunks. + + Because labels can be part of file names, they should contain only + alphanumeric characters and \texttt{\#+-\_}. (Including \texttt{.} + can cause confusion with file extensions.) \end{description} The first (and only the first) option in a code chunk name can be @@ -296,7 +300,7 @@ \subsection{Using scalars in text} There is limited support for using the values of \R{} objects in text -chunks. Any occurrence of \verb|\Sexpr{|\texttt{\textit{expr}}\verb|}| +chunks. Any occurrence of \verb|\Sexpr|\verb|{|\texttt{\textit{expr}}\verb|}| is replaced by the string resulting from coercing the value of the expression \texttt{expr} to a character vector; only the first element of this vector is used. E.g., \verb|\Sexpr{sqrt(9)}| will be replaced diff -Nru r-base-3.1.0/src/main/arithmetic.c r-base-3.1.1/src/main/arithmetic.c --- r-base-3.1.0/src/main/arithmetic.c 2014-03-12 23:03:17.000000000 +0000 +++ r-base-3.1.1/src/main/arithmetic.c 2014-05-20 22:15:04.000000000 +0000 @@ -316,26 +316,9 @@ we can worry about writing alternate code when the need arises. To be safe, we signal a compiler error if int is not 32 bits. */ # error code requires that int have 32 bits -#else -/* Just to be on the safe side, configure ought to check that the - mashine uses two's complement. A define like -#define USES_TWOS_COMPLEMENT (~0 == (unsigned) -1) - might work, but at least one compiler (CodeWarrior 6) chokes on it. - So for now just assume it is true. -*/ -#define USES_TWOS_COMPLEMENT 1 - -#if USES_TWOS_COMPLEMENT -# define OPPOSITE_SIGNS(x, y) ((x < 0) ^ (y < 0)) -# define GOODISUM(x, y, z) (((x) > 0) ? ((y) < (z)) : ! ((y) < (z))) -# define GOODIDIFF(x, y, z) (!(OPPOSITE_SIGNS(x, y) && OPPOSITE_SIGNS(x, z))) -#else -# define GOODISUM(x, y, z) ((double) (x) + (double) (y) == (z)) -# define GOODIDIFF(x, y, z) ((double) (x) - (double) (y) == (z)) #endif -#define GOODIPROD(x, y, z) ((double) (x) * (double) (y) == (z)) + #define INTEGER_OVERFLOW_WARNING _("NAs produced by integer overflow") -#endif #define CHECK_INTEGER_OVERFLOW(call, ans, naflag) do { \ if (naflag) { \ @@ -345,38 +328,39 @@ } \ } while(0) +#define R_INT_MAX INT_MAX +#define R_INT_MIN -INT_MAX +// .. relying on fact that NA_INTEGER is outside of these + static R_INLINE int R_integer_plus(int x, int y, Rboolean *pnaflag) { if (x == NA_INTEGER || y == NA_INTEGER) return NA_INTEGER; - else { - int z = x + y; - if (GOODISUM(x, y, z) && z != NA_INTEGER) - return z; - else { - if (pnaflag != NULL) - *pnaflag = TRUE; - return NA_INTEGER; - } + + if (((y > 0) && (x > (R_INT_MAX - y))) || + ((y < 0) && (x < (R_INT_MIN - y)))) { + if (pnaflag != NULL) + *pnaflag = TRUE; + return NA_INTEGER; } + return x + y; } static R_INLINE int R_integer_minus(int x, int y, Rboolean *pnaflag) { if (x == NA_INTEGER || y == NA_INTEGER) return NA_INTEGER; - else { - int z = x - y; - if (GOODIDIFF(x, y, z) && z != NA_INTEGER) - return z; - else { - if (pnaflag != NULL) - *pnaflag = TRUE; - return NA_INTEGER; - } + + if (((y < 0) && (x > (R_INT_MAX + y))) || + ((y > 0) && (x < (R_INT_MIN + y)))) { + if (pnaflag != NULL) + *pnaflag = TRUE; + return NA_INTEGER; } + return x - y; } +#define GOODIPROD(x, y, z) ((double) (x) * (double) (y) == (z)) static R_INLINE int R_integer_times(int x, int y, Rboolean *pnaflag) { if (x == NA_INTEGER || y == NA_INTEGER) @@ -1280,8 +1264,10 @@ x : allocVector(INTSXP, n); PROTECT(s); /* Note: relying on INTEGER(.) === LOGICAL(.) : */ - for(i = 0 ; i < n ; i++) - INTEGER(s)[i] = abs(INTEGER(x)[i]); + for(i = 0 ; i < n ; i++) { + int xi = INTEGER(x)[i]; + INTEGER(s)[i] = (xi == NA_INTEGER) ? xi : abs(xi); + } } else if (TYPEOF(x) == REALSXP) { R_xlen_t i, n = XLENGTH(x); PROTECT(s = NO_REFERENCES(x) ? x : allocVector(REALSXP, n)); diff -Nru r-base-3.1.0/src/main/coerce.c r-base-3.1.1/src/main/coerce.c --- r-base-3.1.0/src/main/coerce.c 2014-03-25 23:15:08.000000000 +0000 +++ r-base-3.1.1/src/main/coerce.c 2014-06-27 22:15:03.000000000 +0000 @@ -395,6 +395,8 @@ named = (xnames != R_NilValue); xptr = xnew; for (i = 0; i < len; i++) { + if (NAMED(x) > NAMED(VECTOR_ELT(x, i))) + SET_NAMED(VECTOR_ELT(x, i), NAMED(x)); SETCAR(xptr, VECTOR_ELT(x, i)); if (named && CHAR(STRING_ELT(xnames, i))[0] != '\0') /* ASCII */ SET_TAG(xptr, installTrChar(STRING_ELT(xnames, i))); diff -Nru r-base-3.1.0/src/main/connections.c r-base-3.1.1/src/main/connections.c --- r-base-3.1.0/src/main/connections.c 2014-03-12 23:03:14.000000000 +0000 +++ r-base-3.1.1/src/main/connections.c 2014-06-13 22:15:13.000000000 +0000 @@ -935,9 +935,8 @@ Rfifoconn this = con->private; /* uses 'size_t' for len */ - if ((size * sizeof(wchar_t) * nitems) > 50000) { - error(_("too large a block specified")); - } + if ((double) size * (double) nitems > SSIZE_MAX) + error(_("too large a block specified")); return write(this->fd, ptr, size * nitems)/size; } @@ -1205,7 +1204,7 @@ SEXP attribute_hidden do_fifo(SEXP call, SEXP op, SEXP args, SEXP env) { -#if (defined(HAVE_MKFIFO) && defined(HAVE_FCNTL_H)) || defined(WIN32) +#if (defined(HAVE_MKFIFO) && defined(HAVE_FCNTL_H)) || defined(_WIN32) SEXP sfile, sopen, ans, class, enc; const char *file, *open; int ncon, block; diff -Nru r-base-3.1.0/src/main/deparse.c r-base-3.1.1/src/main/deparse.c --- r-base-3.1.0/src/main/deparse.c 2014-03-12 23:03:14.000000000 +0000 +++ r-base-3.1.1/src/main/deparse.c 2014-06-21 22:15:07.000000000 +0000 @@ -339,6 +339,8 @@ UNPROTECT(1); } PROTECT(tval); /* against Rconn_printf */ + if(!inherits(CADR(args), "connection")) + error(_("'file' must be a character string or connection")); ifile = asInteger(CADR(args)); wasopen = 1; @@ -387,6 +389,8 @@ names = CAR(args); file = CADR(args); + if(!inherits(file, "connection")) + error(_("'file' must be a character string or connection")); if(!isString(names)) error( _("character arguments expected")); nobjs = length(names); diff -Nru r-base-3.1.0/src/main/devices.c r-base-3.1.1/src/main/devices.c --- r-base-3.1.0/src/main/devices.c 2013-03-05 23:02:40.000000000 +0000 +++ r-base-3.1.1/src/main/devices.c 2014-05-26 22:15:12.000000000 +0000 @@ -429,7 +429,7 @@ if(gdd->dev->activate) gdd->dev->activate(gdd->dev); /* maintain .Devices (.Device has already been set) */ - PROTECT(t = ScalarString(STRING_ELT(getSymbolValue(R_DeviceSymbol), 0))); + t = PROTECT(duplicate(getSymbolValue(R_DeviceSymbol))); if (appnd) SETCDR(s, CONS(t, R_NilValue)); else diff -Nru r-base-3.1.0/src/main/duplicate.c r-base-3.1.1/src/main/duplicate.c --- r-base-3.1.0/src/main/duplicate.c 2014-03-12 23:03:13.000000000 +0000 +++ r-base-3.1.1/src/main/duplicate.c 2014-04-23 22:15:04.000000000 +0000 @@ -365,10 +365,12 @@ void copyVector(SEXP s, SEXP t) { R_xlen_t i, ns, nt; - + SEXPTYPE sT = TYPEOF(s), tT = TYPEOF(t); + if (sT != tT) + error("vector types do not match in copyVector"); nt = XLENGTH(t); ns = XLENGTH(s); - switch (TYPEOF(s)) { + switch (sT) { case STRSXP: for (i = 0; i < ns; i++) SET_STRING_ELT(s, i, STRING_ELT(t, i % nt)); diff -Nru r-base-3.1.0/src/main/envir.c r-base-3.1.1/src/main/envir.c --- r-base-3.1.0/src/main/envir.c 2014-03-12 23:03:15.000000000 +0000 +++ r-base-3.1.1/src/main/envir.c 2014-06-04 22:15:06.000000000 +0000 @@ -3606,7 +3606,7 @@ PROTECT(cval = allocCharsxp(len)); memcpy(CHAR_RW(cval), name, len); switch(enc) { - case 0: + case CE_NATIVE: break; /* don't set encoding */ case CE_UTF8: SET_UTF8(cval); diff -Nru r-base-3.1.0/src/main/errors.c r-base-3.1.1/src/main/errors.c --- r-base-3.1.0/src/main/errors.c 2014-03-12 23:03:13.000000000 +0000 +++ r-base-3.1.1/src/main/errors.c 2014-07-08 09:49:33.000000000 +0000 @@ -80,7 +80,7 @@ static void reset_stack_limit(void *data) { - unsigned int *limit = (unsigned int *) data; + uintptr_t *limit = (uintptr_t *) data; R_CStackLimit = *limit; } diff -Nru r-base-3.1.0/src/main/eval.c r-base-3.1.1/src/main/eval.c --- r-base-3.1.0/src/main/eval.c 2014-03-12 23:03:17.000000000 +0000 +++ r-base-3.1.1/src/main/eval.c 2014-05-29 22:15:04.000000000 +0000 @@ -218,8 +218,9 @@ get_current_mem(&smallv, &bigv, &nodes); if((len = strlen(buf)) < PROFLINEMAX) snprintf(buf+len, PROFBUFSIZ - len, - ":%ld:%ld:%ld:%ld:", smallv, bigv, - nodes, get_duplicate_counter()); + ":%lu:%lu:%lu:%lu:", + (unsigned long) smallv, (unsigned long) bigv, + (unsigned long) nodes, get_duplicate_counter()); reset_duplicate_counter(); } @@ -1726,7 +1727,8 @@ see an unmodified LHS value. This heuristic fails if the accessor function called here is not a closure but the replacement function is. */ - if (MAYBE_SHARED(nval) || MAYBE_SHARED(CAR(val))) + if (MAYBE_REFERENCED(nval) && + (MAYBE_SHARED(nval) || MAYBE_SHARED(CAR(val)))) nval = shallow_duplicate(nval); UNPROTECT(4); return CONS_NR(nval, val); @@ -1841,17 +1843,9 @@ return installAssignFcnSymbol(fun); } -static R_INLINE SEXP mkEVPROMISE(SEXP expr, SEXP val, SEXP rho, Rboolean track) +static R_INLINE SEXP mkRHSPROMISE(SEXP expr, SEXP rhs) { - SEXP prom = mkPROMISE(expr, rho); - if (! track) DISABLE_REFCNT(prom); - SET_PRVALUE(prom, val); - return prom; -} - -static R_INLINE SEXP mkRHSPROMISE(SEXP expr, SEXP rhs, SEXP rho) -{ - return mkEVPROMISE(expr, rhs, rho, FALSE); + return R_mkEVPROMISE_NR(expr, rhs); } static SEXP applydefine(SEXP call, SEXP op, SEXP args, SEXP rho) @@ -1932,7 +1926,7 @@ PRIMVAL(op)==1 || PRIMVAL(op)==3, tmploc); PROTECT(lhs); - PROTECT(rhsprom = mkRHSPROMISE(CADR(args), rhs, rho)); + PROTECT(rhsprom = mkRHSPROMISE(CADR(args), rhs)); while (isLanguage(CADR(expr))) { nprot = 1; /* the PROTECT of rhs below from this iteration */ @@ -3797,7 +3791,7 @@ last = ncall; while (CDR(last) != R_NilValue) last = CDR(last); - prom = mkRHSPROMISE(CAR(last), rhs, rho); + prom = mkRHSPROMISE(CAR(last), rhs); SETCAR(last, prom); result = tryDispatch(generic, ncall, lhs, rho, pv); UNPROTECT(1); @@ -4904,7 +4898,7 @@ PROTECT(ncall = duplicate(call)); /**** hack to avoid evaluating the symbol */ SETCAR(CDDR(ncall), ScalarString(PRINTNAME(symbol))); - prom = mkRHSPROMISE(CADDDR(ncall), rhs, rho); + prom = mkRHSPROMISE(CADDDR(ncall), rhs); SETCAR(CDR(CDDR(ncall)), prom); dispatched = tryDispatch("$<-", ncall, x, rho, &value); UNPROTECT(1); @@ -5050,25 +5044,25 @@ SETSTACK(-2, args); /* insert evaluated promise for LHS as first argument */ /* promise won't be captured so don't track refrences */ - prom = mkEVPROMISE(R_TmpvalSymbol, lhs, rho, FALSE); + prom = R_mkEVPROMISE_NR(R_TmpvalSymbol, lhs); SETCAR(args, prom); /* insert evaluated promise for RHS as last argument */ last = args; while (CDR(last) != R_NilValue) last = CDR(last); - prom = mkRHSPROMISE(vexpr, rhs, rho); + prom = mkRHSPROMISE(vexpr, rhs); SETCAR(last, prom); /* make the call */ value = PRIMFUN(fun) (call, fun, args, rho); break; case CLOSXP: /* push evaluated promise for RHS onto arguments with 'value' tag */ - prom = mkRHSPROMISE(vexpr, rhs, rho); + prom = mkRHSPROMISE(vexpr, rhs); PUSHCALLARG(prom); SET_TAG(GETSTACK(-1), R_valueSym); /* replace first argument with evaluated promise for LHS */ /* promise might be captured, so track references */ - prom = mkEVPROMISE(R_TmpvalSymbol, lhs, rho, TRUE); + prom = R_mkEVPROMISE(R_TmpvalSymbol, lhs); args = GETSTACK(-2); SETCAR(args, prom); /* make the call */ @@ -5102,7 +5096,7 @@ SETSTACK(-2, args); /* insert evaluated promise for LHS as first argument */ /* promise won't be captured so don't track refrences */ - prom = mkEVPROMISE(R_TmpvalSymbol, lhs, rho, FALSE); + prom = R_mkEVPROMISE_NR(R_TmpvalSymbol, lhs); SETCAR(args, prom); /* make the call */ value = PRIMFUN(fun) (call, fun, args, rho); @@ -5110,7 +5104,7 @@ case CLOSXP: /* replace first argument with evaluated promise for LHS */ /* promise might be captured, so track references */ - prom = mkEVPROMISE(R_TmpvalSymbol, lhs, rho, TRUE); + prom = R_mkEVPROMISE(R_TmpvalSymbol, lhs); args = GETSTACK(-2); SETCAR(args, prom); /* make the call */ @@ -5138,7 +5132,8 @@ will need to see an unmodified LHS value. This heuristic fails if the accessor function called here is not a closure but the replacement function is. */ - if (MAYBE_SHARED(tmp) || MAYBE_SHARED(R_BCNodeStackTop[-3])) + if (MAYBE_REFERENCED(tmp) && + (MAYBE_SHARED(tmp) || MAYBE_SHARED(R_BCNodeStackTop[-3]))) tmp = shallow_duplicate(tmp); R_BCNodeStackTop[-1] = R_BCNodeStackTop[-2]; R_BCNodeStackTop[-2] = tmp; diff -Nru r-base-3.1.0/src/main/gevents.c r-base-3.1.1/src/main/gevents.c --- r-base-3.1.0/src/main/gevents.c 2014-03-12 23:03:13.000000000 +0000 +++ r-base-3.1.1/src/main/gevents.c 2014-06-13 22:15:13.000000000 +0000 @@ -217,9 +217,11 @@ if (TYPEOF(handler) == CLOSXP) { defineVar(install("which"), ScalarInteger(ndevNumber(dd)+1), dd->eventEnv); - int len = (buttons & leftButton) - + (buttons & middleButton) - + (buttons & rightButton); + // Be portable: see PR#15793 + int len = ((buttons & leftButton) != 0) + + ((buttons & middleButton) != 0) + + ((buttons & rightButton) != 0); + PROTECT(bvec = allocVector(INTSXP, len)); i = 0; if (buttons & leftButton) INTEGER(bvec)[i++] = 0; diff -Nru r-base-3.1.0/src/main/gram.c r-base-3.1.1/src/main/gram.c --- r-base-3.1.0/src/main/gram.c 2014-04-09 22:17:06.000000000 +0000 +++ r-base-3.1.1/src/main/gram.c 2014-07-09 22:17:05.000000000 +0000 @@ -3627,6 +3627,8 @@ static void initData(void) { ParseState.data_count = 0 ; + for (int i = 1; i <= ID_COUNT; i++) + ID_ID( i ) = 0; } @@ -4474,9 +4476,7 @@ warning(_("integer literal %s contains decimal; using numeric value"), yytext); else { /* hide the L for the warning message */ - *(yyp-2) = '\0'; warning(_("non-integer value %s qualified with L; using numeric value"), yytext); - *(yyp-2) = (char)c; } } asNumeric = 1; diff -Nru r-base-3.1.0/src/main/gram.y r-base-3.1.1/src/main/gram.y --- r-base-3.1.0/src/main/gram.y 2014-03-12 23:03:13.000000000 +0000 +++ r-base-3.1.1/src/main/gram.y 2014-06-08 22:15:03.000000000 +0000 @@ -1289,6 +1289,8 @@ static void initData(void) { ParseState.data_count = 0 ; + for (int i = 1; i <= ID_COUNT; i++) + ID_ID( i ) = 0; } @@ -2136,9 +2138,7 @@ warning(_("integer literal %s contains decimal; using numeric value"), yytext); else { /* hide the L for the warning message */ - *(yyp-2) = '\0'; warning(_("non-integer value %s qualified with L; using numeric value"), yytext); - *(yyp-2) = (char)c; } } asNumeric = 1; diff -Nru r-base-3.1.0/src/main/localecharset.c r-base-3.1.1/src/main/localecharset.c --- r-base-3.1.0/src/main/localecharset.c 2014-01-05 23:05:31.000000000 +0000 +++ r-base-3.1.1/src/main/localecharset.c 2014-05-26 22:15:12.000000000 +0000 @@ -62,6 +62,7 @@ } name_value; +#ifndef __APPLE__ /* * codeset name defined. * @@ -477,6 +478,7 @@ {"zu_ZA", ENC_ISO8859_1}, }; static const int guess_count = (sizeof(guess)/sizeof(name_value)); +#endif static const name_value known[] = { {"iso88591", "ISO8859-1"}, diff -Nru r-base-3.1.0/src/main/main.c r-base-3.1.1/src/main/main.c --- r-base-3.1.0/src/main/main.c 2014-03-12 23:03:16.000000000 +0000 +++ r-base-3.1.1/src/main/main.c 2014-06-13 22:15:13.000000000 +0000 @@ -248,6 +248,9 @@ R_IoBufferWriteReset(&R_ConsoleIob); return 0; } + /* PR#15770 We don't want to step into expressions entered at the debug prompt. + The 'S' will be changed back to 's' after the next eval. */ + if (R_BrowserLastCommand == 's') R_BrowserLastCommand = 'S'; } R_Visible = FALSE; R_EvalDepth = 0; @@ -264,6 +267,7 @@ Rf_callToplevelHandlers(thisExpr, value, TRUE, wasDisplayed); R_CurrentExpr = value; /* Necessary? Doubt it. */ UNPROTECT(1); + if (R_BrowserLastCommand == 'S') R_BrowserLastCommand = 's'; R_IoBufferWriteReset(&R_ConsoleIob); state->prompt_type = 1; return(1); @@ -667,7 +671,7 @@ int R_SignalHandlers = 1; /* Exposed in R_interface.h */ -unsigned int TimeToSeed(void); /* datetime.c */ +unsigned int TimeToSeed(void); // times.c const char* get_workspace_name(); /* from startup.c */ @@ -682,7 +686,7 @@ else snprintf(localedir, PATH_MAX+20, "%s/library/translations", R_Home); bindtextdomain(PACKAGE, localedir); // PACKAGE = DOMAIN = "R" bindtextdomain("R-base", localedir); -# ifdef WIN32 +# ifdef _WIN32 bindtextdomain("RGui", localedir); # endif #endif @@ -1578,7 +1582,11 @@ F77_CALL(intpr)("dummy", &i, &i, &i); } -/* Used in unix/system.c, avoid inlining */ +/* Used in unix/system.c, avoid inlining by using an extern there. + + This is intended to return a local address. + Use -Wno-return-local-addr when compiling. + */ uintptr_t dummy_ii(void) { int ii; diff -Nru r-base-3.1.0/src/main/memory.c r-base-3.1.1/src/main/memory.c --- r-base-3.1.0/src/main/memory.c 2014-03-12 23:03:14.000000000 +0000 +++ r-base-3.1.1/src/main/memory.c 2014-06-25 22:15:06.000000000 +0000 @@ -104,8 +104,8 @@ static int gc_reporting = 0; static int gc_count = 0; -/* These are used in profiling to separete out time in GC */ -static Rboolean R_in_gc = TRUE; +/* These are used in profiling to separate out time in GC */ +static Rboolean R_in_gc = FALSE; int R_gc_running() { return R_in_gc; } #ifdef TESTING_WRITE_BARRIER @@ -2352,6 +2352,21 @@ return s; } +SEXP R_mkEVPROMISE(SEXP expr, SEXP val) +{ + SEXP prom = mkPROMISE(expr, R_NilValue); + SET_PRVALUE(prom, val); + return prom; +} + +SEXP R_mkEVPROMISE_NR(SEXP expr, SEXP val) +{ + SEXP prom = mkPROMISE(expr, R_NilValue); + DISABLE_REFCNT(prom); + SET_PRVALUE(prom, val); + return prom; +} + /* support for custom allocators that allow vectors to be allocated using non-standard means such as COW mmap() */ @@ -2892,16 +2907,16 @@ /* sanity check on logical scalar values */ if (R_TrueValue != NULL && LOGICAL(R_TrueValue)[0] != TRUE) { LOGICAL(R_TrueValue)[0] = TRUE; - warning("internal TRUE value has been modified"); + error("internal TRUE value has been modified"); } if (R_FalseValue != NULL && LOGICAL(R_FalseValue)[0] != FALSE) { LOGICAL(R_FalseValue)[0] = FALSE; - warning("internal FALSE value has been modified"); + error("internal FALSE value has been modified"); } if (R_LogicalNAValue != NULL && LOGICAL(R_LogicalNAValue)[0] != NA_LOGICAL) { LOGICAL(R_LogicalNAValue)[0] = NA_LOGICAL; - warning("internal logical NA value has been modified"); + error("internal logical NA value has been modified"); } } @@ -3768,7 +3783,8 @@ if(buf->data == NULL) { buf->data = (char *) malloc(blen); - buf->data[0] = '\0'; + if(buf->data) + buf->data[0] = '\0'; } else buf->data = (char *) realloc(buf->data, blen); buf->bufsize = blen; diff -Nru r-base-3.1.0/src/main/mkdtemp.c r-base-3.1.1/src/main/mkdtemp.c --- r-base-3.1.0/src/main/mkdtemp.c 2013-03-05 23:02:40.000000000 +0000 +++ r-base-3.1.1/src/main/mkdtemp.c 2014-05-12 22:15:06.000000000 +0000 @@ -96,7 +96,7 @@ static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; -unsigned int TimeToSeed(void); /* datetime.c */ +unsigned int TimeToSeed(void); // times.c /* Generate a temporary file name based on TMPL. TMPL must match the rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed diff -Nru r-base-3.1.0/src/main/names.c r-base-3.1.1/src/main/names.c --- r-base-3.1.0/src/main/names.c 2014-03-12 23:03:14.000000000 +0000 +++ r-base-3.1.1/src/main/names.c 2014-06-05 22:15:03.000000000 +0000 @@ -662,7 +662,7 @@ {"load", do_load, 0, 111, 2, {PP_FUNCALL, PREC_FN, 0}}, {"loadFromConn2",do_loadFromConn2,0, 111, 3, {PP_FUNCALL, PREC_FN, 0}}, {"serializeToConn", do_serializeToConn, 0, 111, 5, {PP_FUNCALL, PREC_FN, 0}}, -{"unserializeFromConn", do_unserializeFromConn, 0, 111, 2, {PP_FUNCALL, PREC_FN, 0}}, +{"unserializeFromConn", do_unserializeFromConn, 0, 11, 2, {PP_FUNCALL, PREC_FN, 0}}, {"deparse", do_deparse, 0, 11, 5, {PP_FUNCALL, PREC_FN, 0}}, {"dput", do_dput, 0, 111, 3, {PP_FUNCALL, PREC_FN, 0}}, {"dump", do_dump, 0, 111, 5, {PP_FUNCALL, PREC_FN, 0}}, diff -Nru r-base-3.1.0/src/main/objects.c r-base-3.1.1/src/main/objects.c --- r-base-3.1.0/src/main/objects.c 2014-03-12 23:03:15.000000000 +0000 +++ r-base-3.1.1/src/main/objects.c 2014-04-10 22:15:03.000000000 +0000 @@ -838,7 +838,8 @@ break; } if (isObject(CAR(args))) { - SETCAR(args, duplicate(CAR(args))); + if (MAYBE_REFERENCED(CAR(args))) + SETCAR(args, shallow_duplicate(CAR(args))); setAttrib(CAR(args), R_ClassSymbol, R_NilValue); } return CAR(args); diff -Nru r-base-3.1.0/src/main/options.c r-base-3.1.1/src/main/options.c --- r-base-3.1.0/src/main/options.c 2014-03-12 23:03:17.000000000 +0000 +++ r-base-3.1.1/src/main/options.c 2014-04-26 22:15:03.000000000 +0000 @@ -184,7 +184,7 @@ if (value == R_NilValue) { for ( ; t != R_NilValue ; t = CDR(t)) if (TAG(CDR(t)) == tag) { - old = CAR(t); + old = CAR(CDR(t)); SETCDR(t, CDDR(t)); return old; } diff -Nru r-base-3.1.0/src/main/platform.c r-base-3.1.1/src/main/platform.c --- r-base-3.1.0/src/main/platform.c 2014-04-02 22:02:04.000000000 +0000 +++ r-base-3.1.1/src/main/platform.c 2014-06-13 22:15:13.000000000 +0000 @@ -778,10 +778,7 @@ mode, xxclass; #ifdef UNIX_EXTRAS SEXP uid, gid, uname, grname; - struct passwd *stpwd; - struct group *stgrp; #endif - int i, n; #ifdef Win32 SEXP exe; struct _stati64 sb; @@ -793,7 +790,7 @@ fn = CAR(args); if (!isString(fn)) error(_("invalid filename argument")); - n = length(fn); + int n = length(fn); #ifdef UNIX_EXTRAS PROTECT(ans = allocVector(VECSXP, 10)); PROTECT(ansnames = allocVector(STRSXP, 10)); @@ -830,7 +827,7 @@ exe = SET_VECTOR_ELT(ans, 6, allocVector(STRSXP, n)); SET_STRING_ELT(ansnames, 6, mkChar("exe")); #endif - for (i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { #ifdef Win32 wchar_t *wfn = filenameToWchar(STRING_ELT(fn, i), TRUE); /* trailing \ is not valid on Windows except for the @@ -881,12 +878,27 @@ #ifdef UNIX_EXTRAS INTEGER(uid)[i] = (int) sb.st_uid; INTEGER(gid)[i] = (int) sb.st_gid; - stpwd = getpwuid(sb.st_uid); - if (stpwd) SET_STRING_ELT(uname, i, mkChar(stpwd->pw_name)); - else SET_STRING_ELT(uname, i, NA_STRING); - stgrp = getgrgid(sb.st_gid); - if (stgrp) SET_STRING_ELT(grname, i, mkChar(stgrp->gr_name)); - else SET_STRING_ELT(grname, i, NA_STRING); + + /* Usually all of the uid and gid values in a list of + * files are the same so we can avoid most of the calls + * to getpwuid() and getgrgid(), which can be quite slow + * on some systems. (PR#15804) + */ + if (i && INTEGER(uid)[i - 1] == (int) sb.st_uid) + SET_STRING_ELT(uname, i, STRING_ELT(uname, i - 1)); + else { + struct passwd *stpwd = getpwuid(sb.st_uid); + SET_STRING_ELT(uname, i, + stpwd ? mkChar(stpwd->pw_name): NA_STRING); + } + + if (i && INTEGER(gid)[i - 1] == (int) sb.st_gid) + SET_STRING_ELT(grname, i, STRING_ELT(grname, i - 1)); + else { + struct group *stgrp = getgrgid(sb.st_gid); + SET_STRING_ELT(grname, i, + stgrp ? mkChar(stgrp->gr_name): NA_STRING); + } #endif #ifdef Win32 { @@ -1983,7 +1995,7 @@ #endif SET_STRING_ELT(ansnames, i, mkChar("fifo")); -#if (defined(HAVE_MKFIFO) && defined(HAVE_FCNTL_H)) || defined(WIN32) +#if (defined(HAVE_MKFIFO) && defined(HAVE_FCNTL_H)) || defined(_WIN32) LOGICAL(ans)[i++] = TRUE; #else LOGICAL(ans)[i++] = FALSE; diff -Nru r-base-3.1.0/src/main/print.c r-base-3.1.1/src/main/print.c --- r-base-3.1.0/src/main/print.c 2014-03-12 23:03:17.000000000 +0000 +++ r-base-3.1.1/src/main/print.c 2014-05-29 22:15:04.000000000 +0000 @@ -984,6 +984,12 @@ else /* S3 */ PROTECT(call = lang2(install("print"), s)); + if (TYPEOF(s) == SYMSXP || TYPEOF(s) == LANGSXP) + /* If s is not self-evaluating wrap it in a promise. Doing + this unconditionally seems to create problems in the S4 + case. */ + SETCADR(call, R_mkEVPROMISE(s, s)); + eval(call, env); UNPROTECT(1); } else PrintValueRec(s, env); diff -Nru r-base-3.1.0/src/main/random.c r-base-3.1.1/src/main/random.c --- r-base-3.1.0/src/main/random.c 2014-03-12 23:03:16.000000000 +0000 +++ r-base-3.1.1/src/main/random.c 2014-04-23 22:15:04.000000000 +0000 @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1997--2012 The R Core Team + * Copyright (C) 1997--2014 The R Core Team * Copyright (C) 2003--2008 The R Foundation * * This program is free software; you can redistribute it and/or modify @@ -334,8 +334,6 @@ } } -static Rboolean Walker_warn = FALSE; - /* A version using Walker's alias method, based on Alg 3.13B in Ripley (1987). */ @@ -348,12 +346,6 @@ int i, j, k; int *HL, *H, *L; - if (!Walker_warn) { - Walker_warn = TRUE; - warning("Walker's alias method used: results are different from R < 2.2.0"); - } - - /* Create the alias tables. The idea is that for HL[0] ... L-1 label the entries with q < 1 and L ... H[n-1] label those >= 1. diff -Nru r-base-3.1.0/src/main/RNG.c r-base-3.1.1/src/main/RNG.c --- r-base-3.1.0/src/main/RNG.c 2014-03-12 23:03:14.000000000 +0000 +++ r-base-3.1.1/src/main/RNG.c 2014-05-12 22:15:06.000000000 +0000 @@ -332,7 +332,7 @@ return seeds; } -unsigned int TimeToSeed(void); /* datetime.c */ +unsigned int TimeToSeed(void); // times.c static void Randomize(RNGtype kind) { diff -Nru r-base-3.1.0/src/main/Rstrptime.h r-base-3.1.1/src/main/Rstrptime.h --- r-base-3.1.0/src/main/Rstrptime.h 2014-03-12 23:03:16.000000000 +0000 +++ r-base-3.1.1/src/main/Rstrptime.h 2014-04-23 22:15:04.000000000 +0000 @@ -507,7 +507,8 @@ if (val % 100 >= 60) return NULL; val = (val / 100) * 100 + ((val % 100) * 50) / 30; } - if (val > 1200) return NULL; + /* http://en.wikipedia.org/wiki/List_of_UTC_time_offsets */ + if (val > 1400) return NULL; off = ((val * 3600) / 100); if (neg) off = -off; *poffset = off; diff -Nru r-base-3.1.0/src/main/serialize.c r-base-3.1.1/src/main/serialize.c --- r-base-3.1.0/src/main/serialize.c 2014-03-12 23:03:14.000000000 +0000 +++ r-base-3.1.1/src/main/serialize.c 2014-06-03 22:15:03.000000000 +0000 @@ -348,11 +348,11 @@ switch (stream->type) { case R_pstream_ascii_format: InWord(stream, word, sizeof(word)); - sscanf(word, "%s", buf); + if(sscanf(word, "%s", buf) != 1) error(_("read error")); if (strcmp(buf, "NA") == 0) return NA_INTEGER; else - sscanf(buf, "%d", &i); + if(sscanf(buf, "%d", &i) != 1) error(_("read error")); return i; case R_pstream_binary_format: stream->InBytes(stream, &i, sizeof(int)); @@ -374,7 +374,7 @@ switch (stream->type) { case R_pstream_ascii_format: InWord(stream, word, sizeof(word)); - sscanf(word, "%s", buf); + if(sscanf(word, "%s", buf) != 1) error(_("read error")); if (strcmp(buf, "NA") == 0) return NA_REAL; else if (strcmp(buf, "Inf") == 0) @@ -382,7 +382,7 @@ else if (strcmp(buf, "-Inf") == 0) return R_NegInf; else - sscanf(buf, "%lg", &d); + if(sscanf(buf, "%lg", &d) != 1) error(_("read error")); return d; case R_pstream_binary_format: stream->InBytes(stream, &d, sizeof(double)); diff -Nru r-base-3.1.0/src/main/sort.c r-base-3.1.1/src/main/sort.c --- r-base-3.1.0/src/main/sort.c 2014-03-12 23:03:14.000000000 +0000 +++ r-base-3.1.1/src/main/sort.c 2014-06-25 22:15:06.000000000 +0000 @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1998-2013 The R Core Team + * Copyright (C) 1998-2014 The R Core Team * Copyright (C) 2004 The R Foundation * * This program is free software; you can redistribute it and/or modify @@ -653,11 +653,11 @@ if (isObject(x) && !isNull(rho)) { /* so never any NAs */ /* evaluate .gt(x, i, j) */ SEXP si, sj, call; - si = ScalarInteger((int)i+1); - sj = ScalarInteger((int)j+1); + PROTECT(si = ScalarInteger((int)i+1)); + PROTECT(sj = ScalarInteger((int)j+1)); PROTECT(call = lang4(install(".gt"), x, si, sj)); c = asInteger(eval(call, rho)); - UNPROTECT(1); + UNPROTECT(3); } else { switch (TYPEOF(x)) { case LGLSXP: @@ -691,11 +691,11 @@ if (isObject(x) && !isNull(rho)) { /* so never any NAs */ /* evaluate .gt(x, i, j) */ SEXP si, sj, call; - si = ScalarInteger((int)i+1); - sj = ScalarInteger((int)j+1); + PROTECT(si = ScalarInteger((int)i+1)); + PROTECT(sj = ScalarInteger((int)j+1)); PROTECT(call = lang4(install(".gt"), x, si, sj)); c = asInteger(eval(call, rho)); - UNPROTECT(1); + UNPROTECT(3); } else { switch (TYPEOF(x)) { case LGLSXP: @@ -864,7 +864,7 @@ if (n < 2) return; for (t = 0; incs[t] > n; t++); - for (h = incs[t]; t < NI; h = sincs[++t]) + for (h = incs[t]; t < NI; h = incs[++t]) R_CheckUserInterrupt(); for (i = h; i < n; i++) { itmp = indx[i]; diff -Nru r-base-3.1.0/src/main/source.c r-base-3.1.1/src/main/source.c --- r-base-3.1.0/src/main/source.c 2014-01-05 23:05:31.000000000 +0000 +++ r-base-3.1.1/src/main/source.c 2014-06-21 22:15:07.000000000 +0000 @@ -199,6 +199,8 @@ RCNTXT cntxt; checkArity(op, args); + if(!inherits(CAR(args), "connection")) + error(_("'file' must be a character string or connection")); R_ParseError = 0; R_ParseErrorMsg[0] = '\0'; diff -Nru r-base-3.1.0/src/main/subscript.c r-base-3.1.1/src/main/subscript.c --- r-base-3.1.0/src/main/subscript.c 2014-03-12 23:03:14.000000000 +0000 +++ r-base-3.1.1/src/main/subscript.c 2014-04-18 22:15:02.000000000 +0000 @@ -313,6 +313,8 @@ error("invalid subscript for pairlist"); #endif cx = nthcdr(x, (int) offset); + if (NAMED(x) > NAMED(CAR(cx))) + SET_NAMED(CAR(x), NAMED(x)); x = CAR(cx); if (dup && MAYBE_SHARED(x)) { x = shallow_duplicate(x); @@ -321,6 +323,8 @@ } else { cx = x; x = VECTOR_ELT(x, offset); + if (NAMED(cx) > NAMED(x)) + SET_NAMED(x, NAMED(cx)); if (dup && MAYBE_SHARED(x)) { x = shallow_duplicate(x); SET_VECTOR_ELT(cx, offset, x); diff -Nru r-base-3.1.0/src/main/subset.c r-base-3.1.1/src/main/subset.c --- r-base-3.1.0/src/main/subset.c 2014-03-12 23:03:16.000000000 +0000 +++ r-base-3.1.1/src/main/subset.c 2014-04-18 22:15:02.000000000 +0000 @@ -963,8 +963,24 @@ SEXP thesub = CAR(subs); int len = length(thesub); - if (len > 1) + if (len > 1) { +#ifdef SWITCH_TO_REFCNT + if (IS_GETTER_CALL(call)) { + /* this is (most likely) a getter call in a complex + assighment so we duplicate as needed. The original + x should have been duplicated if it might be + shared */ + if (MAYBE_SHARED(x)) + error("getter call used outside of a complex assignment."); + x = vectorIndex(x, thesub, 0, len-1, pok, call, TRUE); + } + else + x = vectorIndex(x, thesub, 0, len-1, pok, call, FALSE); +#else x = vectorIndex(x, thesub, 0, len-1, pok, call, FALSE); +#endif + named_x = NAMED(x); + } offset = get1index(thesub, getAttrib(x, R_NamesSymbol), xlength(x), pok, len > 1 ? len-1 : -1, call); diff -Nru r-base-3.1.0/src/main/sysutils.c r-base-3.1.1/src/main/sysutils.c --- r-base-3.1.0/src/main/sysutils.c 2014-03-12 23:03:16.000000000 +0000 +++ r-base-3.1.1/src/main/sysutils.c 2014-05-27 22:15:06.000000000 +0000 @@ -313,11 +313,18 @@ #endif #ifdef HAVE_SYS_WAIT_H if (WIFEXITED(res)) res = WEXITSTATUS(res); - else res = 0; #else /* assume that this is shifted if a multiple of 256 */ if ((res % 256) == 0) res = res/256; #endif + if (res == -1) { + /* this means that system() failed badly - it didn't + even get to try to run the shell */ + warning(_("system call failed: %s"), strerror(errno)); + /* R system() is documented to return 127 on failure, and a lot of + code relies on that - it will misinterpret -1 as success */ + res = 127; + } return res; } diff -Nru r-base-3.1.0/src/main/unique.c r-base-3.1.1/src/main/unique.c --- r-base-3.1.0/src/main/unique.c 2014-03-12 23:03:13.000000000 +0000 +++ r-base-3.1.1/src/main/unique.c 2014-05-19 22:15:03.000000000 +0000 @@ -543,7 +543,7 @@ /* simpler version of the above : return 1-based index of first, or 0 : */ R_xlen_t any_duplicated(SEXP x, Rboolean from_last) { - int result = 0; + R_xlen_t result = 0; int nmax = NA_INTEGER; if (!isVector(x)) error(_("'duplicated' applies only to vectors")); @@ -554,12 +554,10 @@ if(from_last) { for (i = n-1; i >= 0; i--) { -// if ((i+1) % NINTERRUPT == 0) R_CheckUserInterrupt(); if(isDuplicated(x, i, &data)) { result = ++i; break; } } } else { for (i = 0; i < n; i++) { -// if ((i+1) % NINTERRUPT == 0) R_CheckUserInterrupt(); if(isDuplicated(x, i, &data)) { result = ++i; break; } } } @@ -631,7 +629,7 @@ isDup = FALSE; break; \ } \ if(isDup) { \ - UNPROTECT(1); \ + UNPROTECT(2); \ return ++i; \ } \ /* else continue */ \ @@ -692,15 +690,20 @@ if(length(incomp) && /* S has FALSE to mean empty */ !(isLogical(incomp) && length(incomp) == 1 && LOGICAL(incomp)[0] == 0)) { - if(PRIMVAL(op) == 2) /* return R's 1-based index :*/ - return ScalarInteger(any_duplicated3(x, incomp, fL)); - else + if(PRIMVAL(op) == 2) { + /* return R's 1-based index :*/ + R_xlen_t ind = any_duplicated3(x, incomp, fL); + if(ind > INT_MAX) return ScalarReal((double) ind); + else return ScalarInteger((int)ind); + } else dup = duplicated3(x, incomp, fL, nmax); } else { - if(PRIMVAL(op) == 2) - return ScalarInteger(any_duplicated(x, fL)); - else + if(PRIMVAL(op) == 2) { + R_xlen_t ind = any_duplicated(x, fL); + if(ind > INT_MAX) return ScalarReal((double) ind); + else return ScalarInteger((int)ind); + } else dup = Duplicated(x, fL, nmax); } if (PRIMVAL(op) == 0) /* "duplicated()" */ @@ -1044,10 +1047,6 @@ it is not really possible to optimize there. */ if((n_target > 100) && (10*n_input > n_target)) { - /* - Currently no hashing when using bytes. - - */ HashData data; HashTableSetup(target, &data, NA_INTEGER); data.useUTF8 = useUTF8; diff -Nru r-base-3.1.0/src/main/util.c r-base-3.1.1/src/main/util.c --- r-base-3.1.0/src/main/util.c 2014-03-25 23:15:08.000000000 +0000 +++ r-base-3.1.1/src/main/util.c 2014-06-17 22:15:05.000000000 +0000 @@ -1,7 +1,7 @@ /* * R : A Computer Language for Statistical Data Analysis * Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka - * Copyright (C) 1997--2013 The R Core Team + * Copyright (C) 1997--2014 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -570,13 +570,15 @@ SEXP attribute_hidden do_merge(SEXP call, SEXP op, SEXP args, SEXP rho) { SEXP xi, yi, ansx, ansy, ans, x_lone, y_lone; - int nx = 0, ny = 0, i, j, k, nans = 0, nx_lone = 0, ny_lone = 0; + int nx = 0, ny = 0, i, j, k, nx_lone = 0, ny_lone = 0; int all_x = 0, all_y = 0, ll = 0/* "= 0" : for -Wall */; int *ix, *iy, tmp, nnx, nny, i0, j0; + double dnans = 0; const char *nms[] = {"xi", "yi", "x.alone", "y.alone", ""}; checkArity(op, args); xi = CAR(args); + // NB: long vectors are not supported for input if ( !isInteger(xi) || !(nx = LENGTH(xi)) ) error(_("invalid '%s' argument"), "xinds"); yi = CADR(args); @@ -606,8 +608,11 @@ for(; j < ny; j++) if(INTEGER(yi)[j] >= tmp) break; for(nny = j; nny < ny; nny++) if(INTEGER(yi)[nny] != tmp) break; /* printf("i %d nnx %d j %d nny %d\n", i, nnx, j, nny); */ - nans += (nnx-i)*(nny-j); + dnans += ((double)(nnx-i))*(nny-j); } + if (dnans > INT_MAX) + error(_("number of rows in the result exceeds maximum vector length")); + int nans = (int) dnans; /* 2. allocate and store result components */ @@ -904,7 +909,7 @@ for (i = 0; i < n; i++) { path = translateChar(STRING_ELT(paths, i)); char *res = realpath(path, abspath); - if (res) + if (res) SET_STRING_ELT(ans, i, mkChar(abspath)); else { SET_STRING_ELT(ans, i, STRING_ELT(paths, i)); @@ -1016,7 +1021,7 @@ if(na || s != NA_STRING) { cetype_t ienc = getCharCE(s); if(ienc == CE_UTF8) { - const char *ss = EncodeString(s, w-1000000, quote, + const char *ss = EncodeString(s, w-1000000, quote, (Rprt_adj) justify); SET_STRING_ELT(ans, i, mkCharCE(ss, ienc)); } else { @@ -1506,8 +1511,8 @@ else return 0; } -double R_strtod5(const char *str, char **endptr, char dec, - Rboolean NA, Rboolean exact) +double R_strtod5(const char *str, char **endptr, char dec, + Rboolean NA, int exact) { LDOUBLE ans = 0.0, p10 = 10.0, fac = 1.0; int n, expn = 0, sign = 1, ndigits = 0, exph = -1; @@ -1554,11 +1559,19 @@ else break; if (exph >= 0) exph += 4; } - if (exact && ans > 9e15) { // lost accuracy - ans = NA_REAL; - p = str; /* back out */ - goto done; +#define strtod_EXACT_CLAUSE \ + if(exact && ans > 0x1.fffffffffffffp52) { \ + if(exact == NA_LOGICAL) \ + warning(_( \ + "accuracy loss in conversion from \"%s\" to numeric"), \ + str); \ + else { \ + ans = NA_REAL; \ + p = str; /* back out */ \ + goto done; \ + } \ } + strtod_EXACT_CLAUSE; if (*p == 'p' || *p == 'P') { int expsign = 1; double p2 = 2.0; @@ -1592,12 +1605,7 @@ p = str; /* back out */ goto done; } - if (exact && ans > 9e15) { // lost accuracy -// error("lost accuracy in '%s'\n", str); - ans = NA_REAL; - p = str; /* back out */ - goto done; - } + strtod_EXACT_CLAUSE; if (*p == 'e' || *p == 'E') { int expsign = 1; @@ -1672,20 +1680,20 @@ ans = CAR(args); for (i = 0; i < XLENGTH(ans); i++) { el = STRING_ELT(ans, i); - if (el == NA_STRING) { /* do nothing */ } - else if(PRIMVAL(op) && !known_to_be_utf8) { /* enc2utf8 */ - if(!IS_UTF8(el) && !IS_ASCII(el)) { - if (!duped) { PROTECT(ans = duplicate(ans)); duped = TRUE; } - SET_STRING_ELT(ans, i, - mkCharCE(translateCharUTF8(el), CE_UTF8)); - } - } else { /* enc2native */ - if((known_to_be_latin1 && IS_UTF8(el)) || - (known_to_be_utf8 && IS_LATIN1(el)) || - ENC_KNOWN(el)) { - if (!duped) { PROTECT(ans = duplicate(ans)); duped = TRUE; } + if (el == NA_STRING) continue; + if (PRIMVAL(op) || known_to_be_utf8) { /* enc2utf8 */ + if (IS_UTF8(el) || IS_ASCII(el) || IS_BYTES(el)) continue; + if (!duped) { ans = PROTECT(duplicate(ans)); duped = TRUE; } + SET_STRING_ELT(ans, i, + mkCharCE(translateCharUTF8(el), CE_UTF8)); + } else if (ENC_KNOWN(el)) { /* enc2native */ + if (IS_ASCII(el) || IS_BYTES(el)) continue; + if (known_to_be_latin1 && IS_LATIN1(el)) continue; + if (!duped) { PROTECT(ans = duplicate(ans)); duped = TRUE; } + if (known_to_be_latin1) + SET_STRING_ELT(ans, i, mkCharCE(translateChar(el), CE_LATIN1)); + else SET_STRING_ELT(ans, i, mkChar(translateChar(el))); - } } } if(duped) UNPROTECT(1); @@ -1942,7 +1950,7 @@ return mkString(ans); } -static void +static void bincode(double *x, R_xlen_t n, double *breaks, int nb, int *code, int right, int include_border) { @@ -2009,7 +2017,7 @@ R_xlen_t n = XLENGTH(in); /* FIXME: could in principle be a long vector */ int nb = asInteger(nbin); - if (nb == NA_INTEGER || nb < 0) + if (nb == NA_INTEGER || nb < 0) error(_("invalid '%s' argument"), "nbin"); SEXP ans = allocVector(INTSXP, nb); int *x = INTEGER(in), *y = INTEGER(ans); @@ -2037,7 +2045,7 @@ if (n == NA_INTEGER) error(_("invalid '%s' argument"), "vec"); R_xlen_t nx = XLENGTH(x); int sr = asLogical(right), si = asLogical(inside); - if (sr == NA_INTEGER) + if (sr == NA_INTEGER) error(_("invalid '%s' argument"), "rightmost.closed"); if (si == NA_INTEGER) error(_("invalid '%s' argument"), "all.inside"); @@ -2071,10 +2079,10 @@ int n = asInteger(CAR(args)); args = CDR(args); if (n == NA_INTEGER || n < 0) error(_("invalid '%s' argument"), "n"); int min_n = asInteger(CAR(args)); args = CDR(args); - if (min_n == NA_INTEGER || min_n < 0 || min_n > n) + if (min_n == NA_INTEGER || min_n < 0 || min_n > n) error(_("invalid '%s' argument"), "min.n"); double shrink = asReal(CAR(args)); args = CDR(args); - if (!R_FINITE(shrink) || shrink <= 0.) + if (!R_FINITE(shrink) || shrink <= 0.) error(_("invalid '%s' argument"), "shrink.sml"); PROTECT(hi = coerceVector(CAR(args), REALSXP)); args = CDR(args); double z; @@ -2083,7 +2091,7 @@ if (!R_FINITE(z = REAL(hi)[1]) || z < 0.) error(_("invalid '%s' argument"), "u5.bias"); int eps = asInteger(CAR(args)); /* eps.correct */ - if (eps == NA_INTEGER || eps < 0 || eps > 2) + if (eps == NA_INTEGER || eps < 0 || eps > 2) error(_("'eps.correct' must be 0, 1, or 2")); R_pretty(&l, &u, &n, min_n, shrink, REAL(hi), eps, 1); PROTECT(ans = allocVector(VECSXP, 3)); @@ -2100,7 +2108,7 @@ } /* - r <- .Internal(formatC(x, as.character(mode), width, digits, + r <- .Internal(formatC(x, as.character(mode), width, digits, as.character(format), as.character(flag), i.strlen)) */ @@ -2314,7 +2322,7 @@ } /* if(do_fg) for(i..) */ else for (R_xlen_t i = 0; i < n; i++) - snprintf(result[i], strlen(result[i]) + 1, + snprintf(result[i], strlen(result[i]) + 1, form, width, dig, ((double *)x)[i]); } else error("'type' must be \"real\" for this format"); diff -Nru r-base-3.1.0/src/modules/internet/Makefile.in r-base-3.1.1/src/modules/internet/Makefile.in --- r-base-3.1.0/src/modules/internet/Makefile.in 2013-09-26 22:05:07.000000000 +0000 +++ r-base-3.1.1/src/modules/internet/Makefile.in 2014-06-04 22:15:06.000000000 +0000 @@ -22,7 +22,7 @@ dllversion.rc internet_la = internet$(SHLIB_EXT) -internet_la_LIBADD = $(LIBR) @DYLIB_UNDEFINED_ALLOWED_FALSE@ $(LIBINTL) +internet_la_LIBADD = $(LIBR) @INTERNET_LIBS@ @DYLIB_UNDEFINED_ALLOWED_FALSE@ $(LIBINTL) ALL_CFLAGS = $(ALL_CFLAGS_LO) @C_VISIBILITY@ diff -Nru r-base-3.1.0/src/modules/internet/Rhttpd.c r-base-3.1.1/src/modules/internet/Rhttpd.c --- r-base-3.1.0/src/modules/internet/Rhttpd.c 2013-06-30 22:05:05.000000000 +0000 +++ r-base-3.1.1/src/modules/internet/Rhttpd.c 2014-06-13 22:15:13.000000000 +0000 @@ -58,7 +58,7 @@ /* this is orignally from sisock.h - system independent sockets */ -#ifndef WIN32 +#ifndef _WIN32 # include # include # ifdef HAVE_UNISTD_H @@ -126,7 +126,7 @@ # define donesocks() WSACleanup() typedef int socklen_t; -#endif /* WIN32 */ +#endif /* _WIN32 */ /* --- system-independent part --- */ @@ -183,7 +183,7 @@ typedef struct httpd_conn { SOCKET sock; /* client socket */ struct in_addr peer; /* IP address of the peer */ -#ifdef WIN32 +#ifdef _WIN32 HANDLE thread; /* worker thread */ #else InputHandler *ih; /* worker input handler */ @@ -208,7 +208,7 @@ /* --- flag determining whether one-time initialization is yet to be performed --- */ static int needs_init = 1; -#ifdef WIN32 +#ifdef _WIN32 #define WM_RHTTP_CALLBACK ( WM_USER + 1 ) static HWND message_window; static LRESULT CALLBACK @@ -221,7 +221,7 @@ static void first_init() { initsocks(); -#ifdef WIN32 +#ifdef _WIN32 /* create a dummy message-only window for synchronization with the * main event loop */ HINSTANCE instance = GetModuleHandle(NULL); @@ -277,7 +277,7 @@ static void finalize_worker(httpd_conn_t *c) { DBG(printf("finalizing worker %p\n", (void*) c)); -#ifndef WIN32 +#ifndef _WIN32 if (c->ih) { removeInputHandler(&R_InputHandlers, c->ih); c->ih = NULL; @@ -316,7 +316,7 @@ unsigned int i = 0; for (; i < MAX_WORKERS; i++) if (!workers[i]) { -#ifdef WIN32 +#ifdef _WIN32 DBG(printf("registering worker %p as %d (thread=0x%x)\n", (void*) c, i, (int) c->thread)); #else DBG(printf("registering worker %p as %d (handler=%p)\n", (void*) c, i, (void*) c->ih)); @@ -497,7 +497,7 @@ } } -#ifdef WIN32 +#ifdef _WIN32 /* on Windows we have to guarantee that process_request is performed * on the main thread, so we have to dispatch it through a message */ static void process_request_main_thread(httpd_conn_t *c); @@ -749,7 +749,7 @@ in_process = 0; } -#ifdef WIN32 +#ifdef _WIN32 #undef process_request #endif @@ -1074,7 +1074,7 @@ static SOCKET srv_sock = INVALID_SOCKET; -#ifdef WIN32 +#ifdef _WIN32 /* Windows implementation uses threads to accept and serve connections, using the main event loop to synchronize with R through a message-only window which is created on the R thread @@ -1135,7 +1135,7 @@ c = (httpd_conn_t*) calloc(1, sizeof(httpd_conn_t)); c->sock = cl_sock; c->peer = peer_sa.sin_addr; -#ifndef WIN32 +#ifndef _WIN32 c->ih = addInputHandler(R_InputHandlers, cl_sock, &worker_input_handler, HttpdWorkerActivity); if (c->ih) c->ih->userData = c; @@ -1152,7 +1152,7 @@ int in_R_HTTPDCreate(const char *ip, int port) { -#ifndef WIN32 +#ifndef _WIN32 int reuse = 1; #endif SAIN srv_sa; @@ -1164,7 +1164,7 @@ if (srv_sock != INVALID_SOCKET) closesocket(srv_sock); -#ifdef WIN32 +#ifdef _WIN32 /* on Windows stop the server thread if it exists */ if (server_thread) { DWORD ts = 0; @@ -1179,7 +1179,7 @@ if (srv_sock == INVALID_SOCKET) Rf_error("unable to create socket"); -#ifndef WIN32 +#ifndef _WIN32 /* set socket for reuse so we can re-init if we die */ /* But on Windows, this lets us stomp on any port already in use, so don't do it. */ setsockopt(srv_sock, SOL_SOCKET, SO_REUSEADDR, @@ -1203,7 +1203,7 @@ if (listen(srv_sock, 8)) Rf_error("cannot listen to TCP port %d", port); -#ifndef WIN32 +#ifndef _WIN32 /* all went well, register the socket as a handler */ if (srv_handler) removeInputHandler(&R_InputHandlers, srv_handler); srv_handler = addInputHandler(R_InputHandlers, srv_sock, @@ -1220,7 +1220,7 @@ if (srv_sock != INVALID_SOCKET) closesocket(srv_sock); srv_sock = INVALID_SOCKET; -#ifdef WIN32 +#ifdef _WIN32 /* on Windows stop the server thread if it exists */ if (server_thread) { DWORD ts = 0; diff -Nru r-base-3.1.0/src/modules/lapack/init_win.c r-base-3.1.1/src/modules/lapack/init_win.c --- r-base-3.1.0/src/modules/lapack/init_win.c 2012-04-16 22:05:03.000000000 +0000 +++ r-base-3.1.1/src/modules/lapack/init_win.c 2014-06-13 22:15:14.000000000 +0000 @@ -21,7 +21,7 @@ #include #endif -#ifdef WIN32 +#ifdef _WIN32 # include static void __attribute__((constructor)) diff -Nru r-base-3.1.0/src/modules/X11/dataentry.c r-base-3.1.1/src/modules/X11/dataentry.c --- r-base-3.1.0/src/modules/X11/dataentry.c 2014-01-05 23:05:32.000000000 +0000 +++ r-base-3.1.1/src/modules/X11/dataentry.c 2014-04-15 22:15:03.000000000 +0000 @@ -376,7 +376,7 @@ /* start up the window, more initializing in here */ if (initwin(DE, title)) - errorcall(call, "invalid device"); + errorcall(call, "unable to start data editor"); /* set up a context which will close the window if there is an error */ begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv, @@ -511,7 +511,7 @@ /* start up the window, more initializing in here */ if (initwin(DE, CHAR(STRING_ELT(stitle, 0)))) - errorcall(call, "invalid device"); + errorcall(call, "unable to start data viewer"); /* set up a context which will close the window if there is an error */ begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv, @@ -1943,7 +1943,7 @@ } else { DE->font_info = XLoadQueryFont(iodisplay, font_name); if (DE->font_info == NULL) { - warning("unable to losd font %s", font_name); + warning("unable to load font %s", font_name); return TRUE; /* ERROR */ } } diff -Nru r-base-3.1.0/src/modules/X11/devX11.c r-base-3.1.1/src/modules/X11/devX11.c --- r-base-3.1.0/src/modules/X11/devX11.c 2013-03-05 23:02:41.000000000 +0000 +++ r-base-3.1.1/src/modules/X11/devX11.c 2014-05-22 22:15:04.000000000 +0000 @@ -744,7 +744,7 @@ { if (event.xany.type == Expose) { /* ----- window repaint ------ */ - while (XCheckTypedEvent(display, Expose, &event)) ; + while (XCheckTypedWindowEvent(display, event.xexpose.window, Expose, &event)); if (inclose) return; if (event.xexpose.count != 0) return; caddr_t temp; @@ -810,7 +810,7 @@ #endif dd->size(&(dd->left), &(dd->right), &(dd->bottom), &(dd->top), dd); /* gobble Expose events; we'll redraw anyway */ - while (XCheckTypedEvent(display, Expose, &event)) ; + while (XCheckTypedWindowEvent(display, event.xexpose.window, Expose, &event)); pGEDevDesc gdd = desc2GEDesc(dd); if(gdd->dirty) { GEplayDisplayList(gdd); diff -Nru r-base-3.1.0/src/nmath/dbeta.c r-base-3.1.1/src/nmath/dbeta.c --- r-base-3.1.0/src/nmath/dbeta.c 2014-03-12 23:03:20.000000000 +0000 +++ r-base-3.1.1/src/nmath/dbeta.c 2014-05-15 22:15:05.000000000 +0000 @@ -47,8 +47,24 @@ if (ISNAN(x) || ISNAN(a) || ISNAN(b)) return x + a + b; #endif - if (a <= 0 || b <= 0) ML_ERR_return_NAN; + if (a < 0 || b < 0) ML_ERR_return_NAN; if (x < 0 || x > 1) return(R_D__0); + + // limit cases for (a,b), leading to point masses + if(a == 0 || b == 0 || !R_FINITE(a) || !R_FINITE(b)) { + if(a == 0 && b == 0) { // point mass 1/2 at each of {0,1} : + if (x == 0 || x == 1) return(ML_POSINF); /* else */ return(R_D__0); + } + if (a == 0 || a/b == 0) { // point mass 1 at 0 + if (x == 0) return(ML_POSINF); /* else */ return(R_D__0); + } + if (b == 0 || b/a == 0) { // point mass 1 at 1 + if (x == 1) return(ML_POSINF); /* else */ return(R_D__0); + } + // else, remaining case: a = b = Inf : point mass 1 at 1/2 + if (x == 0.5) return(ML_POSINF); /* else */ return(R_D__0); + } + if (x == 0) { if(a > 1) return(R_D__0); if(a < 1) return(ML_POSINF); @@ -59,11 +75,10 @@ if(b < 1) return(ML_POSINF); /* b == 1 : */ return(R_D_val(a)); } + double lval; if (a <= 2 || b <= 2) lval = (a-1)*log(x) + (b-1)*log1p(-x) - lbeta(a, b); - else if(!R_FINITE(a) || !R_FINITE(b)) - lval = ML_NEGINF; else lval = log(a+b-1) + dbinom_raw(a-1, a+b-2, x, 1-x, TRUE); diff -Nru r-base-3.1.0/src/nmath/dhyper.c r-base-3.1.1/src/nmath/dhyper.c --- r-base-3.1.0/src/nmath/dhyper.c 2014-03-12 23:03:20.000000000 +0000 +++ r-base-3.1.1/src/nmath/dhyper.c 2014-04-22 22:15:04.000000000 +0000 @@ -53,8 +53,8 @@ if (R_D_negInonint(r) || R_D_negInonint(b) || R_D_negInonint(n) || n > r+b) ML_ERR_return_NAN; - if (R_D_negInonint(x)) - return(R_D__0); + if(x < 0) return(R_D__0); + R_D_nonint_check(x);// incl warning x = R_forceint(x); r = R_forceint(r); diff -Nru r-base-3.1.0/src/nmath/dnbinom.c r-base-3.1.1/src/nmath/dnbinom.c --- r-base-3.1.0/src/nmath/dnbinom.c 2014-03-12 23:03:21.000000000 +0000 +++ r-base-3.1.1/src/nmath/dnbinom.c 2014-05-05 22:15:04.000000000 +0000 @@ -72,7 +72,7 @@ if (x < 0 || !R_FINITE(x)) return R_D__0; /* limiting case as size approaches zero is point mass at zero, - * even if mu is kept constant. limit distribution does not + * even if mu is kept constant. limit distribution does not * have mean mu, though. */ if (x == 0 && size==0) return R_D__1; @@ -82,7 +82,8 @@ return R_D_exp(size * (size < mu ? log(size/(size+mu)) : log1p(- mu/(size+mu)))); if(x < 1e-10 * size) { /* don't use dbinom_raw() but MM's formula: */ /* FIXME --- 1e-8 shows problem; rather use algdiv() from ./toms708.c */ - return R_D_exp(x * log(size*mu / (size+mu)) - mu - lgamma(x+1) + + p = (size < mu ? log(size/(1 + size/mu)) : log(mu / (1 + mu/size))); + return R_D_exp(x * p - mu - lgamma(x+1) + log1p(x*(x-1)/(2*size))); } /* else: no unnecessary cancellation inside dbinom_raw, when diff -Nru r-base-3.1.0/src/nmath/dpq.h r-base-3.1.1/src/nmath/dpq.h --- r-base-3.1.0/src/nmath/dpq.h 2014-03-12 23:03:20.000000000 +0000 +++ r-base-3.1.1/src/nmath/dpq.h 2014-05-15 22:15:05.000000000 +0000 @@ -26,6 +26,8 @@ #define R_D__1 (log_p ? 0. : 1.) /* 1 */ #define R_DT_0 (lower_tail ? R_D__0 : R_D__1) /* 0 */ #define R_DT_1 (lower_tail ? R_D__1 : R_D__0) /* 1 */ +#define R_D_half (log_p ? -M_LN2 : 0.5) // 1/2 (lower- or upper tail) + /* Use 0.5 - p + 0.5 to perhaps gain 1 bit of accuracy */ #define R_D_Lval(p) (lower_tail ? (p) : (0.5 - (p) + 0.5)) /* p */ @@ -37,7 +39,7 @@ #define R_D_log(p) (log_p ? (p) : log(p)) /* log(p) */ #define R_D_Clog(p) (log_p ? log1p(-(p)) : (0.5 - (p) + 0.5)) /* [log](1-p) */ -/* log(1 - exp(x)) in more stable form than log1p(- R_D_qIv(x))) : */ +// log(1 - exp(x)) in more stable form than log1p(- R_D_qIv(x)) : #define R_Log1_Exp(x) ((x) > -M_LN2 ? log(-expm1(x)) : log1p(-exp(x))) /* log(1-exp(x)): R_D_LExp(x) == (log1p(- R_D_qIv(x))) but even more stable:*/ @@ -60,7 +62,7 @@ #define R_DT_log(p) (lower_tail? R_D_log(p) : R_D_LExp(p))/* log(p) in qF */ #define R_DT_Clog(p) (lower_tail? R_D_LExp(p): R_D_log(p))/* log(1-p) in qF*/ #define R_DT_Log(p) (lower_tail? (p) : R_Log1_Exp(p)) -/* == R_DT_log when we already "know" log_p == TRUE :*/ +// == R_DT_log when we already "know" log_p == TRUE #define R_Q_P01_check(p) \ @@ -116,6 +118,7 @@ /* [neg]ative or [non int]eger : */ #define R_D_negInonint(x) (x < 0. || R_nonint(x)) +// for discrete d(x, ...) : #define R_D_nonint_check(x) \ if(R_nonint(x)) { \ MATHLIB_WARNING("non-integer x = %f", x); \ diff -Nru r-base-3.1.0/src/nmath/nmath.h r-base-3.1.1/src/nmath/nmath.h --- r-base-3.1.0/src/nmath/nmath.h 2014-03-12 23:03:19.000000000 +0000 +++ r-base-3.1.1/src/nmath/nmath.h 2014-06-02 22:15:04.000000000 +0000 @@ -53,8 +53,8 @@ #else # define R_forceint(x) round(x) #endif -# define R_nonint(x) (fabs((x) - R_forceint(x)) > 1e-7) - +//R >= 3.1.0: # define R_nonint(x) (fabs((x) - R_forceint(x)) > 1e-7) +# define R_nonint(x) (fabs((x) - R_forceint(x)) > 1e-7*fmax2(1., fabs(x))) #ifndef MATHLIB_STANDALONE @@ -64,6 +64,7 @@ # define MATHLIB_WARNING2(fmt,x,x2) warning(fmt,x,x2) # define MATHLIB_WARNING3(fmt,x,x2,x3) warning(fmt,x,x2,x3) # define MATHLIB_WARNING4(fmt,x,x2,x3,x4) warning(fmt,x,x2,x3,x4) +# define MATHLIB_WARNING5(fmt,x,x2,x3,x4,x5) warning(fmt,x,x2,x3,x4,x5) #include #define ML_POSINF R_PosInf @@ -100,6 +101,7 @@ #define MATHLIB_WARNING2(fmt,x,x2) printf(fmt,x,x2) #define MATHLIB_WARNING3(fmt,x,x2,x3) printf(fmt,x,x2,x3) #define MATHLIB_WARNING4(fmt,x,x2,x3,x4) printf(fmt,x,x2,x3,x4) +#define MATHLIB_WARNING5(fmt,x,x2,x3,x4,x5) printf(fmt,x,x2,x3,x4,x5) #define ISNAN(x) (isnan(x)!=0) #define R_FINITE(x) R_finite(x) @@ -195,7 +197,8 @@ double attribute_hidden dbinom_raw(double, double, double, double, int); double attribute_hidden dpois_raw (double, double, int); -double attribute_hidden pnchisq_raw(double, double, double, double, double, int, Rboolean); +double attribute_hidden pnchisq_raw(double, double, double, double, double, + int, Rboolean, Rboolean); double attribute_hidden pgamma_raw(double, double, int, int); double attribute_hidden pbeta_raw(double, double, double, int, int); double attribute_hidden qchisq_appr(double, double, double, int, int, double tol); diff -Nru r-base-3.1.0/src/nmath/pbeta.c r-base-3.1.1/src/nmath/pbeta.c --- r-base-3.1.0/src/nmath/pbeta.c 2012-04-15 22:05:36.000000000 +0000 +++ r-base-3.1.1/src/nmath/pbeta.c 2014-06-02 22:15:04.000000000 +0000 @@ -20,8 +20,8 @@ * * #include * - * double pbeta_raw(double x, double pin, double qin, int lower_tail, int log_p) - * double pbeta (double x, double pin, double qin, int lower_tail, int log_p) + * double pbeta_raw(double x, double a, double b, int lower_tail, int log_p) + * double pbeta (double x, double a, double b, int lower_tail, int log_p) * * DESCRIPTION * @@ -38,28 +38,50 @@ #include "dpq.h" attribute_hidden -double pbeta_raw(double x, double pin, double qin, int lower_tail, int log_p) +double pbeta_raw(double x, double a, double b, int lower_tail, int log_p) { + // treat limit cases correctly here: + if(a == 0 || b == 0 || !R_FINITE(a) || !R_FINITE(b)) { + // NB: 0 < x < 1 : + if(a == 0 && b == 0) // point mass 1/2 at each of {0,1} : + return (log_p ? -M_LN2 : 0.5); + if (a == 0 || a/b == 0) // point mass 1 at 0 ==> P(X <= x) = 1, all x > 0 + return R_DT_1; + if (b == 0 || b/a == 0) // point mass 1 at 1 ==> P(X <= x) = 0, all x < 1 + return R_DT_0; + // else, remaining case: a = b = Inf : point mass 1 at 1/2 + if (x < 0.5) + return R_DT_0; + // else, x >= 0.5 : + return R_DT_1; + } + // Now: 0 < a < Inf; 0 < b < Inf + double x1 = 0.5 - x + 0.5, w, wc; int ierr; - bratio(pin, qin, x, x1, &w, &wc, &ierr, log_p); /* -> ./toms708.c */ + //==== + bratio(a, b, x, x1, &w, &wc, &ierr, log_p); /* -> ./toms708.c */ + //==== /* ierr = 8 is about inaccuracy in extreme cases */ if(ierr && (ierr != 8 || log_p) ) - MATHLIB_WARNING(_("pbeta_raw() -> bratio() gave error code %d"), ierr); + MATHLIB_WARNING4(_("pbeta_raw(%g, a=%g, b=%g, ..) -> bratio() gave error code %d"), + x, a,b, ierr); return lower_tail ? w : wc; } /* pbeta_raw() */ -double pbeta(double x, double pin, double qin, int lower_tail, int log_p) +double pbeta(double x, double a, double b, int lower_tail, int log_p) { #ifdef IEEE_754 - if (ISNAN(x) || ISNAN(pin) || ISNAN(qin)) return x + pin + qin; + if (ISNAN(x) || ISNAN(a) || ISNAN(b)) return x + a + b; #endif - if (pin <= 0 || qin <= 0) ML_ERR_return_NAN; + if (a < 0 || b < 0) ML_ERR_return_NAN; + // allowing a==0 and b==0 <==> treat as one- or two-point mass if (x <= 0) return R_DT_0; if (x >= 1) return R_DT_1; - return pbeta_raw(x, pin, qin, lower_tail, log_p); + + return pbeta_raw(x, a, b, lower_tail, log_p); } diff -Nru r-base-3.1.0/src/nmath/pbinom.c r-base-3.1.1/src/nmath/pbinom.c --- r-base-3.1.0/src/nmath/pbinom.c 2014-03-12 23:03:20.000000000 +0000 +++ r-base-3.1.1/src/nmath/pbinom.c 2014-04-22 22:15:04.000000000 +0000 @@ -33,7 +33,10 @@ if (!R_FINITE(n) || !R_FINITE(p)) ML_ERR_return_NAN; #endif - if(R_nonint(n)) ML_ERR_return_NAN; + if(R_nonint(n)) { + MATHLIB_WARNING("non-integer n = %f", n); + ML_ERR_return_NAN; + } n = R_forceint(n); /* PR#8560: n=0 is a valid value */ if(n < 0 || p < 0 || p > 1) ML_ERR_return_NAN; diff -Nru r-base-3.1.0/src/nmath/pnchisq.c r-base-3.1.1/src/nmath/pnchisq.c --- r-base-3.1.0/src/nmath/pnchisq.c 2014-03-12 23:03:20.000000000 +0000 +++ r-base-3.1.1/src/nmath/pnchisq.c 2014-04-22 22:15:04.000000000 +0000 @@ -11,16 +11,19 @@ * distribution function. Appl.Statist., 41, 478-482. * Other parts - * Copyright (C) 2000-2013 The R Core Team - * Copyright (C) 2003-2009 The R Foundation + * Copyright (C) 2000-2014 The R Core Team + * Copyright (C) 2003-2014 The R Foundation */ + + #include "nmath.h" #include "dpq.h" /*----------- DEBUGGING ------------- * * make CFLAGS='-DDEBUG_pnch ....' +(cd ~/R/D/r-devel/debian-64-inst/src/nmath; gcc -I. -I../../src/include -I../../../R/src/include -I/usr/local/include -DHAVE_CONFIG_H -DDEBUG_pnch -fopenmp -g -pedantic -Wall --std=gnu99 -DDEBUG_q -Wcast-align -Wclobbered -c ../../../R/src/nmath/pnchisq.c -o pnchisq.o ) * -- Feb.6, 2000 (R pre0.99); M.Maechler: still have * bad precision & non-convergence in some cases (x ~= f, both LARGE) @@ -29,11 +32,17 @@ #ifdef HAVE_LONG_DOUBLE # define EXP expl # define FABS fabsl +# define LOG logl #else # define EXP exp # define FABS fabs +# define LOG log #endif +static const double _dbl_min_exp = M_LN2 * DBL_MIN_EXP; +/*= -708.3964 for IEEE double precision */ + + double pnchisq(double x, double df, double ncp, int lower_tail, int log_p) { double ans; @@ -46,26 +55,33 @@ if (df < 0. || ncp < 0.) ML_ERR_return_NAN; - ans = pnchisq_raw(x, df, ncp, 1e-12, 8*DBL_EPSILON, 1000000, lower_tail); + ans = pnchisq_raw(x, df, ncp, 1e-12, 8*DBL_EPSILON, 1000000, lower_tail, log_p); if(ncp >= 80) { if(lower_tail) { - ans = fmin2(ans, 1.0); /* e.g., pchisq(555, 1.01, ncp = 80) */ + ans = fmin2(ans, R_D__1); /* e.g., pchisq(555, 1.01, ncp = 80) */ } else { /* !lower_tail */ /* since we computed the other tail cancellation is likely */ - if(ans < 1e-10) ML_ERROR(ME_PRECISION, "pnchisq"); - ans = fmax2(ans, 0.0); /* Precaution PR#7099 */ + if(ans < (log_p ? (-10. * M_LN10) : 1e-10)) ML_ERROR(ME_PRECISION, "pnchisq"); + if(!log_p) ans = fmax2(ans, 0.0); /* Precaution PR#7099 */ } } - if (!log_p) return ans; - /* if ans is near one, we can do better using the other tail */ - if (ncp >= 80 || ans < 1 - 1e-8) return log(ans); - ans = pnchisq_raw(x, df, ncp, 1e-12, 8*DBL_EPSILON, 1000000, !lower_tail); - return log1p(-ans); + if (!log_p || ans < -1e-8) + return ans; + else { // log_p && ans > -1e-8 + // prob. = exp(ans) is near one: we can do better using the other tail +#ifdef DEBUG_pnch + REprintf(" pnchisq_raw(*, log_p): ans=%g => 2nd call, other tail\n", ans); +#endif + // FIXME: (sum,sum2) will be the same (=> return them as well and reuse here ?) + ans = pnchisq_raw(x, df, ncp, 1e-12, 8*DBL_EPSILON, 1000000, !lower_tail, FALSE); + return log1p(-ans); + } } double attribute_hidden pnchisq_raw(double x, double f, double theta /* = ncp */, - double errmax, double reltol, int itrmax, Rboolean lower_tail) + double errmax, double reltol, int itrmax, + Rboolean lower_tail, Rboolean log_p) { double lam, x2, f2, term, bound, f_x_2n, f_2n; double l_lam = -1., l_x = -1.; /* initialized for -Wall */ @@ -73,9 +89,6 @@ Rboolean lamSml, tSml, is_r, is_b, is_it; LDOUBLE ans, u, v, t, lt, lu =-1; - static const double _dbl_min_exp = M_LN2 * DBL_MIN_EXP; - /*= -708.3964 for IEEE double precision */ - if (x <= 0.) { if(x == 0. && f == 0.) return lower_tail ? exp(-0.5*theta) : -expm1(-0.5*theta); @@ -90,29 +103,60 @@ #endif if(theta < 80) { /* use 110 for Inf, as ppois(110, 80/2, lower.tail=FALSE) is 2e-20 */ - LDOUBLE sum = 0, sum2 = 0, lambda = 0.5*theta, - pr = EXP(-lambda); // does this need a feature test? - double ans; + LDOUBLE sum, sum2, lambda = 0.5 * theta, pr, ans; int i; - /* we need to renormalize here: the result could be very close to 1 */ - for(i = 0; i < 110; pr *= lambda/++i) { - // pr == exp(-lambda) lambda^i / i! == dpois(i, lambda) - sum2 += pr; - sum += pr * pchisq(x, f+2*i, lower_tail, FALSE); - if (sum2 >= 1-1e-15) break; + // Have pgamma(x,s) < x^s / Gamma(s+1) (< and ~= for small x) + // ==> pchisq(x, f) = pgamma(x, f/2, 2) = pgamma(x/2, f/2) + // < (x/2)^(f/2) / Gamma(f/2+1) < eps + // <==> f/2 * log(x/2) - log(Gamma(f/2+1)) < log(eps) ( ~= -708.3964 ) + // <==> log(x/2) < 2/f*(log(Gamma(f/2+1)) + log(eps)) + // <==> log(x) < log(2) + 2/f*(log(Gamma(f/2+1)) + log(eps)) + if(lower_tail && f > 0. && + log(x) < M_LN2 + 2/f*(lgamma(f/2. + 1) + _dbl_min_exp)) { + // all pchisq(x, f+2*i, lower_tail, FALSE), i=0,...,110 would underflow to 0. + // ==> work in log scale + sum = sum2 = ML_NEGINF; + pr = -lambda; + /* we need to renormalize here: the result could be very close to 1 */ + for(i = 0; i < 110; pr += LOG(lambda) - LOG(++i)) { + sum2 = logspace_add(sum2, pr); + sum = logspace_add(sum, pr + pchisq(x, f+2*i, lower_tail, TRUE)); + if (sum2 >= -1e-15) /*<=> EXP(sum2) >= 1-1e-15 */ break; + } + ans = sum - sum2; +#ifdef DEBUG_pnch + REprintf("pnchisq(x=%g, f=%g, th.=%g); th. < 80, logspace: i=%d, ans=(sum=%g)-(sum2=%g)\n", + x,f,theta, i, (double)sum, (double)sum2); +#endif + return (double) (log_p ? ans : EXP(ans)); } - ans = (double) (sum/sum2); + else { + sum = sum2 = 0; + pr = EXP(-lambda); // does this need a feature test? + /* we need to renormalize here: the result could be very close to 1 */ + for(i = 0; i < 110; pr *= lambda/++i) { + // pr == exp(-lambda) lambda^i / i! == dpois(i, lambda) + sum2 += pr; + // pchisq(*, i, *) is strictly decreasing to 0 for lower_tail=TRUE + // and strictly increasing to 1 for lower_tail=FALSE + sum += pr * pchisq(x, f+2*i, lower_tail, FALSE); + if (sum2 >= 1-1e-15) break; + } + ans = sum/sum2; #ifdef DEBUG_pnch - REprintf("pnchisq(x=%g, f=%g, theta=%g); theta < 80: i = %d, sum2 = %g\n", - x,f,theta, i, sum2); + REprintf("pnchisq(x=%g, f=%g, theta=%g); theta < 80: i=%d, sum=%g, sum2=%g\n", + x,f,theta, i, (double)sum, (double)sum2); #endif - return ans; - } - + return (double) (log_p ? LOG(ans) : ans); + } + } // if(theta < 80) + // else: theta == ncp >= 80 -------------------------------------------- #ifdef DEBUG_pnch - REprintf("pnchisq(x=%g, f=%g, theta=%g): ",x,f,theta); + REprintf("pnchisq(x=%g, f=%g, theta=%g >= 80): ",x,f,theta); #endif + // Series expansion ------- FIXME: log_p=TRUE, lower_tail=FALSE only applied at end + lam = .5 * theta; lamSml = (-lam < _dbl_min_exp); if(lamSml) { @@ -156,9 +200,12 @@ tSml = (lt < _dbl_min_exp); if(tSml) { +#ifdef DEBUG_pnch + REprintf(" is very small\n"); +#endif if (x > f + theta + 5* sqrt( 2*(f + 2*theta))) { /* x > E[X] + 5* sigma(X) */ - return lower_tail ? 1. : 0.; /* FIXME: We could be more accurate than 0. */ + return R_DT_1; /* FIXME: could be more accurate than 0. */ } /* else */ l_x = log(x); ans = term = 0.; t = 0; @@ -172,7 +219,7 @@ } for (n = 1, f_2n = f + 2., f_x_2n += 2.; ; n++, f_2n += 2, f_x_2n += 2) { -#ifdef DEBUG_pnch +#ifdef DEBUG_pnch_n REprintf("\n _OL_: n=%d",n); #endif #ifndef MATHLIB_STANDALONE @@ -184,7 +231,7 @@ /* find the error bound and check for convergence */ bound = (double) (t * x / f_x_2n); -#ifdef DEBUG_pnch +#ifdef DEBUG_pnch_n REprintf("\n L10: n=%d; term= %g; bound= %g",n,term,bound); #endif is_r = is_it = FALSE; @@ -210,7 +257,7 @@ lu += l_lam - log(n); /* u = u* lam / n */ if(lu >= _dbl_min_exp) { /* no underflow anymore ==> change regime */ -#ifdef DEBUG_pnch +#ifdef DEBUG_pnch_n REprintf(" n=%d; nomore underflow in u = exp(lu) ==> change\n", n); #endif @@ -226,8 +273,7 @@ if(lt >= _dbl_min_exp) { /* no underflow anymore ==> change regime */ #ifdef DEBUG_pnch - REprintf(" n=%d; nomore underflow in t = exp(lt) ==> change\n", - n); + REprintf(" n=%d; nomore underflow in t = exp(lt) ==> change\n", n); #endif t = EXP(lt); /* the first non-0 't' */ tSml = FALSE; @@ -249,5 +295,5 @@ #ifdef DEBUG_pnch REprintf("\n == L_End: n=%d; term= %g; bound=%g\n",n,term,bound); #endif - return (double) (lower_tail ? ans : 1 - ans); + return (double) R_DT_val(ans); } diff -Nru r-base-3.1.0/src/nmath/qbeta.c r-base-3.1.1/src/nmath/qbeta.c --- r-base-3.1.0/src/nmath/qbeta.c 2014-03-12 23:03:19.000000000 +0000 +++ r-base-3.1.1/src/nmath/qbeta.c 2014-05-15 22:15:05.000000000 +0000 @@ -65,6 +65,30 @@ R_Q_P01_boundaries(alpha, 0, 1); p_ = R_DT_qIv(alpha);/* lower_tail prob (in any case) */ + // Conceptually, 0 < p_ < 1 (but can be 0 or 1 because of cancellation!) + + // p==0, q==0, p = Inf, q = Inf <==> treat as one- or two-point mass + if(p == 0 || q == 0 || !R_FINITE(p) || !R_FINITE(q)) { + // We know 0 < p_ < 1 : pbeta() is constant and trivial in {0, 1/2, 1} +#ifdef DEBUG_qbeta + REprintf( + "qbeta(%g, %g, %g, lower_t=%d, log_p=%d): (p,q)-boundary: trivial\n", + alpha, p,q, lower_tail, log_p); +#endif + if(p == 0 && q == 0) { // point mass 1/2 at each of {0,1} : + if(alpha < R_D_half) return 0.; + if(alpha > R_D_half) return 1.; + // else: alpha == "1/2" + return 0.5; + } else if (p == 0 || p/q == 0) { // point mass 1 at 0 - "flipped around" + return 0.; + } else if (q == 0 || q/p == 0) { // point mass 1 at 0 - "flipped around" + return 1; + } + // else: p = q = Inf : point mass 1 at 1/2 + return 0.5; + } + if(log_p && (p_ == 0. || p_ == 1.)) return p_; /* better than NaN or infinite loop; diff -Nru r-base-3.1.0/src/nmath/qnchisq.c r-base-3.1.1/src/nmath/qnchisq.c --- r-base-3.1.0/src/nmath/qnchisq.c 2012-04-15 22:05:35.000000000 +0000 +++ r-base-3.1.1/src/nmath/qnchisq.c 2014-04-22 22:15:04.000000000 +0000 @@ -72,24 +72,24 @@ if(p > 1 - DBL_EPSILON) return ML_POSINF; pp = fmin2(1 - DBL_EPSILON, p * (1 + Eps)); for(; ux < DBL_MAX && - pnchisq_raw(ux, df, ncp, Eps, rEps, 10000, TRUE) < pp; + pnchisq_raw(ux, df, ncp, Eps, rEps, 10000, TRUE, FALSE) < pp; ux *= 2); pp = p * (1 - Eps); for(lx = fmin2(ux0, DBL_MAX); lx > DBL_MIN && - pnchisq_raw(lx, df, ncp, Eps, rEps, 10000, TRUE) > pp; + pnchisq_raw(lx, df, ncp, Eps, rEps, 10000, TRUE, FALSE) > pp; lx *= 0.5); } else { if(p > 1 - DBL_EPSILON) return 0.0; pp = fmin2(1 - DBL_EPSILON, p * (1 + Eps)); for(; ux < DBL_MAX && - pnchisq_raw(ux, df, ncp, Eps, rEps, 10000, FALSE) > pp; + pnchisq_raw(ux, df, ncp, Eps, rEps, 10000, FALSE, FALSE) > pp; ux *= 2); pp = p * (1 - Eps); for(lx = fmin2(ux0, DBL_MAX); lx > DBL_MIN && - pnchisq_raw(lx, df, ncp, Eps, rEps, 10000, FALSE) < pp; + pnchisq_raw(lx, df, ncp, Eps, rEps, 10000, FALSE, FALSE) < pp; lx *= 0.5); } @@ -97,7 +97,7 @@ if(lower_tail) { do { nx = 0.5 * (lx + ux); - if (pnchisq_raw(nx, df, ncp, accu, racc, 100000, TRUE) > p) + if (pnchisq_raw(nx, df, ncp, accu, racc, 100000, TRUE, FALSE) > p) ux = nx; else lx = nx; @@ -106,7 +106,7 @@ } else { do { nx = 0.5 * (lx + ux); - if (pnchisq_raw(nx, df, ncp, accu, racc, 100000, FALSE) < p) + if (pnchisq_raw(nx, df, ncp, accu, racc, 100000, FALSE, FALSE) < p) ux = nx; else lx = nx; diff -Nru r-base-3.1.0/src/nmath/rbeta.c r-base-3.1.1/src/nmath/rbeta.c --- r-base-3.1.0/src/nmath/rbeta.c 2012-04-15 22:05:36.000000000 +0000 +++ r-base-3.1.1/src/nmath/rbeta.c 2014-05-15 22:15:05.000000000 +0000 @@ -32,9 +32,20 @@ double rbeta(double aa, double bb) { + if (aa < 0. || bb < 0.) + ML_ERR_return_NAN; + if (!R_FINITE(aa) && !R_FINITE(bb)) // a = b = Inf : all mass at 1/2 + return 0.5; + if (aa == 0. && bb == 0.) // point mass 1/2 at each of {0,1} : + return (unif_rand() < 0.5) ? 0. : 1.; + // now, at least one of a, b is finite and positive + if (!R_FINITE(aa) || bb == 0.) + return 1.0; + if (!R_FINITE(bb) || aa == 0.) + return 0.0; + double a, b, alpha; double r, s, t, u1, u2, v, w, y, z; - int qsame; /* FIXME: Keep Globals (properly) for threading */ /* Uses these GLOBALS to save time when many rv's are generated : */ @@ -42,15 +53,6 @@ static double olda = -1.0; static double oldb = -1.0; - if (aa <= 0. || bb <= 0. || (!R_FINITE(aa) && !R_FINITE(bb))) - ML_ERR_return_NAN; - - if (!R_FINITE(aa)) - return 1.0; - - if (!R_FINITE(bb)) - return 0.0; - /* Test if we need new "initializing" */ qsame = (olda == aa) && (oldb == bb); if (!qsame) { olda = aa; oldb = bb; } diff -Nru r-base-3.1.0/src/nmath/toms708.c r-base-3.1.1/src/nmath/toms708.c --- r-base-3.1.0/src/nmath/toms708.c 2014-01-17 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/nmath/toms708.c 2014-06-02 22:15:04.000000000 +0000 @@ -26,8 +26,10 @@ (cd `R-devel-pbeta-dbg RHOME`/src/nmath ; gcc -I. -I../../src/include -I../../../R/src/include -DHAVE_CONFIG_H -fopenmp -g -pedantic -Wall --std=gnu99 -DDEBUG_q -DDEBUG_bratio -Wcast-align -Wclobbered -c ../../../R/src/nmath/toms708.c -o toms708.o; cd ../..; make R) */ #ifdef DEBUG_bratio -/* for REprintf */ # include +# define R_ifDEBUG_printf(...) REprintf(__VA_ARGS__) +#else +# define R_ifDEBUG_printf(...) #endif /* MM added R_D_LExp, so redefine here in terms of rexpm1 */ @@ -130,10 +132,8 @@ if (fabs(z) > eps * 3.0) { *ierr = 5; return; } -#ifdef DEBUG_bratio - REprintf("bratio(a=%g, b=%g, x=%9g, y=%9g, .., log_p=%d): ", a,b,x,y, log_p); -#endif - + R_ifDEBUG_printf("bratio(a=%g, b=%g, x=%9g, y=%9g, .., log_p=%d): ", + a,b,x,y, log_p); *ierr = 0; if (x == 0.0) goto L200; if (y == 0.0) goto L210; @@ -159,9 +159,7 @@ *w1 = a / (a + b); } -#ifdef DEBUG_bratio - REprintf("a & b very small -> simple ratios (%g,%g)\n", *w,*w1); -#endif + R_ifDEBUG_printf("a & b very small -> simple ratios (%g,%g)\n", *w,*w1); return; } @@ -183,32 +181,24 @@ } /* now have x0 <= 1/2 <= y0 (still x0+y0 == 1) */ -#ifdef DEBUG_bratio - REprintf(" min(a,b) <= 1, do_swap=%d;", do_swap); -#endif + R_ifDEBUG_printf(" min(a,b) <= 1, do_swap=%d;", do_swap); if (b0 < min(eps, eps * a0)) { /* L80: */ *w = fpser(a0, b0, x0, eps, log_p); *w1 = log_p ? R_Log1_Exp(*w) : 0.5 - *w + 0.5; -#ifdef DEBUG_bratio - REprintf(" b0 small -> w := fpser(*) = %.15g\n", *w); -#endif + R_ifDEBUG_printf(" b0 small -> w := fpser(*) = %.15g\n", *w); goto L_end; } if (a0 < min(eps, eps * b0) && b0 * x0 <= 1.0) { /* L90: */ *w1 = apser(a0, b0, x0, eps); -#ifdef DEBUG_bratio - REprintf(" a0 small -> w1 := apser(*) = %.15g\n", *w1); -#endif + R_ifDEBUG_printf(" a0 small -> w1 := apser(*) = %.15g\n", *w1); goto L_end_from_w1; } Rboolean did_bup = FALSE; if (max(a0,b0) > 1.0) { /* L20: min(a,b) <= 1 < max(a,b) */ -#ifdef DEBUG_bratio - REprintf("\n L20: min(a,b) <= 1 < max(a,b); "); -#endif + R_ifDEBUG_printf("\n L20: min(a,b) <= 1 < max(a,b); "); if (b0 <= 1.0) goto L_w_bpser; if (x0 >= 0.29) /* was 0.3, PR#13786 */ goto L_w1_bpser; @@ -220,9 +210,7 @@ goto L131; } } else { /* a, b <= 1 */ -#ifdef DEBUG_bratio - REprintf("\n both a,b <= 1; "); -#endif + R_ifDEBUG_printf("\n both a,b <= 1; "); if (a0 >= min(0.2, b0)) goto L_w_bpser; if (pow(x0, a0) <= 0.9) goto L_w_bpser; @@ -231,26 +219,20 @@ } n = 20; /* goto L130; */ *w1 = bup(b0, a0, y0, x0, n, eps, FALSE); did_bup = TRUE; -#ifdef DEBUG_bratio - REprintf(" ... n=20 and *w1 := bup(*) = %.15g; ", *w1); -#endif + R_ifDEBUG_printf(" ... n=20 and *w1 := bup(*) = %.15g; ", *w1); b0 += n; L131: -#ifdef DEBUG_bratio - REprintf(" L131: bgrat(*, w1=%.15g) ", *w1); -#endif + R_ifDEBUG_printf(" L131: bgrat(*, w1=%.15g) ", *w1); bgrat(b0, a0, y0, x0, w1, 15*eps, &ierr1, FALSE); - if(ierr1) *ierr = 8; #ifdef DEBUG_bratio REprintf(" ==> new w1=%.15g", *w1); if(ierr1) REprintf(" ERROR(code=%d)\n", ierr1) ; else REprintf("\n"); #endif - if(*w1 == 0.) { // "almost surely" from underflow, try more: [2013-03-04] + if(*w1 == 0 || (0 < *w1 && *w1 < 1e-310)) { // w1=0 or very close: + // "almost surely" from underflow, try more: [2013-03-04] // FIXME: it is even better to do this in bgrat *directly* at least for the case // !did_bup, i.e., where *w1 = (0 or -Inf) on entry -#ifdef DEBUG_bratio - REprintf(" underflow? -> retrying: "); -#endif + R_ifDEBUG_printf(" denormalized or underflow (?) -> retrying: "); if(did_bup) { // re-do that part on log scale: *w1 = bup(b0-n, a0, y0, x0, n, eps, TRUE); } @@ -264,6 +246,7 @@ goto L_end_from_w1_log; } // else + if(ierr1) *ierr = 8; if(*w1 < 0) MATHLIB_WARNING4("bratio(a=%g, b=%g, x=%g): bgrat() -> w1 = %g", a,b,x, *w1); @@ -284,15 +267,11 @@ SET_0_noswap; } -#ifdef DEBUG_bratio - REprintf(" L30: both a, b > 1; |lambda| = %#g, do_swap = %d\n", - lambda, do_swap); -#endif + R_ifDEBUG_printf(" L30: both a, b > 1; |lambda| = %#g, do_swap = %d\n", + lambda, do_swap); if (b0 < 40.0) { -#ifdef DEBUG_bratio - REprintf(" b0 < 40;"); -#endif + R_ifDEBUG_printf(" b0 < 40;"); if (b0 * x0 <= 0.7 || (log_p && lambda > 650.)) /* << added 2010-03-18 */ goto L_w_bpser; @@ -300,32 +279,24 @@ goto L140; } else if (a0 > b0) { /* ---- a0 > b0 >= 40 ---- */ -#ifdef DEBUG_bratio - REprintf(" a0 > b0 >= 40;"); -#endif + R_ifDEBUG_printf(" a0 > b0 >= 40;"); if (b0 <= 100.0 || lambda > b0 * 0.03) goto L_bfrac; } else if (a0 <= 100.0) { -#ifdef DEBUG_bratio - REprintf(" a0 <= 100; a0 <= b0 >= 40;"); -#endif + R_ifDEBUG_printf(" a0 <= 100; a0 <= b0 >= 40;"); goto L_bfrac; } else if (lambda > a0 * 0.03) { -#ifdef DEBUG_bratio - REprintf(" b0 >= a0 > 100; lambda > a0 * 0.03 "); -#endif + R_ifDEBUG_printf(" b0 >= a0 > 100; lambda > a0 * 0.03 "); goto L_bfrac; } /* else if none of the above L180: */ *w = basym(a0, b0, lambda, eps * 100.0, log_p); *w1 = log_p ? R_Log1_Exp(*w) : 0.5 - *w + 0.5; -#ifdef DEBUG_bratio - REprintf(" b0 >= a0 > 100; lambda <= a0 * 0.03: *w:= basym(*) =%.15g\n", - *w); -#endif + R_ifDEBUG_printf(" b0 >= a0 > 100; lambda <= a0 * 0.03: *w:= basym(*) =%.15g\n", + *w); goto L_end; } /* else: a, b > 1 */ @@ -335,25 +306,19 @@ L_w_bpser: // was L100 *w = bpser(a0, b0, x0, eps, log_p); *w1 = log_p ? R_Log1_Exp(*w) : 0.5 - *w + 0.5; -#ifdef DEBUG_bratio - REprintf(" L_w_bpser: *w := bpser(*) = %.15g\n", *w); -#endif + R_ifDEBUG_printf(" L_w_bpser: *w := bpser(*) = %.15g\n", *w); goto L_end; L_w1_bpser: // was L110 *w1 = bpser(b0, a0, y0, eps, log_p); *w = log_p ? R_Log1_Exp(*w1) : 0.5 - *w1 + 0.5; -#ifdef DEBUG_bratio - REprintf(" L_w1_bpser: *w1 := bpser(*) = %.15g\n", *w1); -#endif + R_ifDEBUG_printf(" L_w1_bpser: *w1 := bpser(*) = %.15g\n", *w1); goto L_end; L_bfrac: *w = bfrac(a0, b0, x0, y0, lambda, eps * 15.0, log_p); *w1 = log_p ? R_Log1_Exp(*w) : 0.5 - *w + 0.5; -#ifdef DEBUG_bratio - REprintf(" L_bfrac: *w := bfrac(*) = %g\n", *w); -#endif + R_ifDEBUG_printf(" L_bfrac: *w := bfrac(*) = %g\n", *w); goto L_end; L140: @@ -366,9 +331,7 @@ *w = bup(b0, a0, y0, x0, n, eps, FALSE); -#ifdef DEBUG_bratio - REprintf(" L140: *w := bup(b0=%g,..) = %.15g; ", b0, *w); -#endif + R_ifDEBUG_printf(" L140: *w := bup(b0=%g,..) = %.15g; ", b0, *w); if(*w < DBL_MIN && log_p) { /* do not believe it; try bpser() : */ /*revert: */ b0 += n; /* which is only valid if b0 <= 1 || b0*x0 <= 0.7 */ @@ -377,23 +340,17 @@ if (x0 <= 0.7) { /* log_p : TODO: w = bup(.) + bpser(.) -- not so easy to use log-scale */ *w += bpser(a0, b0, x0, eps, /* log_p = */ FALSE); -#ifdef DEBUG_bratio - REprintf(" x0 <= 0.7: *w := *w + bpser(*) = %.15g\n", *w); -#endif + R_ifDEBUG_printf(" x0 <= 0.7: *w := *w + bpser(*) = %.15g\n", *w); goto L_end_from_w; } /* L150: */ if (a0 <= 15.0) { n = 20; *w += bup(a0, b0, x0, y0, n, eps, FALSE); -#ifdef DEBUG_bratio - REprintf("\n a0 <= 15: *w := *w + bup(*) = %.15g;", *w); -#endif + R_ifDEBUG_printf("\n a0 <= 15: *w := *w + bup(*) = %.15g;", *w); a0 += n; } -#ifdef DEBUG_bratio - REprintf(" bgrat(*, w=%.15g) ", *w); -#endif + R_ifDEBUG_printf(" bgrat(*, w=%.15g) ", *w); bgrat(a0, b0, x0, y0, w, 15*eps, &ierr1, FALSE); if(ierr1) *ierr = 8; #ifdef DEBUG_bratio @@ -600,7 +557,7 @@ } z = a * log(x) - u; - b0 += -1.0; + b0 += -1.0; // => b0 in (0, 7) apb = a0 + b0; if (apb > 1.0) { u = a0 + b0 - 1.; @@ -626,8 +583,9 @@ ans = a0 / a * exp(z); } } - - if (!log_p && (ans == 0.0 || a <= eps * 0.1)) { + R_ifDEBUG_printf(" bpser(a=%g, b=%g, x=%g, log=%d): prelim.ans = %.14g;\n", + a,b,x, log_p, ans); + if (ans == R_D__0 || (!log_p && a <= eps * 0.1)) { return ans; } @@ -644,8 +602,18 @@ c *= (0.5 - b / n + 0.5) * x; w = c / (a + n); sum += w; - } while (fabs(w) > tol); - + } while (n < 1e7 && fabs(w) > tol); + if(fabs(w) > tol) { // the series did not converge (in time) + // warn only when the result seems to matter: + if(( log_p && !(a*sum > -1. && fabs(log1p(a * sum)) < eps*fabs(ans))) || + (!log_p && fabs(a*sum + 1) != 1.)) + MATHLIB_WARNING5( + " bpser(a=%g, b=%g, x=%g,...) did not converge (n=1e7, |w|/tol=%g > 1; A=%g)", + a,b,x, fabs(w)/tol, ans); + } + R_ifDEBUG_printf(" -> n=%.0f iterations, |w|=%g %s %g=tol:=eps/a ==> a*sum=%g\n", + n, fabs(w), (fabs(w) > tol) ? ">!!>" : "<=", + tol, a*sum); if(log_p) { if (a*sum > -1.0) ans += log1p(a * sum); else ans = ML_NEGINF; @@ -995,9 +963,7 @@ if (b0 >= 8.0) { /* L80: ALGORITHM FOR b0 >= 8 */ u = gamln1(a0) + algdiv(a0, b0); -#ifdef DEBUG_bratio - REprintf(" brcmp1(mu,a,b,*): a0 < 1, b0 >= 8; z=%.15g\n", z); -#endif + R_ifDEBUG_printf(" brcmp1(mu,a,b,*): a0 < 1, b0 >= 8; z=%.15g\n", z); return give_log ? log(a0) + esum(mu, z - u, TRUE) : a0 * esum(mu, z - u, FALSE); @@ -1020,9 +986,7 @@ c = give_log ? log1p(gam1(a)) + log1p(gam1(b)) - log(z) : (gam1(a) + 1.0) * (gam1(b) + 1.0) / z; -#ifdef DEBUG_bratio - REprintf(" brcmp1(mu,a,b,*): a0 < 1, b0 <= 1; c=%.15g\n", c); -#endif + R_ifDEBUG_printf(" brcmp1(mu,a,b,*): a0 < 1, b0 <= 1; c=%.15g\n", c); return give_log ? ans + log(a0) + c - log1p(a0 / b0) : ans * (a0 * c) / (a0 / b0 + 1.0); @@ -1050,9 +1014,7 @@ } else { t = gam1(apb) + 1.0; } -#ifdef DEBUG_bratio - REprintf(" brcmp1(mu,a,b,*): a0 < 1 < b0 < 8; t=%.15g\n", t); -#endif + R_ifDEBUG_printf(" brcmp1(mu,a,b,*): a0 < 1 < b0 < 8; t=%.15g\n", t); // L72: return give_log ? log(a0)+ esum(mu, z, TRUE) + log1p(gam1(b0)) - log(t) // TODO? log(t) = log1p(..) @@ -1079,10 +1041,8 @@ } double lx0 = -log1p(b/a); // in both cases -#ifdef DEBUG_bratio - REprintf(" brcmp1(mu,a,b,*): a,b >= 8; x0=%.15g, lx0=log(x0)=%.15g\n", - x0, lx0); -#endif + R_ifDEBUG_printf(" brcmp1(mu,a,b,*): a,b >= 8; x0=%.15g, lx0=log(x0)=%.15g\n", + x0, lx0); // L110: double e = -lambda / a; if (fabs(e) > 0.6) { @@ -1120,9 +1080,9 @@ * eps is the tolerance used. * ierr is a variable that reports the status of the results. * -* TODO: if(log_w) , *w itself must be in log-space; +* if(log_w), *w itself must be in log-space; * compute w := w + I_x(a,b) but return *w = log(w): -* *w := log(exp(*w) + I_x(a,b)) = logspace_add(*w, log( I_x(a,b) ) +* *w := log(exp(*w) + I_x(a,b)) = logspace_add(*w, log( I_x(a,b) )) * ----------------------------------------------------------------------- */ #define n_terms_bgrat 30 @@ -1133,11 +1093,14 @@ lnx = (y > 0.375) ? log(x) : alnrel(-y), z = -nu * lnx; // z =: u in (9.1) of D.&M.(1992) - if (b * z == 0.0) { /* should *never* happen */ + if (b * z == 0.0) { // should not happen, but does, e.g., + // for pbeta(1e-320, 1e-5, 0.5) i.e., _subnormal_ x, + // Warning ... bgrat(a=20.5, b=1e-05, x=1, y=9.99989e-321): .. MATHLIB_WARNING4( - "bgrat(a=%g, b=%g, x=%g, y=%g): b*z == 0 should not happen: please report", + "bgrat(a=%g, b=%g, x=%g, y=%g): b*z == 0 underflow, hence inaccurate pbeta()", a,b,x,y); - /* L_Error: THE EXPANSION CANNOT BE COMPUTED */ *ierr = 1; return; + /* L_Error: THE EXPANSION CANNOT BE COMPUTED */ + *ierr = 1; return; } /* COMPUTATION OF THE EXPANSION */ @@ -1158,10 +1121,8 @@ u = exp(log_u); if (log_u == ML_NEGINF) { -#ifdef DEBUG_bratio - REprintf(" bgrat(*): underflow log_u = -Inf = log_r -u', log_r = %g ", - log_r); -#endif + R_ifDEBUG_printf(" bgrat(*): underflow log_u = -Inf = log_r -u', log_r = %g ", + log_r); /* L_Error: THE EXPANSION CANNOT BE COMPUTED */ *ierr = 2; return; } @@ -1171,9 +1132,8 @@ ? ((*w == ML_NEGINF) ? 0. : exp( *w - log_u)) : ((*w == 0.) ? 0. : exp(log(*w) - log_u)); -#ifdef DEBUG_bratio - REprintf(" bgrat(a=%g, b=%g, x=%g, *)\n -> u=%g, l='w/u'=%g, ", a,b,x, u, l); -#endif + R_ifDEBUG_printf(" bgrat(a=%g, b=%g, x=%g, *)\n -> u=%g, l='w/u'=%g, ", + a,b,x, u, l); double q_r = grat_r(b, z, log_r, eps), // = q/r of former grat1(b,z, r, &p, &q) v = 0.25 / (nu * nu), @@ -1201,17 +1161,15 @@ double dj = d[nm1] * j; sum += dj; if (sum <= 0.0) { -#ifdef DEBUG_bratio - REprintf(" bgrat(*): sum_n(..) <= 0; should not happen (n=%d)\n", n); -#endif + R_ifDEBUG_printf(" bgrat(*): sum_n(..) <= 0; should not happen (n=%d)\n", n); /* L_Error: THE EXPANSION CANNOT BE COMPUTED */ *ierr = 3; return; } if (fabs(dj) <= eps * (sum + l)) { break; - } else if(n == n_terms_bgrat) - MATHLIB_WARNING4( - "bgrat(a=%g, b=%g, x=%g,..): did *not* converge; rel.err=%g", - a,b,x, fabs(dj) /(sum + l)); + } else if(n == n_terms_bgrat) // never? ; please notify R-core if seen: + MATHLIB_WARNING5( + "bgrat(a=%g, b=%g, x=%g,..): did *not* converge; dj=%g, rel.err=%g\n", + a,b,x, dj, fabs(dj) /(sum + l)); } /* ADD THE RESULTS TO W */ @@ -1248,18 +1206,15 @@ /* L120: */ if (x < 0.25) { double p = erf__(sqrt(x)); -#ifdef DEBUG_bratio - REprintf(" grat_r(a=%g, x=%g ..)): a=1/2 --> p=erf__(.)= %g\n", a,x, p); -#endif + R_ifDEBUG_printf(" grat_r(a=%g, x=%g ..)): a=1/2 --> p=erf__(.)= %g\n", + a, x, p); return (0.5 - p + 0.5)*exp(-log_r); } else { // 2013-02-27: improvement for "large" x: direct computation of q/r: double sx = sqrt(x), q_r = erfc1(1, sx)/sx * M_SQRT_PI; -#ifdef DEBUG_bratio - REprintf(" grat_r(a=%g, x=%g ..)): a=1/2 --> q_r=erfc1(..)/r= %g\n", - a,x, q_r); -#endif + R_ifDEBUG_printf(" grat_r(a=%g, x=%g ..)): a=1/2 --> q_r=erfc1(..)/r= %g\n", + a,x, q_r); return q_r; } @@ -1276,10 +1231,8 @@ sum += t; } while (fabs(t) > tol); -#ifdef DEBUG_bratio - REprintf(" grat_r(a=%g, x=%g, log_r=%g): sum=%g; Taylor w/ %.0f terms", - a,x,log_r, sum, an-3.); -#endif + R_ifDEBUG_printf(" grat_r(a=%g, x=%g, log_r=%g): sum=%g; Taylor w/ %.0f terms", + a,x,log_r, sum, an-3.); double j = a * x * ((sum/6. - 0.5/(a + 2.)) * x + 1./(a + 1.)), z = a * log(x), h = gam1(a), @@ -1290,22 +1243,16 @@ double l = rexpm1(z), q = ((l + 0.5 + 0.5) * j - l) * g - h; if (q <= 0.0) { -#ifdef DEBUG_bratio - REprintf(" => q_r= 0.\n"); -#endif + R_ifDEBUG_printf(" => q_r= 0.\n"); /* L110:*/ return 0.; } else { -#ifdef DEBUG_bratio - REprintf(" => q_r=%.15g\n", q * exp(-log_r)); -#endif + R_ifDEBUG_printf(" => q_r=%.15g\n", q * exp(-log_r)); return q * exp(-log_r); } } else { double p = exp(z) * g * (0.5 - j + 0.5); -#ifdef DEBUG_bratio - REprintf(" => q_r=%.15g\n", (0.5 - p + 0.5) * exp(-log_r)); -#endif + R_ifDEBUG_printf(" => q_r=%.15g\n", (0.5 - p + 0.5) * exp(-log_r)); return /* q/r = */ (0.5 - p + 0.5) * exp(-log_r); } @@ -1329,10 +1276,8 @@ an0 = a2n / b2n; } while (fabs(an0 - am0) >= eps * an0); -#ifdef DEBUG_bratio - REprintf(" grat_r(a=%g, x=%g, log_r=%g): Cont.frac. %.0f terms => q_r=%.15g\n", - a,x, log_r, c-1., an0); -#endif + R_ifDEBUG_printf(" grat_r(a=%g, x=%g, log_r=%g): Cont.frac. %.0f terms => q_r=%.15g\n", + a,x, log_r, c-1., an0); return /* q/r = (r * an0)/r = */ an0; } } /* grat_r */ @@ -1762,9 +1707,9 @@ t = a; d = a - 0.5; - if (d > 0.0) { + // t := if(a > 1/2) a-1 else a + if (d > 0.0) t = d - 0.5; - } if (t < 0.0) { /* L30: */ static double r[9] = { -.422784335098468,-.771330383816272, @@ -1778,12 +1723,13 @@ ) * t + r[3]) * t + r[2]) * t + r[1]) * t + r[0]; bot = (s2 * t + s1) * t + 1.0; w = top / bot; + R_ifDEBUG_printf(" gam1(a = %.15g): t < 0: w=%.15g\n", a, w); if (d > 0.0) return t * w / a; else return a * (w + 0.5 + 0.5); - } else if (t == 0) { /* L10: */ + } else if (t == 0) { // L10: a in {0, 1} return 0.; } else { /* t > 0; L20: */ @@ -1798,6 +1744,8 @@ ) * t + p[1]) * t + p[0]; bot = (((q[4] * t + q[3]) * t + q[2]) * t + q[1]) * t + 1.0; w = top / bot; + R_ifDEBUG_printf(" gam1(a = %.15g): t > 0: (is a < 1.5 ?) w=%.15g\n", + a, w); if (d > 0.0) /* L21: */ return t / a * (w - 0.5 - 0.5); else diff -Nru r-base-3.1.0/src/scripts/config r-base-3.1.1/src/scripts/config --- r-base-3.1.0/src/scripts/config 2014-03-31 22:15:03.000000000 +0000 +++ r-base-3.1.1/src/scripts/config 2014-05-18 22:15:04.000000000 +0000 @@ -5,7 +5,7 @@ ## Usage: ## R CMD config [options] [VAR] -## Copyright (C) 2002-13 The R Core Team +## Copyright (C) 2002-2013 The R Core Team ## ## This document is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -20,11 +20,11 @@ ## A copy of the GNU General Public License is available at ## http://www.r-project.org/Licenses/ -revision='$Revision: 65341 $' +revision='$Revision: 65647 $' version=`set - ${revision}; echo ${2}` version="R configuration information retrieval script: ${R_VERSION} (r${version}) -Copyright (C) 2002-13 The R Core Team. +Copyright (C) 2002-2013 The R Core Team. This is free software; see the GNU General Public License version 2 or later for copying conditions. There is NO warranty." diff -Nru r-base-3.1.0/src/scripts/f77_f2c.in r-base-3.1.1/src/scripts/f77_f2c.in --- r-base-3.1.0/src/scripts/f77_f2c.in 2013-03-05 23:02:41.000000000 +0000 +++ r-base-3.1.1/src/scripts/f77_f2c.in 2014-05-18 22:15:04.000000000 +0000 @@ -6,7 +6,7 @@ ## Usage: ## R CMD f77 [options] files [objs] -## Copyright (C) 2002-5 The R Core Team +## Copyright (C) 2002-2005 The R Core Team ## ## This document is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -21,11 +21,11 @@ ## A copy of the GNU General Public License is available at ## http://www.r-project.org/Licenses/ -revision='$Rev: 59036 $' +revision='$Rev: 65645 $' version=`set - ${revision}; echo ${2}` version="R front-end script to f2c: ${R_VERSION} (r${version}) -Copyright (C) 2002-5 The R Core Team. +Copyright (C) 2002-2005 The R Core Team. This is free software; see the GNU General Public License version 2 or later for copying conditions. There is NO warranty." diff -Nru r-base-3.1.0/src/scripts/javareconf.in r-base-3.1.1/src/scripts/javareconf.in --- r-base-3.1.0/src/scripts/javareconf.in 2014-03-12 23:03:21.000000000 +0000 +++ r-base-3.1.1/src/scripts/javareconf.in 2014-05-18 22:15:04.000000000 +0000 @@ -9,11 +9,11 @@ DYLIB_EXT=`${R_HOME}/bin/R CMD config DYLIB_EXT` tools_classpath=${R_SHARE_DIR}/java -revision='$Rev: 63871 $' +revision='$Rev: 65645 $' version=`set - ${revision}; echo ${2}` version="R Java configurator: ${R_VERSION} (r${version}) -Copyright (C) 2002-13 The R Core Team. +Copyright (C) 2002-2013 The R Core Team. This is free software; see the GNU General Public License version 2 or later for copying conditions. There is NO warranty." diff -Nru r-base-3.1.0/src/unix/Rscript.c r-base-3.1.1/src/unix/Rscript.c --- r-base-3.1.0/src/unix/Rscript.c 2014-01-05 23:05:03.000000000 +0000 +++ r-base-3.1.1/src/unix/Rscript.c 2014-06-13 22:15:08.000000000 +0000 @@ -39,7 +39,7 @@ # include #endif -#ifdef WIN32 +#ifdef _WIN32 #include /* on some systems needs to be included before */ #endif @@ -70,7 +70,7 @@ # endif #endif -#ifndef WIN32 +#ifndef _WIN32 #ifndef R_ARCH /* R_ARCH should be always defined, but for safety ... */ #define R_ARCH "" #endif @@ -131,7 +131,7 @@ } p = getenv("RHOME"); -#ifdef WIN32 +#ifdef _WIN32 if(p && *p) snprintf(cmd, PATH_MAX+1, "%s\\%s\\Rterm.exe", p, BINDIR); else { @@ -233,7 +233,7 @@ if(!set_dp && !getenv("R_DEFAULT_PACKAGES")) putenv("R_DEFAULT_PACKAGES=datasets,utils,grDevices,graphics,stats"); -#ifndef WIN32 +#ifndef _WIN32 /* pass on r_arch from this binary to R as a default */ if (!getenv("R_ARCH") && *rarch) { /* we have to prefix / so we may as well use putenv */ @@ -252,7 +252,7 @@ for(i = 1; i < ac-1; i++) fprintf(stderr, " %s", av[i]); fprintf(stderr, "'\n\n"); } -#ifndef WIN32 +#ifndef _WIN32 res = execv(cmd, av); /* will not return if R is launched */ perror("Rscript execution error"); #else diff -Nru r-base-3.1.0/SVN-REVISION r-base-3.1.1/SVN-REVISION --- r-base-3.1.0/SVN-REVISION 2014-04-10 07:01:17.000000000 +0000 +++ r-base-3.1.1/SVN-REVISION 2014-07-10 07:01:18.000000000 +0000 @@ -1,2 +1,2 @@ -Revision: 65387 -Last Changed Date: 2014-04-10 +Revision: 66115 +Last Changed Date: 2014-07-10 diff -Nru r-base-3.1.0/tests/any-all.Rout.save r-base-3.1.1/tests/any-all.Rout.save --- r-base-3.1.0/tests/any-all.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/any-all.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/arith.Rout.save r-base-3.1.1/tests/arith.Rout.save --- r-base-3.1.0/tests/arith.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/arith.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/arith-true.Rout.save r-base-3.1.1/tests/arith-true.Rout.save --- r-base-3.1.0/tests/arith-true.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/arith-true.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -323,5 +323,5 @@ > > ## Last Line: > cat('Time elapsed: ', proc.time() - .proctime00,'\n') -Time elapsed: 0.182 0.001 0.183 0 0 +Time elapsed: 0.239 0.004 0.245 0 0 > diff -Nru r-base-3.1.0/tests/array-subset.Rout.save r-base-3.1.1/tests/array-subset.Rout.save --- r-base-3.1.0/tests/array-subset.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/array-subset.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/complex.Rout.save r-base-3.1.1/tests/complex.Rout.save --- r-base-3.1.0/tests/complex.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/complex.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/datasets.Rout.save r-base-3.1.1/tests/datasets.Rout.save --- r-base-3.1.0/tests/datasets.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/datasets.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/datetime2.Rout.save r-base-3.1.1/tests/datetime2.Rout.save --- r-base-3.1.0/tests/datetime2.Rout.save 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/tests/datetime2.Rout.save 2014-07-07 22:15:08.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/datetime.Rout.save r-base-3.1.1/tests/datetime.Rout.save --- r-base-3.1.0/tests/datetime.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/datetime.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/demos.Rout.save r-base-3.1.1/tests/demos.Rout.save --- r-base-3.1.0/tests/demos.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/demos.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -115,8 +115,8 @@ + "\n\t starting with 'is.' :\t ", + sum(grepl("^is\\.", ls.base[base.is.f])), "\n", sep = "") -Number of base objects: 1277 -Number of functions in base: 1235 +Number of base objects: 1278 +Number of functions in base: 1236 starting with 'is.' : 49 > ## 0.14 : 31 @@ -1510,5 +1510,5 @@ > par(op) > > cat("Time elapsed: ", proc.time() - .ptime, "\n") -Time elapsed: 1.014 0.02 1.037 0 0 +Time elapsed: 1.242 0.02 1.269 0 0 > diff -Nru r-base-3.1.0/tests/d-p-q-r-tests.R r-base-3.1.1/tests/d-p-q-r-tests.R --- r-base-3.1.0/tests/d-p-q-r-tests.R 2014-03-12 23:03:31.000000000 +0000 +++ r-base-3.1.1/tests/d-p-q-r-tests.R 2014-05-05 22:15:04.000000000 +0000 @@ -694,6 +694,11 @@ mu <- 1e12 * 2^(0:20) stopifnot(all.equal(1/(1+mu), dnbinom(0, size = 1, mu = mu), tolerance = 1e-13)) ## was wrong in 2.7.2 (only) +mu <- sort(outer(1:7, 10^c(0:10,50*(1:6)))) +NB <- dnbinom(5, size=1e305, mu=mu, log=TRUE) +P <- dpois (5, mu, log=TRUE) +stopifnot(abs(rErr(NB,P)) < 9*Meps)# seen 2.5* +## wrong in 3.1.0 and earlier ## Non-central F for large x @@ -758,6 +763,17 @@ ## extreme tail of non-central chisquare stopifnot(all.equal(pchisq(200, 4, ncp=.001, log.p=TRUE), -3.851e-42)) ## jumped to zero too early up to R 2.10.1 (PR#14216) +## left "extreme tail" +lp <- pchisq(2^-(0:200), 100, 1, log=TRUE) +stopifnot(is.finite(lp), lp < -184, + all.equal(lp[201], -7115.10693158)) +dlp <- diff(lp) +dd <- abs(dlp[-(1:30)] - -34.65735902799) +stopifnot(-34.66 < dlp, dlp < -34.41, dd < 1e-8)# 2.2e-10 64bit Lnx +## underflowed to -Inf much too early in R <= 3.1.0 +for(e in c(0, 2e-16))# continuity at 80 (= branch point) +stopifnot(all.equal(pchisq(1:2, 1.01, ncp = 80*(1-e), log=TRUE), + c(-34.57369629, -31.31514671))) ## logit() == qlogit() on the right extreme: x <- c(10:80, 80 + 5*(1:24), 200 + 20*(1:25)) @@ -791,6 +807,26 @@ ldp <- diff(log(diff(pbeta(0.5, 2^-(90+ 1:25), 2^-60, log.p=TRUE)))) stopifnot(abs(ldp - log(1/2)) < 1e-9) ## pbeta(*, log) lost all precision here, for R <= 3.0.x (PR#15641) +## +## "stair function" effect (from denormalized numbers) +a <- 43779; b <- 0.06728 +x. <- .9833 + (0:100)*1e-6 +px <- pbeta(x., a,b, log=TRUE) # plot(x., px) # -> "stair" +d2. <- diff(dpx <- diff(px)) +stopifnot(all.equal(px[1], -746.0986886924, tol=1e-12), + 0.0445741 < dpx, dpx < 0.0445783, + -4.2e-8 < d2., d2. < -4.18e-8) +## were way off in R <= 3.1.0 + + +## pbinom(), dbinom(), dhyper(),.. : R allows "almost integer" n +for (FUN in c(function(n) dbinom(1,n,0.5), function(n) pbinom(1,n,0.5), + function(n) dpois(n, n), function(n) dhyper(n+1, n+5,n+5, n))) + try( lapply(sample(10000, size=1000), function(M) { + ## invisible(lapply(sample(10000, size=1000), function(M) { + n <- (M/100)*10^(2:20); if(anyNA(P <- FUN(n))) + stop("NA for M=",M, "; 10ex=",paste((2:20)[is.na(P)], collapse=", "))})) +## check was too tight for large n in R <= 3.1.0 (PR#15734) cat("Time elapsed: ", proc.time() - .ptime,"\n") diff -Nru r-base-3.1.0/tests/d-p-q-r-tests.Rout.save r-base-3.1.1/tests/d-p-q-r-tests.Rout.save --- r-base-3.1.0/tests/d-p-q-r-tests.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/d-p-q-r-tests.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -1229,6 +1229,11 @@ > mu <- 1e12 * 2^(0:20) > stopifnot(all.equal(1/(1+mu), dnbinom(0, size = 1, mu = mu), tolerance = 1e-13)) > ## was wrong in 2.7.2 (only) +> mu <- sort(outer(1:7, 10^c(0:10,50*(1:6)))) +> NB <- dnbinom(5, size=1e305, mu=mu, log=TRUE) +> P <- dpois (5, mu, log=TRUE) +> stopifnot(abs(rErr(NB,P)) < 9*Meps)# seen 2.5* +> ## wrong in 3.1.0 and earlier > > > ## Non-central F for large x @@ -1293,6 +1298,17 @@ > ## extreme tail of non-central chisquare > stopifnot(all.equal(pchisq(200, 4, ncp=.001, log.p=TRUE), -3.851e-42)) > ## jumped to zero too early up to R 2.10.1 (PR#14216) +> ## left "extreme tail" +> lp <- pchisq(2^-(0:200), 100, 1, log=TRUE) +> stopifnot(is.finite(lp), lp < -184, ++ all.equal(lp[201], -7115.10693158)) +> dlp <- diff(lp) +> dd <- abs(dlp[-(1:30)] - -34.65735902799) +> stopifnot(-34.66 < dlp, dlp < -34.41, dd < 1e-8)# 2.2e-10 64bit Lnx +> ## underflowed to -Inf much too early in R <= 3.1.0 +> for(e in c(0, 2e-16))# continuity at 80 (= branch point) ++ stopifnot(all.equal(pchisq(1:2, 1.01, ncp = 80*(1-e), log=TRUE), ++ c(-34.57369629, -31.31514671))) > > ## logit() == qlogit() on the right extreme: > x <- c(10:80, 80 + 5*(1:24), 200 + 20*(1:25)) @@ -1326,8 +1342,28 @@ > ldp <- diff(log(diff(pbeta(0.5, 2^-(90+ 1:25), 2^-60, log.p=TRUE)))) > stopifnot(abs(ldp - log(1/2)) < 1e-9) > ## pbeta(*, log) lost all precision here, for R <= 3.0.x (PR#15641) +> ## +> ## "stair function" effect (from denormalized numbers) +> a <- 43779; b <- 0.06728 +> x. <- .9833 + (0:100)*1e-6 +> px <- pbeta(x., a,b, log=TRUE) # plot(x., px) # -> "stair" +> d2. <- diff(dpx <- diff(px)) +> stopifnot(all.equal(px[1], -746.0986886924, tol=1e-12), ++ 0.0445741 < dpx, dpx < 0.0445783, ++ -4.2e-8 < d2., d2. < -4.18e-8) +> ## were way off in R <= 3.1.0 +> +> +> ## pbinom(), dbinom(), dhyper(),.. : R allows "almost integer" n +> for (FUN in c(function(n) dbinom(1,n,0.5), function(n) pbinom(1,n,0.5), ++ function(n) dpois(n, n), function(n) dhyper(n+1, n+5,n+5, n))) ++ try( lapply(sample(10000, size=1000), function(M) { ++ ## invisible(lapply(sample(10000, size=1000), function(M) { ++ n <- (M/100)*10^(2:20); if(anyNA(P <- FUN(n))) ++ stop("NA for M=",M, "; 10ex=",paste((2:20)[is.na(P)], collapse=", "))})) +> ## check was too tight for large n in R <= 3.1.0 (PR#15734) > > > cat("Time elapsed: ", proc.time() - .ptime,"\n") -Time elapsed: 0.657 0.009 0.668 0 0 +Time elapsed: 0.885 0.015 0.905 0 0 > diff -Nru r-base-3.1.0/tests/eval-etc.Rout.save r-base-3.1.1/tests/eval-etc.Rout.save --- r-base-3.1.0/tests/eval-etc.Rout.save 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/tests/eval-etc.Rout.save 2014-07-07 22:15:08.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/Examples/datasets-Ex.Rout.save r-base-3.1.1/tests/Examples/datasets-Ex.Rout.save --- r-base-3.1.0/tests/Examples/datasets-Ex.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/Examples/datasets-Ex.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -2635,14 +2635,6 @@ > > ### ** Examples > -> ## Not run: -> ##D require(stats); require(graphics) -> ##D nott <- window(nottem, end = c(1936,12)) -> ##D fit <- arima(nott, order = c(1,0,0), list(order = c(2,1,0), period = 12)) -> ##D nott.fore <- predict(fit, n.ahead = 36) -> ##D ts.plot(nott, nott.fore$pred, nott.fore$pred+2*nott.fore$se, -> ##D nott.fore$pred-2*nott.fore$se, gpars = list(col = c(1,1,4,4))) -> ## End(Not run) > > > cleanEx() @@ -2831,18 +2823,6 @@ > > ### ** Examples > -> ## Not run: -> ##D ## We could re-generate the dataset by the following R code -> ##D seed <- as.double(1) -> ##D RANDU <- function() { -> ##D seed <<- ((2^16 + 3) * seed) %% (2^31) -> ##D seed/(2^31) -> ##D } -> ##D for(i in 1:400) { -> ##D U <- c(RANDU(), RANDU(), RANDU(), RANDU(), RANDU()) -> ##D print(round(U[1:3], 6)) -> ##D } -> ## End(Not run) > > > @@ -3479,7 +3459,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 1.384 0.014 1.403 0 0 +Time elapsed: 1.783 0.04 1.831 0 0 > grDevices::dev.off() null device 1 diff -Nru r-base-3.1.0/tests/Examples/graphics-Ex.Rout.save r-base-3.1.1/tests/Examples/graphics-Ex.Rout.save --- r-base-3.1.0/tests/Examples/graphics-Ex.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/Examples/graphics-Ex.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -624,8 +624,10 @@ > image(x, x, z) > contour(x, x, z, col = "pink", add = TRUE, method = "edge", + vfont = c("sans serif", "plain")) -> contour(x, x, z, ylim = c(1, 6), method = "simple", labcex = 1) -> contour(x, x, z, ylim = c(-6, 6), nlev = 20, lty = 2, method = "simple") +> contour(x, x, z, ylim = c(1, 6), method = "simple", labcex = 1, ++ xlab = quote(x[1]), ylab = quote(x[2])) +> contour(x, x, z, ylim = c(-6, 6), nlev = 20, lty = 2, method = "simple", ++ main = "20 levels; \"simple\" labelling method") > par(op) > > ## Persian Rug Art: @@ -650,16 +652,13 @@ > abline(h = 200*0:4, v = 200*0:4, col = "lightgray", lty = 2, lwd = 0.1) > > ## contourLines produces the same contour lines as contour -> line.list <- contourLines(x, y, volcano) > plot(x = 0, y = 0, type = "n", xlim = rx, ylim = ry, xlab = "", ylab = "") > u <- par("usr") > rect(u[1], u[3], u[2], u[4], col = tcol[8], border = "red") -> contour(x, y, volcano, col = tcol[2], lty = "solid", add = TRUE, -+ vfont = c("sans serif", "plain")) -> templines <- function(clines) { -+ lines(clines[[2]], clines[[3]]) -+ } -> invisible(lapply(line.list, templines)) +> contour(x, y, volcano, col = tcol[1], lty = "solid", add = TRUE, ++ vfont = c("sans serif", "plain")) +> line.list <- contourLines(x, y, volcano) +> invisible(lapply(line.list, lines, lwd=3, col=adjustcolor(2, .3))) > par(opar) > > @@ -2027,7 +2026,7 @@ > points.default # to see how it calls "plot.xy(xy.coords(x, y), ...)" function (x, y = NULL, type = "p", ...) plot.xy(xy.coords(x, y), type = type, ...) - + > > @@ -2898,7 +2897,7 @@ u <- par("usr") xy * c(u[2L] - u[1L], u[4L] - u[3L])/par("pin") } - + > > ## plot labels offset 0.12 inches to the right @@ -2978,7 +2977,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 1.927 0.019 1.951 0 0 +Time elapsed: 2.527 0.055 2.598 0 0 > grDevices::dev.off() null device 1 diff -Nru r-base-3.1.0/tests/Examples/grDevices-Ex.Rout.save r-base-3.1.1/tests/Examples/grDevices-Ex.Rout.save --- r-base-3.1.0/tests/Examples/grDevices-Ex.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/Examples/grDevices-Ex.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -2015,10 +2015,69 @@ > > ### ** Examples > +> # This currently only works on the Windows +> # and X11(type = "Xlib") screen devices... +> ## Not run: +> ##D savepar <- par(ask = FALSE) +> ##D dragplot <- function(..., xlim = NULL, ylim = NULL, xaxs = "r", yaxs = "r") { +> ##D plot(..., xlim = xlim, ylim = ylim, xaxs = xaxs, yaxs = yaxs) +> ##D startx <- NULL +> ##D starty <- NULL +> ##D prevx <- NULL +> ##D prevy <- NULL +> ##D usr <- NULL +> ##D +> ##D devset <- function() +> ##D if (dev.cur() != eventEnv$which) dev.set(eventEnv$which) +> ##D +> ##D dragmousedown <- function(buttons, x, y) { +> ##D startx <<- x +> ##D starty <<- y +> ##D prevx <<- 0 +> ##D prevy <<- 0 +> ##D devset() +> ##D usr <<- par("usr") +> ##D eventEnv$onMouseMove <- dragmousemove +> ##D NULL +> ##D } +> ##D +> ##D dragmousemove <- function(buttons, x, y) { +> ##D devset() +> ##D deltax <- diff(grconvertX(c(startx, x), "ndc", "user")) +> ##D deltay <- diff(grconvertY(c(starty, y), "ndc", "user")) +> ##D if (abs(deltax-prevx) + abs(deltay-prevy) > 0) { +> ##D plot(..., xlim = usr[1:2]-deltax, xaxs = "i", +> ##D ylim = usr[3:4]-deltay, yaxs = "i") +> ##D prevx <<- deltax +> ##D prevy <<- deltay +> ##D } +> ##D NULL +> ##D } +> ##D +> ##D mouseup <- function(buttons, x, y) { +> ##D eventEnv$onMouseMove <- NULL +> ##D } +> ##D +> ##D keydown <- function(key) { +> ##D if (key == "q") return(invisible(1)) +> ##D eventEnv$onMouseMove <- NULL +> ##D NULL +> ##D } +> ##D +> ##D setGraphicsEventHandlers(prompt = "Click and drag, hit q to quit", +> ##D onMouseDown = dragmousedown, +> ##D onMouseUp = mouseup, +> ##D onKeybd = keydown) +> ##D eventEnv <- getGraphicsEventEnv() +> ##D } +> ##D +> ##D dragplot(rnorm(1000), rnorm(1000)) +> ##D getGraphicsEvent() +> ##D par(savepar) +> ## End(Not run) > > > -> graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("gray") > ### * gray @@ -2453,31 +2512,9 @@ > > ### ** Examples > -> ## Not run: -> ##D ## Test function for encodings -> ##D TestChars <- function(encoding = "ISOLatin1", ...) -> ##D { -> ##D pdf(encoding = encoding, ...) -> ##D par(pty = "s") -> ##D plot(c(-1,16), c(-1,16), type = "n", xlab = "", ylab = "", -> ##D xaxs = "i", yaxs = "i") -> ##D title(paste("Centred chars in encoding", encoding)) -> ##D grid(17, 17, lty = 1) -> ##D for(i in c(32:255)) { -> ##D x <- i %% 16 -> ##D y <- i %/% 16 -> ##D points(x, y, pch = i) -> ##D } -> ##D dev.off() -> ##D } -> ##D ## there will be many warnings. -> ##D TestChars("ISOLatin2") -> ##D ## this does not view properly in older viewers. -> ##D TestChars("ISOLatin2", family = "URWHelvetica") -> ##D ## works well for viewing in gs-based viewers, and often in xpdf. -> ## End(Not run) > > +> graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("pdf.options") > ### * pdf.options @@ -3713,7 +3750,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 8.084 0.121 8.226 0 0 +Time elapsed: 10.005 0.172 10.244 0 0 > grDevices::dev.off() null device 1 diff -Nru r-base-3.1.0/tests/Examples/grid-Ex.Rout.save r-base-3.1.1/tests/Examples/grid-Ex.Rout.save --- r-base-3.1.0/tests/Examples/grid-Ex.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/Examples/grid-Ex.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -438,15 +438,6 @@ > > ### ** Examples > -> ## Not run: -> ##D dev.new(width=.5, height=.5) -> ##D grid.rect() -> ##D grid.text("hi") -> ##D cap <- grid.cap() -> ##D dev.off() -> ##D -> ##D grid.raster(cap, width=.5, height=.5, interpolate=FALSE) -> ## End(Not run) > > > @@ -2067,7 +2058,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 1.248 0.019 1.272 0 0 +Time elapsed: 1.696 0.019 1.724 0 0 > grDevices::dev.off() null device 1 diff -Nru r-base-3.1.0/tests/Examples/splines-Ex.Rout.save r-base-3.1.1/tests/Examples/splines-Ex.Rout.save --- r-base-3.1.0/tests/Examples/splines-Ex.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/Examples/splines-Ex.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -576,7 +576,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 0.109 0.002 0.112 0 0 +Time elapsed: 0.137 0.007 0.147 0 0 > grDevices::dev.off() null device 1 diff -Nru r-base-3.1.0/tests/Examples/stats4-Ex.Rout.save r-base-3.1.1/tests/Examples/stats4-Ex.Rout.save --- r-base-3.1.0/tests/Examples/stats4-Ex.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/Examples/stats4-Ex.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -184,7 +184,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 0.371 0.005 0.377 0 0 +Time elapsed: 0.484 0.003 0.49 0 0 > grDevices::dev.off() null device 1 diff -Nru r-base-3.1.0/tests/Examples/stats-Ex.Rout.save r-base-3.1.1/tests/Examples/stats-Ex.Rout.save --- r-base-3.1.0/tests/Examples/stats-Ex.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/Examples/stats-Ex.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -144,6 +144,40 @@ [1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 [16] 0.75 0.80 0.85 0.90 0.95 1.00 > +> ## Visualization, including limit cases: +> pl.beta <- function(a,b, asp = if(isLim) 1, ylim = if(isLim) c(0,1.1)) { ++ if(isLim <- a == 0 || b == 0 || a == Inf || b == Inf) { ++ eps <- 1e-10 ++ x <- c(0, eps, (1:7)/16, 1/2+c(-eps,0,eps), (9:15)/16, 1-eps, 1) ++ } else { ++ x <- seq(0, 1, length = 1025) ++ } ++ fx <- cbind(dbeta(x, a,b), pbeta(x, a,b), qbeta(x, a,b)) ++ f <- fx; f[fx == Inf] <- 1e100 ++ matplot(x, f, ylab="", type="l", ylim=ylim, asp=asp, ++ main = sprintf("[dpq]beta(x, a=%g, b=%g)", a,b)) ++ abline(0,1, col="gray", lty=3) ++ abline(h = 0:1, col="gray", lty=3) ++ legend("top", paste0(c("d","p","q"), "beta(x, a,b)"), ++ col=1:3, lty=1:3, bty = "n") ++ invisible(cbind(x, fx)) ++ } +> pl.beta(3,1) +> +> pl.beta(2, 4) +> pl.beta(3, 7) +> pl.beta(3, 7, asp=1) +> +> pl.beta(0, 0) ## point masses at {0, 1} +> +> pl.beta(0, 2) ## point mass at 0 ; the same as +> pl.beta(1, Inf) +> +> pl.beta(Inf, 2) ## point mass at 1 ; the same as +> pl.beta(3, 0) +> +> pl.beta(Inf, Inf)# point mass at 1/2 +> > > > cleanEx() @@ -241,23 +275,6 @@ 8 | 23 > -> ## Not run: -> ##D ## visual testing -> ##D ## do P-P plots for 1000 points at various degrees of freedom -> ##D L <- 1.2; n <- 1000; pp <- ppoints(n) -> ##D op <- par(mfrow = c(3,3), mar = c(3,3,1,1)+.1, mgp = c(1.5,.6,0), -> ##D oma = c(0,0,3,0)) -> ##D for(df in 2^(4*rnorm(9))) { -> ##D plot(pp, sort(pchisq(rr <- rchisq(n, df = df, ncp = L), df = df, ncp = L)), -> ##D ylab = "pchisq(rchisq(.),.)", pch = ".") -> ##D mtext(paste("df = ", formatC(df, digits = 4)), line = -2, adj = 0.05) -> ##D abline(0, 1, col = 2) -> ##D } -> ##D mtext(expression("P-P plots : Noncentral "* -> ##D chi^2 *"(n=1000, df=X, ncp= 1.2)"), -> ##D cex = 1.5, font = 2, outer = TRUE) -> ##D par(op) -> ## End(Not run) > > ## "analytical" test > lam <- seq(0, 100, by = .25) @@ -268,6 +285,7 @@ > > > +> graphics::par(get("par.postscript", pos = 'CheckExEnv')) > cleanEx() > nameEx("Exponential") > ### * Exponential @@ -3755,7 +3773,7 @@ > > asOneSidedFormula("age") ~age - + > asOneSidedFormula(~ age) ~age > @@ -4718,7 +4736,7 @@ r[cbind(1L:p, 1L:p)] <- 1 r } - + > stopifnot(all.equal(Cl, cov2cor(cov(longley))), + all.equal(cor(longley, method = "kendall"), @@ -7230,7 +7248,7 @@ > environment(as.formula("y ~ x")) > environment(as.formula("y ~ x", env = new.env())) - + > > > ## Create a formula for a model with a large number of variables: @@ -7649,14 +7667,6 @@ outcome 2 5.4523 6 5.1291 treatment 2 0.0000 4 5.1291 > -> ## Not run: -> ##D ## an example with offsets from Venables & Ripley (2002, p.189) -> ##D utils::data(anorexia, package = "MASS") -> ##D -> ##D anorex.1 <- glm(Postwt ~ Prewt + Treat + offset(Prewt), -> ##D family = gaussian, data = anorexia) -> ##D summary(anorex.1) -> ## End(Not run) > > # A Gamma example, from McCullagh & Nelder (1989, pp. 300-2) > clotting <- data.frame( @@ -8555,10 +8565,9 @@ > > ## Multivariate (but non-stationary! ...) > lag.plot(freeny.x, lags = 3) -> ## Not run: -> ##D no lines for long series : -> ##D lag.plot(sqrt(sunspots), set = c(1:4, 9:12), pch = ".", col = "gold") -> ## End(Not run) +> +> ## no lines for long series : +> lag.plot(sqrt(sunspots), set = c(1:4, 9:12), pch = ".", col = "gold") > > > @@ -8789,13 +8798,6 @@ > stopifnot(id(unname(lm.$coef), lm..$coef), + id(unname(lmw$coef), lm.w$coef)) > ## End Don't show -> ## Not run: -> ##D if(require("microbenchmark")) { -> ##D mb <- microbenchmark(lm(y~X), lm.fit(X,y), .lm.fit(X,y)) -> ##D print(mb) -> ##D boxplot(mb, notch=TRUE) -> ##D } -> ## End(Not run) > > > @@ -10501,10 +10503,10 @@ a b 3 2 residual sum-of-squares: 0.000524 -> ## Not run: -> ##D ## terminates in an error, because convergence cannot be confirmed: -> ##D nls(y ~ a + b*x, start = list(a = 0.12345, b = 0.54321)) -> ## End(Not run) +> ## terminates in an error, because convergence cannot be confirmed: +> try(nls(y ~ a + b*x, start = list(a = 0.12345, b = 0.54321))) +Error in nls(y ~ a + b * x, start = list(a = 0.12345, b = 0.54321)) : + number of iterations exceeded maximum of 50 > > ## the nls() internal cheap guess for starting values can be sufficient: > @@ -11514,13 +11516,8 @@ > plot(z, plot.type = "single", lty = 1:3, col = 4:2) > > ## A phase plot: -> plot(nhtemp, c(nhtemp[-1], NA), cex = .8, col = "blue", +> plot(nhtemp, lag(nhtemp, 1), cex = .8, col = "blue", + main = "Lag plot of New Haven temperatures") -> ## a clearer way to do this would be -> ## Not run: -> ##D plot(nhtemp, lag(nhtemp, 1), cex = .8, col = "blue", -> ##D main = "Lag plot of New Haven temperatures") -> ## End(Not run) > > ## xy.lines and xy.labels are FALSE for large series: > plot(lag(sunspots, 1), sunspots, pch = ".") @@ -11716,14 +11713,14 @@ $linkfun function (mu) mu^lambda - - + + $linkinv function (eta) pmax(eta^(1/lambda), .Machine$double.eps) - - + + > > @@ -14717,12 +14714,6 @@ > se.contrast(fit, as.matrix(cont)) A BC 3.377196 3.899650 -> ## Not run: -> ##D # comparison with lme -> ##D library(nlme) -> ##D fit2 <- lme(Yield ~ A + B*C, random = ~1 | Block, data = aovdat) -> ##D summary(fit2)$tTable # same estimates, similar (but smaller) se's. -> ## End(Not run) > > > base::options(contrasts = c(unordered = "contr.treatment",ordered = "contr.poly")) @@ -14998,7 +14989,7 @@ > > ### Name: smooth.spline > ### Title: Fit a Smoothing Spline -> ### Aliases: smooth.spline +> ### Aliases: smooth.spline .nknots.smspl > ### Keywords: smooth > > ### ** Examples @@ -15087,6 +15078,20 @@ > stopifnot(all.equal(cars$dist, + fitted(cars.spl) + residuals(cars.spl))) > +> ## Visualize the behavior of .nknots.smspl() +> nKnots <- Vectorize(.nknots.smspl) ; c.. <- adjustcolor("gray20",.5) +> curve(nKnots, 1, 250, n=250) +> abline(0,1, lty=2, col=c..); text(90,90,"y = x", col=c.., adj=-.25) +> abline(h=100,lty=2); abline(v=200, lty=2) +> +> n <- c(1:799, seq(800, 3490, by=10), seq(3500, 10000, by = 50)) +> plot(n, nKnots(n), type="l", main = "Vectorize(.nknots.smspl) (n)") +> abline(0,1, lty=2, col=c..); text(180,180,"y = x", col=c..) +> n0 <- c(50, 200, 800, 3200); c0 <- adjustcolor("blue3", .5) +> lines(n0, nKnots(n0), type="h", col=c0) +> axis(1, at=n0, line=-2, col.ticks=c0, col=NA, col.axis=c0) +> axis(4, at=.nknots.smspl(10000), line=-.5, col=c..,col.axis=c.., las=1) +> > ##-- artificial example > y18 <- c(1:3, 5, 4, 7:3, 2*(2:5), rep(10, 4)) > xx <- seq(1, length(y18), len = 201) @@ -15505,8 +15510,8 @@ > unclass(sfun0) function (v) .approxfun(x, y, v, method, yleft, yright, f) - - + + attr(,"call") stepfun(1:3, y0, f = 0) > ls(envir = environment(sfun0)) @@ -16476,13 +16481,9 @@ > plot(z, plot.type = "single", lty = 1:3) > > ## A phase plot: -> plot(nhtemp, c(nhtemp[-1], NA), cex = .8, col = "blue", +> plot(nhtemp, lag(nhtemp, 1), cex = .8, col = "blue", + main = "Lag plot of New Haven temperatures") -> ## a clearer way to do this would be -> ## Not run: -> ##D plot(nhtemp, lag(nhtemp, 1), cex = .8, col = "blue", -> ##D main = "Lag plot of New Haven temperatures") -> ## End(Not run) +> > > > cleanEx() @@ -16864,17 +16865,6 @@ > > ### ** Examples > -> ## Not run: -> ##D require(graphics) -> ##D -> ##D fit <- arima(lh, c(1,0,0)) -> ##D tsdiag(fit) -> ##D -> ##D ## see also examples(arima) -> ##D -> ##D (fit <- StructTS(log10(JohnsonJohnson), type = "BSM")) -> ##D tsdiag(fit) -> ## End(Not run) > > > cleanEx() @@ -17809,7 +17799,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 4.692 0.096 4.803 0 0 +Time elapsed: 6.192 0.147 6.371 0 0 > grDevices::dev.off() null device 1 diff -Nru r-base-3.1.0/tests/Examples/tools-Ex.Rout.save r-base-3.1.1/tests/Examples/tools-Ex.Rout.save --- r-base-3.1.0/tests/Examples/tools-Ex.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/Examples/tools-Ex.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -187,7 +187,7 @@ > bibstyle("unsorted", sortKeys = function(refs) seq_along(refs), + fmtPrefix = function(paper) paste0("[", paper$.index, "]"), + .init = TRUE) - + > print(refs, .bibstyle = "unsorted") [1] R Core Team (2013). _R: A Language and Environment for Statistical Computing_. R Foundation for Statistical Computing, Vienna, Austria. @@ -200,6 +200,23 @@ > > > cleanEx() +> nameEx("buildVignettes") +> ### * buildVignettes +> +> flush(stderr()); flush(stdout()) +> +> ### Name: buildVignettes +> ### Title: List and Build Package Vignettes +> ### Aliases: buildVignettes pkgVignettes +> ### Keywords: utilities documentation +> +> ### ** Examples +> +> gVigns <- pkgVignettes("grid") +> +> +> +> cleanEx() > nameEx("charsets") > ### * charsets > @@ -938,7 +955,7 @@ > ### > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 0.197 0.003 0.201 0 0 +Time elapsed: 0.272 0.008 0.282 0 0 > grDevices::dev.off() null device 1 diff -Nru r-base-3.1.0/tests/iec60559.Rout.save r-base-3.1.1/tests/iec60559.Rout.save --- r-base-3.1.0/tests/iec60559.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/iec60559.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/internet.Rout.save r-base-3.1.1/tests/internet.Rout.save --- r-base-3.1.0/tests/internet.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/internet.Rout.save 2014-07-10 07:00:03.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-09 r66112) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -29,37 +29,34 @@ > > # test do_download. > nrow(available.packages(contrib.url("http://cran.r-project.org"))) -[1] 5394 +[1] 5714 > > # test url connections on http > zz <- url("http://cran.r-project.org/") > readLines(zz) - [1] "" - [2] "" - [3] "" - [4] "" - [5] "The Comprehensive R Archive Network" - [6] "" - [7] "" - [8] "" - [9] "" -[10] "" -[11] "" -[12] "" -[13] "" -[14] "" -[15] "" -[16] "" -[17] "" -[18] "<h1>The Comprehensive R Archive Network</h1>" -[19] "" -[20] "Your browser seems not to support frames," -[21] "here is the <A href=\"navbar.html\">contents page</A> of CRAN." -[22] "" -[23] "" -[24] "" -[25] "" -[26] "" + [1] "" + [2] "" + [3] "" + [4] "The Comprehensive R Archive Network" + [5] "" + [6] "" + [7] "" + [8] "" + [9] "" +[10] "" +[11] "" +[12] "" +[13] "" +[14] "" +[15] "" +[16] "" +[17] "" +[18] "<h1>The Comprehensive R Archive Network</h1>" +[19] "" +[20] "Your browser seems not to support frames," +[21] "here is the <A href=\"navbar.html\">contents page</A> of CRAN." +[22] "" +[23] "" > close(zz) > > ## check graceful failure: diff -Nru r-base-3.1.0/tests/isas-tests.Rout.save r-base-3.1.1/tests/isas-tests.Rout.save --- r-base-3.1.0/tests/isas-tests.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/isas-tests.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -2562,6 +2562,6 @@ > f <- try(as.ts( x ), silent = TRUE) > if(!inherits(f, 'try-error')) report(identical(f, as.ts( f ))) > cat('Time elapsed: ', proc.time() - .proctime00,'\n') -Time elapsed: 0.087 0.01 0.097 0 0 +Time elapsed: 0.198 0.015 0.214 0 0 > > diff -Nru r-base-3.1.0/tests/lapack.Rout.save r-base-3.1.1/tests/lapack.Rout.save --- r-base-3.1.0/tests/lapack.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/lapack.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/lm-tests.Rout.save r-base-3.1.1/tests/lm-tests.Rout.save --- r-base-3.1.0/tests/lm-tests.Rout.save 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/tests/lm-tests.Rout.save 2014-07-07 22:15:08.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/method-dispatch.Rout.save r-base-3.1.1/tests/method-dispatch.Rout.save --- r-base-3.1.0/tests/method-dispatch.Rout.save 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/tests/method-dispatch.Rout.save 2014-07-07 22:15:08.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/ok-errors.Rout.save r-base-3.1.1/tests/ok-errors.Rout.save --- r-base-3.1.0/tests/ok-errors.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/ok-errors.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/print-tests.Rout.save r-base-3.1.1/tests/print-tests.Rout.save --- r-base-3.1.0/tests/print-tests.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/print-tests.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/p-r-random-tests.Rout.save r-base-3.1.1/tests/p-r-random-tests.Rout.save --- r-base-3.1.0/tests/p-r-random-tests.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/p-r-random-tests.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -278,6 +278,6 @@ > > > cat('Time elapsed: ', proc.time() - .proctime00,'\n') -Time elapsed: 1.233 0.001 1.236 0 0 +Time elapsed: 1.62 0.002 1.63 0 0 > > diff -Nru r-base-3.1.0/tests/reg-examples1.R r-base-3.1.1/tests/reg-examples1.R --- r-base-3.1.0/tests/reg-examples1.R 2014-03-12 23:03:30.000000000 +0000 +++ r-base-3.1.1/tests/reg-examples1.R 2014-06-08 22:15:04.000000000 +0000 @@ -3,7 +3,7 @@ set.seed(1) if(.Platform$OS.type == "windows") options(pager = "console") -pdf("reg-examples1.pdf", encoding = "ISOLatin1.enc") +pdf("reg-examples-1.pdf", encoding = "ISOLatin1.enc") ## base @@ -65,4 +65,21 @@ ## results are location- and OS-specific example(parseLatex) # charset-specific +## part of example(buildVignettes) at one time +gVigns <- pkgVignettes("grid") +str(gVigns) # contains paths + +vind <- system.file(package = "grid", "doc", "index.html") +if(nzchar(vind)) { # so vignettes have been installed + `%=f=%` <- function(a, b) normalizePath(a) == normalizePath(b) + with(gVigns, + stopifnot(engines == "utils::Sweave", + pkgdir %=f=% system.file(package="grid"), + dir %=f=% system.file(package = "grid", "doc"), + (n. <- length(docs)) >= 12, # have 13 + n. == length(names), n. == length(engines), + length(msg) == 0) ) # as it is a 'base' package + stopifnot("grid" %in% gVigns$names, inherits(gVigns, "pkgVignettes")) +} + proc.time() diff -Nru r-base-3.1.0/tests/reg-examples3.R r-base-3.1.1/tests/reg-examples3.R --- r-base-3.1.0/tests/reg-examples3.R 2013-09-01 22:05:04.000000000 +0000 +++ r-base-3.1.1/tests/reg-examples3.R 2014-05-09 22:15:05.000000000 +0000 @@ -1,9 +1,13 @@ ## For examples skipped in testing because they need recommended packages. +## This is skipped entirely on a Unix-alike if recommended packages are, +## so for Windows +if(!require("MASS")) q() + pdf("reg-examples-3.pdf", encoding = "ISOLatin1.enc") ## From datasets -if(require("survival")){ +if(require("survival")) { model3 <- clogit(case ~ spontaneous+induced+strata(stratum), data = infert) print(summary(model3)) detach("package:survival") # survival (conflicts) diff -Nru r-base-3.1.0/tests/reg-examples3.Rout.save r-base-3.1.1/tests/reg-examples3.Rout.save --- r-base-3.1.0/tests/reg-examples3.Rout.save 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/tests/reg-examples3.Rout.save 2014-07-07 22:15:08.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -17,10 +17,15 @@ > ## For examples skipped in testing because they need recommended packages. > +> ## This is skipped entirely on a Unix-alike if recommended packages are, +> ## so for Windows +> if(!require("MASS")) q() +Loading required package: MASS +> > pdf("reg-examples-3.pdf", encoding = "ISOLatin1.enc") > > ## From datasets -> if(require("survival")){ +> if(require("survival")) { + model3 <- clogit(case ~ spontaneous+induced+strata(stratum), data = infert) + print(summary(model3)) + detach("package:survival") # survival (conflicts) diff -Nru r-base-3.1.0/tests/reg-IO2.Rout.save r-base-3.1.1/tests/reg-IO2.Rout.save --- r-base-3.1.0/tests/reg-IO2.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/reg-IO2.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/reg-IO.Rout.save r-base-3.1.1/tests/reg-IO.Rout.save --- r-base-3.1.0/tests/reg-IO.Rout.save 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/tests/reg-IO.Rout.save 2014-07-07 22:15:08.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/reg-plot.Rout.save r-base-3.1.1/tests/reg-plot.Rout.save --- r-base-3.1.0/tests/reg-plot.Rout.save 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/tests/reg-plot.Rout.save 2014-07-07 22:15:08.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/reg-S4.Rout.save r-base-3.1.1/tests/reg-S4.Rout.save --- r-base-3.1.0/tests/reg-S4.Rout.save 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/tests/reg-S4.Rout.save 2014-07-07 22:15:08.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/reg-tests-1c.R r-base-3.1.1/tests/reg-tests-1c.R --- r-base-3.1.0/tests/reg-tests-1c.R 2014-03-25 23:15:08.000000000 +0000 +++ r-base-3.1.1/tests/reg-tests-1c.R 2014-07-03 22:15:09.000000000 +0000 @@ -349,4 +349,13 @@ ## failed for 2 days in R-devel/-alpha +## numericDeriv failed to duplicate variables in +## the expression before modifying them. PR#15849 +x <- 10; y <- 10 +d1 <- numericDeriv(quote(x+y),c("x","y")) +x <- y <- 10 +d2 <- numericDeriv(quote(x+y),c("x","y")) +stopifnot(identical(d1,d2)) +## The second gave the wrong answer + proc.time() diff -Nru r-base-3.1.0/tests/reg-tests-2.R r-base-3.1.1/tests/reg-tests-2.R --- r-base-3.1.0/tests/reg-tests-2.R 2014-03-21 23:15:15.000000000 +0000 +++ r-base-3.1.1/tests/reg-tests-2.R 2014-06-13 22:15:18.000000000 +0000 @@ -2873,3 +2873,19 @@ d <- data.frame(a=1) d[integer(), "a"] <- 2 ## warned in 3.0.3. + + +## PR#15781 +options(foo = 1) +print(options(foo = NULL)) +## printed wrong value in 3.1.0 + + +## getParseData bug reported by Andrew Redd +raw <- " +function( a # parameter 1 + , b=2 # parameter 2 + ){a+b}" +p <- parse(text = raw) +getParseData(p) +## Got some parents wrong diff -Nru r-base-3.1.0/tests/reg-tests-2.Rout.save r-base-3.1.1/tests/reg-tests-2.Rout.save --- r-base-3.1.0/tests/reg-tests-2.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/reg-tests-2.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -6403,15 +6403,15 @@ > print.function function (x, ...) - attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 19 1 63 19 63 1 1 - .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' + .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' > f function () - attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 17 1 28 17 28 1 1 - .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' + .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' - attr(*, "note")= chr "just a note" - attr(*, "yada")=function () ..- attr(*, "srcref")=Class 'srcref' atomic [1:8] 2 24 2 48 24 48 2 2 - .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' + .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' > rm(print.function) > ## auto-printing and printing differed up to R 2.9.x > @@ -7428,3 +7428,66 @@ > d[integer(), "a"] <- 2 > ## warned in 3.0.3. > +> +> ## PR#15781 +> options(foo = 1) +> print(options(foo = NULL)) +$foo +[1] 1 + +> ## printed wrong value in 3.1.0 +> +> +> ## getParseData bug reported by Andrew Redd +> raw <- " ++ function( a # parameter 1 ++ , b=2 # parameter 2 ++ ){a+b}" +> p <- parse(text = raw) +> getParseData(p) + line1 col1 line2 col2 id parent token +31 2 1 4 15 31 0 expr +3 2 1 2 8 3 31 FUNCTION +4 2 9 2 9 4 31 '(' +5 2 11 2 11 5 31 SYMBOL_FORMALS +6 2 15 2 27 6 31 COMMENT +8 3 10 3 10 8 31 ',' +10 3 12 3 12 10 31 SYMBOL_FORMALS +11 3 13 3 13 11 31 EQ_FORMALS +12 3 14 3 14 12 13 NUM_CONST +13 3 14 3 14 13 31 expr +14 3 16 3 28 14 31 COMMENT +16 4 10 4 10 16 31 ')' +28 4 11 4 15 28 31 expr +18 4 11 4 11 18 28 '{' +25 4 12 4 14 25 28 expr +19 4 12 4 12 19 21 SYMBOL +21 4 12 4 12 21 25 expr +20 4 13 4 13 20 25 '+' +22 4 14 4 14 22 24 SYMBOL +24 4 14 4 14 24 25 expr +23 4 15 4 15 23 28 '}' + terminal text +31 FALSE +3 TRUE function +4 TRUE ( +5 TRUE a +6 TRUE # parameter 1 +8 TRUE , +10 TRUE b +11 TRUE = +12 TRUE 2 +13 FALSE +14 TRUE # parameter 2 +16 TRUE ) +28 FALSE +18 TRUE { +25 FALSE +19 TRUE a +21 FALSE +20 TRUE + +22 TRUE b +24 FALSE +23 TRUE } +> ## Got some parents wrong +> diff -Nru r-base-3.1.0/tests/reg-tests-3.Rout.save r-base-3.1.1/tests/reg-tests-3.Rout.save --- r-base-3.1.0/tests/reg-tests-3.Rout.save 2014-04-05 22:15:09.000000000 +0000 +++ r-base-3.1.1/tests/reg-tests-3.Rout.save 2014-07-07 22:15:08.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) diff -Nru r-base-3.1.0/tests/R-intro.Rout.save r-base-3.1.1/tests/R-intro.Rout.save --- r-base-3.1.0/tests/R-intro.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/R-intro.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -732,6 +732,7 @@ The following object is masked _by_ .GlobalEnv: x + > lrf <- lowess(x, y) > plot(x, y) > lines(x, lrf$y) diff -Nru r-base-3.1.0/tests/simple-true.Rout.save r-base-3.1.1/tests/simple-true.Rout.save --- r-base-3.1.0/tests/simple-true.Rout.save 2014-04-05 22:15:08.000000000 +0000 +++ r-base-3.1.1/tests/simple-true.Rout.save 2014-07-07 22:15:07.000000000 +0000 @@ -1,5 +1,5 @@ -R version 3.1.0 RC (2014-04-04 r65373) -- "Spring Dance" +R version 3.1.1 RC (2014-07-04 r66081) -- "Sock it to Me" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -43,7 +43,7 @@ > typeof(1e-3L) == "double" # gives warning [1] TRUE Warning message: -non-integer value 1e-3 qualified with L; using numeric value +non-integer value 1e-3L qualified with L; using numeric value > 1.L # gives warning [1] 1 Warning message: diff -Nru r-base-3.1.0/VERSION r-base-3.1.1/VERSION --- r-base-3.1.0/VERSION 2014-04-10 07:00:03.000000000 +0000 +++ r-base-3.1.1/VERSION 2014-07-10 07:00:04.000000000 +0000 @@ -1 +1 @@ -3.1.0 +3.1.1 diff -Nru r-base-3.1.0/VERSION-NICK r-base-3.1.1/VERSION-NICK --- r-base-3.1.0/VERSION-NICK 2014-03-26 23:02:05.000000000 +0000 +++ r-base-3.1.1/VERSION-NICK 2014-06-29 22:02:06.000000000 +0000 @@ -1 +1 @@ -Spring Dance +Sock it to Me
    ", + "", sprintf("%s", m$URL[k], m$URL[k]), "