From d6db9ea1dc43510e28e0a29989b4e2e39ee099a7 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Wed, 1 Nov 2017 15:45:50 -0400 Subject: The `lp` and `lpr` commands now provide better error messages when the default printer cannot be found (Issue #5096) - berkeley/lpr.c: Use cupsLastErrorMessage() for not-found errors. - cups/dest.c: Set the last error message in cupsGetNamedDest(). - systemv/lp.c: Use cupsLastErrorMessage() for not-found errors. --- systemv/lp.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'systemv') diff --git a/systemv/lp.c b/systemv/lp.c index 9672b080a..5033459d0 100644 --- a/systemv/lp.c +++ b/systemv/lp.c @@ -1,7 +1,7 @@ /* * "lp" command for CUPS. * - * Copyright 2007-2016 by Apple Inc. + * Copyright 2007-2017 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -586,33 +586,10 @@ main(int argc, /* I - Number of command-line arguments */ if (printer == NULL) { - val = NULL; - - if ((printer = getenv("LPDEST")) == NULL) - { - if ((printer = getenv("PRINTER")) != NULL) - { - if (!strcmp(printer, "lp")) - printer = NULL; - else - val = "PRINTER"; - } - } - else - val = "LPDEST"; - - if (printer && !cupsGetNamedDest(NULL, printer, NULL)) - _cupsLangPrintf(stderr, - _("%s: Error - %s environment variable names " - "non-existent destination \"%s\"."), argv[0], val, - printer); - else if (cupsLastError() == IPP_NOT_FOUND) - _cupsLangPrintf(stderr, - _("%s: Error - no default destination available."), - argv[0]); + if (!cupsGetNamedDest(NULL, NULL, NULL) && cupsLastError() == IPP_STATUS_ERROR_NOT_FOUND) + _cupsLangPrintf(stderr, _("%s: Error - %s"), argv[0], cupsLastErrorString()); else - _cupsLangPrintf(stderr, _("%s: Error - scheduler not responding."), - argv[0]); + _cupsLangPrintf(stderr, _("%s: Error - scheduler not responding."), argv[0]); return (1); } -- cgit v1.2.3