diff options
author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-06-18 20:20:07 +0000 |
---|---|---|
committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-06-18 20:20:07 +0000 |
commit | aa074b9c43f69aa62adb15e3342a0ef63f625678 (patch) | |
tree | 38d6c5d2d53841e3f4e2702521e3b03235c51017 | |
parent | e4d675d55e6d97662493d5696201db55a144db5e (diff) | |
download | busybox-w32-aa074b9c43f69aa62adb15e3342a0ef63f625678.tar.gz busybox-w32-aa074b9c43f69aa62adb15e3342a0ef63f625678.tar.bz2 busybox-w32-aa074b9c43f69aa62adb15e3342a0ef63f625678.zip |
skip_whitespace() shouldn't claim its return value is const, it doesn't know
that and callers wind up typecasting it back.
git-svn-id: svn://busybox.net/trunk/busybox@15420 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | applets/applets.c | 9 | ||||
-rw-r--r-- | coreutils/ls.c | 112 | ||||
-rw-r--r-- | coreutils/test.c | 7 | ||||
-rw-r--r-- | coreutils/uniq.c | 6 | ||||
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | libbb/dump.c | 33 | ||||
-rw-r--r-- | libbb/inet_common.c | 2 | ||||
-rw-r--r-- | libbb/pw_encrypt.c | 2 | ||||
-rw-r--r-- | libbb/skip_whitespace.c | 23 | ||||
-rw-r--r-- | libpwdgrp/pwd_grp.c | 8 | ||||
-rw-r--r-- | networking/libiproute/ll_proto.c | 3 | ||||
-rw-r--r-- | util-linux/hexdump.c | 49 |
12 files changed, 64 insertions, 192 deletions
diff --git a/applets/applets.c b/applets/applets.c index aea116add..27becfd68 100644 --- a/applets/applets.c +++ b/applets/applets.c | |||
@@ -14,8 +14,6 @@ | |||
14 | 14 | ||
15 | #include "busybox.h" | 15 | #include "busybox.h" |
16 | #include <unistd.h> | 16 | #include <unistd.h> |
17 | #include <stdio.h> | ||
18 | #include <stdlib.h> | ||
19 | #include <string.h> | 17 | #include <string.h> |
20 | #include <assert.h> | 18 | #include <assert.h> |
21 | 19 | ||
@@ -43,7 +41,6 @@ const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1); | |||
43 | 41 | ||
44 | #ifdef CONFIG_FEATURE_SUID_CONFIG | 42 | #ifdef CONFIG_FEATURE_SUID_CONFIG |
45 | 43 | ||
46 | #include <sys/stat.h> | ||
47 | #include <ctype.h> | 44 | #include <ctype.h> |
48 | #include "pwd_.h" | 45 | #include "pwd_.h" |
49 | #include "grp_.h" | 46 | #include "grp_.h" |
@@ -99,7 +96,7 @@ static char *get_trimmed_slice(char *s, char *e) | |||
99 | 96 | ||
100 | /* Next, advance past all leading space and return a ptr to the | 97 | /* Next, advance past all leading space and return a ptr to the |
101 | * first non-space char; possibly the terminating nul. */ | 98 | * first non-space char; possibly the terminating nul. */ |
102 | return (char *) bb_skip_whitespace(s); | 99 | return skip_whitespace(s); |
103 | } | 100 | } |
104 | 101 | ||
105 | 102 | ||
@@ -240,7 +237,7 @@ static void parse_config_file(void) | |||
240 | 237 | ||
241 | /* Get the specified mode. */ | 238 | /* Get the specified mode. */ |
242 | 239 | ||
243 | e = (char *) bb_skip_whitespace(e+1); | 240 | e = skip_whitespace(e+1); |
244 | 241 | ||
245 | for (i=0 ; i < 3 ; i++) { | 242 | for (i=0 ; i < 3 ; i++) { |
246 | const char *q; | 243 | const char *q; |
@@ -253,7 +250,7 @@ static void parse_config_file(void) | |||
253 | 250 | ||
254 | /* Now get the the user/group info. */ | 251 | /* Now get the the user/group info. */ |
255 | 252 | ||
256 | s = (char *) bb_skip_whitespace(e); | 253 | s = skip_whitespace(e); |
257 | 254 | ||
258 | /* Note: We require whitespace between the mode and the | 255 | /* Note: We require whitespace between the mode and the |
259 | * user/group info. */ | 256 | * user/group info. */ |
diff --git a/coreutils/ls.c b/coreutils/ls.c index 47acec603..4a20b3396 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -36,32 +36,18 @@ enum { | |||
36 | 36 | ||
37 | /************************************************************************/ | 37 | /************************************************************************/ |
38 | 38 | ||
39 | #include <sys/types.h> | 39 | #include "busybox.h" |
40 | #include <sys/stat.h> | ||
41 | #include <stdio.h> | ||
42 | #include <unistd.h> | 40 | #include <unistd.h> |
43 | #include <dirent.h> | ||
44 | #include <errno.h> | 41 | #include <errno.h> |
45 | #include <stdio.h> | ||
46 | #include <string.h> | 42 | #include <string.h> |
47 | #include <stdlib.h> | ||
48 | #include <fcntl.h> | 43 | #include <fcntl.h> |
49 | #include <signal.h> | 44 | #include <signal.h> |
50 | #include <termios.h> | ||
51 | #include <getopt.h> /* struct option */ | 45 | #include <getopt.h> /* struct option */ |
52 | #include <sys/ioctl.h> | 46 | #include <sys/ioctl.h> |
53 | #include <sys/sysmacros.h> /* major() and minor() */ | 47 | #include <sys/sysmacros.h> /* major() and minor() */ |
54 | #include "busybox.h" | ||
55 | #ifdef CONFIG_SELINUX | ||
56 | #include <selinux/selinux.h> /* for is_selinux_enabled() */ | ||
57 | #endif | ||
58 | |||
59 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | ||
60 | #include <time.h> | 48 | #include <time.h> |
61 | #endif | ||
62 | 49 | ||
63 | /* what is the overall style of the listing */ | 50 | /* what is the overall style of the listing */ |
64 | #define STYLE_AUTO (0) | ||
65 | #define STYLE_COLUMNS (1U<<21) /* fill columns */ | 51 | #define STYLE_COLUMNS (1U<<21) /* fill columns */ |
66 | #define STYLE_LONG (2U<<21) /* one record per line, extended info */ | 52 | #define STYLE_LONG (2U<<21) /* one record per line, extended info */ |
67 | #define STYLE_SINGLE (3U<<21) /* one record per line */ | 53 | #define STYLE_SINGLE (3U<<21) /* one record per line */ |
@@ -99,7 +85,7 @@ enum { | |||
99 | 85 | ||
100 | #define DISP_MASK (((DISP_ROWS << 1) - 1) & ~(DISP_DIRNAME - 1)) | 86 | #define DISP_MASK (((DISP_ROWS << 1) - 1) & ~(DISP_DIRNAME - 1)) |
101 | 87 | ||
102 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 88 | // CONFIG_FEATURE_LS_SORTFILES |
103 | /* how will the files be sorted */ | 89 | /* how will the files be sorted */ |
104 | #define SORT_ORDER_FORWARD 0 /* sort in reverse order */ | 90 | #define SORT_ORDER_FORWARD 0 /* sort in reverse order */ |
105 | #define SORT_ORDER_REVERSE (1U<<27) /* sort in reverse order */ | 91 | #define SORT_ORDER_REVERSE (1U<<27) /* sort in reverse order */ |
@@ -114,7 +100,6 @@ enum { | |||
114 | #define SORT_DIR (7U<<28) /* sort by file or directory */ | 100 | #define SORT_DIR (7U<<28) /* sort by file or directory */ |
115 | 101 | ||
116 | #define SORT_MASK (7U<<28) | 102 | #define SORT_MASK (7U<<28) |
117 | #endif | ||
118 | 103 | ||
119 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | 104 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS |
120 | /* which of the three times will be used */ | 105 | /* which of the three times will be used */ |
@@ -416,11 +401,8 @@ static int sortcmp(const void *a, const void *b) | |||
416 | 401 | ||
417 | if (dif == 0) { | 402 | if (dif == 0) { |
418 | /* sort by name- may be a tie_breaker for time or size cmp */ | 403 | /* sort by name- may be a tie_breaker for time or size cmp */ |
419 | #ifdef CONFIG_LOCALE_SUPPORT | 404 | if (ENABLE_LOCALE_SUPPORT) dif = strcoll(d1->name, d2->name); |
420 | dif = strcoll(d1->name, d2->name); | 405 | else dif = strcmp(d1->name, d2->name); |
421 | #else | ||
422 | dif = strcmp(d1->name, d2->name); | ||
423 | #endif | ||
424 | } | 406 | } |
425 | 407 | ||
426 | if (all_fmt & SORT_ORDER_REVERSE) { | 408 | if (all_fmt & SORT_ORDER_REVERSE) { |
@@ -434,8 +416,12 @@ static void dnsort(struct dnode **dn, int size) | |||
434 | { | 416 | { |
435 | qsort(dn, size, sizeof *dn, sortcmp); | 417 | qsort(dn, size, sizeof *dn, sortcmp); |
436 | } | 418 | } |
419 | #else | ||
420 | #define sortcmp(a, b) 0 | ||
421 | #define dnsort(dn, size) | ||
437 | #endif | 422 | #endif |
438 | 423 | ||
424 | |||
439 | /*----------------------------------------------------------------------*/ | 425 | /*----------------------------------------------------------------------*/ |
440 | static void showfiles(struct dnode **dn, int nfiles) | 426 | static void showfiles(struct dnode **dn, int nfiles) |
441 | { | 427 | { |
@@ -502,11 +488,8 @@ static void showdirs(struct dnode **dn, int ndirs, int first) | |||
502 | { | 488 | { |
503 | int i, nfiles; | 489 | int i, nfiles; |
504 | struct dnode **subdnp; | 490 | struct dnode **subdnp; |
505 | |||
506 | #ifdef CONFIG_FEATURE_LS_RECURSIVE | ||
507 | int dndirs; | 491 | int dndirs; |
508 | struct dnode **dnd; | 492 | struct dnode **dnd; |
509 | #endif | ||
510 | 493 | ||
511 | if (dn == NULL || ndirs < 1) | 494 | if (dn == NULL || ndirs < 1) |
512 | return; | 495 | return; |
@@ -522,9 +505,7 @@ static void showdirs(struct dnode **dn, int ndirs, int first) | |||
522 | nfiles = countfiles(subdnp); | 505 | nfiles = countfiles(subdnp); |
523 | if (nfiles > 0) { | 506 | if (nfiles > 0) { |
524 | /* list all files at this level */ | 507 | /* list all files at this level */ |
525 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 508 | if (ENABLE_FEATURE_LS_SORTFILES) dnsort(subdnp, nfiles); |
526 | dnsort(subdnp, nfiles); | ||
527 | #endif | ||
528 | showfiles(subdnp, nfiles); | 509 | showfiles(subdnp, nfiles); |
529 | #ifdef CONFIG_FEATURE_LS_RECURSIVE | 510 | #ifdef CONFIG_FEATURE_LS_RECURSIVE |
530 | if (all_fmt & DISP_RECURSIVE) { | 511 | if (all_fmt & DISP_RECURSIVE) { |
@@ -532,9 +513,7 @@ static void showdirs(struct dnode **dn, int ndirs, int first) | |||
532 | dnd = splitdnarray(subdnp, nfiles, SPLIT_SUBDIR); | 513 | dnd = splitdnarray(subdnp, nfiles, SPLIT_SUBDIR); |
533 | dndirs = countsubdirs(subdnp, nfiles); | 514 | dndirs = countsubdirs(subdnp, nfiles); |
534 | if (dndirs > 0) { | 515 | if (dndirs > 0) { |
535 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 516 | if (ENABLE_FEATURE_LS_SORTFILES) dnsort(dnd, dndirs); |
536 | dnsort(dnd, dndirs); | ||
537 | #endif | ||
538 | showdirs(dnd, dndirs, 0); | 517 | showdirs(dnd, dndirs, 0); |
539 | free(dnd); /* free the array of dnode pointers to the dirs */ | 518 | free(dnd); /* free the array of dnode pointers to the dirs */ |
540 | } | 519 | } |
@@ -796,12 +775,6 @@ static int list_single(struct dnode *dn) | |||
796 | # define LS_STR_TIMESTAMPS "" | 775 | # define LS_STR_TIMESTAMPS "" |
797 | #endif | 776 | #endif |
798 | 777 | ||
799 | #ifdef CONFIG_FEATURE_LS_SORTFILES | ||
800 | # define LS_STR_SORTFILES "SXrv" | ||
801 | #else | ||
802 | # define LS_STR_SORTFILES "" | ||
803 | #endif | ||
804 | |||
805 | #ifdef CONFIG_FEATURE_LS_FILETYPES | 778 | #ifdef CONFIG_FEATURE_LS_FILETYPES |
806 | # define LS_STR_FILETYPES "Fp" | 779 | # define LS_STR_FILETYPES "Fp" |
807 | #else | 780 | #else |
@@ -840,7 +813,7 @@ static int list_single(struct dnode *dn) | |||
840 | 813 | ||
841 | static const char ls_options[]="Cadil1gnsxAk" \ | 814 | static const char ls_options[]="Cadil1gnsxAk" \ |
842 | LS_STR_TIMESTAMPS \ | 815 | LS_STR_TIMESTAMPS \ |
843 | LS_STR_SORTFILES \ | 816 | USE_FEATURE_LS_SORTFILES("SXrv") \ |
844 | LS_STR_FILETYPES \ | 817 | LS_STR_FILETYPES \ |
845 | LS_STR_FOLLOW_LINKS \ | 818 | LS_STR_FOLLOW_LINKS \ |
846 | LS_STR_RECURSIVE \ | 819 | LS_STR_RECURSIVE \ |
@@ -872,22 +845,10 @@ static const unsigned opt_flags[] = { | |||
872 | 0, /* k - ingored */ | 845 | 0, /* k - ingored */ |
873 | #endif | 846 | #endif |
874 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | 847 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS |
875 | # ifdef CONFIG_FEATURE_LS_SORTFILES | 848 | TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */ |
876 | TIME_CHANGE | SORT_CTIME, /* c */ | ||
877 | # else | ||
878 | TIME_CHANGE, /* c */ | ||
879 | # endif | ||
880 | LIST_FULLTIME, /* e */ | 849 | LIST_FULLTIME, /* e */ |
881 | # ifdef CONFIG_FEATURE_LS_SORTFILES | 850 | ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */ |
882 | SORT_MTIME, /* t */ | 851 | TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */ |
883 | # else | ||
884 | 0, /* t - ignored -- is this correct? */ | ||
885 | # endif | ||
886 | # ifdef CONFIG_FEATURE_LS_SORTFILES | ||
887 | TIME_ACCESS | SORT_ATIME, /* u */ | ||
888 | # else | ||
889 | TIME_ACCESS, /* u */ | ||
890 | # endif | ||
891 | #endif | 852 | #endif |
892 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 853 | #ifdef CONFIG_FEATURE_LS_SORTFILES |
893 | SORT_SIZE, /* S */ | 854 | SORT_SIZE, /* S */ |
@@ -943,14 +904,8 @@ int ls_main(int argc, char **argv) | |||
943 | char *color_opt; | 904 | char *color_opt; |
944 | #endif | 905 | #endif |
945 | 906 | ||
946 | all_fmt = LIST_SHORT | STYLE_AUTO | 907 | all_fmt = LIST_SHORT | (ENABLE_FEATURE_LS_TIMESTAMPS * TIME_MOD) | |
947 | #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | 908 | (ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_ORDER_FORWARD)); |
948 | | TIME_MOD | ||
949 | #endif | ||
950 | #ifdef CONFIG_FEATURE_LS_SORTFILES | ||
951 | | SORT_NAME | SORT_ORDER_FORWARD | ||
952 | #endif | ||
953 | ; | ||
954 | 909 | ||
955 | #ifdef CONFIG_FEATURE_AUTOWIDTH | 910 | #ifdef CONFIG_FEATURE_AUTOWIDTH |
956 | /* Obtain the terminal width. */ | 911 | /* Obtain the terminal width. */ |
@@ -993,11 +948,9 @@ int ls_main(int argc, char **argv) | |||
993 | if (flags & STYLE_MASK_TRIGGER) { | 948 | if (flags & STYLE_MASK_TRIGGER) { |
994 | all_fmt &= ~STYLE_MASK; | 949 | all_fmt &= ~STYLE_MASK; |
995 | } | 950 | } |
996 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 951 | if (ENABLE_FEATURE_LS_SORTFILES && (flags & SORT_MASK_TRIGGER)) { |
997 | if (flags & SORT_MASK_TRIGGER) { | ||
998 | all_fmt &= ~SORT_MASK; | 952 | all_fmt &= ~SORT_MASK; |
999 | } | 953 | } |
1000 | #endif | ||
1001 | if (flags & DISP_MASK_TRIGGER) { | 954 | if (flags & DISP_MASK_TRIGGER) { |
1002 | all_fmt &= ~DISP_MASK; | 955 | all_fmt &= ~DISP_MASK; |
1003 | } | 956 | } |
@@ -1049,12 +1002,12 @@ int ls_main(int argc, char **argv) | |||
1049 | if (all_fmt & DISP_NOLIST) | 1002 | if (all_fmt & DISP_NOLIST) |
1050 | all_fmt &= ~DISP_RECURSIVE; /* no recurse if listing only dir */ | 1003 | all_fmt &= ~DISP_RECURSIVE; /* no recurse if listing only dir */ |
1051 | #endif | 1004 | #endif |
1052 | #if defined (CONFIG_FEATURE_LS_TIMESTAMPS) && defined (CONFIG_FEATURE_LS_SORTFILES) | 1005 | if (ENABLE_FEATURE_LS_TIMESTAMPS && ENABLE_FEATURE_LS_SORTFILES) { |
1053 | if (all_fmt & TIME_CHANGE) | 1006 | if (all_fmt & TIME_CHANGE) |
1054 | all_fmt = (all_fmt & ~SORT_MASK) | SORT_CTIME; | 1007 | all_fmt = (all_fmt & ~SORT_MASK) | SORT_CTIME; |
1055 | if (all_fmt & TIME_ACCESS) | 1008 | if (all_fmt & TIME_ACCESS) |
1056 | all_fmt = (all_fmt & ~SORT_MASK) | SORT_ATIME; | 1009 | all_fmt = (all_fmt & ~SORT_MASK) | SORT_ATIME; |
1057 | #endif | 1010 | } |
1058 | if ((all_fmt & STYLE_MASK) != STYLE_LONG) /* only for long list */ | 1011 | if ((all_fmt & STYLE_MASK) != STYLE_LONG) /* only for long list */ |
1059 | all_fmt &= ~(LIST_ID_NUMERIC|LIST_FULLTIME|LIST_ID_NAME|LIST_ID_NUMERIC); | 1012 | all_fmt &= ~(LIST_ID_NUMERIC|LIST_FULLTIME|LIST_ID_NAME|LIST_ID_NUMERIC); |
1060 | #ifdef CONFIG_FEATURE_LS_USERNAME | 1013 | #ifdef CONFIG_FEATURE_LS_USERNAME |
@@ -1063,13 +1016,8 @@ int ls_main(int argc, char **argv) | |||
1063 | #endif | 1016 | #endif |
1064 | 1017 | ||
1065 | /* choose a display format */ | 1018 | /* choose a display format */ |
1066 | if ((all_fmt & STYLE_MASK) == STYLE_AUTO) | 1019 | if (!(all_fmt & STYLE_MASK)) |
1067 | #if STYLE_AUTO != 0 | ||
1068 | all_fmt = (all_fmt & ~STYLE_MASK) | ||
1069 | | (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE); | ||
1070 | #else | ||
1071 | all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE); | 1020 | all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE); |
1072 | #endif | ||
1073 | 1021 | ||
1074 | /* | 1022 | /* |
1075 | * when there are no cmd line args we have to supply a default "." arg. | 1023 | * when there are no cmd line args we have to supply a default "." arg. |
@@ -1114,9 +1062,7 @@ int ls_main(int argc, char **argv) | |||
1114 | } | 1062 | } |
1115 | 1063 | ||
1116 | if (all_fmt & DISP_NOLIST) { | 1064 | if (all_fmt & DISP_NOLIST) { |
1117 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 1065 | if (ENABLE_FEATURE_LS_SORTFILES) dnsort(dnp, nfiles); |
1118 | dnsort(dnp, nfiles); | ||
1119 | #endif | ||
1120 | if (nfiles > 0) | 1066 | if (nfiles > 0) |
1121 | showfiles(dnp, nfiles); | 1067 | showfiles(dnp, nfiles); |
1122 | } else { | 1068 | } else { |
@@ -1125,17 +1071,13 @@ int ls_main(int argc, char **argv) | |||
1125 | dndirs = countdirs(dnp, nfiles); | 1071 | dndirs = countdirs(dnp, nfiles); |
1126 | dnfiles = nfiles - dndirs; | 1072 | dnfiles = nfiles - dndirs; |
1127 | if (dnfiles > 0) { | 1073 | if (dnfiles > 0) { |
1128 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 1074 | if (ENABLE_FEATURE_LS_SORTFILES) dnsort(dnf, dnfiles); |
1129 | dnsort(dnf, dnfiles); | ||
1130 | #endif | ||
1131 | showfiles(dnf, dnfiles); | 1075 | showfiles(dnf, dnfiles); |
1132 | if (ENABLE_FEATURE_CLEAN_UP) | 1076 | if (ENABLE_FEATURE_CLEAN_UP) |
1133 | free(dnf); | 1077 | free(dnf); |
1134 | } | 1078 | } |
1135 | if (dndirs > 0) { | 1079 | if (dndirs > 0) { |
1136 | #ifdef CONFIG_FEATURE_LS_SORTFILES | 1080 | if (ENABLE_FEATURE_LS_SORTFILES) dnsort(dnd, dndirs); |
1137 | dnsort(dnd, dndirs); | ||
1138 | #endif | ||
1139 | showdirs(dnd, dndirs, dnfiles == 0); | 1081 | showdirs(dnd, dndirs, dnfiles == 0); |
1140 | if (ENABLE_FEATURE_CLEAN_UP) | 1082 | if (ENABLE_FEATURE_CLEAN_UP) |
1141 | free(dnd); | 1083 | free(dnd); |
diff --git a/coreutils/test.c b/coreutils/test.c index 4d920380d..ab3793627 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
@@ -19,14 +19,12 @@ | |||
19 | * "This program is in the Public Domain." | 19 | * "This program is in the Public Domain." |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <sys/types.h> | 22 | #include "busybox.h" |
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | #include <ctype.h> | 24 | #include <ctype.h> |
25 | #include <errno.h> | 25 | #include <errno.h> |
26 | #include <stdlib.h> | ||
27 | #include <string.h> | 26 | #include <string.h> |
28 | #include <setjmp.h> | 27 | #include <setjmp.h> |
29 | #include "busybox.h" | ||
30 | 28 | ||
31 | /* test(1) accepts the following grammar: | 29 | /* test(1) accepts the following grammar: |
32 | oexpr ::= aexpr | aexpr "-o" oexpr ; | 30 | oexpr ::= aexpr | aexpr "-o" oexpr ; |
@@ -482,8 +480,7 @@ static arith_t getn(const char *s) | |||
482 | if (errno != 0) | 480 | if (errno != 0) |
483 | syntax(s, "out of range"); | 481 | syntax(s, "out of range"); |
484 | 482 | ||
485 | /* p = bb_skip_whitespace(p); avoid const warning */ | 483 | if (*(skip_whitespace(p))) |
486 | if (*(bb_skip_whitespace(p))) | ||
487 | syntax(s, "bad number"); | 484 | syntax(s, "bad number"); |
488 | 485 | ||
489 | return r; | 486 | return r; |
diff --git a/coreutils/uniq.c b/coreutils/uniq.c index be3d75c3a..956c50796 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c | |||
@@ -10,12 +10,10 @@ | |||
10 | /* BB_AUDIT SUSv3 compliant */ | 10 | /* BB_AUDIT SUSv3 compliant */ |
11 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/uniq.html */ | 11 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/uniq.html */ |
12 | 12 | ||
13 | #include <stdio.h> | 13 | #include "busybox.h" |
14 | #include <stdlib.h> | ||
15 | #include <string.h> | 14 | #include <string.h> |
16 | #include <ctype.h> | 15 | #include <ctype.h> |
17 | #include <unistd.h> | 16 | #include <unistd.h> |
18 | #include "busybox.h" | ||
19 | 17 | ||
20 | static const char uniq_opts[] = "f:s:" "cdu\0\1\2\4"; | 18 | static const char uniq_opts[] = "f:s:" "cdu\0\1\2\4"; |
21 | 19 | ||
@@ -77,7 +75,7 @@ int uniq_main(int argc, char **argv) | |||
77 | while ((s1 = bb_get_chomped_line_from_file(in)) != NULL) { | 75 | while ((s1 = bb_get_chomped_line_from_file(in)) != NULL) { |
78 | e1 = s1; | 76 | e1 = s1; |
79 | for (i=skip_fields ; i ; i--) { | 77 | for (i=skip_fields ; i ; i--) { |
80 | e1 = bb_skip_whitespace(e1); | 78 | e1 = skip_whitespace(e1); |
81 | while (*e1 && !isspace(*e1)) { | 79 | while (*e1 && !isspace(*e1)) { |
82 | ++e1; | 80 | ++e1; |
83 | } | 81 | } |
diff --git a/include/libbb.h b/include/libbb.h index 5877a4a83..e9d7e7596 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -200,7 +200,7 @@ extern void bb_warn_ignoring_args(int n); | |||
200 | 200 | ||
201 | extern void chomp(char *s); | 201 | extern void chomp(char *s); |
202 | extern void trim(char *s); | 202 | extern void trim(char *s); |
203 | extern const char *bb_skip_whitespace(const char *); | 203 | extern char *skip_whitespace(const char *); |
204 | 204 | ||
205 | extern struct BB_applet *find_applet_by_name(const char *name); | 205 | extern struct BB_applet *find_applet_by_name(const char *name); |
206 | void run_applet_by_name(const char *name, int argc, char **argv); | 206 | void run_applet_by_name(const char *name, int argc, char **argv); |
diff --git a/libbb/dump.c b/libbb/dump.c index 1a54ebbd9..b12a8e223 100644 --- a/libbb/dump.c +++ b/libbb/dump.c | |||
@@ -10,11 +10,10 @@ | |||
10 | * Original copyright notice is retained at the end of this file. | 10 | * Original copyright notice is retained at the end of this file. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <stdlib.h> | 13 | #include "libbb.h" |
14 | #include <string.h> | 14 | #include <string.h> |
15 | #include <unistd.h> | 15 | #include <unistd.h> |
16 | #include <ctype.h> /* for isdigit() */ | 16 | #include <ctype.h> /* for isdigit() */ |
17 | #include "libbb.h" | ||
18 | #include "dump.h" | 17 | #include "dump.h" |
19 | 18 | ||
20 | enum _vflag bb_dump_vflag = FIRST; | 19 | enum _vflag bb_dump_vflag = FIRST; |
@@ -83,9 +82,9 @@ int bb_dump_size(FS * fs) | |||
83 | static void rewrite(FS * fs) | 82 | static void rewrite(FS * fs) |
84 | { | 83 | { |
85 | enum { NOTOKAY, USEBCNT, USEPREC } sokay; | 84 | enum { NOTOKAY, USEBCNT, USEPREC } sokay; |
86 | register PR *pr, **nextpr = NULL; | 85 | PR *pr, **nextpr = NULL; |
87 | register FU *fu; | 86 | FU *fu; |
88 | register char *p1, *p2, *p3; | 87 | char *p1, *p2, *p3; |
89 | char savech, *fmtp; | 88 | char savech, *fmtp; |
90 | const char *byte_count_str; | 89 | const char *byte_count_str; |
91 | int nconv, prec = 0; | 90 | int nconv, prec = 0; |
@@ -98,7 +97,7 @@ static void rewrite(FS * fs) | |||
98 | for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) { | 97 | for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) { |
99 | /* NOSTRICT */ | 98 | /* NOSTRICT */ |
100 | /* DBU:[dvae@cray.com] calloc so that forward ptrs start out NULL*/ | 99 | /* DBU:[dvae@cray.com] calloc so that forward ptrs start out NULL*/ |
101 | pr = (PR *) xzalloc(sizeof(PR)); | 100 | pr = xzalloc(sizeof(PR)); |
102 | if (!fu->nextpr) | 101 | if (!fu->nextpr) |
103 | fu->nextpr = pr; | 102 | fu->nextpr = pr; |
104 | /* ignore nextpr -- its unused inside the loop and is | 103 | /* ignore nextpr -- its unused inside the loop and is |
@@ -246,8 +245,7 @@ static void rewrite(FS * fs) | |||
246 | { | 245 | { |
247 | savech = *p3; | 246 | savech = *p3; |
248 | *p3 = '\0'; | 247 | *p3 = '\0'; |
249 | if (!(pr->fmt = realloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1))) | 248 | pr->fmt = xrealloc(pr->fmt, strlen(pr->fmt)+(p3-p2)+1); |
250 | bb_perror_msg_and_die("hexdump"); | ||
251 | strcat(pr->fmt, p2); | 249 | strcat(pr->fmt, p2); |
252 | *p3 = savech; | 250 | *p3 = savech; |
253 | p2 = p3; | 251 | p2 = p3; |
@@ -673,17 +671,16 @@ int bb_dump_dump(char **argv) | |||
673 | 671 | ||
674 | void bb_dump_add(const char *fmt) | 672 | void bb_dump_add(const char *fmt) |
675 | { | 673 | { |
676 | register const char *p; | 674 | const char *p; |
677 | register char *p1; | 675 | char *p1; |
678 | register char *p2; | 676 | char *p2; |
679 | static FS **nextfs; | 677 | static FS **nextfs; |
680 | FS *tfs; | 678 | FS *tfs; |
681 | FU *tfu, **nextfu; | 679 | FU *tfu, **nextfu; |
682 | const char *savep; | 680 | const char *savep; |
683 | 681 | ||
684 | /* start new linked list of format units */ | 682 | /* start new linked list of format units */ |
685 | /* NOSTRICT */ | 683 | tfs = xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */ |
686 | tfs = (FS *) xzalloc(sizeof(FS)); /*DBU:[dave@cray.com] start out NULL */ | ||
687 | if (!bb_dump_fshead) { | 684 | if (!bb_dump_fshead) { |
688 | bb_dump_fshead = tfs; | 685 | bb_dump_fshead = tfs; |
689 | } else { | 686 | } else { |
@@ -695,7 +692,7 @@ void bb_dump_add(const char *fmt) | |||
695 | /* take the format string and break it up into format units */ | 692 | /* take the format string and break it up into format units */ |
696 | for (p = fmt;;) { | 693 | for (p = fmt;;) { |
697 | /* bb_dump_skip leading white space */ | 694 | /* bb_dump_skip leading white space */ |
698 | p = bb_skip_whitespace(p); | 695 | p = skip_whitespace(p); |
699 | if (!*p) { | 696 | if (!*p) { |
700 | break; | 697 | break; |
701 | } | 698 | } |
@@ -703,7 +700,7 @@ void bb_dump_add(const char *fmt) | |||
703 | /* allocate a new format unit and link it in */ | 700 | /* allocate a new format unit and link it in */ |
704 | /* NOSTRICT */ | 701 | /* NOSTRICT */ |
705 | /* DBU:[dave@cray.com] calloc so that forward pointers start out NULL */ | 702 | /* DBU:[dave@cray.com] calloc so that forward pointers start out NULL */ |
706 | tfu = (FU *) xzalloc(sizeof(FU)); | 703 | tfu = xzalloc(sizeof(FU)); |
707 | *nextfu = tfu; | 704 | *nextfu = tfu; |
708 | nextfu = &tfu->nextfu; | 705 | nextfu = &tfu->nextfu; |
709 | tfu->reps = 1; | 706 | tfu->reps = 1; |
@@ -718,12 +715,12 @@ void bb_dump_add(const char *fmt) | |||
718 | tfu->reps = atoi(savep); | 715 | tfu->reps = atoi(savep); |
719 | tfu->flags = F_SETREP; | 716 | tfu->flags = F_SETREP; |
720 | /* bb_dump_skip trailing white space */ | 717 | /* bb_dump_skip trailing white space */ |
721 | p = bb_skip_whitespace(++p); | 718 | p = skip_whitespace(++p); |
722 | } | 719 | } |
723 | 720 | ||
724 | /* bb_dump_skip slash and trailing white space */ | 721 | /* bb_dump_skip slash and trailing white space */ |
725 | if (*p == '/') { | 722 | if (*p == '/') { |
726 | p = bb_skip_whitespace(++p); | 723 | p = skip_whitespace(++p); |
727 | } | 724 | } |
728 | 725 | ||
729 | /* byte count */ | 726 | /* byte count */ |
@@ -734,7 +731,7 @@ void bb_dump_add(const char *fmt) | |||
734 | } | 731 | } |
735 | tfu->bcnt = atoi(savep); | 732 | tfu->bcnt = atoi(savep); |
736 | /* bb_dump_skip trailing white space */ | 733 | /* bb_dump_skip trailing white space */ |
737 | p = bb_skip_whitespace(++p); | 734 | p = skip_whitespace(++p); |
738 | } | 735 | } |
739 | 736 | ||
740 | /* format */ | 737 | /* format */ |
diff --git a/libbb/inet_common.c b/libbb/inet_common.c index c02c732f3..0051edbdc 100644 --- a/libbb/inet_common.c +++ b/libbb/inet_common.c | |||
@@ -8,13 +8,13 @@ | |||
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include "libbb.h" | ||
11 | #include "inet_common.h" | 12 | #include "inet_common.h" |
12 | #include <stdio.h> | 13 | #include <stdio.h> |
13 | #include <errno.h> | 14 | #include <errno.h> |
14 | #include <stdlib.h> | 15 | #include <stdlib.h> |
15 | #include <string.h> | 16 | #include <string.h> |
16 | #include <unistd.h> | 17 | #include <unistd.h> |
17 | #include "libbb.h" | ||
18 | 18 | ||
19 | #ifdef DEBUG | 19 | #ifdef DEBUG |
20 | # include <resolv.h> | 20 | # include <resolv.h> |
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c index a15339974..94967133c 100644 --- a/libbb/pw_encrypt.c +++ b/libbb/pw_encrypt.c | |||
@@ -20,9 +20,9 @@ | |||
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "libbb.h" | ||
23 | #include <string.h> | 24 | #include <string.h> |
24 | #include <crypt.h> | 25 | #include <crypt.h> |
25 | #include "libbb.h" | ||
26 | 26 | ||
27 | 27 | ||
28 | char *pw_encrypt(const char *clear, const char *salt) | 28 | char *pw_encrypt(const char *clear, const char *salt) |
diff --git a/libbb/skip_whitespace.c b/libbb/skip_whitespace.c index fd5d72540..02c1f5828 100644 --- a/libbb/skip_whitespace.c +++ b/libbb/skip_whitespace.c | |||
@@ -4,30 +4,15 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> | 5 | * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | 8 | */ |
22 | 9 | ||
23 | #include <ctype.h> | 10 | #include <ctype.h> |
24 | #include "libbb.h" | 11 | #include "libbb.h" |
25 | 12 | ||
26 | const char *bb_skip_whitespace(const char *s) | 13 | char *skip_whitespace(const char *s) |
27 | { | 14 | { |
28 | while (isspace(*s)) { | 15 | while (isspace(*s)) ++s; |
29 | ++s; | ||
30 | } | ||
31 | 16 | ||
32 | return s; | 17 | return (char *) s; |
33 | } | 18 | } |
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c index 4f4e0410f..98ecf40a3 100644 --- a/libpwdgrp/pwd_grp.c +++ b/libpwdgrp/pwd_grp.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "libbb.h" | ||
20 | #include <features.h> | 21 | #include <features.h> |
21 | #include <stdio.h> | 22 | #include <stdio.h> |
22 | #include <stdlib.h> | 23 | #include <stdlib.h> |
@@ -27,10 +28,9 @@ | |||
27 | #include <assert.h> | 28 | #include <assert.h> |
28 | #include <ctype.h> | 29 | #include <ctype.h> |
29 | 30 | ||
30 | #include "pwd_.h" | 31 | //#include "pwd_.h" |
31 | #include "grp_.h" | 32 | //#include "grp_.h" |
32 | #include "shadow_.h" | 33 | //#include "shadow_.h" |
33 | #include "libbb.h" | ||
34 | 34 | ||
35 | #ifndef _PATH_SHADOW | 35 | #ifndef _PATH_SHADOW |
36 | #define _PATH_SHADOW "/etc/shadow" | 36 | #define _PATH_SHADOW "/etc/shadow" |
diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c index 9ee5ab23f..2319530ad 100644 --- a/networking/libiproute/ll_proto.c +++ b/networking/libiproute/ll_proto.c | |||
@@ -9,8 +9,7 @@ | |||
9 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 9 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <stdio.h> | 12 | #include "libbb.h" |
13 | #include <arpa/inet.h> | ||
14 | #include <string.h> | 13 | #include <string.h> |
15 | 14 | ||
16 | #include "rt_names.h" | 15 | #include "rt_names.h" |
diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c index e2cbcaf89..17854cb18 100644 --- a/util-linux/hexdump.c +++ b/util-linux/hexdump.c | |||
@@ -5,27 +5,12 @@ | |||
5 | * Copyright (c) 1989 | 5 | * Copyright (c) 1989 |
6 | * The Regents of the University of California. All rights reserved. | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * Licensed under GPLv2 or later, see file License in this tarball for details. |
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | ||
22 | * Original copyright notice is retained at the end of this file. | ||
23 | */ | 9 | */ |
24 | 10 | ||
11 | #include "busybox.h" | ||
25 | #include <getopt.h> | 12 | #include <getopt.h> |
26 | #include <stdlib.h> | ||
27 | #include <string.h> | 13 | #include <string.h> |
28 | #include "busybox.h" | ||
29 | #include "dump.h" | 14 | #include "dump.h" |
30 | 15 | ||
31 | static void bb_dump_addfile(char *name) | 16 | static void bb_dump_addfile(char *name) |
@@ -37,7 +22,7 @@ static void bb_dump_addfile(char *name) | |||
37 | fp = bb_xfopen(name, "r"); | 22 | fp = bb_xfopen(name, "r"); |
38 | 23 | ||
39 | while ((buf = bb_get_chomped_line_from_file(fp)) != NULL) { | 24 | while ((buf = bb_get_chomped_line_from_file(fp)) != NULL) { |
40 | p = (char *) bb_skip_whitespace(buf); | 25 | p = skip_whitespace(buf); |
41 | 26 | ||
42 | if (*p && (*p != '#')) { | 27 | if (*p && (*p != '#')) { |
43 | bb_dump_add(p); | 28 | bb_dump_add(p); |
@@ -116,31 +101,3 @@ int hexdump_main(int argc, char **argv) | |||
116 | 101 | ||
117 | return(bb_dump_dump(argv)); | 102 | return(bb_dump_dump(argv)); |
118 | } | 103 | } |
119 | /* | ||
120 | * Copyright (c) 1989 The Regents of the University of California. | ||
121 | * All rights reserved. | ||
122 | * | ||
123 | * Redistribution and use in source and binary forms, with or without | ||
124 | * modification, are permitted provided that the following conditions | ||
125 | * are met: | ||
126 | * 1. Redistributions of source code must retain the above copyright | ||
127 | * notice, this list of conditions and the following disclaimer. | ||
128 | * 2. Redistributions in binary form must reproduce the above copyright | ||
129 | * notice, this list of conditions and the following disclaimer in the | ||
130 | * documentation and/or other materials provided with the distribution. | ||
131 | * 3. Neither the name of the University nor the names of its contributors | ||
132 | * may be used to endorse or promote products derived from this software | ||
133 | * without specific prior written permission. | ||
134 | * | ||
135 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
136 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
137 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
138 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
139 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
140 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
141 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
142 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
143 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
144 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
145 | * SUCH DAMAGE. | ||
146 | */ | ||