Index: localize.c =================================================================== --- localize.c (revision 5823) +++ localize.c (working copy) @@ -80,6 +80,8 @@ * Range check input... */ + DEBUG_printf(("ppdLocalize(ppd=%p)\n", ppd)); + if (!ppd) return (-1); @@ -93,6 +95,9 @@ strlcpy(ll_CC, lang->language, sizeof(ll_CC)); strlcpy(ll, lang->language, sizeof(ll)); + DEBUG_printf((" lang->language=\"%s\", ll=\"%s\", ll_CC=\"%s\"...\n", + lang->language, ll, ll_CC)); + /* * Now lookup all of the groups, options, choices, etc. */ @@ -165,17 +170,29 @@ ppd_attr_t *attr; /* Current attribute */ + DEBUG_printf(("ppd_text(ppd=%p, keyword=\"%s\", spec=\"%s\", " + "ll_CC=\"%s\", ll=\"%s\")\n", + ppd, keyword, spec, ll_CC, ll)); + /* * Look for Keyword.ll_CC, then Keyword.ll... */ - snprintf(lkeyword, sizeof(lkeyword), "%s.%s", keyword, ll_CC); + snprintf(lkeyword, sizeof(lkeyword), "%s.%s", ll_CC, keyword); if ((attr = ppdFindAttr(ppd, lkeyword, spec)) == NULL) { - snprintf(lkeyword, sizeof(lkeyword), "%s.%s", keyword, ll); + snprintf(lkeyword, sizeof(lkeyword), "%s.%s", ll, keyword); attr = ppdFindAttr(ppd, lkeyword, spec); } +#ifdef DEBUG + if (attr) + printf(" *%s %s/%s: \"%s\"\n", attr->name, attr->spec, attr->text, + attr->value ? attr->value : ""); + else + puts(" NOT FOUND"); +#endif /* DEBUG */ + /* * Return text if we find it... */ Index: ppd.c =================================================================== --- ppd.c (revision 5823) +++ ppd.c (working copy) @@ -2037,10 +2037,8 @@ if ((ret = strcasecmp(a->name, b->name)) != 0) return (ret); - else if (a->spec[0] && b->spec[0]) - return (strcasecmp(a->spec, b->spec)); else - return (0); + return (strcasecmp(a->spec, b->spec)); } Index: attr.c =================================================================== --- attr.c (revision 5823) +++ attr.c (working copy) @@ -44,14 +44,19 @@ * @since CUPS 1.1.19@ */ -ppd_attr_t * /* O - Attribute or NULL if not found */ -ppdFindAttr(ppd_file_t *ppd, /* I - PPD file data */ - const char *name, /* I - Attribute name */ - const char *spec) /* I - Specifier string or NULL */ +ppd_attr_t * /* O - Attribute or NULL if not found */ +ppdFindAttr(ppd_file_t *ppd, /* I - PPD file data */ + const char *name, /* I - Attribute name */ + const char *spec) /* I - Specifier string or NULL */ { - ppd_attr_t key; /* Search key */ + ppd_attr_t key, /* Search key */ + *attr; /* Current attribute */ + int diff; /* Current difference */ + DEBUG_printf(("ppdFindAttr(ppd=%p, name=\"%s\", spec=\"%s\")\n", ppd, + name ? name : "(null)", spec ? spec : "(null)")); + /* * Range check input... */ @@ -72,7 +77,36 @@ * Return the first matching attribute, if any... */ - return ((ppd_attr_t *)cupsArrayFind(ppd->sorted_attrs, &key)); + if ((attr = (ppd_attr_t *)cupsArrayFind(ppd->sorted_attrs, &key)) != NULL) + return (attr); + else if (spec) + return (NULL); + + /* + * No match found, loop through the sorted attributes to see if we can + * find a "wildcard" match for the attribute... + */ + + for (attr = (ppd_attr_t *)cupsArrayFirst(ppd->sorted_attrs); + attr; + attr = (ppd_attr_t *)cupsArrayFirst(ppd->sorted_attrs)) + { + if ((diff = strcasecmp(attr->name, name)) == 0) + break; + + if (diff > 0) + { + /* + * All remaining attributes are > than the one we are trying to find... + */ + + cupsArrayIndex(ppd->sorted_attrs, cupsArrayCount(ppd->sorted_attrs)); + + return (NULL); + } + } + + return (attr); } Index: testppd.c =================================================================== --- testppd.c (revision 5823) +++ testppd.c (working copy) @@ -192,10 +192,18 @@ else { int i, j, k; /* Looping vars */ + ppd_attr_t *attr; /* Current attribute */ ppd_group_t *group; /* Option group */ ppd_option_t *option; /* Option */ + char lang[255]; /* LANG environment variable */ + if (argc > 2) + { + snprintf(lang, sizeof(lang), "LANG=%s", argv[2]); + putenv(lang); + } + ppdLocalize(ppd); for (i = ppd->num_groups, group = ppd->groups; @@ -203,7 +211,7 @@ i --, group ++) { printf("%s (%s):\n", group->name, group->text); - + for (j = group->num_options, option = group->options; j > 0; j --, option ++) @@ -215,6 +223,14 @@ option->choices[k].text); } } + + puts("Attributes:"); + + for (attr = (ppd_attr_t *)cupsArrayFirst(ppd->sorted_attrs); + attr; + attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) + printf(" *%s %s/%s: \"%s\"\n", attr->name, attr->spec, + attr->text, attr->value ? attr->value : ""); } }