correct printing of \n at the end of .plan; and use fopen() not freopen()
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Mon, 2 Oct 1989 07:11:47 +0000 (23:11 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Mon, 2 Oct 1989 07:11:47 +0000 (23:11 -0800)
SCCS-vsn: usr.bin/finger/lprint.c 5.8

usr/src/usr.bin/finger/lprint.c

index 8ab7043..53dcd44 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)lprint.c   5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)lprint.c   5.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -215,16 +215,18 @@ demi_print(str, oddfield)
 show_text(directory, file_name, header)
        char *directory, *file_name, *header;
 {
 show_text(directory, file_name, header)
        char *directory, *file_name, *header;
 {
-       register int ch;
+       register int ch, lastc;
+       register FILE *fp;
 
        (void)sprintf(tbuf, "%s/%s", directory, file_name);
 
        (void)sprintf(tbuf, "%s/%s", directory, file_name);
-       if (!freopen(tbuf, "r", stdin))
+       if ((fp = fopen(tbuf, "r")) == NULL)
                return(0);
        (void)printf("%s\n", header);
                return(0);
        (void)printf("%s\n", header);
-       while ((ch = getchar(fp)) != EOF)
-               vputc(ch);
-       if (ch != '\n')
+       while ((ch = getc(fp)) != EOF)
+               vputc(lastc = ch);
+       if (lastc != '\n')
                (void)putchar('\n');
                (void)putchar('\n');
+       (void)fclose(fp);
        return(1);
 }
 
        return(1);
 }