• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polserver / polserver / 21100551564

17 Jan 2026 08:40PM UTC coverage: 60.504% (+0.01%) from 60.492%
21100551564

Pull #857

github

turleypol
fixed scope
Pull Request #857: ClangTidy readability-else-after-return

837 of 1874 new or added lines in 151 files covered. (44.66%)

48 existing lines in 26 files now uncovered.

44445 of 73458 relevant lines covered (60.5%)

515341.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.1
/pol-core/bscript/escrutil.cpp
1
/** @file
2
 *
3
 * @par History
4
 * - 2005/07/06 Shinigami: convert_numeric will use string representation if overflow
5
 */
6

7

8
#include "escrutil.h"
9

10
#include <climits>
11
#include <cmath>
12
#include <ctype.h>
13
#include <stdlib.h>
14

15
#include "bobject.h"
16
#include "impstr.h"
17

18

19
namespace Pol::Bscript
20
{
21
bool could_be_a_number( const char* s )
9✔
22
{
23
  if ( s[0] == '0' && ( s[1] == 'x' || s[1] == 'X' ) )  // Hex number
9✔
24
  {
25
    s += 2;
×
26
    while ( *s )
×
27
    {
28
      char ch = *s;
×
29
      ++s;
×
30
      if ( isxdigit( ch ) )
×
31
        continue;
×
NEW
32
      if ( isspace( ch ) )
×
33
        return true;
×
NEW
34
      return false;
×
35
    }
36
    return true;
×
37
  }
38
  // expect -, +, 0-9, . only
39
  while ( *s )
39✔
40
  {
41
    char ch = *s;
30✔
42
    ++s;
30✔
43
    if ( ch == '-' || ch == '+' || ( ch >= '0' && ch <= '9' ) || ch == '.' )
30✔
44
    {
45
      continue;
30✔
46
    }
47

NEW
48
    return false;
×
49
  }
50
  return true;
9✔
51
}
52

53
BObjectImp* convert_numeric( const std::string& str, int radix )
771✔
54
{
55
  const char* s = str.c_str();
771✔
56
  int ch = static_cast<unsigned char>( s[0] );
771✔
57
  if ( isdigit( ch ) || ch == '.' || ch == '+' || ch == '-' )
771✔
58
  {
59
    char *endptr = nullptr, *endptr2 = nullptr;
507✔
60
    long l = strtol( s, &endptr, radix );
507✔
61
    double d = strtod( s, &endptr2 );
507✔
62

63
    if ( endptr >= endptr2 )
507✔
64
    {
65
      // it's a long
66
      if ( endptr )
498✔
67
      {
68
        if ( ( l > INT_MIN ) && ( l < INT_MAX ) )
498✔
69
        {
70
          while ( *endptr )
486✔
71
          {
72
            if ( !isspace( *endptr ) )
12✔
73
            {
74
              if ( *endptr == '/' && *( endptr + 1 ) == '/' )
12✔
75
              {  // what follows is a comment
76
                break;
×
77
              }
78
              return nullptr;
12✔
79
            }
80
            ++endptr;
×
81
          }
82
        }
83
        else
84
          return nullptr;  // overflow, read it as string
12✔
85
      }
86
      return new BLong( l );
474✔
87
    }
88

89
    if ( !could_be_a_number( s ) )
9✔
NEW
90
      return nullptr;
×
91
    if ( endptr2 )
9✔
92
    {
93
      if ( ( d != -HUGE_VAL ) && ( d != +HUGE_VAL ) )
9✔
94
      {
95
        while ( *endptr2 )
9✔
96
        {
NEW
97
          if ( !isspace( *endptr2 ) )
×
98
          {
NEW
99
            if ( *endptr2 == '/' && *( endptr2 + 1 ) == '/' )
×
100
            {
101
              // assume what follows is a comment
NEW
102
              break;
×
103
            }
NEW
104
            return nullptr;
×
105
          }
NEW
106
          ++endptr2;
×
107
        }
108
      }
109
      else
NEW
110
        return nullptr;  // overflow, read it as string
×
111
    }
112
    return new Double( d );
9✔
113
  }
114
  return nullptr;
264✔
115
}
116

117
BObjectImp* bobject_from_string( const std::string& str, int radix )
771✔
118
{
119
  BObjectImp* imp = convert_numeric( str, radix );
771✔
120
  if ( imp )
771✔
121
    return imp;
483✔
122
  return new ConstString( str );
288✔
123
}
124

125

126
std::string normalize_ecl_filename( const std::string& filename )
252✔
127
{
128
  if ( filename.find( ".ecl" ) == std::string::npos )
252✔
129
    return filename + ".ecl";
140✔
130
  return filename;
112✔
131
}
132
}  // namespace Pol::Bscript
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc