]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Always produce the test logs artifacts, especially for failed tests... :)
authorMichael R Sweet <msweet@msweet.org>
Fri, 21 Nov 2025 13:59:53 +0000 (08:59 -0500)
committerMichael R Sweet <msweet@msweet.org>
Fri, 21 Nov 2025 13:59:53 +0000 (08:59 -0500)
.github/workflows/build.yml
scheduler/type.c

index 234364885e16d7d343ad223452f3f2a08e84ac53..39168b40d02acf37dadb3790a9832674501debe5 100644 (file)
@@ -35,6 +35,7 @@ jobs:
       run: make test
     - name: Upload Test Results
       uses: actions/upload-artifact@v4
+      if: !canceled()
       with:
         name: ubuntu-openssl-test-results
         path: |
@@ -66,6 +67,7 @@ jobs:
       run: make test
     - name: Upload Test Results
       uses: actions/upload-artifact@v4
+      if: !canceled()
       with:
         name: ubuntu-gnutls-test-results
         path: |
@@ -92,6 +94,7 @@ jobs:
       run: make test
     - name: Upload Test Results
       uses: actions/upload-artifact@v4
+      if: !canceled()
       with:
         name: macos-test-results
         path: |
index 2851f6218170d3f310cea4227208ef4c9fd3a0a1..ba6aa3dfb14b56d3066b0dcd3d76a31f2e1ea0ec 100644 (file)
@@ -86,30 +86,21 @@ mimeAddType(mime_t     *mime,               // I - MIME database
   DEBUG_printf(("mimeAddType(mime=%p, super=\"%s\", type=\"%s\")", mime, super,
                 type));
 
- /*
-  * Range check input...
-  */
-
-  if (!mime || !super || !type)
+  // Range check input...
+  if (!mime || !super || !*super || !type || !*type)
   {
     DEBUG_puts("1mimeAddType: Returning NULL (bad arguments).");
     return (NULL);
   }
 
- /*
-  * See if the type already exists; if so, return the existing type...
-  */
-
+  // See if the type already exists; if so, return the existing type...
   if ((temp = mimeType(mime, super, type)) != NULL)
   {
     DEBUG_printf("1mimeAddType: Returning %p (existing).", temp);
     return (temp);
   }
 
- /*
-  * The type doesn't exist; add it...
-  */
-
+  // The type doesn't exist; add it...
   if (!mime->types)
     mime->types = cupsArrayNew3((cups_array_cb_t)_mimeCompareTypes, /*cb_data*/NULL, /*hash_cb*/NULL, /*hash_size*/0, /*copy_cb*/NULL, (cups_afree_cb_t)_mimeFreeType);
 
@@ -162,29 +153,20 @@ mimeAddTypeRule(mime_type_t *mt,  // I - Type to add to
   DEBUG_printf(("mimeAddTypeRule(mt=%p(%s/%s), rule=\"%s\")", mt,
                 mt ? mt->super : "???", mt ? mt->type : "???", rule));
 
- /*
-  * Range check input...
-  */
-
+  // Range check input...
   if (!mt || !rule)
     return (-1);
 
- /*
-  * Find the last rule in the top-level of the rules tree.
-  */
-
+  // Find the last rule in the top-level of the rules tree.
   for (current = mt->rules; current; current = current->next)
     if (!current->next)
       break;
 
- /*
-  * Parse the rules string.  Most rules are either a file extension or a
-  * comparison function:
-  *
-  *    extension
-  *    function(parameters)
-  */
-
+  // Parse the rules string.  Most rules are either a file extension or a
+  // comparison function:
+  //
+  //   extension
+  //   function(parameters)
   logic  = MIME_MAGIC_NOP;
   invert = 0;
 
@@ -219,11 +201,8 @@ mimeAddTypeRule(mime_type_t *mt,   // I - Type to add to
       if (logic != MIME_MAGIC_AND &&
           current->prev != NULL)
       {
-       /*
-        * OK, we have more than 1 rule in the current tree level...  Make a
-       * new group tree and move the previous rule to it...
-       */
-
+        // OK, we have more than 1 rule in the current tree level.  Make a
+       // new group tree and move the previous rule to it...
        if ((temp = calloc(1, sizeof(mime_magic_t))) == NULL)
          return (-1);
 
@@ -240,8 +219,7 @@ mimeAddTypeRule(mime_type_t *mt,    // I - Type to add to
       }
       else if (current->parent)
       {
-        DEBUG_printf(("1mimeAddTypeRule: Setting group %p op to AND.",
-                     current->parent));
+        DEBUG_printf("1mimeAddTypeRule: Setting group %p op to AND.", current->parent);
         current->parent->op = MIME_MAGIC_AND;
       }
 
@@ -252,23 +230,16 @@ mimeAddTypeRule(mime_type_t *mt,  // I - Type to add to
     {
       if (logic != MIME_MAGIC_OR && current != NULL)
       {
-       /*
-        * OK, we have two possibilities; either this is the top-level rule or
-       * we have a bunch of AND rules at this level.
-       */
-
+        // OK, we have two possibilities; either this is the top-level rule or
+       // we have a bunch of AND rules at this level.
        if (current->parent == NULL)
        {
-        /*
-         * This is the top-level rule; we have to move *all* of the AND rules
-         * down a level, as AND has precedence over OR.
-         */
-
+         // This is the top-level rule; we have to move *all* of the AND rules
+         // down a level, as AND has precedence over OR.
          if ((temp = calloc(1, sizeof(mime_magic_t))) == NULL)
            return (-1);
 
-          DEBUG_printf(("1mimeAddTypeRule: Creating new AND group %p inside OR "
-                       "group.", temp));
+          DEBUG_printf("1mimeAddTypeRule: Creating new AND group %p inside OR group.", temp);
 
           while (current->prev != NULL)
          {
@@ -284,10 +255,7 @@ mimeAddTypeRule(mime_type_t *mt,   // I - Type to add to
        }
        else
        {
-        /*
-         * This isn't the top rule, so go up one level...
-         */
-
+         // This isn't the top rule, so go up one level...
           DEBUG_puts("1mimeAddTypeRule: Going up one level.");
          current = current->parent;
        }
@@ -304,10 +272,7 @@ mimeAddTypeRule(mime_type_t *mt,   // I - Type to add to
     }
     else if (isalnum(*rule & 255))
     {
-     /*
-      * Read an extension name or a function...
-      */
-
+      // Read an extension name or a function...
       ptr = name;
       while (isalnum(*rule & 255) && (size_t)(ptr - name) < (sizeof(name) - 1))
         *ptr++ = *rule++;
@@ -316,39 +281,26 @@ mimeAddTypeRule(mime_type_t *mt,  // I - Type to add to
 
       if (*rule == '(')
       {
-       /*
-        * Read function parameters...
-       */
-
+        // Read function parameters...
        rule ++;
-       for (num_values = 0;
-            num_values < (int)(sizeof(value) / sizeof(value[0]));
-            num_values ++)
+       for (num_values = 0; num_values < (int)(sizeof(value) / sizeof(value[0])); num_values ++)
        {
          ptr = value[num_values];
 
-         while ((size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1) &&
-                *rule != '\0' && *rule != ',' && *rule != ')')
+         while ((size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1) && *rule != '\0' && *rule != ',' && *rule != ')')
          {
            if (isspace(*rule & 255))
            {
-            /*
-             * Ignore whitespace...
-             */
-
+             // Ignore whitespace...
              rule ++;
              continue;
            }
            else if (*rule == '\"' || *rule == '\'')
            {
-            /*
-             * Copy quoted strings literally...
-             */
-
+             // Copy quoted strings literally...
              quote = *rule++;
 
-             while (*rule != '\0' && *rule != quote &&
-                    (size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1))
+             while (*rule != '\0' && *rule != quote && (size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1))
                *ptr++ = *rule++;
 
               if (*rule == quote)
@@ -360,8 +312,7 @@ mimeAddTypeRule(mime_type_t *mt,    // I - Type to add to
            {
              rule ++;
 
-             while (*rule != '>' && *rule != '\0' &&
-                    (size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1))
+             while (*rule != '>' && *rule != '\0' && (size_t)(ptr - value[num_values]) < (sizeof(value[0]) - 1))
              {
                if (isxdigit(rule[0] & 255) && isxdigit(rule[1] & 255))
                {
@@ -376,7 +327,9 @@ mimeAddTypeRule(mime_type_t *mt,    // I - Type to add to
                    *ptr++ |= tolower(*rule++) - 'a' + 10;
                }
                else
+               {
                  return (-1);
+               }
              }
 
               if (*rule == '>')
@@ -385,7 +338,9 @@ mimeAddTypeRule(mime_type_t *mt,    // I - Type to add to
                return (-1);
            }
            else
+           {
              *ptr++ = *rule++;
+           }
          }
 
           *ptr = '\0';
@@ -405,10 +360,7 @@ mimeAddTypeRule(mime_type_t *mt,   // I - Type to add to
 
        rule ++;
 
-       /*
-        * Figure out the function...
-       */
-
+        // Figure out the function...
         if (!strcmp(name, "match"))
          op = MIME_MAGIC_MATCH;
        else if (!strcmp(name, "ascii"))
@@ -441,20 +393,14 @@ mimeAddTypeRule(mime_type_t *mt,  // I - Type to add to
       }
       else
       {
-       /*
-        * This is just a filename match on the extension...
-       */
-
+        // This is just a filename match on the extension...
        snprintf(value[0], sizeof(value[0]), "*.%s", name);
        length[0]  = (int)strlen(value[0]);
        op         = MIME_MAGIC_MATCH;
        num_values = 1;
       }
 
-     /*
-      * Add a rule for this operation.
-      */
-
+      // Add a rule for this operation.
       if ((temp = calloc(1, sizeof(mime_magic_t))) == NULL)
        return (-1);
 
@@ -465,18 +411,16 @@ mimeAddTypeRule(mime_type_t *mt,  // I - Type to add to
        current->next = temp;
       }
       else
+      {
         mt->rules = temp;
+      }
 
       temp->prev = current;
 
       if (logic == MIME_MAGIC_NOP)
       {
-       /*
-        * Add parenthetical grouping...
-       */
-
-        DEBUG_printf(("1mimeAddTypeRule: Making new OR group %p for "
-                     "parenthesis.", temp));
+        // Add parenthetical grouping...
+        DEBUG_printf("1mimeAddTypeRule: Making new OR group %p for parenthesis.", temp);
 
         temp->op = MIME_MAGIC_OR;
 
@@ -491,14 +435,9 @@ mimeAddTypeRule(mime_type_t *mt,   // I - Type to add to
         logic = MIME_MAGIC_OR;
       }
 
-      DEBUG_printf(("1mimeAddTypeRule: Adding %p: %s, op=MIME_MAGIC_%s(%d), "
-                   "logic=MIME_MAGIC_%s, invert=%d.", temp, name,
-                   debug_ops[op], op, debug_ops[logic], invert));
-
-     /*
-      * Fill in data for the rule...
-      */
+      DEBUG_printf("1mimeAddTypeRule: Adding %p: %s, op=MIME_MAGIC_%s(%d), logic=MIME_MAGIC_%s, invert=%d.", temp, name, debug_ops[op], op, debug_ops[logic], invert);
 
+      // Fill in data for the rule...
       current  = temp;
       temp->op = (short)op;
       invert   = 0;
@@ -568,7 +507,9 @@ mimeAddTypeRule(mime_type_t *mt,    // I - Type to add to
       }
     }
     else
+    {
       break;
+    }
   }
 
   return (0);
@@ -615,20 +556,14 @@ mimeFileType(mime_t     *mime,            // I - MIME database
   DEBUG_printf(("mimeFileType(mime=%p, pathname=\"%s\", filename=\"%s\", "
                 "compression=%p)", mime, pathname, filename, compression));
 
- /*
-  * Range check input parameters...
-  */
-
+  // Range check input parameters...
   if (!mime || !pathname)
   {
     DEBUG_puts("1mimeFileType: Returning NULL.");
     return (NULL);
   }
 
- /*
-  * Try to open the file...
-  */
-
+  // Try to open the file...
   if ((fb.fp = cupsFileOpen(pathname, "r")) == NULL)
   {
     DEBUG_printf(("1mimeFileType: Unable to open \"%s\": %s", pathname,
@@ -637,11 +572,8 @@ mimeFileType(mime_t     *mime,             // I - MIME database
     return (NULL);
   }
 
- /*
-  * Then preload the first MIME_MAX_BUFFER bytes of the file into the file
-  * buffer, returning an error if we can't read anything...
-  */
-
+  // Then preload the first MIME_MAX_BUFFER bytes of the file into the file
+  // buffer, returning an error if we can't read anything...
   fb.offset = 0;
   fb.length = (int)cupsFileRead(fb.fp, (char *)fb.buffer, MIME_MAX_BUFFER);
 
@@ -655,10 +587,7 @@ mimeFileType(mime_t     *mime,             // I - MIME database
     return (NULL);
   }
 
- /*
-  * Figure out the base filename (without directory portion)...
-  */
-
+  // Figure out the base filename (without directory portion)...
   if (filename)
   {
     if ((base = strrchr(filename, '/')) != NULL)
@@ -667,27 +596,25 @@ mimeFileType(mime_t     *mime,            // I - MIME database
       base = filename;
   }
   else if ((base = strrchr(pathname, '/')) != NULL)
+  {
     base ++;
+  }
   else
+  {
     base = pathname;
+  }
 
- /*
-  * Then check it against all known types...
-  */
-
-  for (type = (mime_type_t *)cupsArrayFirst(mime->types), best = NULL;
-       type;
-       type = (mime_type_t *)cupsArrayNext(mime->types))
+  // Then check it against all known types...
+  for (type = (mime_type_t *)cupsArrayFirst(mime->types), best = NULL; type; type = (mime_type_t *)cupsArrayNext(mime->types))
+  {
     if (mime_check_rules(base, &fb, type->rules))
     {
       if (!best || type->priority > best->priority)
         best = type;
     }
+  }
 
- /*
-  * Finally, close the file and return a match (if any)...
-  */
-
+  // Finally, close the file and return a match (if any)...
   if (compression)
   {
     *compression = cupsFileCompression(fb.fp);
@@ -733,20 +660,14 @@ mimeType(mime_t     *mime,                // I - MIME database
   DEBUG_printf(("mimeType(mime=%p, super=\"%s\", type=\"%s\")", mime, super,
                 type));
 
- /*
-  * Range check input...
-  */
-
+  // Range check input...
   if (!mime || !super || !type)
   {
     DEBUG_puts("1mimeType: Returning NULL.");
     return (NULL);
   }
 
- /*
-  * Lookup the type in the array...
-  */
-
+  // Lookup the type in the array...
   cupsCopyString(key.super, super, sizeof(key.super));
   cupsCopyString(key.type, type, sizeof(key.type));
 
@@ -775,8 +696,7 @@ mime_check_rules(
   unsigned char        *bufptr;                // Pointer into buffer
 
 
-  DEBUG_printf(("4mime_check_rules(filename=\"%s\", fb=%p, rules=%p)", filename,
-                fb, rules));
+  DEBUG_printf("4mime_check_rules(filename=\"%s\", fb=%p, rules=%p)", filename, fb, rules);
 
   if (rules == NULL)
     return (0);
@@ -790,10 +710,7 @@ mime_check_rules(
 
   while (rules != NULL)
   {
-   /*
-    * Compute the result of this rule...
-    */
-
+    // Compute the result of this rule...
     switch (rules->op)
     {
       case MIME_MAGIC_MATCH :
@@ -801,17 +718,10 @@ mime_check_rules(
          break;
 
       case MIME_MAGIC_ASCII :
-         /*
-         * Load the buffer if necessary...
-         */
-
-          if (fb->offset < 0 || rules->offset < fb->offset ||
-             (rules->offset + rules->length) > (fb->offset + fb->length))
+          // Load the buffer if necessary...
+          if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + rules->length) > (fb->offset + fb->length))
          {
-          /*
-           * Reload file buffer...
-           */
-
+           // Reload file buffer...
             if (cupsFileSeek(fb->fp, rules->offset) < 0)
             {
               fb->length = 0;
@@ -826,10 +736,7 @@ mime_check_rules(
            DEBUG_printf("4mime_check_rules: MIME_MAGIC_ASCII fb->length=%d", fb->length);
          }
 
-         /*
-         * Test for ASCII printable characters plus standard control chars.
-         */
-
+          // Test for ASCII printable characters plus standard control chars.
          if ((rules->offset + rules->length) > (fb->offset + fb->length))
            n = fb->offset + fb->length - rules->offset;
          else
@@ -837,6 +744,7 @@ mime_check_rules(
 
           bufptr = fb->buffer + rules->offset - fb->offset;
          while (n > 0)
+         {
            if ((*bufptr >= 32 && *bufptr <= 126) ||
                (*bufptr >= 8 && *bufptr <= 13) ||
                *bufptr == 26 || *bufptr == 27)
@@ -845,23 +753,19 @@ mime_check_rules(
              bufptr ++;
            }
            else
+           {
              break;
+           }
+         }
 
          result = (n == 0);
          break;
 
       case MIME_MAGIC_PRINTABLE :
-         /*
-         * Load the buffer if necessary...
-         */
-
-          if (fb->offset < 0 || rules->offset < fb->offset ||
-             (rules->offset + rules->length) > (fb->offset + fb->length))
+          // Load the buffer if necessary...
+          if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + rules->length) > (fb->offset + fb->length))
          {
-          /*
-           * Reload file buffer...
-           */
-
+           // Reload file buffer...
             if (cupsFileSeek(fb->fp, rules->offset) < 0)
             {
               fb->length = 0;
@@ -876,10 +780,7 @@ mime_check_rules(
            DEBUG_printf("4mime_check_rules: MIME_MAGIC_PRINTABLE fb->length=%d", fb->length);
          }
 
-         /*
-         * Test for 8-bit printable characters plus standard control chars.
-         */
-
+          // Test for 8-bit printable characters plus standard control chars.
          if ((rules->offset + rules->length) > (fb->offset + fb->length))
            n = fb->offset + fb->length - rules->offset;
          else
@@ -888,35 +789,26 @@ mime_check_rules(
           bufptr = fb->buffer + rules->offset - fb->offset;
 
          while (n > 0)
-           if (*bufptr >= 128 ||
-               (*bufptr >= 32 && *bufptr <= 126) ||
-               (*bufptr >= 8 && *bufptr <= 13) ||
-               *bufptr == 26 || *bufptr == 27)
+         {
+           if (*bufptr >= 128 || (*bufptr >= 32 && *bufptr <= 126) || (*bufptr >= 8 && *bufptr <= 13) || *bufptr == 26 || *bufptr == 27)
            {
              n --;
              bufptr ++;
            }
            else
              break;
+         }
 
          result = (n == 0);
          break;
 
       case MIME_MAGIC_REGEX :
-          DEBUG_printf(("5mime_check_rules: regex(%d, \"%s\")", rules->offset,
-                       rules->value.stringv));
+          DEBUG_printf("5mime_check_rules: regex(%d, \"%s\")", rules->offset, rules->value.stringv);
 
-         /*
-         * Load the buffer if necessary...
-         */
-
-          if (fb->offset < 0 || rules->offset < fb->offset ||
-             (rules->offset + rules->length) > (fb->offset + fb->length))
+          // Load the buffer if necessary...
+          if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + rules->length) > (fb->offset + fb->length))
          {
-          /*
-           * Reload file buffer...
-           */
-
+           // Reload file buffer...
             if (cupsFileSeek(fb->fp, rules->offset) < 0)
             {
               fb->length = 0;
@@ -930,17 +822,11 @@ mime_check_rules(
 
            DEBUG_printf("4mime_check_rules: MIME_MAGIC_REGEX fb->length=%d", fb->length);
 
-            DEBUG_printf(("5mime_check_rules: loaded %d byte fb->buffer at %d, starts "
-                         "with \"%c%c%c%c\".",
-                         fb->length, fb->offset, fb->buffer[0], fb->buffer[1],
-                         fb->buffer[2], fb->buffer[3]));
+            DEBUG_printf("5mime_check_rules: loaded %d byte fb->buffer at %d, starts with \"%c%c%c%c\".", fb->length, fb->offset, fb->buffer[0], fb->buffer[1], fb->buffer[2], fb->buffer[3]);
          }
 
-         /*
-         * Compare the buffer against the string.  If the file is too
-         * short then don't compare - it can't match...
-         */
-
+          // Compare the buffer against the string.  If the file is too
+         // short then don't compare - it can't match...
           if (fb->length > 0)
           {
             char temp[MIME_MAX_BUFFER + 1];
@@ -955,20 +841,12 @@ mime_check_rules(
          break;
 
       case MIME_MAGIC_STRING :
-          DEBUG_printf(("5mime_check_rules: string(%d, \"%s\")", rules->offset,
-                       rules->value.stringv));
+          DEBUG_printf("5mime_check_rules: string(%d, \"%s\")", rules->offset, rules->value.stringv);
 
-         /*
-         * Load the buffer if necessary...
-         */
-
-          if (fb->offset < 0 || rules->offset < fb->offset ||
-             (rules->offset + rules->length) > (fb->offset + fb->length))
+          // Load the buffer if necessary...
+          if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + rules->length) > (fb->offset + fb->length))
          {
-          /*
-           * Reload file buffer...
-           */
-
+           // Reload file buffer...
             if (cupsFileSeek(fb->fp, rules->offset) < 0)
             {
               fb->length = 0;
@@ -982,17 +860,11 @@ mime_check_rules(
 
            DEBUG_printf("4mime_check_rules: MIME_MAGIC_STRING fb->length=%d", fb->length);
 
-            DEBUG_printf(("5mime_check_rules: loaded %d byte fb->buffer at %d, starts "
-                         "with \"%c%c%c%c\".",
-                         fb->length, fb->offset, fb->buffer[0], fb->buffer[1],
-                         fb->buffer[2], fb->buffer[3]));
+            DEBUG_printf("5mime_check_rules: loaded %d byte fb->buffer at %d, starts with \"%c%c%c%c\".", fb->length, fb->offset, fb->buffer[0], fb->buffer[1], fb->buffer[2], fb->buffer[3]);
          }
 
-         /*
-         * Compare the buffer against the string.  If the file is too
-         * short then don't compare - it can't match...
-         */
-
+          // Compare the buffer against the string.  If the file is too
+         // short then don't compare - it can't match...
          if ((rules->offset + rules->length) > (fb->offset + fb->length))
            result = 0;
          else
@@ -1001,17 +873,10 @@ mime_check_rules(
          break;
 
       case MIME_MAGIC_ISTRING :
-         /*
-         * Load the buffer if necessary...
-         */
-
-          if (fb->offset < 0 || rules->offset < fb->offset ||
-             (rules->offset + rules->length) > (fb->offset + fb->length))
+          // Load the buffer if necessary...
+          if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + rules->length) > (fb->offset + fb->length))
          {
-          /*
-           * Reload file buffer...
-           */
-
+           // Reload file buffer...
             if (cupsFileSeek(fb->fp, rules->offset) < 0)
             {
               fb->length = 0;
@@ -1026,11 +891,8 @@ mime_check_rules(
            DEBUG_printf("4mime_check_rules: MIME_MAGIC_ISTRING fb->length=%d", fb->length);
          }
 
-         /*
-         * Compare the buffer against the string.  If the file is too
-         * short then don't compare - it can't match...
-         */
-
+          // Compare the buffer against the string.  If the file is too
+         // short then don't compare - it can't match...
          if ((rules->offset + rules->length) > (fb->offset + fb->length))
            result = 0;
          else
@@ -1038,16 +900,10 @@ mime_check_rules(
          break;
 
       case MIME_MAGIC_CHAR :
-         /*
-         * Load the buffer if necessary...
-         */
-
+          // Load the buffer if necessary...
           if (fb->offset < 0 || rules->offset < fb->offset)
          {
-          /*
-           * Reload file buffer...
-           */
-
+           // Reload file buffer...
             if (cupsFileSeek(fb->fp, rules->offset) < 0)
             {
               fb->length = 0;
@@ -1062,11 +918,8 @@ mime_check_rules(
            DEBUG_printf("4mime_check_rules: MIME_MAGIC_CHAR fb->length=%d", fb->length);
          }
 
-        /*
-         * Compare the character values; if the file is too short, it
-         * can't match...
-         */
-
+         // Compare the character values; if the file is too short, it
+         // can't match...
          if (fb->length < 1)
            result = 0;
          else
@@ -1074,17 +927,10 @@ mime_check_rules(
          break;
 
       case MIME_MAGIC_SHORT :
-         /*
-         * Load the buffer if necessary...
-         */
-
-          if (fb->offset < 0 || rules->offset < fb->offset ||
-             (rules->offset + 2) > (fb->offset + fb->length))
+          // Load the buffer if necessary...
+          if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + 2) > (fb->offset + fb->length))
          {
-          /*
-           * Reload file buffer...
-           */
-
+           // Reload file buffer...
             if (cupsFileSeek(fb->fp, rules->offset) < 0)
             {
               fb->length = 0;
@@ -1099,11 +945,7 @@ mime_check_rules(
            DEBUG_printf("4mime_check_rules: MIME_MAGIC_SHORT fb->length=%d", fb->length);
          }
 
-        /*
-         * Compare the short values; if the file is too short, it
-         * can't match...
-         */
-
+         // Compare the short values; if the file is too short, it can't match...
          if (fb->length < 2)
          {
            result = 0;
@@ -1117,17 +959,10 @@ mime_check_rules(
          break;
 
       case MIME_MAGIC_INT :
-         /*
-         * Load the buffer if necessary...
-         */
-
-          if (fb->offset < 0 || rules->offset < fb->offset ||
-             (rules->offset + 4) > (fb->offset + fb->length))
+          // Load the buffer if necessary...
+          if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + 4) > (fb->offset + fb->length))
          {
-          /*
-           * Reload file buffer...
-           */
-
+           // Reload file buffer...
             if (cupsFileSeek(fb->fp, rules->offset) < 0)
             {
               fb->length = 0;
@@ -1142,11 +977,7 @@ mime_check_rules(
            DEBUG_printf("4mime_check_rules: MIME_MAGIC_INT fb->length=%d", fb->length);
          }
 
-        /*
-         * Compare the int values; if the file is too short, it
-         * can't match...
-         */
-
+         // Compare the int values; if the file is too short, it can't match...
          if (fb->length < 4)
          {
            result = 0;
@@ -1164,21 +995,14 @@ mime_check_rules(
           result = !strcmp(rules->value.localev, setlocale(LC_ALL, ""));
 #else
           result = !strcmp(rules->value.localev, setlocale(LC_MESSAGES, ""));
-#endif // __APPLE__
+#endif // _WIN32 || __EMX__ || __APPLE__
          break;
 
       case MIME_MAGIC_CONTAINS :
-         /*
-         * Load the buffer if necessary...
-         */
-
-          if (fb->offset < 0 || rules->offset < fb->offset ||
-             (rules->offset + rules->region) > (fb->offset + fb->length))
+          // Load the buffer if necessary...
+          if (fb->offset < 0 || rules->offset < fb->offset || (rules->offset + rules->region) > (fb->offset + fb->length))
          {
-          /*
-           * Reload file buffer...
-           */
-
+           // Reload file buffer...
             if (cupsFileSeek(fb->fp, rules->offset) < 0)
             {
               fb->length = 0;
@@ -1193,11 +1017,8 @@ mime_check_rules(
            DEBUG_printf("4mime_check_rules: MIME_MAGIC_CONTAINS fb->length=%d", fb->length);
          }
 
-         /*
-         * Compare the buffer against the string.  If the file is too
-         * short then don't compare - it can't match...
-         */
-
+          // Compare the buffer against the string.  If the file is too
+         // short then don't compare - it can't match...
          result = 0;
          if ((rules->offset + rules->length) <= (fb->offset + fb->length))
          {
@@ -1206,12 +1027,14 @@ mime_check_rules(
            else
              region = fb->length - rules->length;
 
-                 for (n = 0; n < region; n ++)
+           for (n = 0; n < region; n ++)
+           {
              if (!memcmp(fb->buffer + rules->offset - fb->offset + n, rules->value.stringv, (size_t)rules->length))
-                   {
-                     result = 1;
-                     break;
-                   }
+             {
+               result = 1;
+               break;
+             }
+           }
          }
          break;
 
@@ -1223,30 +1046,19 @@ mime_check_rules(
          break;
     }
 
-   /*
-    * If the logic is inverted, invert the result...
-    */
-
+    // If the logic is inverted, invert the result...
     if (rules->invert)
       result = !result;
 
-   /*
-    * OK, now if the current logic is OR and this result is true, this
-    * rule set is true.  If the current logic is AND and this result is false,
-    * the rule set is false...
-    */
-
-    DEBUG_printf(("5mime_check_rules: result of test %p (MIME_MAGIC_%s) is %d",
-                  rules, debug_ops[rules->op], result));
+    // OK, now if the current logic is OR and this result is true, this
+    // rule set is true.  If the current logic is AND and this result is false,
+    // the rule set is false...
+    DEBUG_printf("5mime_check_rules: result of test %p (MIME_MAGIC_%s) is %d", rules, debug_ops[rules->op], result);
 
-    if ((result && logic == MIME_MAGIC_OR) ||
-        (!result && logic == MIME_MAGIC_AND))
+    if ((result && logic == MIME_MAGIC_OR) || (!result && logic == MIME_MAGIC_AND))
       return (result);
 
-   /*
-    * Otherwise the jury is still out on this one, so move to the next rule.
-    */
-
+    // Otherwise the jury is still out on this one, so move to the next rule.
     rules = rules->next;
   }
 
@@ -1291,34 +1103,22 @@ static int                              // O - 1 if match, 0 if no match
 mime_patmatch(const char *s,           // I - String to match against
               const char *pat)         // I - Pattern to match against
 {
- /*
-  * Range check the input...
-  */
-
+  // Range check the input...
   if (s == NULL || pat == NULL)
     return (0);
 
- /*
-  * Loop through the pattern and match strings, and stop if we come to a
-  * point where the strings don't match or we find a complete match.
-  */
-
+  // Loop through the pattern and match strings, and stop if we come to a
+  // point where the strings don't match or we find a complete match.
   while (*s != '\0' && *pat != '\0')
   {
     if (*pat == '*')
     {
-     /*
-      * Wildcard - 0 or more characters...
-      */
-
+      // Wildcard - 0 or more characters...
       pat ++;
       if (*pat == '\0')
         return (1);    // Last pattern char is *, so everything matches...
 
-     /*
-      * Test all remaining combinations until we get to the end of the string.
-      */
-
+      // Test all remaining combinations until we get to the end of the string.
       while (*s != '\0')
       {
         if (mime_patmatch(s, pat))
@@ -1329,26 +1129,22 @@ mime_patmatch(const char *s,            // I - String to match against
     }
     else if (*pat == '?')
     {
-     /*
-      * Wildcard - 1 character...
-      */
-
+      // Wildcard - 1 character...
       pat ++;
       s ++;
       continue;
     }
     else if (*pat == '[')
     {
-     /*
-      * Match a character from the input set [chars]...
-      */
-
+      // Match a character from the input set [chars]...
       pat ++;
       while (*pat != ']' && *pat != '\0')
+      {
         if (*s == *pat)
          break;
        else
          pat ++;
+      }
 
       if (*pat == ']' || *pat == '\0')
         return (0);
@@ -1363,25 +1159,16 @@ mime_patmatch(const char *s,            // I - String to match against
     }
     else if (*pat == '\\')
     {
-     /*
-      * Handle quoted characters...
-      */
-
+      // Handle quoted characters...
       pat ++;
     }
 
-   /*
-    * Stop if the pattern and string don't match...
-    */
-
+    // Stop if the pattern and string don't match...
     if (*pat++ != *s++)
       return (0);
   }
 
- /*
-  * Done parsing the pattern and string; return 1 if the last character
-  * matches and 0 otherwise...
-  */
-
+  // Done parsing the pattern and string; return 1 if the last character
+  // matches and 0 otherwise...
   return (*s == *pat);
 }