From 7876a31985c12f505a3caa242c898f5acb01f756 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Thu, 25 Jan 2024 13:31:49 +0100 Subject: [PATCH] ppd-ipp.c: Use bitwise OR in cond and save value --- ppd/ppd-ipp.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ppd/ppd-ipp.c b/ppd/ppd-ipp.c index f157e201..3c432e63 100644 --- a/ppd/ppd-ipp.c +++ b/ppd/ppd-ipp.c @@ -339,6 +339,7 @@ ppdLoadAttributes( int def_found, order, face_up, + num, have_custom_size = 0; cups_page_header_t header; static const char * const pdls[][2] = @@ -657,13 +658,16 @@ ppdLoadAttributes( yres = res_y[0]; } } - else if (strlen(items[0]) > 0 && - ((int)(strtol(items[0], &p, 10) * 0) || - (errno == 0 && *p == '\0'))) + else if (items[0][0] && ((num = strtol(items[0], &p, 10)) | 1) && errno == 0 && *p == '\0') { + // bitwise OR is used in case the read string is "0". + // we had to use strtol() in case there are keyword values starting with a number... + int_item[0] = num; + // Integer number(s) - for (j = 0; j < num_items; j ++) - int_item[j] = (int)strtol(items[j], NULL, 10); + for (j = 1; j < num_items; j ++) + int_item[j] = (int)strtol(items[j], &p, 10); + ippAddIntegers(attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, item_buf, num_items, int_item); }