[Rd] Minor portability patch

coypu at sdf.org coypu at sdf.org
Tue Feb 9 06:41:16 CET 2016


Hi, I've used the following patch

First because re-defining strtoi is a problem, and it's named Strtoi
elsewhere.
Second because that is the sole use of strtoi that isn't Strtoi.
Third, use = instead of ==, which is bash-specific.

Additionally I must note there are a number of tests in configure.ac which
do not append x to the beginning of the string.
I have been told that it may result in undefined behaviour in some shells when
the string is empty.

If you wish, I will provide a patch for this as well.


--- src/main/character.c.orig	2016-02-03 01:59:38.000000000 +0000
+++ src/main/character.c
@@ -1561,7 +1561,7 @@ SEXP attribute_hidden do_strtrim(SEXP ca
     return s;
 }
 
-static int strtoi(SEXP s, int base)
+static int Strtoi(SEXP s, int base)
 {
     long int res;
     char *endp;
@@ -1595,7 +1595,7 @@ SEXP attribute_hidden do_strtoi(SEXP cal
 
     PROTECT(ans = allocVector(INTSXP, n = LENGTH(x)));
     for(i = 0; i < n; i++)
-	INTEGER(ans)[i] = strtoi(STRING_ELT(x, i), base);
+	INTEGER(ans)[i] = Strtoi(STRING_ELT(x, i), base);
     UNPROTECT(1);
 
     return ans;

--- configure.ac.orig	2016-02-05 17:07:44.000000000 +0000
+++ configure.ac
@@ -327,7 +327,7 @@ AC_ARG_ENABLE([lto],
 if test "x${want_lto}" != xno; then
   LTO=-flto
 fi
-if test "x${want_lto}" == xyes; then
+if test "x${want_lto}" = xyes; then
   LTOALL=-flto
 fi
 AC_SUBST(LTO)



More information about the R-devel mailing list