From d5bb462f25c260ee83d2671cae95191d4f56900a Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Wed, 24 Sep 2025 19:19:50 -0400 Subject: [PATCH] Separate `isLetter` into `isUpper` and `isLower` --- include/util.hpp | 2 ++ src/fix/mbc.cpp | 10 +++++----- src/util.cpp | 10 +++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/util.hpp b/include/util.hpp index 07c6ddc2..46ab672c 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -26,6 +26,8 @@ bool isNewline(int c); bool isBlankSpace(int c); bool isWhitespace(int c); bool isPrintable(int c); +bool isUpper(int c); +bool isLower(int c); bool isLetter(int c); bool isDigit(int c); bool isBinDigit(int c); diff --git a/src/fix/mbc.cpp b/src/fix/mbc.cpp index bf3bbeac..c375a7c2 100644 --- a/src/fix/mbc.cpp +++ b/src/fix/mbc.cpp @@ -12,7 +12,7 @@ #include "helpers.hpp" // unreachable_ #include "platform.hpp" // strcasecmp -#include "util.hpp" // isBlankSpace, isDigit +#include "util.hpp" // isBlankSpace, isLower, isDigit #include "fix/warning.hpp" @@ -107,10 +107,10 @@ static void skipMBCSpace(char const *&ptr) { } static char normalizeMBCChar(char c) { - if (c >= 'a' && c <= 'z') { // Uppercase for comparison with `mbc_Name`s - c = c - 'a' + 'A'; - } else if (c == '_') { // Treat underscores as spaces - c = ' '; + if (isLower(c)) { + c = c - 'a' + 'A'; // Uppercase for comparison with `mbc_Name`s + } else if (c == '_') { + c = ' '; // Treat underscores as spaces } return c; } diff --git a/src/util.cpp b/src/util.cpp index a3bac118..c530d135 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -26,8 +26,16 @@ bool isPrintable(int c) { return c >= ' ' && c <= '~'; } +bool isUpper(int c) { + return c >= 'A' && c <= 'Z'; +} + +bool isLower(int c) { + return c >= 'a' && c <= 'z'; +} + bool isLetter(int c) { - return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); + return isUpper(c) || isLower(c); } bool isDigit(int c) {