From 31e2ae380a8ab9d49345294e70842a64cb565432 Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Sun, 13 Apr 2014 01:26:07 -0700 Subject: 32540: in doexpandhist(), discard saved line position data rather than restoring from it (updates 32531). --- Src/Zle/zle_tricky.c | 2 +- Src/Zle/zle_utils.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'Src') diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index b916bd653..499c4ae77 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -2795,7 +2795,7 @@ doexpandhist(void) if (!err) { zlemetacs = excs; if (strcmp(zlemetaline, ol)) { - zle_restore_positions(); + zle_free_positions(); unmetafy_line(); /* For vi mode -- reset the beginning-of-insertion pointer * * to the beginning of the line. This seems a little silly, * diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index 9cfa8813d..1089e274f 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -709,6 +709,27 @@ zle_restore_positions(void) zfree(oldpos, sizeof(*oldpos)); } +/* + * Discard positions previously saved, the line has been updated. + */ + +/**/ +mod_export void +zle_free_positions(void) +{ + struct zle_position *oldpos = zle_positions; + struct zle_region *oldrhp; + + zle_positions = oldpos->next; + oldrhp = oldpos->regions; + while (oldrhp) { + struct zle_region *nextrhp = oldrhp->next; + zfree(oldrhp, sizeof(*oldrhp)); + oldrhp = nextrhp; + } + zfree(oldpos, sizeof(*oldpos)); +} + /* * Basic utility functions for adding to line or removing from line. * At this level the counts supplied are raw character counts, so -- cgit 1.4.1