From 820ef8137714525da7685071eaf5f34c74d23f11 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 22 Nov 2018 21:51:32 +0100 Subject: [PATCH] bad_alloc_str in now usable in the entire namespace finalcut --- src/fapplication.cpp | 2 +- src/fbutton.cpp | 2 +- src/fbuttongroup.cpp | 2 +- src/fdialog.cpp | 14 +++++++------- src/ffiledialog.cpp | 4 ++-- src/fkeyboard.cpp | 2 +- src/flabel.cpp | 6 +++--- src/flistbox.cpp | 2 +- src/flistview.cpp | 4 ++-- src/fmenu.cpp | 8 ++++---- src/fmenubar.cpp | 5 ++--- src/fmenuitem.cpp | 6 ++---- src/fmessagebox.cpp | 20 +++++--------------- src/fobject.cpp | 2 +- src/fscrollview.cpp | 2 +- src/fstring.cpp | 4 ---- src/fterm.cpp | 2 +- src/ftermdetection.cpp | 4 ++-- src/ftermlinux.cpp | 6 +++--- src/ftermxterminal.cpp | 4 ++-- src/ftextview.cpp | 14 ++++++++++---- src/ftogglebutton.cpp | 2 +- src/fvterm.cpp | 8 ++++---- src/fwidget.cpp | 4 ++-- src/include/final/emptyfstring.h | 2 +- src/include/final/fstring.h | 1 - src/include/final/ftypes.h | 3 +++ src/include/final/fwidget.h | 2 +- test/ftermdetection-test.cpp | 12 +++++++++--- 29 files changed, 73 insertions(+), 76 deletions(-) diff --git a/src/fapplication.cpp b/src/fapplication.cpp index b3280310..7aa3af71 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -401,7 +401,7 @@ void FApplication::init (long key_time, long dblclick_time) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; std::abort(); } } diff --git a/src/fbutton.cpp b/src/fbutton.cpp index dc11b50c..407b9dd8 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -727,7 +727,7 @@ void FButton::draw() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 256e5ce2..648e1b89 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -506,7 +506,7 @@ void FButtonGroup::drawLabel() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 672c2928..4c8c2a12 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -887,7 +887,7 @@ void FDialog::init() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -906,7 +906,7 @@ void FDialog::initDialogMenu() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -934,7 +934,7 @@ void FDialog::initMoveSizeMenuItem (FMenu* menu) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -957,7 +957,7 @@ void FDialog::initZoomMenuItem (FMenu* menu) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -980,7 +980,7 @@ void FDialog::initCloseMenuItem (FMenu* menu) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -1446,7 +1446,7 @@ inline void FDialog::passEventToSubMenu ( mouseStates& ms } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } } @@ -1727,7 +1727,7 @@ void FDialog::cb_move (FWidget*, data_ptr) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index 69fabf46..7b48fa91 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -276,7 +276,7 @@ const FString FFileDialog::fileOpenChooser ( FWidget* parent } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return FString(); } @@ -319,7 +319,7 @@ const FString FFileDialog::fileSaveChooser ( FWidget* parent } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return FString(); } diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 7ef9c060..114e5728 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -373,7 +373,7 @@ bool FKeyboard::isKeypressTimeout() FKey FKeyboard::UTF8decode (const char utf8[]) { FKey ucs = 0; // Universal coded character - const int max = 4; + const std::size_t max = 4; std::size_t len = std::strlen(utf8); if ( len > max ) diff --git a/src/flabel.cpp b/src/flabel.cpp index 9d9cd8bd..3b911783 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -293,7 +293,7 @@ void FLabel::onMouseDown (FMouseEvent* ev) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } } @@ -529,7 +529,7 @@ void FLabel::drawMultiLine() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -574,7 +574,7 @@ void FLabel::drawSingleLine() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/flistbox.cpp b/src/flistbox.cpp index bbf0e497..38f64495 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -844,7 +844,7 @@ void FListBox::init() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/flistview.cpp b/src/flistview.cpp index 154b09f7..fd18fc58 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -877,7 +877,7 @@ FObject::FObjectIterator FListView::insert ( const FStringList& cols } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return FListView::null_iter; } @@ -1468,7 +1468,7 @@ void FListView::init() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 1dae568d..5c1ab420 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -953,7 +953,7 @@ void FMenu::passEventToSubMenu (FMouseEvent*& ev) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; } } @@ -977,7 +977,7 @@ void FMenu::passEventToSuperMenu (FMouseEvent*& ev) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; } } @@ -1002,7 +1002,7 @@ void FMenu::passEventToMenuBar (FMouseEvent*& ev) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; } } @@ -1336,7 +1336,7 @@ inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index e53b6074..fc9cd088 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -566,7 +566,7 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -1027,8 +1027,7 @@ void FMenuBar::passEventToMenu (FMouseEvent*& ev) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " - << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; } } } diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 84f4d4db..c0e021eb 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -692,8 +692,7 @@ void FMenuItem::createDialogList (FMenu* winmenu) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " - << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -742,8 +741,7 @@ void FMenuItem::passMouseEvent ( T widget, FMouseEvent* ev } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " - << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index 38c35bd7..026d3f83 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -202,7 +202,7 @@ int FMessageBox::info ( FWidget* parent } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return FDialog::Reject; } @@ -231,7 +231,7 @@ int FMessageBox::info ( FWidget* parent } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return FDialog::Reject; } @@ -259,7 +259,7 @@ int FMessageBox::error ( FWidget* parent } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return FDialog::Reject; } @@ -374,7 +374,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } } @@ -423,10 +423,8 @@ inline void FMessageBox::initCallbacks() //---------------------------------------------------------------------- void FMessageBox::calculateDimensions() { - int x, y; std::size_t w, h; std::size_t headline_height = 0; - FWidget* parent_widget = getParentWidget(); text_split = text.split("\n"); text_num_lines = uInt(text_split.size()); text_components = &text_split[0]; @@ -449,15 +447,7 @@ void FMessageBox::calculateDimensions() if ( w < 20 ) w = 20; - if ( parent_widget ) - { - x = 1 + int((parent_widget->getWidth() - w) / 2); - y = 1 + int((parent_widget->getHeight() - h) / 3); - } - else - x = y = 1; - - setGeometry (x, y, w, h); + setSize (w, h); } //---------------------------------------------------------------------- diff --git a/src/fobject.cpp b/src/fobject.cpp index 80436273..5fcddb2a 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -59,7 +59,7 @@ FObject::FObject (FObject* parent) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } } diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index b238e47b..be9257ef 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -787,7 +787,7 @@ void FScrollView::init_scrollbar() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/fstring.cpp b/src/fstring.cpp index b9c8cbea..1f4ec257 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -28,10 +28,6 @@ namespace finalcut { -// static class constant -const char* const FString::bad_alloc_str = "not enough memory " \ - "to alloc a new string"; - //---------------------------------------------------------------------- // class FString //---------------------------------------------------------------------- diff --git a/src/fterm.cpp b/src/fterm.cpp index 842957e3..af1f6205 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -1696,7 +1696,7 @@ inline void FTerm::allocationValues() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; std::abort(); } } diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 1b02a358..0438b951 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -557,7 +557,7 @@ char* FTermDetection::parseAnswerbackMsg (char current_termtype[]) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return 0; } @@ -628,7 +628,7 @@ char* FTermDetection::parseSecDA (char current_termtype[]) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return current_termtype; } diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 77470bc1..b1f93849 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -541,7 +541,7 @@ bool FTermLinux::getScreenFont() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return false; } @@ -588,7 +588,7 @@ bool FTermLinux::getUnicodeMap() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return false; } @@ -665,7 +665,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return -1; } diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index 2aee3374..27b6f49c 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -832,7 +832,7 @@ const FString* FTermXTerminal::captureXTermFont() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return 0; } @@ -887,7 +887,7 @@ const FString* FTermXTerminal::captureXTermTitle() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return 0; } diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 880bb1aa..9d685be2 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -444,7 +444,7 @@ void FTextView::onMouseDown (FMouseEvent* ev) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; } } } @@ -473,7 +473,7 @@ void FTextView::onMouseUp (FMouseEvent* ev) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; } } } @@ -509,7 +509,7 @@ void FTextView::onMouseMove (FMouseEvent* ev) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; } } } @@ -580,6 +580,9 @@ void FTextView::adjustSize() if ( yoffset < 0 ) yoffset = 0; + if ( height < 3 ) + return; + vbar->setMaximum (last_line - int(height) + 2 - nf_offset); vbar->setPageSize (last_line, int(height) - 2 + nf_offset); vbar->setX (int(width)); @@ -587,6 +590,9 @@ void FTextView::adjustSize() vbar->setValue (yoffset); vbar->resize(); + if ( width < 3 ) + return; + hbar->setMaximum (max_width - int(width) + nf_offset + 2); hbar->setPageSize (max_width, int(width) - nf_offset - 2); hbar->setY (int(height)); @@ -639,7 +645,7 @@ void FTextView::init() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 16fe9d27..466825e1 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -498,7 +498,7 @@ void FToggleButton::drawLabel() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } diff --git a/src/fvterm.cpp b/src/fvterm.cpp index bfa74ed4..221a405f 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -630,7 +630,7 @@ void FVTerm::createArea ( int offset_left, int offset_top } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -757,7 +757,7 @@ inline bool FVTerm::reallocateTextArea ( term_area* area } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return false; } @@ -776,7 +776,7 @@ inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return false; } @@ -1986,7 +1986,7 @@ void FVTerm::init (bool disable_alt_screen) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; std::abort(); } diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 0dffe645..1902b0c1 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1958,7 +1958,7 @@ void FWidget::init() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return; } @@ -1991,7 +1991,7 @@ void FWidget::init() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; } } diff --git a/src/include/final/emptyfstring.h b/src/include/final/emptyfstring.h index 7835a8b2..e00cfa71 100644 --- a/src/include/final/emptyfstring.h +++ b/src/include/final/emptyfstring.h @@ -82,7 +82,7 @@ inline const FString& emptyFString::get() } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; } } diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index 8d3d9286..6e9c28f4 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -264,7 +264,6 @@ class FString static const uInt FWDBUFFER = 15; static const uInt INPBUFFER = 200; static const uInt CHAR_SIZE = sizeof(wchar_t); // bytes per character - static const char* const bad_alloc_str; // Methods void initLength (std::size_t); diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h index c0d17f8e..2902674c 100644 --- a/src/include/final/ftypes.h +++ b/src/include/final/ftypes.h @@ -64,6 +64,9 @@ typedef uInt32 FKey; namespace finalcut { +const char* const bad_alloc_str = \ + "not enough memory to alloc "; + template struct is_negative { diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index 2d030453..67d81623 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -1032,7 +1032,7 @@ inline char* createBlankArray (std::size_t size) } catch (const std::bad_alloc& ex) { - std::cerr << "not enough memory to alloc " << ex.what() << std::endl; + std::cerr << bad_alloc_str << ex.what() << std::endl; return 0; } diff --git a/test/ftermdetection-test.cpp b/test/ftermdetection-test.cpp index bf78ca1a..027b586e 100644 --- a/test/ftermdetection-test.cpp +++ b/test/ftermdetection-test.cpp @@ -2297,7 +2297,7 @@ void FTermDetectionTest::terminalSimulation (console con) { fd_set ifds; struct timeval tv; - int len; + ssize_t len; FD_ZERO(&ifds); FD_SET(fd_stdin, &ifds); @@ -2314,8 +2314,11 @@ void FTermDetectionTest::terminalSimulation (console con) { len = read (fd_stdin, buffer, sizeof(buffer)); - if ( len > 0 ) + if ( len != -1 && std::size_t(len) < sizeof(buffer) ) + { + buffer[len] = '\0'; write (fd_master, buffer, len); // Send data to the master side + } } // Data on the master side of PTY @@ -2323,10 +2326,13 @@ void FTermDetectionTest::terminalSimulation (console con) { len = read (fd_master, buffer, sizeof(buffer)); - if ( len < 0 ) + if ( len == -1 || std::size_t(len) >= sizeof(buffer) ) break; else if ( len > 0 ) + { + buffer[len] = '\0'; parseTerminalBuffer (len, con); + } } } }