Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions cpp/src/gandiva/precompiled/string_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,8 @@ const char* binary_string(gdv_int64 context, const char* text, gdv_int32 text_le
(text[i + 1] == 'x' || text[i + 1] == 'X')) {
char hd1 = text[i + 2];
char hd2 = text[i + 3];
if (isxdigit(hd1) && isxdigit(hd2)) {
if (isxdigit(static_cast<unsigned char>(hd1)) &&
isxdigit(static_cast<unsigned char>(hd2))) {
// [a-fA-F0-9]
ret[j] = to_binary_from_hex(hd1) * 16 + to_binary_from_hex(hd2);
i += 3;
Expand Down Expand Up @@ -2345,7 +2346,7 @@ const char* binary_string(gdv_int64 context, const char* text, gdv_int32 text_le
int read_index = 0; \
while (read_index < in_len) { \
char c1 = in[read_index]; \
if (isxdigit(c1)) { \
if (isxdigit(static_cast<unsigned char>(c1))) { \
digit = to_binary_from_hex(c1); \
\
OUT_TYPE next = result * 16 - digit; \
Expand Down Expand Up @@ -2916,7 +2917,8 @@ const char* from_hex_utf8(int64_t context, const char* text, int32_t text_len,
for (int32_t i = 0; i < text_len; i += 2) {
char b1 = text[i];
char b2 = text[i + 1];
if (isxdigit(b1) && isxdigit(b2)) {
if (isxdigit(static_cast<unsigned char>(b1)) &&
isxdigit(static_cast<unsigned char>(b2))) {
// [a-fA-F0-9]
ret[j++] = to_binary_from_hex(b1) * 16 + to_binary_from_hex(b2);
} else {
Expand Down Expand Up @@ -2984,9 +2986,9 @@ const char* soundex_utf8(gdv_int64 context, const char* in, gdv_int32 in_len,

int start_idx = 0;
for (int i = 0; i < in_len; ++i) {
if (isalpha(in[i]) > 0) {
if (isalpha(static_cast<unsigned char>(in[i])) > 0) {
// Retain the first letter
ret[0] = toupper(in[i]);
ret[0] = toupper(static_cast<unsigned char>(in[i]));
start_idx = i + 1;
break;
}
Expand All @@ -3002,8 +3004,8 @@ const char* soundex_utf8(gdv_int64 context, const char* in, gdv_int32 in_len,
soundex[0] = '\0';
// Replace consonants with digits and special letters with 0
for (int i = start_idx; i < in_len; i++) {
if (isalpha(in[i]) > 0) {
c = toupper(in[i]) - 65;
if (isalpha(static_cast<unsigned char>(in[i])) > 0) {
c = toupper(static_cast<unsigned char>(in[i])) - 65;
if (mappings[c] != soundex[si - 1]) {
soundex[si] = mappings[c];
si++;
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/gandiva/precompiled/time.cc
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ gdv_date64 castDATE_utf8(int64_t context, const char* input, gdv_int32 length) {
int dateIndex = 0, index = 0, value = 0;
int year_str_len = 0;
while (dateIndex < 3 && index < length) {
if (!isdigit(input[index])) {
if (!isdigit(static_cast<unsigned char>(input[index]))) {
dateFields[dateIndex++] = value;
value = 0;
} else {
Expand Down Expand Up @@ -713,7 +713,7 @@ gdv_timestamp castTIMESTAMP_utf8(int64_t context, const char* input, gdv_int32 l
int year_str_len = 0, sub_seconds_len = 0;
int ts_field_index = TimeFields::kYear, index = 0, value = 0;
while (ts_field_index < TimeFields::kMax && index < length) {
if (isdigit(input[index])) {
if (isdigit(static_cast<unsigned char>(input[index]))) {
value = (value * 10) + (input[index] - '0');
if (ts_field_index == TimeFields::kYear) {
year_str_len++;
Expand Down Expand Up @@ -842,7 +842,7 @@ gdv_time32 castTIME_utf8(int64_t context, const char* input, int32_t length) {

bool has_invalid_digit = false;
while (time_field_idx < TimeFields::kDisplacementHours && index < length) {
if (isdigit(input[index])) {
if (isdigit(static_cast<unsigned char>(input[index]))) {
value = (value * 10) + (input[index] - '0');

if (time_field_idx == TimeFields::kSubSeconds) {
Expand Down
Loading