(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero

-Fix: one couldn't rename things with too long default/automatic name
-Fix: buffer overflow in console when too long (1024 bytes) command was entered
This commit is contained in:
smatz
2008-10-22 19:12:10 +00:00
parent 852940b45b
commit bc1d994f6c
7 changed files with 52 additions and 46 deletions

View File

@@ -11,12 +11,12 @@
#include "core/enum_type.hpp"
struct Textbuf {
char *buf; ///< buffer in which text is saved
uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes
uint16 length, width; ///< the current size of the string. Width specifies screensize in pixels, length is in bytes
bool caret; ///< is the caret ("_") visible or not
uint16 caretpos; ///< the current position of the caret in the buffer, in bytes
uint16 caretxoffs; ///< the current position of the caret in pixels
char *buf; ///< buffer in which text is saved
uint16 maxsize, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxsize is in bytes (including terminating '\0')
uint16 size, width; ///< the current size of the string. Width specifies screensize in pixels, size is in bytes
bool caret; ///< is the caret ("_") visible or not
uint16 caretpos; ///< the current position of the caret in the buffer, in bytes
uint16 caretxoffs; ///< the current position of the caret in pixels
};
bool HandleCaret(Textbuf *tb);
@@ -26,7 +26,7 @@ bool DeleteTextBufferChar(Textbuf *tb, int delmode);
bool InsertTextBufferChar(Textbuf *tb, uint32 key);
bool InsertTextBufferClipboard(Textbuf *tb);
bool MoveTextBufferPos(Textbuf *tb, int navmode);
void InitializeTextBuffer(Textbuf *tb, const char *buf, uint16 maxlength, uint16 maxwidth);
void InitializeTextBuffer(Textbuf *tb, char *buf, uint16 maxsize, uint16 maxwidth);
void UpdateTextBufferSize(Textbuf *tb);
/** Flags used in ShowQueryString() call */