diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-14 07:26:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-14 07:28:09 +0400 |
commit | 7c78bcef6cb9c7cde928ed8062a12ab6ba88d2cb (patch) | |
tree | cfb655c167db843910bd87540f4317b5ca002930 /source | |
parent | 6e9c2d0c5559f1f6077787f932c648fb6ca7a13e (diff) |
Fix for crash un-indenting in the text editor
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 17 |
1 files changed, 8 insertions, 9 deletions
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; |