]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - systemv/cupstestppd.c
Load cups into easysw/current.
[thirdparty/cups.git] / systemv / cupstestppd.c
index 068a4b81be00e2ac7ff615bebefc14a73a0d5f03..474ad02b237d17151a6910f73087ed7f552f20b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: cupstestppd.c 6322 2007-03-08 19:25:26Z mike $"
+ * "$Id: cupstestppd.c 6430 2007-04-02 14:01:55Z mike $"
  *
  *   PPD test program for the Common UNIX Printing System (CUPS).
  *
@@ -1010,16 +1010,22 @@ main(int  argc,                 /* I - Number of command-line arguments */
         * This file contains localizations, check them...
        */
 
-        char   *languages,             /* Copy of attribute value */
-               *langstart,             /* Start of current language */
-               *langptr,               /* Pointer into languages */
-               keyword[PPD_MAX_NAME],  /* Localization keyword */
-               ckeyword[PPD_MAX_NAME]; /* Custom option keyword */
+        char           *languages,     /* Copy of attribute value */
+                       *langstart,     /* Start of current language */
+                       *langptr,       /* Pointer into languages */
+                       keyword[PPD_MAX_NAME],
+                                       /* Localization keyword */
+                       ckeyword[PPD_MAX_NAME];
+                                       /* Custom option keyword */
        ppd_coption_t   *coption;       /* Custom option */
        ppd_cparam_t    *cparam;        /* Custom parameter */
+        cups_array_t   *langlist;      /* List of languages so far */
+        char           ll[3];          /* Base language */
 
 
         languages = strdup(attr->value);
+       langlist  = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+
        for (langptr = languages; *langptr;)
        {
         /*
@@ -1060,6 +1066,8 @@ main(int  argc,                   /* I - Number of command-line arguments */
            continue;
          }
 
+          cupsArrayAdd(langlist, langstart);
+
          /*
          * Loop through all options and choices...
          */
@@ -1132,24 +1140,8 @@ main(int  argc,                  /* I - Number of command-line arguments */
                snprintf(ckeyword, sizeof(ckeyword), "%s.Custom%s",
                         langstart, option->keyword);
 
-               if ((attr = ppdFindAttr(ppd, ckeyword, "True")) == NULL)
-               {
-                 if (verbose >= 0)
-                 {
-                   if (!errors && !verbose)
-                     _cupsLangPuts(stdout, _(" FAIL\n"));
-
-                   _cupsLangPrintf(stdout,
-                                   _("      **FAIL**  Missing \"%s\" "
-                                     "translation string for option %s, "
-                                     "choice %s!\n"),
-                                   langstart, ckeyword + 1 + strlen(langstart),
-                                   "True");
-                 }
-
-                 errors ++;
-               }
-               else if (!valid_utf8(attr->text))
+               if ((attr = ppdFindAttr(ppd, ckeyword, "True")) != NULL &&
+                   !valid_utf8(attr->text))
                {
                  if (verbose >= 0)
                  {
@@ -1273,6 +1265,48 @@ main(int  argc,                  /* I - Number of command-line arguments */
             }
          }
         }
+
+       /*
+        * Verify that we have the base language for each localized one...
+       */
+
+        for (langptr = (char *)cupsArrayFirst(langlist);
+            langptr;
+            langptr = (char *)cupsArrayNext(langlist))
+         if (langptr[2])
+         {
+          /*
+           * Lookup the base language...
+           */
+
+           cupsArraySave(langlist);
+
+           strlcpy(ll, langptr, sizeof(ll));
+
+           if (!cupsArrayFind(langlist, ll))
+           {
+             if (verbose >= 0)
+             {
+               if (!errors && !verbose)
+                 _cupsLangPuts(stdout, _(" FAIL\n"));
+
+               _cupsLangPrintf(stdout,
+                               _("      **FAIL**  No base translation \"%s\" "
+                                 "is included in file!\n"), ll);
+             }
+
+             errors ++;
+           }
+
+           cupsArrayRestore(langlist);
+         }
+
+       /*
+        * Free memory used for the languages...
+       */
+
+        cupsArrayDelete(langlist);
+       free(languages);
       }
 
       for (attr = ppdFindAttr(ppd, "cupsFilter", NULL);
@@ -1933,5 +1967,5 @@ valid_utf8(const char *s)         /* I - String to check */
 
 
 /*
- * End of "$Id: cupstestppd.c 6322 2007-03-08 19:25:26Z mike $".
+ * End of "$Id: cupstestppd.c 6430 2007-04-02 14:01:55Z mike $".
  */