Skip to content

Commit 4e629e3

Browse files
committed
Fix conversion warning in Tokens
+ constexpr and some noexcept
1 parent ac54b96 commit 4e629e3

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/common/Tokens.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131

3232
namespace {
3333

34-
const Firebird::Tokens::Comment sqlComments[3] = {
34+
constexpr Firebird::Tokens::Comment sqlComments[3] = {
3535
{ "/*", "*/", false },
3636
{ "--", "\n", true },
3737
{ NULL, NULL, false }
3838
};
39-
const char* sqlSpaces = " \t\r\n";
40-
const char* sqlSeps = "!\"#%&'()*+,-./:;<=>?@[\\]^`{|}~";
41-
const char* sqlQuotes = "\"'";
39+
constexpr const char* sqlSpaces = " \t\r\n";
40+
constexpr const char* sqlSeps = "!\"#%&'()*+,-./:;<=>?@[\\]^`{|}~";
41+
constexpr const char* sqlQuotes = "\"'";
4242

4343
} // anonymous namespace
4444

@@ -59,7 +59,7 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
5959
tokens.clear();
6060

6161
if (!length)
62-
length = strlen(toParse);
62+
length = fb_strlen(toParse);
6363
str.assign(toParse, length);
6464

6565
char inStr = '\0';
@@ -79,7 +79,7 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
7979
{
8080
if (strncmp(comm->start, &str[p], strlen(comm->start)) == 0)
8181
{
82-
FB_SIZE_T p2 = p + strlen(comm->start);
82+
FB_SIZE_T p2 = p + fb_strlen(comm->start);
8383
p2 = str.find(comm->stop, p2);
8484

8585
if (p2 == str.npos)
@@ -102,7 +102,7 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
102102
continue;
103103
}
104104

105-
char c = str[p];
105+
const char c = str[p];
106106

107107
if (inStr)
108108
{
@@ -140,7 +140,7 @@ void Tokens::parse(FB_SIZE_T length, const char* toParse)
140140
continue;
141141
}
142142

143-
bool quote = qs && strchr(qs, c);
143+
const bool quote = qs && strchr(qs, c);
144144

145145
if (quote)
146146
{
@@ -218,7 +218,7 @@ void Tokens::error(const char* fmt, ...)
218218
string Tokens::Tok::stripped() const
219219
{
220220
string rc;
221-
char q = text[0];
221+
const char q = text[0];
222222

223223
for (FB_SIZE_T i = 1; i < length - 1; ++i)
224224
{

src/common/Tokens.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,34 @@ class Tokens : public AutoStorage
5454

5555
Tokens();
5656

57-
void spaces(const char* s)
57+
void spaces(const char* s) noexcept
5858
{
5959
wsps = s;
6060
}
6161

62-
void quotes(const char* s)
62+
void quotes(const char* s) noexcept
6363
{
6464
qs = s;
6565
}
6666

67-
void comments(const Comment* ptr)
67+
void comments(const Comment* ptr) noexcept
6868
{
6969
comms = ptr;
7070
}
7171

72-
void separators(const char* s)
72+
void separators(const char* s) noexcept
7373
{
7474
seps = s;
7575
}
7676

7777
void parse(FB_SIZE_T length, const char* string);
7878

79-
const Tok& operator[](FB_SIZE_T pos) const
79+
const Tok& operator[](FB_SIZE_T pos) const noexcept
8080
{
8181
return tokens[pos];
8282
}
8383

84-
FB_SIZE_T getCount() const
84+
FB_SIZE_T getCount() const noexcept
8585
{
8686
return tokens.getCount();
8787
}

0 commit comments

Comments
 (0)