Skip to content

Commit

Permalink
Overcome string length limit in messageBox
Browse files Browse the repository at this point in the history
  • Loading branch information
magiblot committed May 20, 2023
1 parent 7c2d667 commit a357e7d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions source/tvision/msgbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#define Uses_TLabel
#include <tvision/tv.h>

#if !defined( __STDIO_H )
#include <stdio.h>
#endif // __STDIO_H

#if !defined( __STRING_H )
#include <string.h>
#endif // __STRING_H
Expand Down Expand Up @@ -104,13 +100,15 @@ ushort messageBoxRect( const TRect &r,
... ) noexcept
{
va_list argptr;
char msg[256];

va_start( argptr, fmt );
vsnprintf( msg, 256, fmt, argptr );
char *msg = vfmtStr( fmt, argptr );
va_end( argptr );

return messageBoxRect( r, msg, aOptions );
ushort ret = messageBoxRect( r, msg, aOptions );

delete[] msg;
return ret;
}

static TRect makeRect(TStringView text)
Expand All @@ -134,13 +132,15 @@ ushort messageBox( TStringView msg, ushort aOptions ) noexcept
ushort messageBox( unsigned aOptions, const char *fmt, ... ) noexcept
{
va_list argptr;
char msg[256];

va_start( argptr, fmt );
vsnprintf( msg, 256, fmt, argptr );
char *msg = vfmtStr( fmt, argptr );
va_end( argptr );

return messageBoxRect( makeRect(msg), msg, aOptions );
ushort ret = messageBoxRect( makeRect(msg), msg, aOptions );

delete[] msg;
return ret;
}

ushort inputBox( TStringView Title, TStringView aLabel, char *s, uchar limit ) noexcept
Expand Down

0 comments on commit a357e7d

Please sign in to comment.