Introduction
Introduction Statistics Contact Development Disclaimer Help
ed: Don't discard full lines - sbase - suckless unix tools
git clone git://git.suckless.org/sbase
Log
Files
Refs
README
LICENSE
---
commit feeb6e32792b1e4611a9a57476417fcf6b49e6c8
parent 2cbf61dff99c349c5e629d4e8dc7714d03b576fa
Author: Roberto E. Vargas Caballero <[email protected]>
Date: Fri, 22 Sep 2023 19:43:37 +0200
ed: Don't discard full lines
Discard() was reading stdin until a new line was found, but in
case of having an empty line in the input buffer then it didn't
make sense because we were just discarding the full next line.
Diffstat:
M ed.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/ed.c b/ed.c
@@ -76,15 +76,14 @@ discard(void)
{
int c;
- if (repidx >= 0)
+ if (repidx >= 0 || cmdline.siz == 0)
return;
/* discard until the end of the line */
- if (cmdline.siz > 0 && cmdline.str[cmdline.siz-1] == '\n')
- return;
-
- while ((c = getchar()) != '\n' && c != EOF)
- ;
+ if (cmdline.str[cmdline.siz-1] != '\n') {
+ while ((c = getchar()) != '\n' && c != EOF)
+ ;
+ }
}
static void undo(void);
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.