Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH Re: Issue with histreduceblanks



On Sep 26,  2:03pm, Bart Schaefer wrote:
}
} might be a compiler optimization issue; in any case I think memcpy() is not
} guaranteed to work with overlapping regions and histreduceblanks() ought to
} be using memmove() instead.  I seem to recall us having to fix this in a
} different part of the shell some while ago.


diff --git a/Src/hist.c b/Src/hist.c
index f78c97d..3d6068e 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -953,7 +953,7 @@ histreduceblanks(void)
 	len = chwords[i+1] - chwords[i];
 	needblank = (i < chwordpos-2 && chwords[i+2] > chwords[i+1]);
 	if (pos != chwords[i]) {
-	    memcpy(chline + pos, chline + chwords[i], len + needblank);
+	    memmove(chline + pos, chline + chwords[i], len + needblank);
 	    chwords[i] = pos;
 	    chwords[i+1] = chwords[i] + len;
 	}



Messages sorted by: Reverse Date, Date, Thread, Author