From owner-freebsd-bugs@FreeBSD.ORG Tue Oct 24 03:10:24 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 458D816A403 for ; Tue, 24 Oct 2006 03:10:24 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7FEC943D66 for ; Tue, 24 Oct 2006 03:10:21 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9O3ALYg018849 for ; Tue, 24 Oct 2006 03:10:21 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9O3AL2o018848; Tue, 24 Oct 2006 03:10:21 GMT (envelope-from gnats) Resent-Date: Tue, 24 Oct 2006 03:10:21 GMT Resent-Message-Id: <200610240310.k9O3AL2o018848@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Sean Farley Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3D41316A4A7 for ; Tue, 24 Oct 2006 03:04:55 +0000 (UTC) (envelope-from sean-freebsd@farley.org) Received: from mail.farley.org (farley.org [67.64.95.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id C633843D55 for ; Tue, 24 Oct 2006 03:04:53 +0000 (GMT) (envelope-from sean-freebsd@farley.org) Received: from thor.farley.org (thor.farley.org [192.168.1.5]) by mail.farley.org (8.13.8/8.13.8) with ESMTP id k9O36RSX052462 for ; Mon, 23 Oct 2006 22:06:27 -0500 (CDT) (envelope-from sean-freebsd@mail.farley.org) Received: from thor.farley.org (localhost [127.0.0.1]) by thor.farley.org (8.13.8/8.13.8) with ESMTP id k9O34lM7002734 for ; Mon, 23 Oct 2006 22:04:47 -0500 (CDT) (envelope-from sean-freebsd@thor.farley.org) Received: (from sean@localhost) by thor.farley.org (8.13.8/8.13.8/Submit) id k9O34lOq002733; Mon, 23 Oct 2006 22:04:47 -0500 (CDT) (envelope-from sean-freebsd) Message-Id: <200610240304.k9O34lOq002733@thor.farley.org> Date: Mon, 23 Oct 2006 22:04:47 -0500 (CDT) From: Sean Farley To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/104731: [patch] missing newline in lpq output X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Sean Farley List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2006 03:10:24 -0000 >Number: 104731 >Category: bin >Synopsis: [patch] missing newline in lpq output >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Oct 24 03:10:20 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Sean Farley >Release: FreeBSD 6.2-PRERELEASE i386 >Organization: >Environment: System: FreeBSD thor.farley.org 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #1: Sun Oct 1 12:38:47 CDT 2006 root@thor.farley.org:/usr/obj/usr/src/sys/THOR i386 >Description: When lpq outputs the status from a remote printer/lpd, it prints exactly what is given to it. With an HP 3055 that has no jobs, the output is "queue empty" without the newline. >How-To-Repeat: lpq run against a printer or lpd that does not send a closing newline. >Fix: I am providing two patches. The first simply prints a newline following a complete output from the printer. The second checks for a newline and prints one only if the last character was not a newline. I prefer the second patch, but the first is better than nothing. There is a second spot in the display code, but I am not certain that it requires the same type of patch. The patches will also be available at: http://www.farley.org/freebsd/tmp/PR//lpq-patch1.txt http://www.farley.org/freebsd/tmp/PR//lpq-patch2.txt ------ First patch ------ diff -ru /usr/src/usr.sbin/lpr/common_source/displayq.c lpr/common_source/displayq.c --- /usr/src/usr.sbin/lpr/common_source/displayq.c Thu Dec 30 18:36:28 2004 +++ lpr/common_source/displayq.c Mon Oct 23 20:44:15 2006 @@ -255,6 +255,7 @@ fatal(pp, "Lost connection"); while ((i = read(fd, line, sizeof(line))) > 0) (void) fwrite(line, 1, i, stdout); + fprintf(stdout, "\n"); (void) close(fd); } } ------ First patch ------ ------ Second patch ------ diff -ru /usr/src/usr.sbin/lpr/common_source/displayq.c lpr/common_source/displayq.c --- /usr/src/usr.sbin/lpr/common_source/displayq.c Thu Dec 30 18:36:28 2004 +++ lpr/common_source/displayq.c Mon Oct 23 20:54:32 2006 @@ -96,6 +96,7 @@ { register struct jobqueue *q; register int i, nitems, fd, ret; + int lastChar; char *cp, *endp; struct jobqueue **queue; struct stat statb; @@ -253,8 +254,13 @@ i = strlen(line); if (write(fd, line, i) != i) fatal(pp, "Lost connection"); - while ((i = read(fd, line, sizeof(line))) > 0) + lastChar = 0; + while ((i = read(fd, line, sizeof(line))) > 0) { (void) fwrite(line, 1, i, stdout); + lastChar = i - 1; + } + if (lastChar > 0 && line[lastChar] != '\n') + fprintf(stdout, "\n"); (void) close(fd); } } ------ Second patch ------ >Release-Note: >Audit-Trail: >Unformatted: