diff --git a/examples/tvdemo/fileview.cpp b/examples/tvdemo/fileview.cpp index b8473a80..713b169c 100644 --- a/examples/tvdemo/fileview.cpp +++ b/examples/tvdemo/fileview.cpp @@ -30,7 +30,6 @@ __link(RScrollBar) #include #include -#include #include #include "tvcmds.h" @@ -93,10 +92,7 @@ void TFileViewer::readFile( const char *fName ) ifstream fileToView( fName ); if( !fileToView ) { - char buf[256] = {0}; - ostrstream os( buf, sizeof( buf )-1 ); - os << "Failed to open file '" << fName << "'." << ends; - messageBox( buf, mfError | mfOKButton ); + messageBox( mfError | mfOKButton, "Failed to open file '%s'.", fName ); isValid = False; } else diff --git a/examples/tvforms/fields.cpp b/examples/tvforms/fields.cpp index cc624327..f601aad6 100755 --- a/examples/tvforms/fields.cpp +++ b/examples/tvforms/fields.cpp @@ -31,11 +31,6 @@ __link( RInputLine ) #include #endif // __STDLIB_H -#if !defined( __STRSTREAM_H ) -#include -#endif // __STRSTREAM_H - - // TKeyInputLine const char *const TKeyInputLine::name = "TKeyInputLine"; @@ -137,8 +132,6 @@ Boolean TNumInputLine::valid( ushort command ) { int32_t value; Boolean ok; - char msg[80]; - ostrstream os(msg, 80); ok = True; if ( (command != cmCancel) && (command != cmValid) ) @@ -149,8 +142,7 @@ Boolean TNumInputLine::valid( ushort command ) if ( (value == 0) || (value < min) || (value > max) ) { select(); - os << "Number must be from " << min << " to " << max << "." << ends; - messageBox(os.str(), mfError + mfOKButton); + messageBox(mfError | mfOKButton, "Number must be from %ld to %ld.", (long) min, (long) max); selectAll(True); ok = False; } diff --git a/examples/tvforms/genparts.h b/examples/tvforms/genparts.h index ab1126bd..cf1b5e7b 100755 --- a/examples/tvforms/genparts.h +++ b/examples/tvforms/genparts.h @@ -129,7 +129,7 @@ TForm *makeForm() y = 2; r = TRect(inputCol, y, inputCol + partNumWidth + 2, y + 1); - c = new TNumInputLine(r, partNumWidth, 0, 9999); + c = new TNumInputLine(r, partNumWidth, 1, 9999); f->insert(c); r = TRect(labelCol, y, labelCol + labelWid, y + 1); diff --git a/source/tvision/tchdrdlg.cpp b/source/tvision/tchdrdlg.cpp index 70f90a0c..57f01896 100644 --- a/source/tvision/tchdrdlg.cpp +++ b/source/tvision/tchdrdlg.cpp @@ -37,10 +37,6 @@ #include #endif // __STRING_H -#if !defined( __STRSTREAM_H ) -#include -#endif - TChDirDialog::TChDirDialog( ushort opts, ushort histId ) noexcept : TWindowInit( &TChDirDialog::initFrame ), TDialog( TRect( 16, 2, 64, 20 ), changeDirTitle ) @@ -215,11 +211,7 @@ Boolean TChDirDialog::valid( ushort command ) if( changeDir( path ) != 0 ) { - char buf[256]; - ostrstream os( buf, sizeof( buf )-1 ); - os << invalidText << ": '" << path << "'." << ends; - buf[sizeof( buf )-1] = '\0'; - messageBox( buf, mfError | mfOKButton ); + messageBox( mfError | mfOKButton, "%s: '%s'.", invalidText, path ); return False; } return True; diff --git a/source/tvision/tdirlist.cpp b/source/tvision/tdirlist.cpp index f0428d74..8216c9c1 100644 --- a/source/tvision/tdirlist.cpp +++ b/source/tvision/tdirlist.cpp @@ -47,8 +47,7 @@ TDirListBox::~TDirListBox() void TDirListBox::getText( char *text, short item, short maxChars ) { - strncpy( text, list()->at(item)->text(), maxChars ); - text[maxChars] = '\0'; + strnzcpy( text, list()->at(item)->text(), maxChars + 1 ); } void TDirListBox::selectItem( short item ) @@ -56,21 +55,6 @@ void TDirListBox::selectItem( short item ) message( owner, evCommand, cmChangeDir, list()->at(item) ); } -/* -void TDirListBox::handleEvent( TEvent& event ) -{ - if( event.what == evMouseDown && (event.mouse.eventFlags & meDoubleClick) ) - { - event.what = evCommand; - event.message.command = cmChangeDir; - putEvent( event ); - clearEvent( event ); - } - else - TListBox::handleEvent( event ); -} -*/ - Boolean TDirListBox::isSelected( short item ) { return Boolean( item == cur ); diff --git a/source/tvision/tfildlg.cpp b/source/tvision/tfildlg.cpp index 799a14db..580d8797 100644 --- a/source/tvision/tfildlg.cpp +++ b/source/tvision/tfildlg.cpp @@ -48,10 +48,6 @@ #include #endif // __STRING_H -#if !defined( __STRSTREAM_H ) -#include -#endif - TFileDialog::TFileDialog( TStringView aWildCard, TStringView aTitle, TStringView inputName, @@ -288,11 +284,7 @@ Boolean TFileDialog::checkDirectory( const char *str ) return True; else { - char buf[256]; - ostrstream os( buf, sizeof( buf )-1 ); - os << invalidDriveText << ": '" << str << "'" << ends; - buf[sizeof( buf )-1] = '\0'; - messageBox( buf, mfError | mfOKButton ); + messageBox( mfError | mfOKButton, "%s: '%s'", invalidDriveText, str ); fileName->select(); return False; } @@ -348,11 +340,7 @@ char ext[MAXEXT]; return True; else { - char buf[256]; - ostrstream os( buf, sizeof( buf )-1 ); - os << invalidFileText << ": '" << fName << "'" << ends; - buf[sizeof( buf )-1] = '\0'; - messageBox( buf, mfError | mfOKButton ); + messageBox( mfError | mfOKButton, "%s: '%s'", invalidFileText, fName ); return False; } }