svn commit: trunk/busybox: coreutils libbb miscutils

vda at busybox.net vda at busybox.net
Sat Sep 23 16:01:09 UTC 2006


Author: vda
Date: 2006-09-23 09:01:09 -0700 (Sat, 23 Sep 2006)
New Revision: 16206

Log:
remove unneeded #includes, fix indentation


Modified:
   trunk/busybox/coreutils/printf.c
   trunk/busybox/libbb/xgetcwd.c
   trunk/busybox/miscutils/runlevel.c


Changeset:
Modified: trunk/busybox/coreutils/printf.c
===================================================================
--- trunk/busybox/coreutils/printf.c	2006-09-23 15:58:01 UTC (rev 16205)
+++ trunk/busybox/coreutils/printf.c	2006-09-23 16:01:09 UTC (rev 16206)
@@ -38,37 +38,30 @@
 
 //   19990508 Busy Boxed! Dave Cinege
 
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <assert.h>
 #include "busybox.h"
 
-static int print_formatted (char *format, int argc, char **argv);
-static void print_direc (char *start, size_t length,
+static int print_formatted(char *format, int argc, char **argv);
+static void print_direc(char *start, size_t length,
 			int field_width, int precision, char *argument);
 
 typedef int (*converter)(char *arg, void *result);
+
 static void multiconvert(char *arg, void *result, converter convert)
 {
 	char s[16];
 	if (*arg == '"' || *arg == '\'') {
-		sprintf(s,"%d",(unsigned)*(++arg));
-		arg=s;
+		sprintf(s, "%d", (unsigned)arg[1]);
+		arg = s;
 	}
-	if(convert(arg,result)) fprintf(stderr, "%s", arg);
+	if (convert(arg, result))
+		fputs(arg, stderr);
 }
 
 static unsigned long xstrtoul(char *arg)
 {
 	unsigned long result;
 
-	multiconvert(arg,&result, (converter)safe_strtoul);
+	multiconvert(arg, &result, (converter)safe_strtoul);
 	return result;
 }
 
@@ -104,7 +97,7 @@
 	char *format;
 	int args_used;
 
-	if (argc <= 1 || **(argv + 1) == '-') {
+	if (argc <= 1 || argv[1][0] == '-') {
 		bb_show_usage();
 	}
 
@@ -119,9 +112,8 @@
 	}
 	while (args_used > 0 && argc > 0);
 
-/*
-  if (argc > 0)
-    fprintf(stderr, "excess args ignored");
+/*	if (argc > 0)
+		fprintf(stderr, "excess args ignored");
 */
 
 	return EXIT_SUCCESS;
@@ -199,9 +191,9 @@
 				++direc_length;
 			}
 			/*
-			   if (!strchr ("diouxXfeEgGcs", *f))
-			   fprintf(stderr, "%%%c: invalid directive", *f);
-			 */
+			if (!strchr ("diouxXfeEgGcs", *f))
+			fprintf(stderr, "%%%c: invalid directive", *f);
+			*/
 			++direc_length;
 			if (argc > 0) {
 				print_direc(direc_start, direc_length, field_width,
@@ -232,7 +224,7 @@
 print_direc(char *start, size_t length, int field_width, int precision,
 			char *argument)
 {
-	char *p;					/* Null-terminated copy of % directive. */
+	char *p;		/* Null-terminated copy of % directive. */
 
 	p = xmalloc((unsigned) (length + 1));
 	strncpy(p, start, length);

Modified: trunk/busybox/libbb/xgetcwd.c
===================================================================
--- trunk/busybox/libbb/xgetcwd.c	2006-09-23 15:58:01 UTC (rev 16205)
+++ trunk/busybox/libbb/xgetcwd.c	2006-09-23 16:01:09 UTC (rev 16206)
@@ -7,11 +7,6 @@
  * Special function for busybox written by Vladimir Oleynik <dzo at simtreas.ru>
 */
 
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <limits.h>
-#include <sys/param.h>
 #include "libbb.h"
 
 /* Amount to increase buffer size by in each try. */
@@ -23,27 +18,27 @@
 */
 
 char *
-xgetcwd (char *cwd)
+xgetcwd(char *cwd)
 {
-  char *ret;
-  unsigned path_max;
+	char *ret;
+	unsigned path_max;
 
-  path_max = (unsigned) PATH_MAX;
-  path_max += 2;                /* The getcwd docs say to do this. */
+	path_max = (unsigned) PATH_MAX;
+	path_max += 2;                /* The getcwd docs say to do this. */
 
-  if(cwd==0)
-	cwd = xmalloc (path_max);
+	if (cwd==0)
+		cwd = xmalloc(path_max);
 
-  while ((ret = getcwd (cwd, path_max)) == NULL && errno == ERANGE) {
-      path_max += PATH_INCR;
-      cwd = xrealloc (cwd, path_max);
-  }
+	while ((ret = getcwd(cwd, path_max)) == NULL && errno == ERANGE) {
+		path_max += PATH_INCR;
+		cwd = xrealloc(cwd, path_max);
+	}
 
-  if (ret == NULL) {
-      free (cwd);
-      bb_perror_msg("getcwd()");
-      return NULL;
-  }
+	if (ret == NULL) {
+		free(cwd);
+		bb_perror_msg("getcwd");
+		return NULL;
+	}
 
-  return cwd;
+	return cwd;
 }

Modified: trunk/busybox/miscutils/runlevel.c
===================================================================
--- trunk/busybox/miscutils/runlevel.c	2006-09-23 15:58:01 UTC (rev 16205)
+++ trunk/busybox/miscutils/runlevel.c	2006-09-23 16:01:09 UTC (rev 16206)
@@ -20,24 +20,23 @@
 
 int runlevel_main(int argc, char *argv[])
 {
-  struct utmp *ut;
-  char prev;
+	struct utmp *ut;
+	char prev;
 
-  if (argc > 1) utmpname(argv[1]);
+	if (argc > 1) utmpname(argv[1]);
 
-  setutent();
-  while ((ut = getutent()) != NULL) {
-	if (ut->ut_type == RUN_LVL) {
-		prev = ut->ut_pid / 256;
-		if (prev == 0) prev = 'N';
-		printf("%c %c\n", prev, ut->ut_pid % 256);
-		endutent();
-		return (0);
+	setutent();
+	while ((ut = getutent()) != NULL) {
+		if (ut->ut_type == RUN_LVL) {
+			prev = ut->ut_pid / 256;
+			if (prev == 0) prev = 'N';
+			printf("%c %c\n", prev, ut->ut_pid % 256);
+			endutent();
+			return 0;
+		}
 	}
-  }
 
-  printf("unknown\n");
-  endutent();
-  return (1);
+	puts("unknown");
+	endutent();
+	return 1;
 }
-




More information about the busybox-cvs mailing list