From 62831258e97190415057c372451762f514780584 Mon Sep 17 00:00:00 2001 From: deraadt Date: Sat, 4 May 1996 11:52:47 +0000 Subject: [PATCH] correct -P, $PRINTER, and DEFLP interactions. bug reported by scott.burns@labatt.com --- usr.sbin/lpr/lpq/lpq.c | 7 ++++++- usr.sbin/lpr/lpr/lpr.c | 10 ++++++++-- usr.sbin/lpr/lprm/lprm.c | 7 ++++++- usr.sbin/lpr/pac/pac.c | 9 +++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c index e9026bf8e5d..8559dc93cda 100644 --- a/usr.sbin/lpr/lpq/lpq.c +++ b/usr.sbin/lpr/lpq/lpq.c @@ -104,8 +104,13 @@ main(argc, argv) usage(); } - if (printer == NULL && (printer = getenv("PRINTER")) == NULL) + if (printer == NULL) { + char *p; + printer = DEFLP; + if ((p = getenv("PRINTER")) + printer = p; + } for (argc -= optind, argv += optind; argc; --argc, ++argv) if (isdigit(argv[0][0])) { diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c index 037851a05ff..bd299a8d7f6 100644 --- a/usr.sbin/lpr/lpr/lpr.c +++ b/usr.sbin/lpr/lpr/lpr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lpr.c,v 1.2 1996/04/21 23:40:42 deraadt Exp $ */ +/* $OpenBSD: lpr.c,v 1.3 1996/05/04 11:52:55 deraadt Exp $ */ /* $NetBSD: lpr.c,v 1.10 1996/03/21 18:12:25 jtc Exp $ */ /* @@ -259,8 +259,14 @@ main(argc, argv) } } } - if (printer == NULL && (printer = getenv("PRINTER")) == NULL) + + if (printer == NULL) { + char *p; + printer = DEFLP; + if ((p = getenv("PRINTER")) + printer = p; + } chkprinter(printer); if (SC && ncopies > 1) fatal2("multiple copies are not allowed"); diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c index df3a6cb3b04..88607c2083f 100644 --- a/usr.sbin/lpr/lprm/lprm.c +++ b/usr.sbin/lpr/lprm/lprm.c @@ -133,8 +133,13 @@ main(argc, argv) } } } - if (printer == NULL && (printer = getenv("PRINTER")) == NULL) + if (printer == NULL) { + char *p; + printer = DEFLP; + if ((p = getenv("PRINTER")) + printer = p; + } rmjob(); exit(0); diff --git a/usr.sbin/lpr/pac/pac.c b/usr.sbin/lpr/pac/pac.c index ac8abc21374..36e15f253f7 100644 --- a/usr.sbin/lpr/pac/pac.c +++ b/usr.sbin/lpr/pac/pac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pac.c,v 1.3 1996/04/21 23:40:48 deraadt Exp $ */ +/* $OpenBSD: pac.c,v 1.4 1996/05/04 11:53:05 deraadt Exp $ */ /* $NetBSD: pac.c,v 1.7 1996/03/21 18:21:20 jtc Exp $ */ /* @@ -169,8 +169,13 @@ fprintf(stderr, (void) enter(--cp); allflag = 0; } - if (printer == NULL && (printer = getenv("PRINTER")) == NULL) + if (printer == NULL) { + char *p; + printer = DEFLP; + if ((p = getenv("PRINTER")) + printer = p; + } if (!chkprinter(printer)) { printf("pac: unknown printer %s\n", printer); exit(2); -- 2.20.1