diff options
author | Paul Fox <pgf@brightstareng.com> | 2005-11-28 18:07:53 +0000 |
---|---|---|
committer | Paul Fox <pgf@brightstareng.com> | 2005-11-28 18:07:53 +0000 |
commit | d957b9537ee2b93af93c92dbb8a2a6cfc3682318 (patch) | |
tree | 6666c2de7ccb0bf480435053d9537b747f218f79 | |
parent | 5a16a8942706839a57a600b5d11059ddfe2f94cd (diff) | |
download | busybox-w32-d957b9537ee2b93af93c92dbb8a2a6cfc3682318.tar.gz busybox-w32-d957b9537ee2b93af93c92dbb8a2a6cfc3682318.tar.bz2 busybox-w32-d957b9537ee2b93af93c92dbb8a2a6cfc3682318.zip |
fix bug #474:
0000474: vi crashes often
problem was that the buffer used for "." command ("last_modifying_cmd")
wasn't being maintined correctly -- the recording code was walking back
over the front of that buffer when a repeatable insert command
included backspacing (e.g. "i\b\b\bfoo"). the fix is to simply
record the backspaces along with the rest of the command.
also, cleaned up start_new_cmd_q() slightly.
-rw-r--r-- | editors/vi.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/editors/vi.c b/editors/vi.c index e6c87560d..6689e290b 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -1615,16 +1615,6 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p' | |||
1615 | if ((p[-1] != '\n') && (dot>text)) { | 1615 | if ((p[-1] != '\n') && (dot>text)) { |
1616 | p--; | 1616 | p--; |
1617 | p = text_hole_delete(p, p); // shrink buffer 1 char | 1617 | p = text_hole_delete(p, p); // shrink buffer 1 char |
1618 | #ifdef CONFIG_FEATURE_VI_DOT_CMD | ||
1619 | // also rmove char from last_modifying_cmd | ||
1620 | if (last_modifying_cmd != 0 && strlen((char *) last_modifying_cmd) > 0) { | ||
1621 | Byte *q; | ||
1622 | |||
1623 | q = last_modifying_cmd; | ||
1624 | q[strlen((char *) q) - 1] = '\0'; // erase BS | ||
1625 | q[strlen((char *) q) - 1] = '\0'; // erase prev char | ||
1626 | } | ||
1627 | #endif /* CONFIG_FEATURE_VI_DOT_CMD */ | ||
1628 | } | 1618 | } |
1629 | } else { | 1619 | } else { |
1630 | // insert a char into text[] | 1620 | // insert a char into text[] |
@@ -2009,11 +1999,10 @@ static void start_new_cmd_q(Byte c) | |||
2009 | memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue | 1999 | memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue |
2010 | // if there is a current cmd count put it in the buffer first | 2000 | // if there is a current cmd count put it in the buffer first |
2011 | if (cmdcnt > 0) | 2001 | if (cmdcnt > 0) |
2012 | sprintf((char *) last_modifying_cmd, "%d", cmdcnt); | 2002 | sprintf((char *) last_modifying_cmd, "%d%c", cmdcnt, c); |
2013 | // save char c onto queue | 2003 | else // just save char c onto queue |
2014 | last_modifying_cmd[strlen((char *) last_modifying_cmd)] = c; | 2004 | last_modifying_cmd[0] = c; |
2015 | adding2q = 1; | 2005 | adding2q = 1; |
2016 | return; | ||
2017 | } | 2006 | } |
2018 | 2007 | ||
2019 | static void end_cmd_q(void) | 2008 | static void end_cmd_q(void) |