From 48a67c4eab2b02f3b742e51a552464d19d7b509c Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 22 Feb 2021 20:29:49 +0100 Subject: [PATCH] Some string pointer fixes --- .travis.yml | 15 +++++++++++++++ src/foptiattr.cpp | 21 ++++++++++----------- src/foptimove.cpp | 32 ++++++++++++++++---------------- src/fterm.cpp | 7 +++++-- src/fvterm.cpp | 4 ++-- src/include/final/fterm.h | 2 +- 6 files changed, 49 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index 331fe5e4..eebbc2d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -170,3 +170,18 @@ jobs: - ./configure --prefix=/usr - make -j10 + # + # Linux ARM64 build + # + - arch: arm64 + os: linux + env: + - TEST="ARM64" + before_install: + - uname -a + - g++ --version + script: + - autoreconf -v --install --force + - ./configure --prefix=/usr + - make -j10 + diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 1dbef51f..8356f916 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -1368,7 +1368,6 @@ inline void FOptiAttr::change_to_default_color ( FChar& term, FChar& next inline void FOptiAttr::change_current_color ( const FChar& term , FColor fg, FColor bg ) { - const char* color_str{}; const auto& AF = F_set_a_foreground.cap; const auto& AB = F_set_a_background.cap; const auto& Sf = F_set_foreground.cap; @@ -1386,36 +1385,36 @@ inline void FOptiAttr::change_current_color ( const FChar& term if ( term.fg_color != fg || frev ) { - color_str = FTermcap::encodeParameter(AF, uInt16(ansi_fg), 0, 0, 0, 0, 0, 0, 0, 0).data(); - append_sequence (color_str); + const auto& color_str = FTermcap::encodeParameter(AF, uInt16(ansi_fg), 0, 0, 0, 0, 0, 0, 0, 0); + append_sequence (color_str.data()); } if ( term.bg_color != bg || frev ) { - color_str = FTermcap::encodeParameter(AB, uInt16(ansi_bg), 0, 0, 0, 0, 0, 0, 0, 0).data(); - append_sequence (color_str); + const auto& color_str = FTermcap::encodeParameter(AB, uInt16(ansi_bg), 0, 0, 0, 0, 0, 0, 0, 0); + append_sequence (color_str.data()); } } else if ( Sf && Sb ) { if ( term.fg_color != fg || frev ) { - color_str = FTermcap::encodeParameter(Sf, uInt16(fg), 0, 0, 0, 0, 0, 0, 0, 0).data(); - append_sequence (color_str); + const auto& color_str = FTermcap::encodeParameter(Sf, uInt16(fg), 0, 0, 0, 0, 0, 0, 0, 0); + append_sequence (color_str.data()); } if ( term.bg_color != bg || frev ) { - color_str = FTermcap::encodeParameter(Sb, uInt16(bg), 0, 0, 0, 0, 0, 0, 0, 0).data(); - append_sequence (color_str); + const auto& color_str = FTermcap::encodeParameter(Sb, uInt16(bg), 0, 0, 0, 0, 0, 0, 0, 0); + append_sequence (color_str.data()); } } else if ( sp ) { fg = vga2ansi(fg); bg = vga2ansi(bg); - color_str = FTermcap::encodeParameter(sp, uInt16(fg), uInt16(bg), 0, 0, 0, 0, 0, 0, 0).data(); - append_sequence (color_str); + const auto& color_str = FTermcap::encodeParameter(sp, uInt16(fg), uInt16(bg), 0, 0, 0, 0, 0, 0, 0); + append_sequence (color_str.data()); } } diff --git a/src/foptimove.cpp b/src/foptimove.cpp index c16b56d4..aea7e4c0 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -266,7 +266,7 @@ void FOptiMove::set_cursor_address (const char cap[]) { if ( cap && FTermcap::isInitialized() ) { - const auto temp = FTermcap::encodeMotionParameter(cap, 23, 23); + const auto& temp = FTermcap::encodeMotionParameter(cap, 23, 23); F_cursor_address.cap = cap; F_cursor_address.duration = capDuration (temp.data(), 1); F_cursor_address.length = capDurationToLength (F_cursor_address.duration); @@ -284,7 +284,7 @@ void FOptiMove::set_column_address (const char cap[]) { if ( cap && FTermcap::isInitialized() ) { - const auto temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0); + const auto& temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0); F_column_address.cap = cap; F_column_address.duration = capDuration (temp.data(), 1); F_column_address.length = capDurationToLength (F_column_address.duration); @@ -302,9 +302,9 @@ void FOptiMove::set_row_address (const char cap[]) { if ( cap && FTermcap::isInitialized() ) { - const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data(); + const auto& temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0); F_row_address.cap = cap; - F_row_address.duration = capDuration (temp, 1); + F_row_address.duration = capDuration (temp.data(), 1); F_row_address.length = capDurationToLength (F_row_address.duration); } else @@ -320,9 +320,9 @@ void FOptiMove::set_parm_up_cursor (const char cap[]) { if ( cap && FTermcap::isInitialized() ) { - const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data(); + const auto& temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0); F_parm_up_cursor.cap = cap; - F_parm_up_cursor.duration = capDuration (temp, 1); + F_parm_up_cursor.duration = capDuration (temp.data(), 1); F_parm_up_cursor.length = capDurationToLength (F_parm_up_cursor.duration); } else @@ -338,9 +338,9 @@ void FOptiMove::set_parm_down_cursor (const char cap[]) { if ( cap && FTermcap::isInitialized() ) { - const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data(); + const auto& temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0); F_parm_down_cursor.cap = cap; - F_parm_down_cursor.duration = capDuration (temp, 1); + F_parm_down_cursor.duration = capDuration (temp.data(), 1); F_parm_down_cursor.length = capDurationToLength (F_parm_down_cursor.duration); } else @@ -356,9 +356,9 @@ void FOptiMove::set_parm_left_cursor (const char cap[]) { if ( cap && FTermcap::isInitialized() ) { - const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data(); + const auto& temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0); F_parm_left_cursor.cap = cap; - F_parm_left_cursor.duration = capDuration (temp, 1); + F_parm_left_cursor.duration = capDuration (temp.data(), 1); F_parm_left_cursor.length = capDurationToLength (F_parm_left_cursor.duration); } else @@ -374,9 +374,9 @@ void FOptiMove::set_parm_right_cursor (const char cap[]) { if ( cap && FTermcap::isInitialized() ) { - const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data(); + const auto& temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0); F_parm_right_cursor.cap = cap; - F_parm_right_cursor.duration = capDuration (temp, 1); + F_parm_right_cursor.duration = capDuration (temp.data(), 1); F_parm_right_cursor.length = capDurationToLength (F_parm_right_cursor.duration); } else @@ -392,9 +392,9 @@ void FOptiMove::set_erase_chars (const char cap[]) { if ( cap && FTermcap::isInitialized() ) { - const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data(); + const auto& temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0); F_erase_chars.cap = cap; - F_erase_chars.duration = capDuration (temp, 1); + F_erase_chars.duration = capDuration (temp.data(), 1); F_erase_chars.length = capDurationToLength (F_erase_chars.duration); } else @@ -410,9 +410,9 @@ void FOptiMove::set_repeat_char (const char cap[]) { if ( cap && FTermcap::isInitialized() ) { - const char* temp = FTermcap::encodeParameter(cap, ' ', 23, 0, 0, 0, 0, 0, 0, 0).data(); + const auto& temp = FTermcap::encodeParameter(cap, ' ', 23, 0, 0, 0, 0, 0, 0, 0); F_repeat_char.cap = cap; - F_repeat_char.duration = capDuration (temp, 1); + F_repeat_char.duration = capDuration (temp.data(), 1); F_repeat_char.length = capDurationToLength (F_repeat_char.duration); } else diff --git a/src/fterm.cpp b/src/fterm.cpp index a92de2ae..5e59c226 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -743,7 +743,7 @@ int FTerm::closeConsole() } //---------------------------------------------------------------------- -const char* FTerm::moveCursorString (int xold, int yold, int xnew, int ynew) +std::string FTerm::moveCursorString (int xold, int yold, int xnew, int ynew) { // Returns the cursor move string @@ -755,7 +755,10 @@ const char* FTerm::moveCursorString (int xold, int yold, int xnew, int ynew) return opti_move->moveCursor (xold, yold, xnew, ynew); } else - return FTermcap::encodeMotionParameter(TCAP(t_cursor_address), xnew, ynew).data(); + { + const auto& cursor_addr = FTermcap::encodeMotionParameter(TCAP(t_cursor_address), xnew, ynew); + return cursor_addr; + } } //---------------------------------------------------------------------- diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 2f386a22..fbcb5e01 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -151,9 +151,9 @@ void FVTerm::setTermXY (int x, int y) const const int term_x = term_pos->getX(); const int term_y = term_pos->getY(); - const char* move_str = FTerm::moveCursorString (term_x, term_y, x, y); + const auto& move_str = FTerm::moveCursorString (term_x, term_y, x, y); - if ( move_str ) + if ( ! move_str.empty() ) appendOutputBuffer(FTermControl{move_str}); term_pos->setPoint(x, y); diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index cd3a7324..e02d9236 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -267,7 +267,7 @@ class FTerm final static bool resetFont(); static int openConsole(); static int closeConsole(); - static const char* moveCursorString (int, int, int, int); + static std::string moveCursorString (int, int, int, int); static const char* cursorsVisibilityString (bool = true); static void detectTermSize(); static void setTermSize (const FSize&);