From 1a0bf42025860a755e3c6b48e9f17325def279f2 Mon Sep 17 00:00:00 2001 From: 2005m Date: Tue, 25 Jun 2024 23:31:24 +0100 Subject: [PATCH] Small correction --- MD5 | 6 +++--- src/psum.c | 4 ++-- src/utils.c | 7 +++---- src/vswitch.c | 12 ++++++------ 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/MD5 b/MD5 index 01c11a7..f80afd0 100644 --- a/MD5 +++ b/MD5 @@ -28,10 +28,10 @@ a52426250b954a335b1121948e057ee7 *src/Makevars.in 95e3011e37d9dde0d75f3a3819b2acd3 *src/Makevars.win 1e8b11cf04b116653c0a82a20f72490b *src/nswitch.c 7b6cc295ee89e397e47957097cf15417 *src/psort.c -d9e5ee62440914d68cec114cd9717af2 *src/psum.c +8c15e9c171d447aed088cec849323fab *src/psum.c 7589054d8388fe7ed3354a5aa388eb02 *src/share.c ef9329d7e748c13b9526fca1788a1891 *src/topn.c -8b27a6955a60f8c94b6ae39845948bb9 *src/utils.c -ffd709a7cfedf05d54c7577f8a248a28 *src/vswitch.c +58a06280212a06ea2b8039bebb03fcdf *src/utils.c +37787d47d80dfd40bc3d12699ed30441 *src/vswitch.c 6af1b66c0c90f6809c960e2133c1b5e4 *tests/test_kit.R 0dce9bd953fe40b1c8fae3d01a597e7c *tests/test_kit.Rout.save diff --git a/src/psum.c b/src/psum.c index f6b70b6..ffc196d 100644 --- a/src/psum.c +++ b/src/psum.c @@ -950,14 +950,14 @@ SEXP pfirstR(SEXP last, SEXP args) { } } break; case STRSXP: { - SEXP *restrict pans = STRING_PTR_RO(ans); + const SEXP *restrict pans = STRING_PTR_RO(ans); for (int i = 1; i < n; ++i) { const SEXP *restrict pa = STRING_PTR_RO(PTR_ETL(args, i)); ssize_t nna = 0; for (ssize_t j = 0; j < len0; ++j) { if(pans[j] == NA_STRING) { if(pa[j] == NA_STRING) ++nna; - else pans[j] = pa[j]; + else SET_STRING_ELT(ans, j, pa[j]); } } if(nna == 0) break; diff --git a/src/utils.c b/src/utils.c index 29cbd31..a559ec7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -261,9 +261,8 @@ SEXP subSetRowDataFrame(SEXP df, SEXP rws) { case STRSXP : { const SEXP *restrict ptmp = STRING_PTR_RO(pdf[i]); SEXP TYPECOL = PROTECT(allocVector(STRSXP, len_rws)); - SEXP *restrict pc = STRING_PTR_RO(TYPECOL); for (R_xlen_t j = 0; j < len_rws; ++j) { - pc[j] = ptmp[prws[j]]; + SET_STRING_ELT(TYPECOL,j, ptmp[prws[j]]); } copyMostAttrib(pdf[i], TYPECOL); SET_VECTOR_ELT(dfo, i, TYPECOL); @@ -812,7 +811,7 @@ SEXP dfToMatrix(SEXP df) { bool isMixEnc(SEXP x) { const R_xlen_t len = xlength(x); - SEXP *px = STRING_PTR_RO(x); + const SEXP *px = STRING_PTR_RO(x); const cetype_t ces = getCharCE(px[0]); for (R_xlen_t i = 1; i < len; ++i) if(getCharCE(px[i]) != ces) @@ -821,7 +820,7 @@ bool isMixEnc(SEXP x) { } SEXP enc2UTF8(SEXP x) { - SEXP *px = STRING_PTR_RO(x); + const SEXP *px = STRING_PTR_RO(x); const R_xlen_t len = xlength(x); if (getCharCE(px[0]) != CE_UTF8) { SEXP ans = PROTECT(allocVector(STRSXP, len)); diff --git a/src/vswitch.c b/src/vswitch.c index 5445d60..764736e 100644 --- a/src/vswitch.c +++ b/src/vswitch.c @@ -514,7 +514,7 @@ SEXP vswitchR(SEXP x, SEXP values, SEXP outputs, SEXP na, SEXP nthreads, SEXP ch const int *restrict px = LOGICAL(x); const int *restrict pvalues = LOGICAL(values); for (ssize_t i=0; i