From 7c78bcef6cb9c7cde928ed8062a12ab6ba88d2cb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Apr 2014 13:26:12 +1000 Subject: Fix for crash un-indenting in the text editor --- source/blender/blenkernel/intern/text.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern/text.c') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index f42663401ee..c34fe32296a 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2775,23 +2775,21 @@ void txt_unindent(Text *text) } while (true) { - int i = 0; - - if (BLI_strncasecmp(text->curl->line, remove, indentlen) == 0) { + bool changed = false; + if (strncmp(text->curl->line, remove, indentlen) == 0) { if (num == 0) unindented_first = true; - while (i < text->curl->len) { - text->curl->line[i] = text->curl->line[i + indentlen]; - i++; - } text->curl->len -= indentlen; + memmove(text->curl->line, text->curl->line + indentlen, text->curl->len + 1); + changed = true; } txt_make_dirty(text); txt_clean_text(text); if (text->curl == text->sell) { - if (i > 0) text->selc = MAX2(text->selc - indentlen, 0); + if (changed) + text->selc = MAX2(text->selc - indentlen, 0); break; } else { @@ -2801,7 +2799,8 @@ void txt_unindent(Text *text) } - if (unindented_first) text->curc = MAX2(text->curc - indentlen, 0); + if (unindented_first) + text->curc = MAX2(text->curc - indentlen, 0); while (num > 0) { text->curl = text->curl->prev; -- cgit v1.2.3