aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-23 16:01:09 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-23 16:01:09 +0000
commitc290563319b61c8230deca52ab625d8dc335e2d3 (patch)
tree0961ae48901bd3defbcc6bbd5cd57bd90a3f849e
parentc1876d7364a260e06cd23a3255b9058240527b02 (diff)
downloadbusybox-w32-c290563319b61c8230deca52ab625d8dc335e2d3.tar.gz
busybox-w32-c290563319b61c8230deca52ab625d8dc335e2d3.tar.bz2
busybox-w32-c290563319b61c8230deca52ab625d8dc335e2d3.zip
remove unneeded #includes, fix indentation
-rw-r--r--coreutils/printf.c38
-rw-r--r--libbb/xgetcwd.c39
-rw-r--r--miscutils/runlevel.c31
3 files changed, 47 insertions, 61 deletions
diff --git a/coreutils/printf.c b/coreutils/printf.c
index 93b142765..4a208040f 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -38,37 +38,30 @@
38 38
39// 19990508 Busy Boxed! Dave Cinege 39// 19990508 Busy Boxed! Dave Cinege
40 40
41#include <unistd.h>
42#include <stdio.h>
43#include <sys/types.h>
44#include <string.h>
45#include <errno.h>
46#include <stdlib.h>
47#include <fcntl.h>
48#include <ctype.h>
49#include <assert.h>
50#include "busybox.h" 41#include "busybox.h"
51 42
52static int print_formatted (char *format, int argc, char **argv); 43static int print_formatted(char *format, int argc, char **argv);
53static void print_direc (char *start, size_t length, 44static void print_direc(char *start, size_t length,
54 int field_width, int precision, char *argument); 45 int field_width, int precision, char *argument);
55 46
56typedef int (*converter)(char *arg, void *result); 47typedef int (*converter)(char *arg, void *result);
48
57static void multiconvert(char *arg, void *result, converter convert) 49static void multiconvert(char *arg, void *result, converter convert)
58{ 50{
59 char s[16]; 51 char s[16];
60 if (*arg == '"' || *arg == '\'') { 52 if (*arg == '"' || *arg == '\'') {
61 sprintf(s,"%d",(unsigned)*(++arg)); 53 sprintf(s, "%d", (unsigned)arg[1]);
62 arg=s; 54 arg = s;
63 } 55 }
64 if(convert(arg,result)) fprintf(stderr, "%s", arg); 56 if (convert(arg, result))
57 fputs(arg, stderr);
65} 58}
66 59
67static unsigned long xstrtoul(char *arg) 60static unsigned long xstrtoul(char *arg)
68{ 61{
69 unsigned long result; 62 unsigned long result;
70 63
71 multiconvert(arg,&result, (converter)safe_strtoul); 64 multiconvert(arg, &result, (converter)safe_strtoul);
72 return result; 65 return result;
73} 66}
74 67
@@ -104,7 +97,7 @@ int printf_main(int argc, char **argv)
104 char *format; 97 char *format;
105 int args_used; 98 int args_used;
106 99
107 if (argc <= 1 || **(argv + 1) == '-') { 100 if (argc <= 1 || argv[1][0] == '-') {
108 bb_show_usage(); 101 bb_show_usage();
109 } 102 }
110 103
@@ -119,9 +112,8 @@ int printf_main(int argc, char **argv)
119 } 112 }
120 while (args_used > 0 && argc > 0); 113 while (args_used > 0 && argc > 0);
121 114
122/* 115/* if (argc > 0)
123 if (argc > 0) 116 fprintf(stderr, "excess args ignored");
124 fprintf(stderr, "excess args ignored");
125*/ 117*/
126 118
127 return EXIT_SUCCESS; 119 return EXIT_SUCCESS;
@@ -199,9 +191,9 @@ static int print_formatted(char *format, int argc, char **argv)
199 ++direc_length; 191 ++direc_length;
200 } 192 }
201 /* 193 /*
202 if (!strchr ("diouxXfeEgGcs", *f)) 194 if (!strchr ("diouxXfeEgGcs", *f))
203 fprintf(stderr, "%%%c: invalid directive", *f); 195 fprintf(stderr, "%%%c: invalid directive", *f);
204 */ 196 */
205 ++direc_length; 197 ++direc_length;
206 if (argc > 0) { 198 if (argc > 0) {
207 print_direc(direc_start, direc_length, field_width, 199 print_direc(direc_start, direc_length, field_width,
@@ -232,7 +224,7 @@ static void
232print_direc(char *start, size_t length, int field_width, int precision, 224print_direc(char *start, size_t length, int field_width, int precision,
233 char *argument) 225 char *argument)
234{ 226{
235 char *p; /* Null-terminated copy of % directive. */ 227 char *p; /* Null-terminated copy of % directive. */
236 228
237 p = xmalloc((unsigned) (length + 1)); 229 p = xmalloc((unsigned) (length + 1));
238 strncpy(p, start, length); 230 strncpy(p, start, length);
diff --git a/libbb/xgetcwd.c b/libbb/xgetcwd.c
index f6cfb34a7..0ac450d3b 100644
--- a/libbb/xgetcwd.c
+++ b/libbb/xgetcwd.c
@@ -7,11 +7,6 @@
7 * Special function for busybox written by Vladimir Oleynik <dzo@simtreas.ru> 7 * Special function for busybox written by Vladimir Oleynik <dzo@simtreas.ru>
8*/ 8*/
9 9
10#include <stdlib.h>
11#include <errno.h>
12#include <unistd.h>
13#include <limits.h>
14#include <sys/param.h>
15#include "libbb.h" 10#include "libbb.h"
16 11
17/* Amount to increase buffer size by in each try. */ 12/* Amount to increase buffer size by in each try. */
@@ -23,27 +18,27 @@
23*/ 18*/
24 19
25char * 20char *
26xgetcwd (char *cwd) 21xgetcwd(char *cwd)
27{ 22{
28 char *ret; 23 char *ret;
29 unsigned path_max; 24 unsigned path_max;
30 25
31 path_max = (unsigned) PATH_MAX; 26 path_max = (unsigned) PATH_MAX;
32 path_max += 2; /* The getcwd docs say to do this. */ 27 path_max += 2; /* The getcwd docs say to do this. */
33 28
34 if(cwd==0) 29 if (cwd==0)
35 cwd = xmalloc (path_max); 30 cwd = xmalloc(path_max);
36 31
37 while ((ret = getcwd (cwd, path_max)) == NULL && errno == ERANGE) { 32 while ((ret = getcwd(cwd, path_max)) == NULL && errno == ERANGE) {
38 path_max += PATH_INCR; 33 path_max += PATH_INCR;
39 cwd = xrealloc (cwd, path_max); 34 cwd = xrealloc(cwd, path_max);
40 } 35 }
41 36
42 if (ret == NULL) { 37 if (ret == NULL) {
43 free (cwd); 38 free(cwd);
44 bb_perror_msg("getcwd()"); 39 bb_perror_msg("getcwd");
45 return NULL; 40 return NULL;
46 } 41 }
47 42
48 return cwd; 43 return cwd;
49} 44}
diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c
index a042a7012..91d49fa55 100644
--- a/miscutils/runlevel.c
+++ b/miscutils/runlevel.c
@@ -20,24 +20,23 @@
20 20
21int runlevel_main(int argc, char *argv[]) 21int runlevel_main(int argc, char *argv[])
22{ 22{
23 struct utmp *ut; 23 struct utmp *ut;
24 char prev; 24 char prev;
25 25
26 if (argc > 1) utmpname(argv[1]); 26 if (argc > 1) utmpname(argv[1]);
27 27
28 setutent(); 28 setutent();
29 while ((ut = getutent()) != NULL) { 29 while ((ut = getutent()) != NULL) {
30 if (ut->ut_type == RUN_LVL) { 30 if (ut->ut_type == RUN_LVL) {
31 prev = ut->ut_pid / 256; 31 prev = ut->ut_pid / 256;
32 if (prev == 0) prev = 'N'; 32 if (prev == 0) prev = 'N';
33 printf("%c %c\n", prev, ut->ut_pid % 256); 33 printf("%c %c\n", prev, ut->ut_pid % 256);
34 endutent(); 34 endutent();
35 return (0); 35 return 0;
36 }
36 } 37 }
37 }
38 38
39 printf("unknown\n"); 39 puts("unknown");
40 endutent(); 40 endutent();
41 return (1); 41 return 1;
42} 42}
43