From 56e967da7983056706f230087d2788ad1f86d3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 23 Aug 2023 11:00:36 +0200 Subject: [PATCH] Fixed cppcheck warning --- .../Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc b/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc index a6940f62..2bccda5e 100644 --- a/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc +++ b/src/OpenMesh/Apps/VDProgMesh/mkbalancedpm/mkbalancedpm.cc @@ -178,9 +178,18 @@ replace_extension( std::string& _s, const std::string& _e ) { std::string::size_type dot = _s.rfind("."); if (dot == std::string::npos) - { _s += "." + _e; } + { + // The name does not include a dot and therefore no extension. Adding both. + _s += "." + _e; + } else - { _s = _s.substr(0,dot+1)+_e; } + { + // get everything of the name including the dot but remove the extension. + const std::string name = _s.substr(0,dot+1); + + // Add the new extenion + _s = name + _e; + } return _s; }