From 867a0c11b03d3f78180a65aaea4ea1b9fb6b85cd Mon Sep 17 00:00:00 2001 From: "Maxim [maxirmx] Samsonov" Date: Sun, 2 Jun 2024 00:39:17 +0300 Subject: [PATCH] Fixed sexp_simple_string comparator --- .github/workflows/build-and-test-rh.yml | 9 +++++++++ include/sexpp/sexp.h | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test-rh.yml b/.github/workflows/build-and-test-rh.yml index bb82d29..e2df65d 100644 --- a/.github/workflows/build-and-test-rh.yml +++ b/.github/workflows/build-and-test-rh.yml @@ -95,12 +95,21 @@ jobs: run: sudo yum -y install findutils - name: Checkout shell test framework + if: matrix.image != 'centos:7' uses: actions/checkout@v4 with: repository: kward/shunit2 path: ${{github.workspace}}/tests/shunit2 fetch-depth: 1 + - name: Checkout shell test framework centos7 + if: matrix.image == 'centos:7' + uses: actions/checkout@v3 + with: + repository: kward/shunit2 + path: ${{github.workspace}}/tests/shunit2 + fetch-depth: 1 + - name: Run additional tests shell: bash run: tests/scripts/tests.sh diff --git a/include/sexpp/sexp.h b/include/sexpp/sexp.h index 9e2d1fd..de0d093 100644 --- a/include/sexpp/sexp.h +++ b/include/sexpp/sexp.h @@ -251,12 +251,14 @@ class SEXP_PUBLIC_SYMBOL sexp_string_t : public sexp_object_t { inline bool operator==(const sexp_string_t *left, const std::string &right) noexcept { - return memcmp(left->get_string().data(), right.c_str(), right.size()) == 0; + return left->get_string().size() == right.length() && + memcmp(left->get_string().data(), right.c_str(), left->get_string().size()) == 0; } inline bool operator!=(const sexp_string_t *left, const std::string &right) noexcept { - return memcmp(left->get_string().data(), right.c_str(), right.size()) != 0; + return left->get_string().size() != right.length() || + memcmp(left->get_string().data(), right.c_str(), left->get_string().size()) != 0; } /*