diff options
author | Kevin Steves <stevesk@cvs.openbsd.org> | 2007-04-08 23:11:38 +0000 |
---|---|---|
committer | Kevin Steves <stevesk@cvs.openbsd.org> | 2007-04-08 23:11:38 +0000 |
commit | eaa89f31c3e009f841a2cf725ebd5d665f81a609 (patch) | |
tree | 6cab343d1f91a50870f032244d8fa435728d08d3 /usr.sbin/lpr | |
parent | 4b03e0e125a81620629436ba28dec4c13d9d127b (diff) |
I have an HP LaserJet (P2015dn) whose LPR implementation may not end
the send queue state command stream with '\n'; check for this case
and print '\n' if needed. Without this you may see something like:
$ lpq
queue empty$
ok millert@
Diffstat (limited to 'usr.sbin/lpr')
-rw-r--r-- | usr.sbin/lpr/common_source/displayq.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c index 400801f10eb..40529f6b383 100644 --- a/usr.sbin/lpr/common_source/displayq.c +++ b/usr.sbin/lpr/common_source/displayq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: displayq.c,v 1.28 2007/04/07 21:12:11 stevesk Exp $ */ +/* $OpenBSD: displayq.c,v 1.29 2007/04/08 23:11:37 stevesk Exp $ */ /* $NetBSD: displayq.c,v 1.21 2001/08/30 00:51:50 itojun Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static const char sccsid[] = "@(#)displayq.c 8.4 (Berkeley) 4/28/95"; #else -static const char rcsid[] = "$OpenBSD: displayq.c,v 1.28 2007/04/07 21:12:11 stevesk Exp $"; +static const char rcsid[] = "$OpenBSD: displayq.c,v 1.29 2007/04/08 23:11:37 stevesk Exp $"; #endif #endif /* not lint */ @@ -282,6 +282,7 @@ displayq(int format) else { struct sigaction osa, nsa; char *visline; + int n = 0; i = strlen(line); if (write(fd, line, i) != i) @@ -295,10 +296,13 @@ displayq(int format) if ((visline = (char *)malloc(4 * sizeof(line) + 1)) == NULL) fatal("Out of memory"); while ((i = read(fd, line, sizeof(line))) > 0) { - i = strvisx(visline, line, i, VIS_SAFE|VIS_NOSLASH); - (void)fwrite(visline, 1, i, stdout); + n = strvisx(visline, line, i, VIS_SAFE|VIS_NOSLASH); + (void)fwrite(visline, 1, n, stdout); alarm(wait_time); } + /* XXX some LPR implementations may not end stream with '\n' */ + if (n > 0 && visline[n-1] != '\n') + putchar('\n'); alarm(0); (void)sigaction(SIGALRM, &osa, NULL); free(visline); |