Skip to content

Commit

Permalink
Fixed sexp_simple_string comparator
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jun 1, 2024
1 parent fd21736 commit 867a0c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-and-test-rh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 4 additions & 2 deletions include/sexpp/sexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit 867a0c1

Please sign in to comment.