svn commit: trunk/busybox/coreutils

vda at busybox.net vda at busybox.net
Mon Dec 18 21:22:16 UTC 2006


Author: vda
Date: 2006-12-18 13:22:16 -0800 (Mon, 18 Dec 2006)
New Revision: 16995

Log:
du: dietlibc compat fix, style fixes. Thanks to sampo at symlabs.com.


Modified:
   trunk/busybox/coreutils/du.c


Changeset:
Modified: trunk/busybox/coreutils/du.c
===================================================================
--- trunk/busybox/coreutils/du.c	2006-12-18 21:02:00 UTC (rev 16994)
+++ trunk/busybox/coreutils/du.c	2006-12-18 21:22:16 UTC (rev 16995)
@@ -25,26 +25,22 @@
 
 #include "busybox.h"
 
-#ifdef CONFIG_FEATURE_HUMAN_READABLE
-# ifdef CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
+#if ENABLE_FEATURE_HUMAN_READABLE
+# if ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
 static unsigned long disp_hr = 1024;
 # else
 static unsigned long disp_hr = 512;
 # endif
-#elif defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
-static unsigned int disp_k = 1;
+#elif ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
+static unsigned disp_k = 1;
 #else
-static unsigned int disp_k;	/* bss inits to 0 */
+static unsigned disp_k;	/* bss inits to 0 */
 #endif
 
 static int max_print_depth = INT_MAX;
 static nlink_t count_hardlinks = 1;
 
-static int status
-#if EXIT_SUCCESS == 0
-	= EXIT_SUCCESS
-#endif
-	;
+static int status;
 static int print_files;
 static int slink_depth;
 static int du_depth;
@@ -55,9 +51,9 @@
 static void print(long size, const char * const filename)
 {
 	/* TODO - May not want to defer error checking here. */
-#ifdef CONFIG_FEATURE_HUMAN_READABLE
+#if ENABLE_FEATURE_HUMAN_READABLE
 	printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr),
-		   filename);
+			filename);
 #else
 	if (disp_k) {
 		size++;
@@ -73,7 +69,7 @@
 	struct stat statbuf;
 	long sum;
 
-	if ((lstat(filename, &statbuf)) != 0) {
+	if (lstat(filename, &statbuf) != 0) {
 		bb_perror_msg("%s", filename);
 		status = EXIT_FAILURE;
 		return 0;
@@ -91,7 +87,7 @@
 
 	if (S_ISLNK(statbuf.st_mode)) {
 		if (slink_depth > du_depth) {	/* -H or -L */
-			if ((stat(filename, &statbuf)) != 0) {
+			if (stat(filename, &statbuf) != 0) {
 				bb_perror_msg("%s", filename);
 				status = EXIT_FAILURE;
 				return 0;
@@ -130,7 +126,7 @@
 			char *name = entry->d_name;
 
 			newfile = concat_subpath_file(filename, name);
-			if(newfile == NULL)
+			if (newfile == NULL)
 				continue;
 			++du_depth;
 			sum += du(newfile);
@@ -155,9 +151,9 @@
 	char *smax_print_depth;
 	unsigned opt;
 
-#ifdef CONFIG_FEATURE_DU_DEFUALT_BLOCKSIZE_1K
+#if ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
 	if (getenv("POSIXLY_CORRECT")) {	/* TODO - a new libbb function? */
-#ifdef CONFIG_FEATURE_HUMAN_READABLE
+#if ENABLE_FEATURE_HUMAN_READABLE
 		disp_hr = 512;
 #else
 		disp_k = 0;
@@ -171,55 +167,55 @@
 	 * gnu du exits with an error code in this case.  We choose to simply
 	 * ignore -a.  This is consistent with -s being equivalent to -d 0.
 	 */
-#ifdef CONFIG_FEATURE_HUMAN_READABLE
+#if ENABLE_FEATURE_HUMAN_READABLE
 	opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
 	opt = getopt32(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
-	if((opt & (1 << 9))) {
+	if (opt & (1 << 9)) {
 		/* -h opt */
 		disp_hr = 0;
 	}
-	if((opt & (1 << 10))) {
+	if (opt & (1 << 10)) {
 		/* -m opt */
 		disp_hr = 1024*1024;
 	}
-	if((opt & (1 << 2))) {
+	if (opt & (1 << 2)) {
 		/* -k opt */
 		disp_hr = 1024;
 	}
 #else
 	opt_complementary = "H-L:L-H:s-d:d-s";
 	opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
-#if !defined CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
-	if((opt & (1 << 2))) {
+#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
+	if (opt & (1 << 2)) {
 		/* -k opt */
-			disp_k = 1;
+		disp_k = 1;
 	}
 #endif
 #endif
-	if((opt & (1 << 0))) {
+	if (opt & (1 << 0)) {
 		/* -a opt */
 		print_files = INT_MAX;
 	}
-	if((opt & (1 << 1))) {
+	if (opt & (1 << 1)) {
 		/* -H opt */
 		slink_depth = 1;
 	}
-	if((opt & (1 << 3))) {
+	if (opt & (1 << 3)) {
 		/* -L opt */
-			slink_depth = INT_MAX;
+		slink_depth = INT_MAX;
 	}
-	if((opt & (1 << 4))) {
+	if (opt & (1 << 4)) {
 		/* -s opt */
-			max_print_depth = 0;
-		}
+		max_print_depth = 0;
+	}
 	one_file_system = opt & (1 << 5); /* -x opt */
-	if((opt & (1 << 6))) {
+	if (opt & (1 << 6)) {
 		/* -d opt */
 		max_print_depth = xatoi_u(smax_print_depth);
 	}
-	if((opt & (1 << 7))) {
+	if (opt & (1 << 7)) {
 		/* -l opt */
-		count_hardlinks = INT_MAX;
+		count_hardlinks = MAXINT(nlink_t);
 	}
 	print_final_total = opt & (1 << 8); /* -c opt */
 
@@ -238,7 +234,7 @@
 		total += du(*argv);
 		slink_depth = slink_depth_save;
 	} while (*++argv);
-#ifdef CONFIG_FEATURE_CLEAN_UP
+#if ENABLE_FEATURE_CLEAN_UP
 	reset_ino_dev_hashtable();
 #endif
 




More information about the busybox-cvs mailing list