]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
du: update debug option setup
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 19 Feb 2025 04:09:10 +0000 (20:09 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 19 Feb 2025 04:10:19 +0000 (20:10 -0800)
Current Gnulib arranges for fts debugging if GNULIB_FTS_DEBUG
is defined, so key off that rather than off DU_DEBUG.
* src/du.c (fts_debug): Remove decl, as Gnulib does this now.
(FTS_CROSS_CHECK): Remove; all uses removed.
(FTS_DEBUG) [!GNULIB_FTS_DEBUG]: Remove.
(long_options) [GNULIB_FTS_DEBUG]: Add a ---debug option.
(du_files): Call fts_cross_check only if fts_debug and GNULIB_FTS_DEBUG.
(main): Set fts_debug if GNULIB_FTS_DEBUG, not DU_DEBUG.

src/du.c

index 0e5d860a926f1ad12c519875ae31ff5fa1ea3f11..bac372a042943792f9de59baf97c6c3e1ae61933 100644 (file)
--- a/src/du.c
+++ b/src/du.c
@@ -43,8 +43,6 @@
 #include "xstrtol.h"
 #include "xstrtol-error.h"
 
-extern bool fts_debug;
-
 /* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "du"
 
@@ -54,12 +52,6 @@ extern bool fts_debug;
   proper_name ("Paul Eggert"), \
   proper_name ("Jim Meyering")
 
-#if DU_DEBUG
-# define FTS_CROSS_CHECK(Fts) fts_cross_check (Fts)
-#else
-# define FTS_CROSS_CHECK(Fts)
-#endif
-
 /* A set of dev/ino pairs to help identify files and directories
    whose sizes have already been counted.  */
 static struct di_set *di_files;
@@ -206,7 +198,9 @@ enum
   EXCLUDE_OPTION,
   FILES0_FROM_OPTION,
   HUMAN_SI_OPTION,
+#if GNULIB_FTS_DEBUG
   FTS_DEBUG,
+#endif
   TIME_OPTION,
   TIME_STYLE_OPTION,
   INODES_OPTION
@@ -219,7 +213,9 @@ static struct option const long_options[] =
   {"block-size", required_argument, nullptr, 'B'},
   {"bytes", no_argument, nullptr, 'b'},
   {"count-links", no_argument, nullptr, 'l'},
-  /* {"-debug", no_argument, nullptr, FTS_DEBUG}, */
+#if GNULIB_FTS_DEBUG
+  {"-debug", no_argument, nullptr, FTS_DEBUG},
+#endif
   {"dereference", no_argument, nullptr, 'L'},
   {"dereference-args", no_argument, nullptr, 'D'},
   {"exclude", required_argument, nullptr, EXCLUDE_OPTION},
@@ -686,7 +682,11 @@ du_files (char **files, int bit_flags)
               prev_level = 0;
               break;
             }
-          FTS_CROSS_CHECK (fts);
+
+#if GNULIB_FTS_DEBUG
+          if (fts_debug)
+            fts_cross_check (fts);
+#endif
 
           ok &= process_file (fts, ent);
         }
@@ -745,7 +745,7 @@ main (int argc, char **argv)
 
       switch (c)
         {
-#if DU_DEBUG
+#if GNULIB_FTS_DEBUG
         case FTS_DEBUG:
           fts_debug = true;
           break;