From 9d88032504ee6a265e24cbd468511b5da22a2292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sat, 25 Sep 2021 22:52:39 +0200 Subject: [PATCH 1/4] Update GHA platforms and R versions * Use R versions up to R 4.1. * Remove old R versions, 3.2, 3.3, they are not supported any more. * Update Ubuntu to 18.04. --- .github/workflows/R-CMD-check.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index e7d8cfb..26a4061 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -19,13 +19,14 @@ jobs: matrix: config: - {os: windows-latest, r: '3.6'} + - {os: windows-latest, r: '4.1'} - {os: macOS-latest, r: '3.6'} - {os: macOS-latest, r: 'devel'} - - {os: ubuntu-16.04, r: '3.2', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.3', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.4', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.5', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.6', rspm: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} + - {os: ubuntu-18.04, r: '3.4', rspm: "https://demo.rstudiopm.com/all/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '3.5', rspm: "https://demo.rstudiopm.com/all/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '3.6', rspm: "https://demo.rstudiopm.com/all/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '4.0', rspm: "https://demo.rstudiopm.com/all/__linux__/bionic/latest"} + - {os: ubuntu-18.04, r: '4.1', rspm: "https://demo.rstudiopm.com/all/__linux__/bionic/latest"} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true @@ -51,8 +52,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('depends.Rds') }} - restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}- + key: ${{ runner.os }}-r-${{ matrix.config.r }}-1-${{ hashFiles('depends.Rds') }} + restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-1- - name: Install system dependencies if: runner.os == 'Linux' From c9f9cf9771401236e0612d8cbf09251a4c496bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sat, 25 Sep 2021 23:07:12 +0200 Subject: [PATCH 2/4] Make untermiated quotes error Closes #219. --- src/glue.c | 6 ++++++ tests/testthat/test-glue.R | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/glue.c b/src/glue.c index 12cdee4..2682565 100644 --- a/src/glue.c +++ b/src/glue.c @@ -176,6 +176,12 @@ SEXP glue_(SEXP x, SEXP f, SEXP open_arg, SEXP close_arg) { if (state == delim) { free(str); Rf_error("Expecting '%s'", close); + } else if (state == single_quote) { + free(str); + Rf_error("Unterminated quote (')"); + } else if (state == double_quote) { + free(str); + Rf_error("Unterminated quote (\")"); } free(str); diff --git a/tests/testthat/test-glue.R b/tests/testthat/test-glue.R index a9d8ed1..f4507e1 100644 --- a/tests/testthat/test-glue.R +++ b/tests/testthat/test-glue.R @@ -424,3 +424,8 @@ test_that("+ method for glue works", { x <- 1 expect_identical(glue("x = ") + "{x}", glue("x = {x}")) }) + +test_that("unterminated quotes are error", { + expect_error(glue("{this doesn\"t work}"), "Unterminated quote") + expect_error(glue("{this doesn't work}"), "Unterminated quote") +}) From 1fbb9a342203372c33647996b68664d648d261c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Sun, 26 Sep 2021 01:04:02 +0200 Subject: [PATCH 3/4] Unterminated comments error now Instead of generating an empty string. Closes #224. --- src/glue.c | 3 +++ tests/testthat/test-glue.R | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/glue.c b/src/glue.c index 2682565..41ed2a0 100644 --- a/src/glue.c +++ b/src/glue.c @@ -182,6 +182,9 @@ SEXP glue_(SEXP x, SEXP f, SEXP open_arg, SEXP close_arg) { } else if (state == double_quote) { free(str); Rf_error("Unterminated quote (\")"); + } else if (state == comment) { + free(str); + Rf_error("Unterminated comment"); } free(str); diff --git a/tests/testthat/test-glue.R b/tests/testthat/test-glue.R index f4507e1..0eb0178 100644 --- a/tests/testthat/test-glue.R +++ b/tests/testthat/test-glue.R @@ -429,3 +429,10 @@ test_that("unterminated quotes are error", { expect_error(glue("{this doesn\"t work}"), "Unterminated quote") expect_error(glue("{this doesn't work}"), "Unterminated quote") }) + +test_that("unterminated comment", { + expect_error(glue("pre {1 + 5 # comment} post"), "Unterminated comment") + expect_error(glue("pre {1 + 5 # comment"), "Unterminated comment") + + expect_equal(glue("pre {1 + 5 + #comment\n 4} post"), "pre 10 post") +}) From e5016faffe4f77fdf05725d0e166f1763886844e Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Mon, 27 Sep 2021 16:26:45 -0400 Subject: [PATCH 4/4] Add note to news --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 8926803..5be7b14 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # glue 1.4.2 +* Unterminated comments in glue expression now throw an error (#227, @gaborcsardi) * Unterminated quotes in glue expressions now throw an error (#226, @gaborcsardi) * `glue_safe()` gives a slightly nicer error message * The required version of R is now 3.2 (#189)