Discard input at the end of global commands
If there is no any match, then the rest of the line is not read, and it means that ed thins it is a new command.
This commit is contained in:
parent
d1bef890ea
commit
a65e180e5e
26
ed.c
26
ed.c
|
@ -65,28 +65,35 @@ static struct undo udata;
|
||||||
static int newcmd;
|
static int newcmd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
discard(void)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
/* discard until end of line */
|
||||||
|
if (repidx < 0 &&
|
||||||
|
((cmdsiz > 0 && cmdline[cmdsiz-1] != '\n') || cmdsiz == 0)) {
|
||||||
|
while ((c = getchar()) != '\n' && c != EOF)
|
||||||
|
/* nothing */;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void undo(void);
|
static void undo(void);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
error(char *msg)
|
error(char *msg)
|
||||||
{
|
{
|
||||||
int c;
|
|
||||||
|
|
||||||
exstatus = 1;
|
exstatus = 1;
|
||||||
lasterr = msg;
|
lasterr = msg;
|
||||||
fputs("?\n", stderr);
|
fputs("?\n", stderr);
|
||||||
|
|
||||||
if (optverbose)
|
if (optverbose)
|
||||||
fprintf(stderr, "%s\n", msg);
|
fprintf(stderr, "%s\n", msg);
|
||||||
|
|
||||||
/* discard until end of line */
|
|
||||||
if (repidx < 0 && cmdsiz > 0 && cmdline[cmdsiz-1] != '\n') {
|
|
||||||
while ((c = getchar()) != '\n' && c != EOF)
|
|
||||||
/* nothing */;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!newcmd)
|
if (!newcmd)
|
||||||
undo();
|
undo();
|
||||||
|
|
||||||
|
discard();
|
||||||
curln = ocurln;
|
curln = ocurln;
|
||||||
longjmp(savesp, 1);
|
longjmp(savesp, 1);
|
||||||
}
|
}
|
||||||
|
@ -1293,6 +1300,7 @@ doglobal(void)
|
||||||
}
|
}
|
||||||
docmd();
|
docmd();
|
||||||
}
|
}
|
||||||
|
discard(); /* cover the case of not matchingc anything */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue
Block a user