summaryrefslogtreecommitdiff
path: root/test/editor.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2005-12-30 10:13:17 +0000
committerMatthias Melcher <fltk@matthiasm.com>2005-12-30 10:13:17 +0000
commitd3db965083a783672ce39c36883c194a403abdac (patch)
tree0c0c73ef968f7b84fcb5c2f7b59cdb83061287b8 /test/editor.cxx
parent10fae2dd8a3b2383d3ec004d68a46fd945a8d4d6 (diff)
Fixed a few memory faults found by Valgrind (yes, I finally got my Linux
machine up and running again) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4723 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test/editor.cxx')
-rw-r--r--test/editor.cxx18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/editor.cxx b/test/editor.cxx
index 34d77e0ae..e8c1f42ae 100644
--- a/test/editor.cxx
+++ b/test/editor.cxx
@@ -379,20 +379,26 @@ style_update(int pos, // I - Position of update
end = textbuf->line_end(pos + nInserted);
text = textbuf->text_range(start, end);
style = stylebuf->text_range(start, end);
- last = style[end - start - 1];
+ if (start==end)
+ last = 0;
+ else
+ last = style[end - start - 1];
-// printf("start = %d, end = %d, text = \"%s\", style = \"%s\"...\n",
-// start, end, text, style);
+// printf("start = %d, end = %d, text = \"%s\", style = \"%s\", last='%c'...\n",
+// start, end, text, style, last);
style_parse(text, style, end - start);
-// printf("new style = \"%s\"...\n", style);
+// printf("new style = \"%s\", new last='%c'...\n",
+// style, style[end - start - 1]);
stylebuf->replace(start, end, style);
((Fl_Text_Editor *)cbArg)->redisplay_range(start, end);
- if (last != style[end - start - 1]) {
- // The last character on the line changed styles, so reparse the
+ if (start==end || last != style[end - start - 1]) {
+// printf("Recalculate the rest of the buffer style\n");
+ // Either the user deleted some text, or the last character
+ // on the line changed styles, so reparse the
// remainder of the buffer...
free(text);
free(style);