Coverage Report

Created: 2025-06-13 06:46

/src/Fast-DDS/thirdparty/taocpp-pegtl/pegtl/internal/demangle_sanitise.hpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) 2017-2020 Dr. Colin Hirsch and Daniel Frey
2
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4
#ifndef TAO_PEGTL_INTERNAL_DEMANGLE_SANITISE_HPP
5
#define TAO_PEGTL_INTERNAL_DEMANGLE_SANITISE_HPP
6
7
#include <string>
8
9
#include "../config.hpp"
10
11
namespace tao
12
{
13
   namespace TAO_PEGTL_NAMESPACE
14
   {
15
      namespace internal
16
      {
17
         inline void demangle_sanitise_chars( std::string& s )
18
0
         {
19
0
            std::string::size_type p;
20
0
            while( ( p = s.find( "(char)" ) ) != std::string::npos ) {
21
0
               int c = 0;
22
0
               std::string::size_type q;
23
0
               for( q = p + 6; ( q < s.size() ) && ( s[ q ] >= '0' ) && ( s[ q ] <= '9' ); ++q ) {
24
0
                  c *= 10;
25
0
                  c += s[ q ] - '0';
26
0
               }
27
0
               if( c == '\'' ) {
28
0
                  s.replace( p, q - p, "'\\''" );
29
0
               }
30
0
               else if( c == '\\' ) {
31
0
                  s.replace( p, q - p, "'\\\\'" );
32
0
               }
33
0
               else if( ( c < 32 ) || ( c > 126 ) ) {
34
0
                  s.replace( p, 6, std::string() );
35
0
               }
36
0
               else {
37
0
                  s.replace( p, q - p, std::string( 1, '\'' ) + char( c ) + '\'' );
38
0
               }
39
0
            }
40
0
         }
41
42
      }  // namespace internal
43
44
   }  // namespace TAO_PEGTL_NAMESPACE
45
46
}  // namespace tao
47
48
#endif