From: Michael Sweet Date: Mon, 2 May 2016 21:07:54 +0000 (-0400) Subject: Deal with duplicate finishing-template values due to templates for different X-Git-Tag: v2.2b1~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30ea77599bb0905fd90a147a6556ef6997b99076;p=thirdparty%2Fcups.git Deal with duplicate finishing-template values due to templates for different media sizes. --- diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index fac6fcab60..f3a66f6c04 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -3499,8 +3499,10 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ ipp_attribute_t *template; /* "finishing-template" member */ const char *name; /* String name */ int value; /* Enum value, if any */ + cups_array_t *names; /* Names we've added */ count = ippGetCount(attr); + names = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free); cupsFilePrintf(fp, "*OpenUI *cupsFinishingTemplate/%s: PickMany\n" "*OrderDependency: 10 AnySetup *cupsFinishingTemplate\n" @@ -3516,6 +3518,11 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ if ((name = ippGetString(template, 0, NULL)) == NULL || !strcmp(name, "none")) continue; + if (cupsArrayFind(names, (char *)name)) + continue; /* Already did this finishing template */ + + cupsArrayAdd(names, (char *)name); + for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++) { if (!strcmp(finishings[j][0], name)) @@ -3531,6 +3538,8 @@ _ppdCreateFromIPP(char *buffer, /* I - Filename buffer */ } } + cupsArrayDelete(names); + cupsFilePuts(fp, "*CloseUI: *cupsFinishingTemplate\n"); } else if ((attr = ippFindAttribute(response, "finishings-supported", IPP_TAG_ENUM)) != NULL && (count = ippGetCount(attr)) > 1 )