summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/demo.cxx12
-rw-r--r--test/editor.cxx18
2 files changed, 19 insertions, 11 deletions
diff --git a/test/demo.cxx b/test/demo.cxx
index 9c3c5714e..ece3369bd 100644
--- a/test/demo.cxx
+++ b/test/demo.cxx
@@ -182,7 +182,8 @@ void push_menu(const char* nnn)
if (menus[men].icommand[i][0] != '@') but[bn]->tooltip(menus[men].icommand[i]);
else but[bn]->tooltip(0);
}
- strcpy(stack[stsize],nnn);
+ if (stack[stsize]!=nnn)
+ strcpy(stack[stsize],nnn);
stsize++;
}
@@ -255,8 +256,8 @@ void dobut(Fl_Widget *, long arg)
CreateProcess(NULL, command, NULL, NULL, FALSE,
NORMAL_PRIORITY_CLASS, NULL, NULL, &suInfo, &prInfo);
- delete command;
- delete copy_of_icommand;
+ delete[] command;
+ delete[] copy_of_icommand;
#else // NON WIN32 systems.
@@ -266,7 +267,7 @@ void dobut(Fl_Widget *, long arg)
sprintf(command, "./%s &", menus[men].icommand[bn]);
system(command);
- delete command;
+ delete[] command;
#endif // WIN32
}
}
@@ -336,7 +337,8 @@ int main(int argc, char **argv) {
if (i < argc) fname = argv[i];
if (!load_the_menu(fname)) Fl::fatal("Can't open %s",fname);
- strcpy(buf,fname);
+ if (buf!=fname)
+ strcpy(buf,fname);
const char *c = fl_filename_name(buf);
if (c > buf) {buf[c-buf] = 0; chdir(buf);}
push_menu("@main");
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);