Skip to content

Commit

Permalink
Fix usages of 'toupper'
Browse files Browse the repository at this point in the history
'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...
  • Loading branch information
magiblot committed Oct 23, 2024
1 parent a24182d commit 2e848ca
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion source/platform/strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion source/tvision/edits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/tvision/tbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 == ' '
Expand Down
2 changes: 1 addition & 1 deletion source/tvision/tchdrdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down
2 changes: 1 addition & 1 deletion source/tvision/tcluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion source/tvision/tdircoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/tvision/tfillist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion source/tvision/tinputli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion source/tvision/tlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/tvision/tmnuview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions source/tvision/tvtext2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down

0 comments on commit 2e848ca

Please sign in to comment.