|
| 1 | +diff --git a/configure b/configure |
| 2 | +index 6aea90a..add4f05 100755 |
| 3 | +--- a/configure |
| 4 | ++++ b/configure |
| 5 | +@@ -33626,7 +33626,7 @@ char BZ2_bzlibVersion (); |
| 6 | + |
| 7 | + #endif |
| 8 | + int |
| 9 | +-main () |
| 10 | ++main (void) |
| 11 | + { |
| 12 | + return BZ2_bzlibVersion (); |
| 13 | + ; |
| 14 | +@@ -33690,9 +33690,11 @@ else |
| 15 | + /* end confdefs.h. */ |
| 16 | + |
| 17 | + #ifdef HAVE_BZLIB_H |
| 18 | ++#include <stdlib.h> // for exit |
| 19 | ++#include <string.h> // for strcmp |
| 20 | + #include <bzlib.h> |
| 21 | + #endif |
| 22 | +-int main() { |
| 23 | ++int main(void) { |
| 24 | + char *ver = BZ2_bzlibVersion(); |
| 25 | + exit(strcmp(ver, "1.0.6") < 0); |
| 26 | + } |
| 27 | +From 5c5c426023c4f2c9d22582a5f94f9b3337f4973b Mon Sep 17 00:00:00 2001 |
| 28 | +From: plummer <plummer@00db46b3-68df-0310-9c12-caf00c1e9a41> |
| 29 | +Date: Wed, 16 Apr 2025 21:29:31 +0000 |
| 30 | +Subject: [PATCH] Fixes for Tcl v9 |
| 31 | + |
| 32 | +git-svn-id: https://svn.r-project.org/R/trunk@88149 00db46b3-68df-0310-9c12-caf00c1e9a41 |
| 33 | +--- |
| 34 | + src/library/tcltk/src/tcltk.c | 46 ++++++++++++++++++++--------------- |
| 35 | + 1 file changed, 26 insertions(+), 20 deletions(-) |
| 36 | + |
| 37 | +diff --git a/src/library/tcltk/src/tcltk.c b/src/library/tcltk/src/tcltk.c |
| 38 | +index a326ddb6731..c55c9b31424 100644 |
| 39 | +--- a/src/library/tcltk/src/tcltk.c |
| 40 | ++++ b/src/library/tcltk/src/tcltk.c |
| 41 | +@@ -36,6 +36,11 @@ |
| 42 | + |
| 43 | + Tcl_Interp *RTcl_interp; |
| 44 | + |
| 45 | ++/* For Tcl < 8.7 */ |
| 46 | ++#ifndef TCL_SIZE_MAX |
| 47 | ++typedef int Tcl_Size; |
| 48 | ++#endif |
| 49 | ++ |
| 50 | + static void RTcl_dec_refcount(SEXP R_tclobj) |
| 51 | + { |
| 52 | + Tcl_DecrRefCount((Tcl_Obj *) R_ExternalPtrAddr(R_tclobj)); |
| 53 | +@@ -331,9 +336,9 @@ SEXP RTcl_StringFromObj(SEXP args) |
| 54 | + |
| 55 | + SEXP RTcl_ObjAsCharVector(SEXP args) |
| 56 | + { |
| 57 | +- int count; |
| 58 | ++ Tcl_Size count, i; |
| 59 | + Tcl_Obj **elem, *obj; |
| 60 | +- int ret, i; |
| 61 | ++ int ret; |
| 62 | + SEXP ans; |
| 63 | + |
| 64 | + if (TYPEOF(CADR(args)) != EXTPTRSXP) |
| 65 | +@@ -341,10 +346,10 @@ SEXP RTcl_ObjAsCharVector(SEXP args) |
| 66 | + obj = (Tcl_Obj *) R_ExternalPtrAddr(CADR(args)); |
| 67 | + if (!obj) error(_("invalid tclObj -- perhaps saved from another session?")); |
| 68 | + ret = Tcl_ListObjGetElements(RTcl_interp, obj, &count, &elem); |
| 69 | +- if (ret != TCL_OK) |
| 70 | ++ if (ret != TCL_OK || count > R_XLEN_T_MAX) |
| 71 | + return RTcl_StringFromObj(args); |
| 72 | +- |
| 73 | +- PROTECT(ans = allocVector(STRSXP, count)); |
| 74 | ++ |
| 75 | ++ PROTECT(ans = allocVector(STRSXP, (R_xlen_t) count)); |
| 76 | + for (i = 0 ; i < count ; i++) { |
| 77 | + char *s; |
| 78 | + Tcl_DString s_ds; |
| 79 | +@@ -405,9 +410,9 @@ SEXP RTcl_ObjFromCharVector(SEXP args) |
| 80 | + |
| 81 | + SEXP RTcl_ObjAsDoubleVector(SEXP args) |
| 82 | + { |
| 83 | +- int count; |
| 84 | ++ Tcl_Size count, i; |
| 85 | + Tcl_Obj **elem, *obj; |
| 86 | +- int ret, i; |
| 87 | ++ int ret; |
| 88 | + double x; |
| 89 | + SEXP ans; |
| 90 | + |
| 91 | +@@ -422,10 +427,10 @@ SEXP RTcl_ObjAsDoubleVector(SEXP args) |
| 92 | + |
| 93 | + /* Then try as list */ |
| 94 | + ret = Tcl_ListObjGetElements(RTcl_interp, obj, &count, &elem); |
| 95 | +- if (ret != TCL_OK) /* didn't work, return NULL */ |
| 96 | ++ if (ret != TCL_OK || count > R_XLEN_T_MAX) /* didn't work, return NULL */ |
| 97 | + return R_NilValue; |
| 98 | +- |
| 99 | +- ans = allocVector(REALSXP, count); |
| 100 | ++ |
| 101 | ++ ans = allocVector(REALSXP, (R_xlen_t) count); |
| 102 | + for (i = 0 ; i < count ; i++){ |
| 103 | + ret = Tcl_GetDoubleFromObj(RTcl_interp, elem[i], &x); |
| 104 | + if (ret != TCL_OK) x = NA_REAL; |
| 105 | +@@ -470,9 +475,9 @@ SEXP RTcl_ObjFromDoubleVector(SEXP args) |
| 106 | + |
| 107 | + SEXP RTcl_ObjAsIntVector(SEXP args) |
| 108 | + { |
| 109 | +- int count; |
| 110 | ++ Tcl_Size count, i; |
| 111 | + Tcl_Obj **elem, *obj; |
| 112 | +- int ret, i; |
| 113 | ++ int ret; |
| 114 | + int x; |
| 115 | + SEXP ans; |
| 116 | + |
| 117 | +@@ -487,10 +492,10 @@ SEXP RTcl_ObjAsIntVector(SEXP args) |
| 118 | + |
| 119 | + /* Then try as list */ |
| 120 | + ret = Tcl_ListObjGetElements(RTcl_interp, obj, &count, &elem); |
| 121 | +- if (ret != TCL_OK) /* didn't work, return NULL */ |
| 122 | ++ if (ret != TCL_OK || count > R_XLEN_T_MAX) /* didn't work, return NULL */ |
| 123 | + return R_NilValue; |
| 124 | +- |
| 125 | +- ans = allocVector(INTSXP, count); |
| 126 | ++ |
| 127 | ++ ans = allocVector(INTSXP, (R_xlen_t) count); |
| 128 | + for (i = 0 ; i < count ; i++){ |
| 129 | + ret = Tcl_GetIntFromObj(RTcl_interp, elem[i], &x); |
| 130 | + if (ret != TCL_OK) x = NA_INTEGER; |
| 131 | +@@ -525,7 +530,7 @@ SEXP RTcl_ObjFromIntVector(SEXP args) |
| 132 | + |
| 133 | + SEXP RTcl_ObjAsRawVector(SEXP args) |
| 134 | + { |
| 135 | +- int nb, count, i, j; |
| 136 | ++ Tcl_Size count, nb, i, j; |
| 137 | + Tcl_Obj **elem, *obj; |
| 138 | + unsigned char *ret; |
| 139 | + SEXP ans, el; |
| 140 | +@@ -536,7 +541,7 @@ SEXP RTcl_ObjAsRawVector(SEXP args) |
| 141 | + if (!obj) error(_("invalid tclObj -- perhaps saved from another session?")); |
| 142 | + ret = Tcl_GetByteArrayFromObj(obj, &nb); |
| 143 | + if (ret) { |
| 144 | +- ans = allocVector(RAWSXP, nb); |
| 145 | ++ ans = allocVector(RAWSXP, (R_xlen_t) nb); |
| 146 | + for (j = 0 ; j < nb ; j++) RAW(ans)[j] = ret[j]; |
| 147 | + return ans; |
| 148 | + } |
| 149 | +@@ -544,10 +549,11 @@ SEXP RTcl_ObjAsRawVector(SEXP args) |
| 150 | + /* Then try as list */ |
| 151 | + if (Tcl_ListObjGetElements(RTcl_interp, obj, &count, &elem) |
| 152 | + != TCL_OK) return R_NilValue; |
| 153 | +- |
| 154 | +- PROTECT(ans = allocVector(VECSXP, count)); |
| 155 | ++ if (count > R_XLEN_T_MAX) return R_NilValue; |
| 156 | ++ |
| 157 | ++ PROTECT(ans = allocVector(VECSXP, (R_xlen_t) count)); |
| 158 | + for (i = 0 ; i < count ; i++) { |
| 159 | +- el = allocVector(RAWSXP, nb); |
| 160 | ++ el = allocVector(RAWSXP, (R_xlen_t) nb); |
| 161 | + SET_VECTOR_ELT(ans, i, el); |
| 162 | + ret = Tcl_GetByteArrayFromObj(elem[i], &nb); |
| 163 | + for (j = 0 ; j < nb ; j++) RAW(el)[j] = ret[j]; |
0 commit comments