diff --git a/ChangeLog b/ChangeLog index 18b3819d..2c6e546f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2018-09-01 Markus Gans + * Compiles now with newer gcc + 2018-08-31 Markus Gans * Fixed a problem for a non-debug compilation diff --git a/examples/termcap.cpp b/examples/termcap.cpp index f3719c04..01113269 100644 --- a/examples/termcap.cpp +++ b/examples/termcap.cpp @@ -203,9 +203,9 @@ void tcapString (const std::string& name, const char cap_str[]) } //---------------------------------------------------------------------- +#if DEBUG void debug (FApplication& TermApp) { -#if DEBUG const FString& ab_s = TermApp.getAnswerbackString(); const FString& sec_da = TermApp.getSecDAString(); std::cout << "\n.------------------- debug -------------------\r\n"; @@ -228,8 +228,12 @@ void debug (FApplication& TermApp) tcapString ("| The SecDA String", sec_da); std::cout << "`------------------- debug -------------------\r\n"; -#endif + } +#else +void debug (FApplication&) +{ } +#endif //---------------------------------------------------------------------- void booleans() diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 1e67ad94..756bd4a0 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -725,9 +725,11 @@ int FOptiMove::relativeMove ( char move[] if ( move ) { if ( *move ) - std::strncat (move, hmove, BUF_SIZE - std::strlen(move) - 1); + std::strncat (move, hmove, BUF_SIZE - std::strlen(move)); else - std::strncpy (move, hmove, BUF_SIZE - 1); + std::strncpy (move, hmove, BUF_SIZE); + + move[BUF_SIZE - 1] = '\0'; } } @@ -876,7 +878,8 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime if ( htime_r < htime ) { - std::strncpy (hmove, str, BUF_SIZE - 1); + std::strncpy (hmove, str, BUF_SIZE); + hmove[BUF_SIZE - 1] = '\0'; htime = htime_r; } } @@ -929,7 +932,8 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime if ( htime_l < htime ) { - std::strncpy (hmove, str, BUF_SIZE - 1); + std::strncpy (hmove, str, BUF_SIZE); + hmove[BUF_SIZE - 1] = '\0'; htime = htime_l; } } diff --git a/src/fterm.cpp b/src/fterm.cpp index 0b18e04e..19afde28 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -168,9 +168,8 @@ void FTerm::setTermType (const char term_name[]) if ( ! term_name ) return; - std::strncpy ( termtype - , term_name - , std::strlen(term_name) + 1 ); + std::strncpy (termtype, term_name, sizeof(termtype)); + termtype[sizeof(termtype) - 1] = '\0'; } //---------------------------------------------------------------------- diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index a4515a1d..25a6a7bd 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -86,9 +86,7 @@ void FTermDetection::setTermFileName (char term_filename[]) if ( ! term_filename ) return; - std::strncpy ( termfilename - , term_filename - , std::strlen(term_filename) + 1 ); + std::strncpy (termfilename, term_filename, sizeof(termfilename) - 1); } //---------------------------------------------------------------------- @@ -314,7 +312,7 @@ void FTermDetection::detectTerminal() if ( new_termtype ) { setenv(C_STR("TERM"), new_termtype, 1); - std::strncpy (termtype, new_termtype, std::strlen(new_termtype) + 1); + std::strncpy (termtype, new_termtype, sizeof(termtype) - 1); } }