do not say ...more... when there is no more (4.3BSD/etc/146)
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 24 Aug 1988 01:20:51 +0000 (17:20 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 24 Aug 1988 01:20:51 +0000 (17:20 -0800)
SCCS-vsn: libexec/comsat/comsat.c 5.13

usr/src/libexec/comsat/comsat.c

index 904911f..c71fc77 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)comsat.c   5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)comsat.c   5.13 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -227,14 +227,15 @@ jkfprintf(tp, name, offset)
                            strncmp(line, "Subject:", 8))
                                continue;
                }
                            strncmp(line, "Subject:", 8))
                                continue;
                }
+               if (linecnt <= 0 || charcnt <= 0) {
+                       fprintf(tp, "...more...%s\n", cr);
+                       return;
+               }
                if (cp = index(line, '\n'))
                        *cp = '\0';
                fprintf(tp, "%s%s\n", line, cr);
                charcnt -= strlen(line);
                if (cp = index(line, '\n'))
                        *cp = '\0';
                fprintf(tp, "%s%s\n", line, cr);
                charcnt -= strlen(line);
-               if (--linecnt <= 0 || charcnt <= 0) {
-                       fprintf(tp, "...more...%s\n", cr);
-                       return;
-               }
+               linecnt--;
        }
        fprintf(tp, "----%s\n", cr);
 }
        }
        fprintf(tp, "----%s\n", cr);
 }