From db3c2c4c2a70ef19a1cd1e1a59d071a4ef85db7b Mon Sep 17 00:00:00 2001 From: Marco S Hyman Date: Mon, 8 Mar 1999 02:01:03 +0000 Subject: Handle comments that do not end in \n correctly; WHS --- usr.sbin/pkg_install/info/show.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c index 5419bed5aae..2e24c8d8364 100644 --- a/usr.sbin/pkg_install/info/show.c +++ b/usr.sbin/pkg_install/info/show.c @@ -1,7 +1,7 @@ -/* $OpenBSD: show.c,v 1.6 1998/11/22 23:22:41 espie Exp $ */ +/* $OpenBSD: show.c,v 1.7 1999/03/08 02:01:02 marc Exp $ */ #ifndef lint -static const char *rcsid = "$OpenBSD: show.c,v 1.6 1998/11/22 23:22:41 espie Exp $"; +static const char *rcsid = "$OpenBSD: show.c,v 1.7 1999/03/08 02:01:02 marc Exp $"; #endif /* @@ -97,10 +97,12 @@ show_index(char *title, char *fname) } else { if (fgets(line, MAXINDEXSIZE+1, fp)) { - if (line[MAXINDEXSIZE-1] != '\n') { - line[MAXINDEXSIZE] = '\n'; + int line_length = strlen(line); + + if (line[line_length-1] != '\n') { + line[line_length] = '\n'; + line[line_length+1] = 0; } - line[MAXINDEXSIZE+1] = 0; } (void) fclose(fp); } -- cgit v1.2.3