aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pw.13
-rw-r--r--pw.c15
2 files changed, 13 insertions, 5 deletions
diff --git a/pw.1 b/pw.1
index 1f25b7e..1cc8bc7 100644
--- a/pw.1
+++ b/pw.1
@@ -137,6 +137,9 @@ The commands may be prefixed by a numeric argument, which is ignored by
commands to which it is not applicable. The numeric argument is specified by
entering digits, which are not echoed. The last 3 digits of the input are
retained, so that the argument has an effective range from 0 to 999.
+Leading zeros are interpreted as the
+.B 0
+command.
The commands are:
diff --git a/pw.c b/pw.c
index 7a22523..a949617 100644
--- a/pw.c
+++ b/pw.c
@@ -881,10 +881,6 @@ int main(int argc, char **argv)
stat |= stat_force;
}
break;
- case '0':
- hpos = 0;
- stat |= stat_force;
- break;
case ' ':
if ((stat & stat_eof) == 0)
stat |= stat_susp;
@@ -927,6 +923,13 @@ int main(int argc, char **argv)
snapshot = resizebuf(snapshot, maxlines, maxlines + 1);
}
break;
+ case '0':
+ if (cmdcount == UINT_MAX) {
+ hpos = 0;
+ stat |= stat_force;
+ break;
+ }
+ // fallthrough
default:
if (isdigit(ch)) {
if (cmdcount == UINT_MAX)
@@ -934,6 +937,8 @@ int main(int argc, char **argv)
cmdcount = (cmdcount * 10 + (ch - '0')) % 1000;
}
}
+ if (kbd_state == kbd_cmd && !isdigit(ch))
+ cmdcount = UINT_MAX;
break;
case kbd_esc:
if (ch == '[') {
@@ -1057,7 +1062,7 @@ int main(int argc, char **argv)
if (len == 1) {
kbd_state = kbd_cmd;
curcmd = 0;
- cmdcount = UINT_MAX;
+ // cmdcount deliberately not reset to UNIT_MAX
} else {
cmdbuf[--len] = 0;
}