8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:43:03 +01:00

Fix debug build failure with assertion in CRT (#8121)

This commit is contained in:
Dimitry Sibiryakov 2024-05-16 18:28:09 +02:00 committed by GitHub
parent d3adce137d
commit c952682135
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 25 additions and 21 deletions

View File

@ -2751,13 +2751,13 @@ bool CVT_get_boolean(const dsc* desc, ErrorFunction err)
// Remove heading and trailing spaces.
while (len > 0 && isspace((UCHAR) *p))
while (len > 0 && fb_utils::isspace(*p))
{
++p;
--len;
}
while (len > 0 && isspace((UCHAR) p[len - 1]))
while (len > 0 && fb_utils::isspace(p[len - 1]))
--len;
if (len == 4 && fb_utils::strnicmp(p, "TRUE", len) == 0)

View File

@ -29,6 +29,7 @@
#ifndef INCLUDE_UTILS_PROTO_H
#define INCLUDE_UTILS_PROTO_H
#include <cctype>
#include <string.h>
#include "../common/classes/fb_string.h"
#include "../common/classes/array.h"
@ -99,6 +100,13 @@ namespace fb_utils
#endif
}
// std::isspace behavior is undefined with char and signed char.
// https://en.cppreference.com/w/cpp/string/byte/isspace
static inline int isspace(const char c)
{
return std::isspace((int)(UCHAR)c);
}
#ifdef WIN_NT
bool prefix_kernel_object_name(char* name, size_t bufsize);
bool isGlobalKernelPrefix();

View File

@ -162,7 +162,7 @@ void Parser::transformString(const char* start, unsigned length, string& dest)
const char* s = lex.start + mark.pos;
buffer.add(pos, s - pos);
if (!isspace(UCHAR(pos[s - pos - 1])))
if (!fb_utils::isspace(pos[s - pos - 1]))
buffer.add(' '); // fix _charset'' becoming invalid syntax _charsetX''
const FB_SIZE_T count = buffer.getCount();
@ -1255,7 +1255,7 @@ int Parser::yylexAux()
// Must be punctuation -- test for double character punctuation
if (lex.last_token + 1 < lex.end && !isspace(UCHAR(lex.last_token[1])))
if (lex.last_token + 1 < lex.end && !fb_utils::isspace(lex.last_token[1]))
{
const MetaName str(lex.last_token, 2);

View File

@ -22,6 +22,7 @@
*/
#include "firebird.h"
#include "../common/utils_proto.h"
#include "../isql/FrontendLexer.h"
#include <algorithm>
#include <cctype>
@ -29,13 +30,12 @@
static std::string trim(std::string_view str);
static std::string trim(std::string_view str)
{
auto finish = str.end();
auto start = str.begin();
while (start != finish && isspace(*start))
while (start != finish && fb_utils::isspace(*start))
++start;
if (start == finish)
@ -43,7 +43,7 @@ static std::string trim(std::string_view str)
--finish;
while (finish > start && isspace(*finish))
while (finish > start && fb_utils::isspace(*finish))
--finish;
return std::string(start, finish + 1);
@ -210,7 +210,7 @@ FrontendLexer::Token FrontendLexer::getToken()
break;
default:
while (pos != end && !isspace(*pos))
while (pos != end && !fb_utils::isspace(*pos))
++pos;
token.processedText = std::string(start, pos);
@ -333,9 +333,9 @@ std::optional<FrontendLexer::Token> FrontendLexer::getStringToken()
void FrontendLexer::skipSpacesAndComments()
{
while (pos != end && (isspace(*pos) || *pos == '-' || *pos == '/'))
while (pos != end && (fb_utils::isspace(*pos) || *pos == '-' || *pos == '/'))
{
while (pos != end && isspace(*pos))
while (pos != end && fb_utils::isspace(*pos))
++pos;
if (pos == end)

View File

@ -297,11 +297,6 @@ static inline bool commit_trans(Firebird::ITransaction** x)
return true;
}
static inline int fb_isspace(const char c)
{
return isspace((int)(UCHAR)c);
}
static inline int fb_isdigit(const char c)
{
return isdigit((int)(UCHAR)c);
@ -2307,7 +2302,7 @@ void ISQL_print_validation(FILE* fp,
{
// computed field SQL syntax correction
while (fb_isspace(*p))
while (fb_utils::isspace(*p))
p++;
if (*p == '(')
issql = true;
@ -2316,7 +2311,7 @@ void ISQL_print_validation(FILE* fp,
{
// Validation SQL syntax correction
while (fb_isspace(*p))
while (fb_utils::isspace(*p))
p++;
if (!fb_utils::strnicmp(p, "CHECK", 5))
issql = true;
@ -5005,7 +5000,7 @@ static processing_state escape(const TEXT* cmd)
shellcmd += strlen("shell");
// Eat whitespace at beginning of command
while (*shellcmd && fb_isspace(*shellcmd))
while (*shellcmd && fb_utils::isspace(*shellcmd))
shellcmd++;
#ifdef WIN_NT
@ -5418,7 +5413,7 @@ static void frontend_load_parms(const TEXT* p, TEXT* parms[], TEXT* lparms[],
else
{
// Prevent overflow. Do not copy the string (redundant).
while (*p && !fb_isspace(*p) && j < BUFFER_LENGTH256 - 1)
while (*p && !fb_utils::isspace(*p) && j < BUFFER_LENGTH256 - 1)
{
j++;
++p;
@ -5430,7 +5425,7 @@ static void frontend_load_parms(const TEXT* p, TEXT* parms[], TEXT* lparms[],
lparms[i] = (TEXT*) ISQL_ALLOC((SLONG) (length + 1));
memcpy(parms[i], quoted ? buffer : p - j, length);
parms[i][length] = 0;
while (*p && fb_isspace(*p))
while (*p && fb_utils::isspace(*p))
p++;
strcpy(lparms[i], parms[i]);
if (!role_found)

View File

@ -34,6 +34,7 @@
#include "ibase.h"
#include "isql.h"
#include "../common/classes/MsgPrint.h"
#include "../common/utils_proto.h"
#include <stdarg.h>
using MsgFormat::SafeArg;
@ -249,7 +250,7 @@ void IUTILS_truncate_term(TEXT* str, USHORT len)
* CVC: Notice isspace may be influenced by locales.
**************************************/
int i = len - 1;
while (i >= 0 && (isspace(UCHAR(str[i])) || (str[i] == 0)))
while (i >= 0 && (str[i] == 0 || fb_utils::isspace(str[i])))
--i;
str[i + 1] = 0;
}