From 2e848ca2bca2545471f9076311a92acae049eb7e Mon Sep 17 00:00:00 2001 From: magiblot Date: Thu, 24 Oct 2024 00:57:11 +0200 Subject: [PATCH] Fix usages of 'toupper' 'TMenuView::findItem' was unable to match the Alt+Space shortcut on Alpine Linux (using muslc). What's surprising is that this had been working everywhere else... --- source/platform/strings.cpp | 2 +- source/tvision/edits.cpp | 2 +- source/tvision/tbutton.cpp | 2 +- source/tvision/tchdrdlg.cpp | 2 +- source/tvision/tcluster.cpp | 2 +- source/tvision/tdircoll.cpp | 2 +- source/tvision/tfillist.cpp | 2 +- source/tvision/tinputli.cpp | 2 +- source/tvision/tlabel.cpp | 2 +- source/tvision/tmnuview.cpp | 4 ++-- source/tvision/tvtext2.cpp | 4 ++-- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/source/platform/strings.cpp b/source/platform/strings.cpp index 2ed52db2e..630c8d2fe 100644 --- a/source/platform/strings.cpp +++ b/source/platform/strings.cpp @@ -77,7 +77,7 @@ int strnicmp( const char *s1, const char *s2, size_t maxlen ) noexcept char *strupr(char *s) noexcept { char* p = s; - while ((*p = toupper(*p))) + while ((*p = toupper((uchar) *p))) p++; return s; } diff --git a/source/tvision/edits.cpp b/source/tvision/edits.cpp index 1bf6d9c6a..0211b4d46 100644 --- a/source/tvision/edits.cpp +++ b/source/tvision/edits.cpp @@ -178,7 +178,7 @@ uint iScan( const char *block, uint size, const char *str ) while (i < size) { uint j = i, k = 0; - while (j < size && toupper(block[j++]) == toupper(str[k])) + while (j < size && toupper((uchar) block[j++]) == toupper((uchar) str[k])) if (++k == len) return i; ++i; diff --git a/source/tvision/tbutton.cpp b/source/tvision/tbutton.cpp index 0de510b12..c82afcd3e 100644 --- a/source/tvision/tbutton.cpp +++ b/source/tvision/tbutton.cpp @@ -217,7 +217,7 @@ void TButton::handleEvent( TEvent& event ) ( event.keyDown.keyCode == getAltCode(c) || ( owner->phase == phPostProcess && c != 0 && - toupper(event.keyDown.charScan.charCode) == c + c == (char) toupper(event.keyDown.charScan.charCode) ) || ( (state & sfFocused) != 0 && event.keyDown.charScan.charCode == ' ' diff --git a/source/tvision/tchdrdlg.cpp b/source/tvision/tchdrdlg.cpp index 57f01896c..57939a0f7 100644 --- a/source/tvision/tchdrdlg.cpp +++ b/source/tvision/tchdrdlg.cpp @@ -194,7 +194,7 @@ void TChDirDialog::setUpDialog() static int changeDir( const char *path ) { if( path[1] == ':' ) - setdisk( toupper(path[0]) - 'A' ); + setdisk( (char) toupper((uchar) path[0]) - 'A' ); return chdir( path ); } diff --git a/source/tvision/tcluster.cpp b/source/tvision/tcluster.cpp index 61915e93d..752057dd8 100644 --- a/source/tvision/tcluster.cpp +++ b/source/tvision/tcluster.cpp @@ -264,7 +264,7 @@ void TCluster::handleEvent( TEvent& event ) (state & sfFocused) != 0 ) && c != 0 && - toupper(event.keyDown.charScan.charCode) == c + c == (char) toupper(event.keyDown.charScan.charCode) ) ) ) diff --git a/source/tvision/tdircoll.cpp b/source/tvision/tdircoll.cpp index 07450a66b..1ee1a04b7 100644 --- a/source/tvision/tdircoll.cpp +++ b/source/tvision/tdircoll.cpp @@ -60,7 +60,7 @@ I INT 21H I XCHG AX, CX // Put the return value into AX return Boolean(_AX); #else - drive = (char) toupper( drive ); + drive = toupper((uchar) drive); DWORD mask = 0x01 << (drive - 'A'); return (Boolean) (GetLogicalDrives() & mask); #endif diff --git a/source/tvision/tfillist.cpp b/source/tvision/tfillist.cpp index 437189eab..99779214b 100644 --- a/source/tvision/tfillist.cpp +++ b/source/tvision/tfillist.cpp @@ -320,7 +320,7 @@ static int getPathDrive( const char *path ) { if( path[0] && path[1] == ':' ) { - int drive = toupper(path[0]) - 'A'; + int drive = (char) toupper((uchar) path[0]) - 'A'; if (0 <= drive && drive <= 'Z' - 'A') return drive; } diff --git a/source/tvision/tinputli.cpp b/source/tvision/tinputli.cpp index 3d72a14d8..c2d06b2ce 100644 --- a/source/tvision/tinputli.cpp +++ b/source/tvision/tinputli.cpp @@ -43,7 +43,7 @@ char hotKey( const char *s ) noexcept char *p; if( (p = strchr( (char *) s, '~' )) != 0 ) - return toupper(p[1]); + return toupper((uchar) p[1]); else return 0; } diff --git a/source/tvision/tlabel.cpp b/source/tvision/tlabel.cpp index 81783939c..95cded9a6 100644 --- a/source/tvision/tlabel.cpp +++ b/source/tvision/tlabel.cpp @@ -92,7 +92,7 @@ void TLabel::handleEvent( TEvent& event ) if( event.keyDown.keyCode != 0 && ( getAltCode(c) == event.keyDown.keyCode || ( c != 0 && owner->phase == TGroup::phPostProcess && - toupper(event.keyDown.charScan.charCode) == c ) + c == (char) toupper(event.keyDown.charScan.charCode) ) ) ) focusLink(event); diff --git a/source/tvision/tmnuview.cpp b/source/tvision/tmnuview.cpp index e0b3c93b4..d17df7788 100644 --- a/source/tvision/tmnuview.cpp +++ b/source/tvision/tmnuview.cpp @@ -413,14 +413,14 @@ ushort TMenuView::execute() TMenuItem *TMenuView::findItem( char ch ) { - ch = toupper(ch); + ch = toupper((uchar) ch); TMenuItem *p = menu->items; while( p != 0 ) { if( p->name != 0 && !p->disabled ) { char *loc = strchr( (char *) p->name, '~' ); - if( loc != 0 && (uchar)ch == toupper( loc[1] ) ) + if( loc != 0 && ch == (char) toupper((uchar) loc[1]) ) return p; } p = p->next; diff --git a/source/tvision/tvtext2.cpp b/source/tvision/tvtext2.cpp index acfbfa926..a47133289 100644 --- a/source/tvision/tvtext2.cpp +++ b/source/tvision/tvtext2.cpp @@ -61,10 +61,10 @@ ushort getAltCode(char c) noexcept if( c == 0 ) return 0; - c = toupper(c); + c = toupper((uchar) c); if( c == '\xF0' ) - return 0x200; // special case to handle alt-Space + return kbAltSpace; // special case to handle alt-Space size_t i; for( i = 0; i < sizeof( altCodes1 ); i++)