Better alignment testing

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7807 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2010-11-06 23:58:57 +00:00
parent 213318ccb3
commit f099311481
3 changed files with 5 additions and 1 deletions

View File

@ -39,8 +39,10 @@
#ifdef ASSERT_UTF8
# include <assert.h>
# define IS_UTF8_ALIGNED(a) if (a && *a) assert(fl_utf8len(*(a))>0);
# define IS_UTF8_ALIGNED2(a, b) if (b>=0 && b<a->length()) assert(fl_utf8len(a->byte_at(b))>0);
#else
# define IS_UTF8_ALIGNED(a)
# define IS_UTF8_ALIGNED2(a, b)
#endif

View File

@ -1287,7 +1287,7 @@ void Fl_Text_Buffer::replace_selection_(Fl_Text_Selection * sel,
void Fl_Text_Buffer::call_modify_callbacks(int pos, int nDeleted,
int nInserted, int nRestyled,
const char *deletedText) const {
IS_UTF8_ALIGNED(address(pos))
IS_UTF8_ALIGNED2(this, pos)
for (int i = 0; i < mNModifyProcs; i++)
(*mModifyProcs[i]) (pos, nInserted, nDeleted, nRestyled,
deletedText, mCbArgs[i]);

View File

@ -805,6 +805,7 @@ Fl_Window* new_view() {
int main(int argc, char **argv) {
textbuf = new Fl_Text_Buffer;
#if 1
textbuf->text(
"void saveas_cb() {\n"
" Fl_Native_File_Chooser fnfc;\n"
@ -848,6 +849,7 @@ int main(int argc, char **argv) {
"And superficial dreams / Shall no longer delude you.\n"
"(from Iroha-uta)"
);
#endif
style_init();
Fl_Window* window = new_view();