← Commit list

38ae0f3e3

Ron Yorston
Ron Yorston
2021-04-15
SUCCESS Duration: 154s

Subject

vi: reset command count when specifying '0' range

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

editors/vi.c+10 -5
@@ -1128,11 +1128,16 @@ static int get_motion_char(void)
int c, cnt;
c = get_one_char();
- if (c != '0' && isdigit(c)) {
- // get any non-zero motion count
- for (cnt = 0; isdigit(c); c = get_one_char())
- cnt = cnt * 10 + (c - '0');
- cmdcnt = (cmdcnt ?: 1) * cnt;
+ if (isdigit(c)) {
+ if (c != '0') {
+ // get any non-zero motion count
+ for (cnt = 0; isdigit(c); c = get_one_char())
+ cnt = cnt * 10 + (c - '0');
+ cmdcnt = (cmdcnt ?: 1) * cnt;
+ } else {
+ // ensure standalone '0' works
+ cmdcnt = 0;
+ }
}
return c;