GCC Code Coverage Report


Directory: ./
File: pdserv/src/lib/StringUtils.cpp
Date: 2026-09-27 04:07:30
Exec Total Coverage
Lines: 0 13 0.0%
Branches: 0 12 0.0%

Line Branch Exec Source
1 /*****************************************************************************
2 *
3 * Copyright 2026 Florian Pose <fp@igh.de>
4 *
5 * This file is part of the pdserv library.
6 *
7 * The pdserv library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or (at
10 * your option) any later version.
11 *
12 * The pdserv library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with the pdserv library. If not, see <http://www.gnu.org/licenses/>.
19 *
20 *****************************************************************************/
21
22 #include "StringUtils.h"
23
24 #include <cctype> // isspace()
25
26 /////////////////////////////////////////////////////////////////////////////
27 ✗ std::string normalizeWhitespace(const std::string &text)
28 {
29 ✗ std::string result;
30 ✗ result.reserve(text.size());
31 ✗ bool pendingSpace {false};
32
33 ✗ for (char c : text) {
34 ✗ if (std::isspace(static_cast<unsigned char>(c))) {
35 ✗ pendingSpace = not result.empty();
36 ✗ continue;
37 }
38 ✗ if (pendingSpace) {
39 ✗ result += ' ';
40 ✗ pendingSpace = false;
41 }
42 ✗ result += c;
43 }
44
45 ✗ return result;
46 }
47