From 8d471113cec11d09c7a9fc3200f90437a95b3161 Mon Sep 17 00:00:00 2001 From: Renge Date: Thu, 3 Mar 2022 17:43:40 -0500 Subject: [PATCH] fix: setdefaults & input of EOF --- hw2/src/par.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw2/src/par.c b/hw2/src/par.c index 06026f2..5b9cd2a 100644 --- a/hw2/src/par.c +++ b/hw2/src/par.c @@ -235,7 +235,7 @@ static void setdefaults( start = *inlines; for (end = start; *end; ++end); for (line = inlines + 1; *line; ++line) { - for (p2 = *line; *p2; ++p2) + for (p2 = *line; *p2; ++p2); for (p1 = end; p1 > start && p2 > *line && p1[-1] == p2[-1]; --p1, --p2); @@ -297,6 +297,7 @@ int original_main(int argc, const char * const *argv) for (;;) { for (;;) { c = getchar(); + if (c == EOF) goto parcleanup; if (c != '\n') break; putchar(c); }