]> git.wh0rd.org Git - nano.git/commitdiff
in do_replace_loop(), fix problem where replacing e.g. single-byte
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Mon, 9 Jul 2007 23:24:37 +0000 (23:24 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Mon, 9 Jul 2007 23:24:37 +0000 (23:24 +0000)
characters with multibyte ones could result in openfile->totsize's being
miscalculated

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4130 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/search.c

index 04a769266b4fdf947cb4177eec90c347a9fa349e..3ed253cc06f32680fdfa5504c506960f085e11cf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@
        has_blank_mbchars): Simplify by using for loops instead of while
        loops where possible, to match the single-byte versions of these
        functions.
+       * search.c (do_replace_loop): Fix problem where replacing e.g.
+       single-byte characters with multibyte ones could result in
+       openfile->totsize's being miscalculated.
 
 2007-07-06  David Lawrence Ramsey  <pooka109@gmail.com>
 
index a1e5d644e0c162b43ced2c8a8f2fd84f927501f3..4761623d2a9881300d8c971096b08d5bbcd5fd7d 100644 (file)
@@ -827,7 +827,8 @@ ssize_t do_replace_loop(
                openfile->current_x += match_len + length_change - 1;
 
            /* Cleanup. */
-           openfile->totsize += length_change;
+           openfile->totsize += mbstrlen(copy) -
+               mbstrlen(openfile->current->data);
            free(openfile->current->data);
            openfile->current->data = copy;