]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
dircolors: speed up processing of TERM entries
authorPádraig Brady <P@draigBrady.com>
Mon, 14 Feb 2022 17:25:04 +0000 (17:25 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 15 Feb 2022 17:01:19 +0000 (17:01 +0000)
* src/dircolors.c (main): Avoid glob matching
when we've already matched in a group of {COLOR,}TERM entries.

src/dircolors.c

index 5c92299621f6a1c79ca81f6bda97bda62ef554ca..f8e2f549f0ce9b0b9d6ace120e9805c9d053cdd7 100644 (file)
@@ -328,17 +328,13 @@ dc_parse_stream (FILE *fp, char const *filename)
       unrecognized = false;
       if (c_strcasecmp (keywd, "TERM") == 0)
         {
-          if (fnmatch (arg, term, 0) == 0)
-            state = ST_TERMSURE;
-          else if (state != ST_TERMSURE)
-            state = ST_TERMNO;
+          if (state != ST_TERMSURE)
+            state = fnmatch (arg, term, 0) == 0 ? ST_TERMSURE : ST_TERMNO;
         }
       else if (c_strcasecmp (keywd, "COLORTERM") == 0)
         {
-          if (fnmatch (arg, colorterm, 0) == 0)
-            state = ST_TERMSURE;
-          else if (state != ST_TERMSURE)
-            state = ST_TERMNO;
+          if (state != ST_TERMSURE)
+            state = fnmatch (arg, colorterm, 0) == 0 ? ST_TERMSURE : ST_TERMNO;
         }
       else
         {