summaryrefslogtreecommitdiff
path: root/FL
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-05-19 18:57:18 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-05-19 18:57:18 +0200
commit89454508a2024da5fde5db309ede45a0af9cdeb3 (patch)
tree89a42c469312b86afc1c81d28aeccfb9a7b058fa /FL
parent033880673addca9c96abcfb09e68f855b6712b56 (diff)
Fix Fl_Simple_Terminal::append(str, len) assumes a null terminated string (#728)
Diffstat (limited to 'FL')
-rw-r--r--FL/Fl_Text_Buffer.H20
1 files changed, 12 insertions, 8 deletions
diff --git a/FL/Fl_Text_Buffer.H b/FL/Fl_Text_Buffer.H
index 28ac349ed..ac0221b5c 100644
--- a/FL/Fl_Text_Buffer.H
+++ b/FL/Fl_Text_Buffer.H
@@ -283,15 +283,17 @@ public:
/**
Inserts null-terminated string \p text at position \p pos.
\param pos insertion position as byte offset (must be UTF-8 character aligned)
- \param text UTF-8 encoded and nul terminated text
+ \param text UTF-8 encoded text
+ \param insertedLength number of bytes to insert, or -1 to indicate \p text is null-terminated
*/
- void insert(int pos, const char* text);
+ void insert(int pos, const char* text, int insertedLength = -1);
/**
Appends the text string to the end of the buffer.
- \param t UTF-8 encoded and nul terminated text
+ \param t UTF-8 encoded text
+ \param addedLength number of bytes to append, or -1 to indicate \p t is null-terminated
*/
- void append(const char* t) { insert(length(), t); }
+ void append(const char* t, int addedLength = -1) { insert(length(), t, addedLength); }
void vprintf(const char *fmt, va_list ap);
void printf(const char* fmt, ...);
@@ -308,9 +310,10 @@ public:
null-terminated string \p text in their place in the buffer.
\param start byte offset to first character to be removed and new insert position
\param end byte offset to character after last character to be removed
- \param text UTF-8 encoded and nul terminated text
+ \param text UTF-8 encoded text
+ \param insertedLength number of bytes to insert, or -1 to indicate \p text is null-terminated
*/
- void replace(int start, int end, const char *text);
+ void replace(int start, int end, const char *text, int insertedLength = -1);
/**
Copies text from another Fl_Text_Buffer to this one.
@@ -784,13 +787,14 @@ protected:
/**
Internal (non-redisplaying) version of insert().
- Returns the length of text inserted (this is just strlen(\p text), however
+ Returns the length of text inserted (this is just strlen(\p text) if
+ \p insertedLength == -1, however
this calculation can be expensive and the length will be required by any
caller who will continue on to call redisplay). \p pos must be contiguous
with the existing text in the buffer (i.e. not past the end).
\return the number of bytes inserted
*/
- int insert_(int pos, const char* text);
+ int insert_(int pos, const char* text, int insertedLength = -1);
/**
Internal (non-redisplaying) version of remove().