diff --git a/ChangeLog b/ChangeLog index b3a67b82..9747c9ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2018-09-12 Markus Gans + * Removes the deprecated keyword "register" + from the source code + 2018-09-02 Markus Gans * Fix mouse wheel behavior over horizontal scroll bars in FTextView diff --git a/include/final/fcolorpalette.h b/include/final/fcolorpalette.h index 3c0bf64c..4582a667 100644 --- a/include/final/fcolorpalette.h +++ b/include/final/fcolorpalette.h @@ -44,8 +44,11 @@ class FColorPalette { public: + // Constructor + explicit FColorPalette(); + // Destructor - virtual ~FColorPalette() = 0; + virtual ~FColorPalette(); // Typedefs typedef void (*funcp)(short, int, int, int); diff --git a/include/final/fobject.h b/include/final/fobject.h index 111e2b31..397e6a93 100644 --- a/include/final/fobject.h +++ b/include/final/fobject.h @@ -96,7 +96,7 @@ class FObject // Timer methods static void getCurrentTime (timeval*); - static bool isTimeout (timeval*, register long); + static bool isTimeout (timeval*, long); int addTimer (int); bool delTimer (int); bool delOwnTimer(); diff --git a/include/final/foptiattr.h b/include/final/foptiattr.h index 6ecd54d6..805c4299 100644 --- a/include/final/foptiattr.h +++ b/include/final/foptiattr.h @@ -213,7 +213,7 @@ class FOptiAttr // Methods void initialize(); - static short vga2ansi (register short); + static short vga2ansi (short); char* changeAttribute (charData*&, charData*&); private: diff --git a/include/final/fscrollview.h b/include/final/fscrollview.h index f57d1593..20622719 100644 --- a/include/final/fscrollview.h +++ b/include/final/fscrollview.h @@ -4,7 +4,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2017 Markus Gans * +* Copyright 2017-2018 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -99,8 +99,8 @@ class FScrollView : public FWidget virtual void setHeight (int, bool = true); virtual void setSize (int, int, bool = true); void setGeometry (int, int, int, int, bool = true); - void setCursorPos (register int, register int); - void setPrintPos (register int, register int); + void setCursorPos (int, int); + void setPrintPos (int, int); bool setViewportPrint (bool); bool setViewportPrint(); bool unsetViewportPrint(); diff --git a/include/final/fterm.h b/include/final/fterm.h index 589a10d6..c7503445 100644 --- a/include/final/fterm.h +++ b/include/final/fterm.h @@ -296,11 +296,11 @@ class FTerm static void putstring (const char[], int = 1); #if defined(__sun) && defined(__SVR4) - static int putchar_ASCII (register char); + static int putchar_ASCII (char); #endif - static int putchar_ASCII (register int); - static int putchar_UTF8 (register int); + static int putchar_ASCII (int); + static int putchar_UTF8 (int); #if DEBUG static int framebuffer_bpp; diff --git a/include/final/ftermdetection.h b/include/final/ftermdetection.h index 91539071..040ed4ab 100644 --- a/include/final/ftermdetection.h +++ b/include/final/ftermdetection.h @@ -180,6 +180,7 @@ class FTermDetection static char* parseAnswerbackMsg (char[]); static const FString getAnswerbackMsg(); static char* parseSecDA (char[]); + static int str2int (const FString&); static const FString getSecDA(); static char* secDA_Analysis (char[]); static char* secDA_Analysis_0 (char[]); diff --git a/include/final/fvterm.h b/include/final/fvterm.h index 7d293105..c7fa717f 100644 --- a/include/final/fvterm.h +++ b/include/final/fvterm.h @@ -128,76 +128,76 @@ class FVTerm : public FTerm static charData getAttribute(); // Mutators - static void setTermXY (register int, register int); + static void setTermXY (int, int); static void hideCursor (bool); static void hideCursor(); static void showCursor(); void setPrintCursor (const FPoint&); - void setPrintCursor (register int, register int); + void setPrintCursor (int, int); void setColor (short, short); static void setNormal(); - static bool setBold (register bool); + static bool setBold (bool); static bool setBold(); static bool unsetBold(); - static bool setDim (register bool); + static bool setDim (bool); static bool setDim(); static bool unsetDim(); - static bool setItalic (register bool); + static bool setItalic (bool); static bool setItalic(); static bool unsetItalic(); - static bool setUnderline (register bool); + static bool setUnderline (bool); static bool setUnderline(); static bool unsetUnderline(); - static bool setBlink (register bool); + static bool setBlink (bool); static bool setBlink(); static bool unsetBlink(); - static bool setReverse (register bool); + static bool setReverse (bool); static bool setReverse(); static bool unsetReverse(); - static bool setStandout (register bool); + static bool setStandout (bool); static bool setStandout(); static bool unsetStandout(); - static bool setInvisible (register bool); + static bool setInvisible (bool); static bool setInvisible(); static bool unsetInvisible(); - static bool setProtected (register bool); + static bool setProtected (bool); static bool setProtected(); static bool unsetProtected(); - static bool setCrossedOut (register bool); + static bool setCrossedOut (bool); static bool setCrossedOut(); static bool unsetCrossedOut(); - static bool setDoubleUnderline (register bool); + static bool setDoubleUnderline (bool); static bool setDoubleUnderline(); static bool unsetDoubleUnderline(); - static bool setAltCharset (register bool); + static bool setAltCharset (bool); static bool setAltCharset(); static bool unsetAltCharset(); - static bool setPCcharset (register bool); + static bool setPCcharset (bool); static bool setPCcharset(); static bool unsetPCcharset(); - static bool setTransparent (register bool); + static bool setTransparent (bool); static bool setTransparent(); static bool unsetTransparent(); - static bool setTransShadow (register bool); + static bool setTransShadow (bool); static bool setTransShadow(); static bool unsetTransShadow(); - static bool setInheritBackground (register bool); + static bool setInheritBackground (bool); static bool setInheritBackground(); static bool unsetInheritBackground(); @@ -564,7 +564,7 @@ inline void FVTerm::setPrintCursor (const FPoint& pos) { setPrintCursor (pos.getX(), pos.getY()); } //---------------------------------------------------------------------- -inline void FVTerm::setColor (register short fg, register short bg) +inline void FVTerm::setColor (short fg, short bg) { // Changes colors next_attribute.fg_color = fg; @@ -583,7 +583,7 @@ inline void FVTerm::setNormal() } //---------------------------------------------------------------------- -inline bool FVTerm::setBold (register bool on) +inline bool FVTerm::setBold (bool on) { return (next_attribute.attr.bit.bold = on); } //---------------------------------------------------------------------- @@ -595,7 +595,7 @@ inline bool FVTerm::unsetBold() { return setBold(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setDim (register bool on) +inline bool FVTerm::setDim (bool on) { return (next_attribute.attr.bit.dim = on); } //---------------------------------------------------------------------- @@ -607,7 +607,7 @@ inline bool FVTerm::unsetDim() { return setDim(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setItalic (register bool on) +inline bool FVTerm::setItalic (bool on) { return (next_attribute.attr.bit.italic = on); } //---------------------------------------------------------------------- @@ -619,7 +619,7 @@ inline bool FVTerm::unsetItalic() { return setItalic(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setUnderline (register bool on) +inline bool FVTerm::setUnderline (bool on) { return (next_attribute.attr.bit.underline = on); } //---------------------------------------------------------------------- @@ -631,7 +631,7 @@ inline bool FVTerm::unsetUnderline() { return setUnderline(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setBlink (register bool on) +inline bool FVTerm::setBlink (bool on) { return (next_attribute.attr.bit.blink = on); } //---------------------------------------------------------------------- @@ -643,7 +643,7 @@ inline bool FVTerm::unsetBlink() { return setBlink(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setReverse (register bool on) +inline bool FVTerm::setReverse (bool on) { return (next_attribute.attr.bit.reverse = on); } //---------------------------------------------------------------------- @@ -655,7 +655,7 @@ inline bool FVTerm::unsetReverse() { return setReverse(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setStandout (register bool on) +inline bool FVTerm::setStandout (bool on) { return (next_attribute.attr.bit.standout = on); } //---------------------------------------------------------------------- @@ -667,7 +667,7 @@ inline bool FVTerm::unsetStandout() { return setStandout(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setInvisible (register bool on) +inline bool FVTerm::setInvisible (bool on) { return (next_attribute.attr.bit.invisible = on); } //---------------------------------------------------------------------- @@ -679,7 +679,7 @@ inline bool FVTerm::unsetInvisible() { return setInvisible(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setProtected (register bool on) +inline bool FVTerm::setProtected (bool on) { return (next_attribute.attr.bit.protect = on); } //---------------------------------------------------------------------- @@ -691,7 +691,7 @@ inline bool FVTerm::unsetProtected() { return setProtected(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setCrossedOut (register bool on) +inline bool FVTerm::setCrossedOut (bool on) { return (next_attribute.attr.bit.crossed_out = on); } //---------------------------------------------------------------------- @@ -703,7 +703,7 @@ inline bool FVTerm::unsetCrossedOut() { return setCrossedOut(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setDoubleUnderline (register bool on) +inline bool FVTerm::setDoubleUnderline (bool on) { return (next_attribute.attr.bit.dbl_underline = on); } //---------------------------------------------------------------------- @@ -715,7 +715,7 @@ inline bool FVTerm::unsetDoubleUnderline() { return setDoubleUnderline(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setAltCharset (register bool on) +inline bool FVTerm::setAltCharset (bool on) { return (next_attribute.attr.bit.alt_charset = on); } //---------------------------------------------------------------------- @@ -727,7 +727,7 @@ inline bool FVTerm::unsetAltCharset() { return setAltCharset(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setPCcharset (register bool on) +inline bool FVTerm::setPCcharset (bool on) { return (next_attribute.attr.bit.pc_charset = on); } //---------------------------------------------------------------------- @@ -739,7 +739,7 @@ inline bool FVTerm::unsetPCcharset() { return setPCcharset(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setTransparent (register bool on) +inline bool FVTerm::setTransparent (bool on) { return (next_attribute.attr.bit.transparent = on); } //---------------------------------------------------------------------- @@ -751,7 +751,7 @@ inline bool FVTerm::unsetTransparent() { return setTransparent(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setTransShadow (register bool on) +inline bool FVTerm::setTransShadow (bool on) { return (next_attribute.attr.bit.trans_shadow = on); } //---------------------------------------------------------------------- @@ -763,7 +763,7 @@ inline bool FVTerm::unsetTransShadow() { return setTransShadow(false); } //---------------------------------------------------------------------- -inline bool FVTerm::setInheritBackground (register bool on) +inline bool FVTerm::setInheritBackground (bool on) { return (next_attribute.attr.bit.inherit_bg = on); } //---------------------------------------------------------------------- diff --git a/include/final/fwidget.h b/include/final/fwidget.h index ae9ca1a8..73096507 100644 --- a/include/final/fwidget.h +++ b/include/final/fwidget.h @@ -241,10 +241,10 @@ class FWidget : public FVTerm, public FObject void setMaximumSize (int, int); void setFixedSize (int, int); bool setCursorPos (const FPoint&); - bool setCursorPos (register int, register int); + bool setCursorPos (int, int); void unsetCursorPos(); void setPrintPos (const FPoint&); - void setPrintPos (register int, register int); + void setPrintPos (int, int); void setDoubleFlatLine (fc::sides, bool = true); void unsetDoubleFlatLine (fc::sides); void setDoubleFlatLine (fc::sides, int, bool = true); diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 0347cdff..ae347166 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -288,13 +288,14 @@ void FButton::hide() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { std::cerr << "not enough memory to alloc " << ex.what() << std::endl; return; } + std::memset(blank, ' ', uLong(size)); blank[size] = '\0'; @@ -751,7 +752,7 @@ void FButton::draw() try { - button_text = new wchar_t[txtlength + 1](); + button_text = new wchar_t[uInt(txtlength) + 1](); } catch (const std::bad_alloc& ex) { diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 7aa823fe..7ea40735 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -226,7 +226,7 @@ void FButtonGroup::hide() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { diff --git a/src/fcolorpalette.cpp b/src/fcolorpalette.cpp index 9e564f44..e50a9945 100644 --- a/src/fcolorpalette.cpp +++ b/src/fcolorpalette.cpp @@ -27,6 +27,16 @@ // class FColorPalette //---------------------------------------------------------------------- +// constructors and destructor +//---------------------------------------------------------------------- +FColorPalette::FColorPalette() +{ } + +//---------------------------------------------------------------------- +FColorPalette::~FColorPalette() // destructor +{ } + + // public methods of FColorPalette //---------------------------------------------------------------------- void FColorPalette::set8ColorPalette (funcp setPalette) diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 9124f883..1d33dc9b 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -132,7 +132,7 @@ bool& FKeyboard::unprocessedInput() //---------------------------------------------------------------------- bool FKeyboard::isKeyPressed() { - register int result; + int result; fd_set ifds; struct timeval tv; int stdin_no = FTermios::getStdIn(); @@ -202,7 +202,7 @@ inline int FKeyboard::getMouseProtocolKey() if ( ! mouse_support ) return -1; - register std::size_t buf_len = std::strlen(fifo_buf); + std::size_t buf_len = std::strlen(fifo_buf); // x11 mouse tracking if ( buf_len >= 6 && fifo_buf[1] == '[' && fifo_buf[2] == 'M' ) @@ -236,11 +236,11 @@ inline int FKeyboard::getTermcapKey() for (int i = 0; keymap[i].tname[0] != 0; i++) { char* k = keymap[i].string; - register int len = ( k ) ? int(std::strlen(k)) : 0; + int len = ( k ) ? int(std::strlen(k)) : 0; if ( k && std::strncmp(k, fifo_buf, uInt(len)) == 0 ) // found { - register int n; + int n; for (n = len; n < fifo_buf_size; n++) // Remove founded entry fifo_buf[n - len] = fifo_buf[n]; @@ -266,11 +266,11 @@ inline int FKeyboard::getMetaKey() for (int i = 0; fc::Fmetakey[i].string[0] != 0; i++) { char* kmeta = fc::Fmetakey[i].string; // The string is never null - register int len = int(std::strlen(kmeta)); + int len = int(std::strlen(kmeta)); if ( std::strncmp(kmeta, fifo_buf, uInt(len)) == 0 ) // found { - register int n; + int n; if ( len == 2 && ( fifo_buf[1] == 'O' || fifo_buf[1] == '[' @@ -299,7 +299,7 @@ inline int FKeyboard::getSingleKey() { // Looking for single key code in the buffer - register uChar firstchar = uChar(fifo_buf[0]); + uChar firstchar = uChar(fifo_buf[0]); int keycode, n, len; len = 1; @@ -370,16 +370,16 @@ bool FKeyboard::isKeypressTimeout() //---------------------------------------------------------------------- int FKeyboard::UTF8decode (const char utf8[]) { - register int ucs = 0; + int ucs = 0; const int max = 4; int len = int(std::strlen(utf8)); if ( len > max ) len = max; - for (register int i = 0; i < len; ++i) + for (int i = 0; i < len; ++i) { - register uChar ch = uChar(utf8[i]); + uChar ch = uChar(utf8[i]); if ( (ch & 0xc0) == 0x80 ) { @@ -419,7 +419,7 @@ int FKeyboard::UTF8decode (const char utf8[]) //---------------------------------------------------------------------- inline ssize_t FKeyboard::readKey() { - register ssize_t bytes; + ssize_t bytes; setNonBlockingInput(); bytes = read(FTermios::getStdIn(), &k_buf, sizeof(k_buf) - 1); unsetNonBlockingInput(); @@ -429,7 +429,7 @@ inline ssize_t FKeyboard::readKey() //---------------------------------------------------------------------- void FKeyboard::parseKeyBuffer() { - register ssize_t bytesread; + ssize_t bytesread; FObject::getCurrentTime (&time_keypressed); while ( (bytesread = readKey()) > 0 ) diff --git a/src/flabel.cpp b/src/flabel.cpp index fcf4105f..29afa303 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -265,7 +265,7 @@ void FLabel::hide() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 97d58eff..2f854d9c 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -306,7 +306,7 @@ void FLineEdit::hide() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 1c314940..49ee6635 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2017 Markus Gans * +* Copyright 2014-2018 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -265,7 +265,7 @@ void FListBox::hide() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { @@ -400,7 +400,7 @@ void FListBox::clear() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index be469baa..0c7ef529 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -68,7 +68,7 @@ void FMenuBar::hide() try { - blank = new char[screenWidth + 1]; + blank = new char[uInt(screenWidth) + 1]; } catch (const std::bad_alloc& ex) { diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 740f8206..d2270064 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -424,8 +424,8 @@ void FMouseGPM::drawGpmPointer() //---------------------------------------------------------------------- int FMouseGPM::gpmEvent (bool clear) { - register int result; - register int max = ( gpm_fd > stdin_no ) ? gpm_fd : stdin_no; + int result; + int max = ( gpm_fd > stdin_no ) ? gpm_fd : stdin_no; fd_set ifds; struct timeval tv; @@ -722,7 +722,7 @@ void FMouseSGR::setRawData (char fifo_buf[], int fifo_buf_size) void FMouseSGR::processEvent (struct timeval* time) { const FPoint& mouse_position = getPos(); - register char* p; + char* p; int btn; short x, y; @@ -977,9 +977,9 @@ void FMouseUrxvt::processEvent (struct timeval* time) // Parse and interpret the X11 xterm mouse string (Urxvt-Mode) const FPoint& mouse_position = getPos(); - register char* p; - register bool x_neg; - register bool y_neg; + char* p; + bool x_neg; + bool y_neg; int btn; short x, y; diff --git a/src/fobject.cpp b/src/fobject.cpp index 18edc005..0a1bb96f 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -205,11 +205,11 @@ void FObject::getCurrentTime (timeval* time) } //---------------------------------------------------------------------- -bool FObject::isTimeout (timeval* time, register long timeout) +bool FObject::isTimeout (timeval* time, long timeout) { // Checks whether the specified time span (timeout in µs) has elapse - register long diff_usec; + long diff_usec; struct timeval now; struct timeval diff; diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 06711826..060f2313 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -549,7 +549,7 @@ void FOptiAttr::initialize() } //---------------------------------------------------------------------- -short FOptiAttr::vga2ansi (register short color) +short FOptiAttr::vga2ansi (short color) { // VGA | ANSI // i R G B | i B G R diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 756bd4a0..eecbc9fe 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -666,9 +666,9 @@ int FOptiMove::repeatedAppend ( const capability& o , volatile int count , char* dst ) { - register std::size_t src_len; - register std::size_t dst_len; - register int total; + std::size_t src_len; + std::size_t dst_len; + int total; src_len = std::strlen(o.cap); dst_len = ( dst != 0 ) ? std::strlen(dst) : 0; diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 1af33ac0..722063ff 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2017 Markus Gans * +* Copyright 2014-2018 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -124,7 +124,7 @@ void FProgressbar::hide() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index f95e1356..e93bd385 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -270,13 +270,13 @@ void FScrollView::setGeometry (int x, int y, int w, int h, bool adjust) } //---------------------------------------------------------------------- -void FScrollView::setCursorPos (register int x, register int y) +void FScrollView::setCursorPos (int x, int y) { FWidget::setCursorPos (x + getLeftPadding(), y + getTopPadding()); } //---------------------------------------------------------------------- -void FScrollView::setPrintPos (register int x, register int y) +void FScrollView::setPrintPos (int x, int y) { FWidget::setPrintPos (x + getLeftPadding(), y + getTopPadding()); } diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 6e276cab..80578559 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -208,7 +208,7 @@ void FStatusBar::hide() try { - blank = new char[screenWidth + 1]; + blank = new char[uInt(screenWidth) + 1]; } catch (const std::bad_alloc& ex) { diff --git a/src/fstring.cpp b/src/fstring.cpp index 5d6d2fb5..ab8263a9 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -85,8 +85,8 @@ FString::FString (uInt len, wchar_t c) , bufsize(0) , c_string(0) { - register wchar_t* ps; - register wchar_t* pe; + wchar_t* ps; + wchar_t* pe; initLength(len); ps = string; @@ -121,8 +121,8 @@ FString::FString (uInt len, char c) , bufsize(0) , c_string(0) { - register wchar_t* ps; - register wchar_t* pe; + wchar_t* ps; + wchar_t* pe; initLength(len); ps = string; @@ -798,9 +798,11 @@ FString& FString::sprintf (const char format[], ...) if ( len >= int(sizeof(buf)) ) { + uLong buf_size = uInt(len) + 1; + try { - buffer = new char[len + 1](); + buffer = new char[buf_size](); } catch (const std::bad_alloc& ex) { @@ -809,7 +811,7 @@ FString& FString::sprintf (const char format[], ...) } va_start (args, format); - vsnprintf (buffer, uLong(len + 1), format, args); + vsnprintf (buffer, buf_size, format, args); va_end (args); } @@ -890,7 +892,7 @@ const std::string FString::toString() const //---------------------------------------------------------------------- FString FString::toLower() const { - register wchar_t* p; + wchar_t* p; FString s(string); p = s.string; @@ -909,7 +911,7 @@ FString FString::toLower() const //---------------------------------------------------------------------- FString FString::toUpper() const { - register wchar_t* p; + wchar_t* p; FString s(string); p = s.string; @@ -928,7 +930,7 @@ FString FString::toUpper() const //---------------------------------------------------------------------- sInt16 FString::toShort() const { - register long num; + long num; num = toLong(); if ( num > SHRT_MAX ) @@ -943,7 +945,7 @@ sInt16 FString::toShort() const //---------------------------------------------------------------------- uInt16 FString::toUShort() const { - register uLong num; + uLong num; num = uLong(toULong()); if ( num > USHRT_MAX ) @@ -955,7 +957,7 @@ uInt16 FString::toUShort() const //---------------------------------------------------------------------- int FString::toInt() const { - register long num; + long num; num = toLong(); if ( num > INT_MAX ) @@ -970,7 +972,7 @@ int FString::toInt() const //---------------------------------------------------------------------- uInt FString::toUInt() const { - register uLong num; + uLong num; num = uLong(toULong()); if ( num > UINT_MAX ) @@ -982,11 +984,11 @@ uInt FString::toUInt() const //---------------------------------------------------------------------- long FString::toLong() const { - register bool neg; - register long num; - register long tenth_limit; - register long tenth_limit_digit; - register wchar_t* p; + bool neg; + long num; + long tenth_limit; + long tenth_limit_digit; + wchar_t* p; FString s; neg = false; @@ -1016,7 +1018,7 @@ long FString::toLong() const while ( std::iswdigit(wint_t(*p)) ) { - register uChar d = uChar((*p) - L'0'); + uChar d = uChar((*p) - L'0'); if ( num > tenth_limit || (num == tenth_limit && d > tenth_limit_digit) ) @@ -1043,10 +1045,10 @@ long FString::toLong() const //---------------------------------------------------------------------- uLong FString::toULong() const { - register uLong num; - register uLong tenth_limit; - register uLong tenth_limit_digit; - register wchar_t* p; + uLong num; + uLong tenth_limit; + uLong tenth_limit_digit; + wchar_t* p; FString s; num = 0; @@ -1072,7 +1074,7 @@ uLong FString::toULong() const while ( std::iswdigit(wint_t(*p)) ) { - register uChar d = uChar((*p) - L'0'); + uChar d = uChar((*p) - L'0'); if ( num > tenth_limit || (num == tenth_limit && d > tenth_limit_digit) ) @@ -1093,13 +1095,13 @@ uLong FString::toULong() const //---------------------------------------------------------------------- float FString::toFloat() const { - register double num; + double num; num = toDouble(); if ( num > double(FLT_MAX) || num < double(-FLT_MAX) ) throw std::overflow_error ("overflow"); - if ( std::fabs(num) < FLT_EPSILON ) // num == 0.0f + if ( std::fabs(num) < double(FLT_EPSILON) ) // num == 0.0f throw std::underflow_error ("underflow"); return float(num); @@ -1109,7 +1111,7 @@ float FString::toFloat() const double FString::toDouble() const { wchar_t* p; - register double ret; + double ret; if ( ! string ) throw std::invalid_argument ("null value"); @@ -1137,7 +1139,7 @@ double FString::toDouble() const //---------------------------------------------------------------------- FString FString::ltrim() const { - register wchar_t* p; + wchar_t* p; FString s(string); // handle NULL and empty string @@ -1155,8 +1157,8 @@ FString FString::ltrim() const //---------------------------------------------------------------------- FString FString::rtrim() const { - register wchar_t* p; - register wchar_t* last; + wchar_t* p; + wchar_t* last; FString s(string); // handle NULL and empty string @@ -1200,7 +1202,7 @@ FString FString::left (int len) const //---------------------------------------------------------------------- FString FString::left (uInt len) const { - register wchar_t* p; + wchar_t* p; FString s(string); // handle NULL and empty string @@ -1228,7 +1230,7 @@ FString FString::right (int len) const //---------------------------------------------------------------------- FString FString::right (uInt len) const { - register wchar_t* p; + wchar_t* p; FString s(string); // handle NULL and empty string @@ -1260,8 +1262,8 @@ FString FString::mid (int pos, int len) const //---------------------------------------------------------------------- FString FString::mid (uInt pos, uInt len) const { - register wchar_t* p; - register wchar_t* first; + wchar_t* p; + wchar_t* first; FString s(string); // handle NULL and empty string @@ -1326,8 +1328,8 @@ FString& FString::setString (const char s[]) //---------------------------------------------------------------------- FString& FString::setNumber (long num) { - register wchar_t* s; - register bool neg; + wchar_t* s; + bool neg; wchar_t buf[30]; s = &buf[29]; @@ -1361,7 +1363,7 @@ FString& FString::setNumber (long num) //---------------------------------------------------------------------- FString& FString::setNumber (uLong num) { - register wchar_t* s; + wchar_t* s; wchar_t buf[30]; s = &buf[29]; @@ -1381,7 +1383,7 @@ FString& FString::setNumber (uLong num) //---------------------------------------------------------------------- FString& FString::setNumber (lDouble num, int precision) { - register wchar_t* s; + wchar_t* s; wchar_t format[20]; // = "%.Lg" s = &format[0]; @@ -1414,9 +1416,9 @@ FString& FString::setNumber (lDouble num, int precision) //---------------------------------------------------------------------- FString& FString::setFormatedNumber (long num, char separator) { - register int n; - register wchar_t* s; - register bool neg; + int n; + wchar_t* s; + bool neg; wchar_t buf[30]; n = 0; @@ -1457,8 +1459,8 @@ FString& FString::setFormatedNumber (long num, char separator) //---------------------------------------------------------------------- FString& FString::setFormatedNumber (uLong num, char separator) { - register int n; - register wchar_t* s; + int n; + wchar_t* s; wchar_t buf[30]; n = 0; @@ -1860,7 +1862,7 @@ const FString& FString::insert (const char c, uInt pos) //---------------------------------------------------------------------- FString FString::replace (const FString& from, const FString& to) { - register wchar_t* p; + wchar_t* p; uInt from_length, to_length, pos; FString s(string); @@ -2165,7 +2167,7 @@ FString FString::replace (const char from[], const char to) //---------------------------------------------------------------------- FString FString::replace (const wchar_t from, const FString& to) { - register wchar_t* p; + wchar_t* p; FString s(string); // handle NULL and empty string @@ -2290,7 +2292,7 @@ FString FString::replace (const char from, const wchar_t to) //---------------------------------------------------------------------- FString FString::replace (const char from, const char to) { - register wchar_t* p; + wchar_t* p; FString s(string); // handle NULL and empty string @@ -2313,7 +2315,7 @@ FString FString::replace (const char from, const char to) //---------------------------------------------------------------------- FString FString::replaceControlCodes() const { - register wchar_t* p; + wchar_t* p; FString s(string); p = s.string; @@ -2374,8 +2376,7 @@ FString FString::expandTabs (int tabstop) const //---------------------------------------------------------------------- FString FString::removeDel() const { - register wchar_t* p; - + wchar_t* p; FString s(string); p = s.string; @@ -2414,8 +2415,7 @@ FString FString::removeDel() const //---------------------------------------------------------------------- FString FString::removeBackspaces() const { - register wchar_t* p; - + wchar_t* p; FString s(string); p = s.string; @@ -2824,7 +2824,7 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const try { - c_string = new char[dest_size](); + c_string = new char[uInt(dest_size)](); // pre-initialiaze the whole string with '\0' std::memset (c_string, '\0', std::size_t(dest_size)); @@ -2881,7 +2881,7 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const try { - dest = new wchar_t[size](); + dest = new wchar_t[uInt(size)](); // pre-initialiaze the whole string with '\0' std::wmemset (dest, L'\0', std::size_t(size)); } @@ -2921,7 +2921,7 @@ inline wchar_t* FString::extractToken ( wchar_t* rest[] , const wchar_t s[] , const wchar_t delim[] ) { - register wchar_t* token; + wchar_t* token; token = ( s ) ? const_cast(s) : *rest; if ( ! token ) diff --git a/src/fterm.cpp b/src/fterm.cpp index 19afde28..406d1e27 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -800,7 +800,7 @@ void FTerm::putstring (const char s[], int affcnt) #if defined(__sun) && defined(__SVR4) //---------------------------------------------------------------------- -int FTerm::putchar_ASCII (register char c) +int FTerm::putchar_ASCII (char c) { if ( std::putchar(c) == EOF ) return 0; @@ -810,7 +810,7 @@ int FTerm::putchar_ASCII (register char c) #endif //---------------------------------------------------------------------- -int FTerm::putchar_ASCII (register int c) +int FTerm::putchar_ASCII (int c) { if ( std::putchar(char(c)) == EOF ) return 0; @@ -819,7 +819,7 @@ int FTerm::putchar_ASCII (register int c) } //---------------------------------------------------------------------- -int FTerm::putchar_UTF8 (register int c) +int FTerm::putchar_UTF8 (int c) { if ( c < 0x80 ) { @@ -2196,9 +2196,9 @@ void FTerm::finish_encoding() //---------------------------------------------------------------------- uInt FTerm::cp437_to_unicode (uChar c) { - register uInt ucs = uInt(c); + uInt ucs = uInt(c); - for (register uInt i = 0; i <= fc::lastCP437Item; i++) + for (uInt i = 0; i <= fc::lastCP437Item; i++) { if ( fc::cp437_to_ucs[i][0] == c ) // found { diff --git a/src/ftermbuffer.cpp b/src/ftermbuffer.cpp index 48a626d2..910d584d 100644 --- a/src/ftermbuffer.cpp +++ b/src/ftermbuffer.cpp @@ -76,7 +76,7 @@ int FTermBuffer::writef (const char format[], ...) { try { - buffer = new char[len + 1](); + buffer = new char[uInt(len) + 1](); } catch (const std::bad_alloc& ex) { @@ -131,7 +131,7 @@ int FTermBuffer::write (const std::string& s) int FTermBuffer::write (const FString& s) { assert ( ! s.isNull() ); - register int len = 0; + int len = 0; const wchar_t* p = s.wc_str(); if ( p ) @@ -155,7 +155,7 @@ int FTermBuffer::write (const FString& s) } //---------------------------------------------------------------------- -int FTermBuffer::write (register int c) +int FTermBuffer::write (int c) { charData nc; // next character nc = FVTerm::getAttribute(); diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 18b7b7a3..a403a0ea 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -615,40 +615,13 @@ char* FTermDetection::parseSecDA (char current_termtype[]) return current_termtype; // Read the terminal type - try - { - secondary_da.terminal_id_type = sec_da_components[0].toInt(); - } - catch (const std::exception&) - { - secondary_da.terminal_id_type = -1; - } + secondary_da.terminal_id_type = str2int(sec_da_components[0]); // Read the terminal (firmware) version - try - { - if ( sec_da_components[1] ) - secondary_da.terminal_id_version = sec_da_components[1].toInt(); - else - secondary_da.terminal_id_version = -1; - } - catch (const std::exception&) - { - secondary_da.terminal_id_version = -1; - } + secondary_da.terminal_id_version = str2int(sec_da_components[1]); // Read the terminal hardware option - try - { - if ( sec_da_components[2] ) - secondary_da.terminal_id_hardware = sec_da_components[2].toInt(); - else - secondary_da.terminal_id_hardware = -1; - } - catch (const std::exception&) - { - secondary_da.terminal_id_hardware = -1; - } + secondary_da.terminal_id_hardware = str2int(sec_da_components[2]); char* new_termtype = secDA_Analysis(current_termtype); @@ -663,6 +636,22 @@ char* FTermDetection::parseSecDA (char current_termtype[]) return new_termtype; } +//---------------------------------------------------------------------- +int FTermDetection::str2int (const FString& s) +{ + if ( ! s ) + return -1; + + try + { + return s.toInt(); + } + catch (const std::exception&) + { + return -1; + } +} + //---------------------------------------------------------------------- const FString FTermDetection::getSecDA() { diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index ec5fc6dc..feae48e1 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -581,9 +581,12 @@ bool FTermLinux::getUnicodeMap() count = screen_unicode_map.entry_ct; + if ( count <= 0 ) + return false; + try { - screen_unicode_map.entries = new struct unipair[count](); + screen_unicode_map.entries = new struct unipair[uInt(count)](); } catch (const std::bad_alloc& ex) { diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 1033a67c..cebf83bf 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -218,7 +218,7 @@ void FTextView::hide() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { @@ -353,7 +353,7 @@ void FTextView::clear() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index d44cb377..8b7ec392 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -241,7 +241,7 @@ void FToggleButton::hide() try { - blank = new char[size + 1]; + blank = new char[uInt(size) + 1]; } catch (const std::bad_alloc& ex) { diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 2a866696..c63a6ba4 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -99,7 +99,7 @@ FPoint FVTerm::getPrintCursor() } //---------------------------------------------------------------------- -void FVTerm::setTermXY (register int x, register int y) +void FVTerm::setTermXY (int x, int y) { // Sets the hardware cursor to the given (x,y) position int term_x, term_y, term_width, term_height; @@ -149,7 +149,7 @@ void FVTerm::hideCursor (bool on) } //---------------------------------------------------------------------- -void FVTerm::setPrintCursor (register int x, register int y) +void FVTerm::setPrintCursor (int x, int y) { term_area* win = getPrintArea(); @@ -248,7 +248,7 @@ void FVTerm::updateTerminal() // Update data on VTerm updateVTerm(); - for (register uInt y = 0; y < uInt(vterm->height); y++) + for (uInt y = 0; y < uInt(vterm->height); y++) updateTerminalLine (y); // sets the new input cursor position @@ -325,7 +325,7 @@ int FVTerm::printf (const char format[], ...) { try { - buffer = new char[len + 1](); + buffer = new char[uInt(len) + 1](); } catch (const std::bad_alloc& ex) { @@ -481,7 +481,7 @@ int FVTerm::print (const std::vector& term_string) //---------------------------------------------------------------------- int FVTerm::print (term_area* area, const std::vector& term_string) { - register int len = 0; + int len = 0; std::vector::const_iterator iter; iter = term_string.begin(); uInt tabstop = uInt(getTabstop()); @@ -540,7 +540,7 @@ int FVTerm::print (term_area* area, const std::vector& term_string) } //---------------------------------------------------------------------- -int FVTerm::print (register int c) +int FVTerm::print (int c) { term_area* area = getPrintArea(); @@ -556,7 +556,7 @@ int FVTerm::print (register int c) } //---------------------------------------------------------------------- -int FVTerm::print (term_area* area, register int c) +int FVTerm::print (term_area* area, int c) { charData nc; // next character @@ -828,6 +828,9 @@ inline bool FVTerm::reallocateTextArea ( term_area* area , int height , int size ) { + assert ( height > 0 ); + assert ( size > 0 ); + if ( area->changes != 0 ) delete[] area->changes; @@ -836,8 +839,8 @@ inline bool FVTerm::reallocateTextArea ( term_area* area try { - area->changes = new line_changes[height]; - area->text = new charData[size]; + area->changes = new line_changes[uInt(height)]; + area->text = new charData[uInt(size)]; } catch (const std::bad_alloc& ex) { @@ -851,12 +854,14 @@ inline bool FVTerm::reallocateTextArea ( term_area* area //---------------------------------------------------------------------- inline bool FVTerm::reallocateTextArea (term_area* area, int size) { + assert ( size > 0 ); + if ( area->text != 0 ) delete[] area->text; try { - area->text = new charData[size]; + area->text = new charData[uInt(size)]; } catch (const std::bad_alloc& ex) { @@ -1594,7 +1599,7 @@ void FVTerm::putArea (int ax, int ay, term_area* area) if ( length < 1 ) return; - for (register int y = 0; y < y_end; y++) // line loop + for (int y = 0; y < y_end; y++) // line loop { int line_len = aw + rsh; @@ -1608,7 +1613,7 @@ void FVTerm::putArea (int ax, int ay, term_area* area) else { // Line has one or more transparent characters - for (register int x = 0; x < length; x++) // column loop + for (int x = 0; x < length; x++) // column loop { int cx = ax + x; int cy = ay + y; diff --git a/src/fwidget.cpp b/src/fwidget.cpp index d9acce1d..42ab68b9 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -729,7 +729,7 @@ void FWidget::setGeometry (int x, int y, int w, int h, bool adjust) } //---------------------------------------------------------------------- -bool FWidget::setCursorPos (register int x, register int y) +bool FWidget::setCursorPos (int x, int y) { // sets the input cursor position @@ -765,7 +765,7 @@ bool FWidget::setCursorPos (register int x, register int y) } //---------------------------------------------------------------------- -void FWidget::setPrintPos (register int x, register int y) +void FWidget::setPrintPos (int x, int y) { setPrintCursor ( offset.getX1() + getX() + x - 1, offset.getY1() + getY() + y - 1 ); @@ -1493,7 +1493,7 @@ void FWidget::clearFlatBorder() setColor (wc.dialog_fg, wc.dialog_bg); // clear on left side - for (register int y = 0; y < getHeight(); y++) + for (int y = 0; y < getHeight(); y++) { setPrintPos (x1 - 1, y1 + y + 1); @@ -1504,7 +1504,7 @@ void FWidget::clearFlatBorder() } // clear on right side - for (register int y = 0; y < getHeight(); y++) + for (int y = 0; y < getHeight(); y++) { setPrintPos (x2, y1 + y + 1); @@ -1517,7 +1517,7 @@ void FWidget::clearFlatBorder() // clear at top setPrintPos (x1, y1); - for (register int x = 0; x < getWidth(); x++) + for (int x = 0; x < getWidth(); x++) { if ( double_flatline_mask.top[uLong(x)] ) print (fc::NF_border_line_upper); @@ -1528,7 +1528,7 @@ void FWidget::clearFlatBorder() // clear at bottom setPrintPos (x1, y2); - for (register int x = 0; x < getWidth(); x++) + for (int x = 0; x < getWidth(); x++) { if ( double_flatline_mask.bottom[uLong(x)] ) print (fc::NF_border_line_bottom);