Skip to content

Commit

Permalink
ppd-ipp.c: Use bitwise OR in cond and save value (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdohnal authored Mar 8, 2024
1 parent d17b102 commit 327b61c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ppd/ppd-ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand Down Expand Up @@ -659,13 +660,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);
}
Expand Down

0 comments on commit 327b61c

Please sign in to comment.