summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabien Costantini <fabien@onepost.net>2009-07-03 23:32:47 +0000
committerFabien Costantini <fabien@onepost.net>2009-07-03 23:32:47 +0000
commitd4e85cef93dac1fee682804f82e77fec86e6e589 (patch)
treeb0549e7fde10324f58bc286315c9fd46bff5e749
parent510ad42f4e37803c1c2ccc78c546f3317bf89030 (diff)
UTF8: Fl_Text_Display and related:
+ Made char * text() const., this method should be further checked for UTF8 compat. + Added a fixme comment to remember we must check for the potential incorrect assumption that that a buffer size equals the string length + 1. + Correct a protected attrib. typo as we don't need to care about ABI compat. for now. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6818 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Text_Buffer.H4
-rw-r--r--src/Fl_Text_Buffer.cxx30
2 files changed, 17 insertions, 17 deletions
diff --git a/FL/Fl_Text_Buffer.H b/FL/Fl_Text_Buffer.H
index 967cda148..dc70b9fc1 100644
--- a/FL/Fl_Text_Buffer.H
+++ b/FL/Fl_Text_Buffer.H
@@ -102,7 +102,7 @@ class FL_EXPORT Fl_Text_Buffer {
/** Returns the number of characters in the buffer. */
int length() { return mLength; }
- char* text();
+ char* text() const;
void text(const char* text);
char* text_range(int start, int end);
char character(int pos);
@@ -297,7 +297,7 @@ class FL_EXPORT Fl_Text_Buffer {
tabs for padding in rectangular operations */
int mNModifyProcs; /**< number of modify-redisplay procs attached */
Fl_Text_Modify_Cb* /**< procedures to call when buffer is */
- mNodifyProcs; /**< modified to redisplay contents */
+ mModifyProcs; /**< modified to redisplay contents */
void** mCbArgs; /**< caller arguments for modifyProcs above */
int mNPredeleteProcs; /**< number of pre-delete procs attached */
Fl_Text_Predelete_Cb* /**< procedure to call before text is deleted */
diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx
index 55f82abd8..a6fce80a4 100644
--- a/src/Fl_Text_Buffer.cxx
+++ b/src/Fl_Text_Buffer.cxx
@@ -122,7 +122,7 @@ Fl_Text_Buffer::Fl_Text_Buffer(int requestedSize, int preferredGapSize) {
mHighlight.mSelected = 0;
mHighlight.mStart = mHighlight.mEnd = 0;
mHighlight.mRectangular = 0;
- mNodifyProcs = NULL;
+ mModifyProcs = NULL;
mCbArgs = NULL;
mNModifyProcs = 0;
mNPredeleteProcs = 0;
@@ -140,7 +140,7 @@ Fl_Text_Buffer::Fl_Text_Buffer(int requestedSize, int preferredGapSize) {
Fl_Text_Buffer::~Fl_Text_Buffer() {
free(mBuf);
if (mNModifyProcs != 0) {
- delete[] mNodifyProcs;
+ delete[] mModifyProcs;
delete[] mCbArgs;
}
if (mNPredeleteProcs != 0) {
@@ -153,10 +153,10 @@ Fl_Text_Buffer::~Fl_Text_Buffer() {
Get the entire contents of a text buffer. Memory is allocated to contain
the returned string, which the caller must free.
*/
-char * Fl_Text_Buffer::text() {
+char * Fl_Text_Buffer::text() const {
char *t;
- t = (char *)malloc(mLength + 1);
+ t = (char *)malloc(mLength + 1); // FIX ME UTF8: we alloc from a string len, is len the strlen or the string buffer size ?
memcpy(t, mBuf, mGapStart);
memcpy(&t[ mGapStart ], &mBuf[ mGapEnd ],
mLength - mGapStart);
@@ -777,17 +777,17 @@ void Fl_Text_Buffer::add_modify_callback(Fl_Text_Modify_Cb bufModifiedCB,
newModifyProcs = new Fl_Text_Modify_Cb [ mNModifyProcs + 1 ];
newCBArgs = new void * [ mNModifyProcs + 1 ];
for (i = 0; i < mNModifyProcs; i++) {
- newModifyProcs[ i + 1 ] = mNodifyProcs[ i ];
+ newModifyProcs[ i + 1 ] = mModifyProcs[ i ];
newCBArgs[ i + 1 ] = mCbArgs[ i ];
}
if (mNModifyProcs != 0) {
- delete [] mNodifyProcs;
+ delete [] mModifyProcs;
delete [] mCbArgs;
}
newModifyProcs[ 0 ] = bufModifiedCB;
newCBArgs[ 0 ] = cbArg;
mNModifyProcs++;
- mNodifyProcs = newModifyProcs;
+ mModifyProcs = newModifyProcs;
mCbArgs = newCBArgs;
}
/** Removes a modify callback.*/
@@ -799,7 +799,7 @@ void Fl_Text_Buffer::remove_modify_callback(Fl_Text_Modify_Cb bufModifiedCB,
/* find the matching callback to remove */
for (i = 0; i < mNModifyProcs; i++) {
- if (mNodifyProcs[ i ] == bufModifiedCB && mCbArgs[ i ] == cbArg) {
+ if (mModifyProcs[ i ] == bufModifiedCB && mCbArgs[ i ] == cbArg) {
toRemove = i;
break;
}
@@ -814,8 +814,8 @@ void Fl_Text_Buffer::remove_modify_callback(Fl_Text_Modify_Cb bufModifiedCB,
mNModifyProcs--;
if (mNModifyProcs == 0) {
mNModifyProcs = 0;
- delete[] mNodifyProcs;
- mNodifyProcs = NULL;
+ delete[] mModifyProcs;
+ mModifyProcs = NULL;
delete[] mCbArgs;
mCbArgs = NULL;
return;
@@ -825,16 +825,16 @@ void Fl_Text_Buffer::remove_modify_callback(Fl_Text_Modify_Cb bufModifiedCB,
/* copy out the remaining members and free the old lists */
for (i = 0; i < toRemove; i++) {
- newModifyProcs[ i ] = mNodifyProcs[ i ];
+ newModifyProcs[ i ] = mModifyProcs[ i ];
newCBArgs[ i ] = mCbArgs[ i ];
}
for (; i < mNModifyProcs; i++) {
- newModifyProcs[ i ] = mNodifyProcs[ i + 1 ];
+ newModifyProcs[ i ] = mModifyProcs[ i + 1 ];
newCBArgs[ i ] = mCbArgs[ i + 1 ];
}
- delete[] mNodifyProcs;
+ delete[] mModifyProcs;
delete[] mCbArgs;
- mNodifyProcs = newModifyProcs;
+ mModifyProcs = newModifyProcs;
mCbArgs = newCBArgs;
}
@@ -2102,7 +2102,7 @@ void Fl_Text_Buffer::call_modify_callbacks(int pos, int nDeleted,
int i;
for (i = 0; i < mNModifyProcs; i++)
- (*mNodifyProcs[ i ]) (pos, nInserted, nDeleted, nRestyled,
+ (*mModifyProcs[ i ]) (pos, nInserted, nDeleted, nRestyled,
deletedText, mCbArgs[ i ]);
}