From cc116898ac78d911b485d738ef7a7e034e799053 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Mon, 9 Jul 2007 23:24:37 +0000 Subject: [PATCH] in do_replace_loop(), fix problem where replacing e.g. single-byte characters with multibyte ones could result in openfile->totsize's being miscalculated git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_0_branch/nano@4130 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/search.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9e08a0d1..fbc52ba5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,11 @@ CVS code - - prompt.c: do_yesno_prompt() - Remove redundant check for NO_HELP's being FALSE. (DLR) +- 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. (DLR) - winio.c: get_key_buffer() - Fix inaccurate comments. (DLR) diff --git a/src/search.c b/src/search.c index a1e5d644..4761623d 100644 --- a/src/search.c +++ b/src/search.c @@ -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; -- 2.39.5