Some string pointer fixes

This commit is contained in:
Markus Gans 2021-02-22 20:29:49 +01:00
parent a55b33977c
commit 48a67c4eab
6 changed files with 49 additions and 32 deletions

View File

@ -170,3 +170,18 @@ jobs:
- ./configure --prefix=/usr - ./configure --prefix=/usr
- make -j10 - 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

View File

@ -1368,7 +1368,6 @@ inline void FOptiAttr::change_to_default_color ( FChar& term, FChar& next
inline void FOptiAttr::change_current_color ( const FChar& term inline void FOptiAttr::change_current_color ( const FChar& term
, FColor fg, FColor bg ) , FColor fg, FColor bg )
{ {
const char* color_str{};
const auto& AF = F_set_a_foreground.cap; const auto& AF = F_set_a_foreground.cap;
const auto& AB = F_set_a_background.cap; const auto& AB = F_set_a_background.cap;
const auto& Sf = F_set_foreground.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 ) if ( term.fg_color != fg || frev )
{ {
color_str = FTermcap::encodeParameter(AF, uInt16(ansi_fg), 0, 0, 0, 0, 0, 0, 0, 0).data(); const auto& color_str = FTermcap::encodeParameter(AF, uInt16(ansi_fg), 0, 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str.data());
} }
if ( term.bg_color != bg || frev ) if ( term.bg_color != bg || frev )
{ {
color_str = FTermcap::encodeParameter(AB, uInt16(ansi_bg), 0, 0, 0, 0, 0, 0, 0, 0).data(); const auto& color_str = FTermcap::encodeParameter(AB, uInt16(ansi_bg), 0, 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str.data());
} }
} }
else if ( Sf && Sb ) else if ( Sf && Sb )
{ {
if ( term.fg_color != fg || frev ) if ( term.fg_color != fg || frev )
{ {
color_str = FTermcap::encodeParameter(Sf, uInt16(fg), 0, 0, 0, 0, 0, 0, 0, 0).data(); const auto& color_str = FTermcap::encodeParameter(Sf, uInt16(fg), 0, 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str.data());
} }
if ( term.bg_color != bg || frev ) if ( term.bg_color != bg || frev )
{ {
color_str = FTermcap::encodeParameter(Sb, uInt16(bg), 0, 0, 0, 0, 0, 0, 0, 0).data(); const auto& color_str = FTermcap::encodeParameter(Sb, uInt16(bg), 0, 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str.data());
} }
} }
else if ( sp ) else if ( sp )
{ {
fg = vga2ansi(fg); fg = vga2ansi(fg);
bg = vga2ansi(bg); bg = vga2ansi(bg);
color_str = FTermcap::encodeParameter(sp, uInt16(fg), uInt16(bg), 0, 0, 0, 0, 0, 0, 0).data(); const auto& color_str = FTermcap::encodeParameter(sp, uInt16(fg), uInt16(bg), 0, 0, 0, 0, 0, 0, 0);
append_sequence (color_str); append_sequence (color_str.data());
} }
} }

View File

@ -266,7 +266,7 @@ void FOptiMove::set_cursor_address (const char cap[])
{ {
if ( cap && FTermcap::isInitialized() ) 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.cap = cap;
F_cursor_address.duration = capDuration (temp.data(), 1); F_cursor_address.duration = capDuration (temp.data(), 1);
F_cursor_address.length = capDurationToLength (F_cursor_address.duration); 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() ) 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.cap = cap;
F_column_address.duration = capDuration (temp.data(), 1); F_column_address.duration = capDuration (temp.data(), 1);
F_column_address.length = capDurationToLength (F_column_address.duration); 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() ) 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.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); F_row_address.length = capDurationToLength (F_row_address.duration);
} }
else else
@ -320,9 +320,9 @@ void FOptiMove::set_parm_up_cursor (const char cap[])
{ {
if ( cap && FTermcap::isInitialized() ) 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.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); F_parm_up_cursor.length = capDurationToLength (F_parm_up_cursor.duration);
} }
else else
@ -338,9 +338,9 @@ void FOptiMove::set_parm_down_cursor (const char cap[])
{ {
if ( cap && FTermcap::isInitialized() ) 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.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); F_parm_down_cursor.length = capDurationToLength (F_parm_down_cursor.duration);
} }
else else
@ -356,9 +356,9 @@ void FOptiMove::set_parm_left_cursor (const char cap[])
{ {
if ( cap && FTermcap::isInitialized() ) 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.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); F_parm_left_cursor.length = capDurationToLength (F_parm_left_cursor.duration);
} }
else else
@ -374,9 +374,9 @@ void FOptiMove::set_parm_right_cursor (const char cap[])
{ {
if ( cap && FTermcap::isInitialized() ) 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.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); F_parm_right_cursor.length = capDurationToLength (F_parm_right_cursor.duration);
} }
else else
@ -392,9 +392,9 @@ void FOptiMove::set_erase_chars (const char cap[])
{ {
if ( cap && FTermcap::isInitialized() ) 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.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); F_erase_chars.length = capDurationToLength (F_erase_chars.duration);
} }
else else
@ -410,9 +410,9 @@ void FOptiMove::set_repeat_char (const char cap[])
{ {
if ( cap && FTermcap::isInitialized() ) 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.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); F_repeat_char.length = capDurationToLength (F_repeat_char.duration);
} }
else else

View File

@ -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 // 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); return opti_move->moveCursor (xold, yold, xnew, ynew);
} }
else 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;
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -151,9 +151,9 @@ void FVTerm::setTermXY (int x, int y) const
const int term_x = term_pos->getX(); const int term_x = term_pos->getX();
const int term_y = term_pos->getY(); 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}); appendOutputBuffer(FTermControl{move_str});
term_pos->setPoint(x, y); term_pos->setPoint(x, y);

View File

@ -267,7 +267,7 @@ class FTerm final
static bool resetFont(); static bool resetFont();
static int openConsole(); static int openConsole();
static int closeConsole(); 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 const char* cursorsVisibilityString (bool = true);
static void detectTermSize(); static void detectTermSize();
static void setTermSize (const FSize&); static void setTermSize (const FSize&);