diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-05-13 17:27:36 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-05-13 17:27:36 +0200 |
commit | 66ca241dcae32d7932c58398d27945d43702fc4e (patch) | |
tree | dc5a9f0d16761070475d345d820a2478e9338569 /coreutils/ls.c | |
parent | d27ac299eb34fc2be3038d029e8cd581138d0a06 (diff) | |
download | busybox-w32-66ca241dcae32d7932c58398d27945d43702fc4e.tar.gz busybox-w32-66ca241dcae32d7932c58398d27945d43702fc4e.tar.bz2 busybox-w32-66ca241dcae32d7932c58398d27945d43702fc4e.zip |
ls: avoid forward declaration. No code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/ls.c')
-rw-r--r-- | coreutils/ls.c | 88 |
1 files changed, 43 insertions, 45 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 0914d752b..46abb6201 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -890,51 +890,6 @@ static off_t calculate_blocks(struct dnode **dn) | |||
890 | #endif | 890 | #endif |
891 | 891 | ||
892 | 892 | ||
893 | static struct dnode **list_dir(const char *, unsigned *); | ||
894 | |||
895 | static void showdirs(struct dnode **dn, int first) | ||
896 | { | ||
897 | unsigned nfiles; | ||
898 | struct dnode **subdnp; | ||
899 | |||
900 | for (; *dn; dn++) { | ||
901 | if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) { | ||
902 | if (!first) | ||
903 | bb_putchar('\n'); | ||
904 | first = 0; | ||
905 | printf("%s:\n", (*dn)->fullname); | ||
906 | } | ||
907 | subdnp = list_dir((*dn)->fullname, &nfiles); | ||
908 | #if ENABLE_DESKTOP | ||
909 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) | ||
910 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); | ||
911 | #endif | ||
912 | if (nfiles > 0) { | ||
913 | /* list all files at this level */ | ||
914 | dnsort(subdnp, nfiles); | ||
915 | showfiles(subdnp, nfiles); | ||
916 | if (ENABLE_FEATURE_LS_RECURSIVE | ||
917 | && (all_fmt & DISP_RECURSIVE) | ||
918 | ) { | ||
919 | struct dnode **dnd; | ||
920 | unsigned dndirs; | ||
921 | /* recursive - list the sub-dirs */ | ||
922 | dnd = splitdnarray(subdnp, SPLIT_SUBDIR); | ||
923 | dndirs = count_dirs(subdnp, SPLIT_SUBDIR); | ||
924 | if (dndirs > 0) { | ||
925 | dnsort(dnd, dndirs); | ||
926 | showdirs(dnd, 0); | ||
927 | /* free the array of dnode pointers to the dirs */ | ||
928 | free(dnd); | ||
929 | } | ||
930 | } | ||
931 | /* free the dnodes and the fullname mem */ | ||
932 | dfree(subdnp); | ||
933 | } | ||
934 | } | ||
935 | } | ||
936 | |||
937 | |||
938 | /* Returns NULL-terminated malloced vector of pointers (or NULL) */ | 893 | /* Returns NULL-terminated malloced vector of pointers (or NULL) */ |
939 | static struct dnode **list_dir(const char *path, unsigned *nfiles_p) | 894 | static struct dnode **list_dir(const char *path, unsigned *nfiles_p) |
940 | { | 895 | { |
@@ -996,6 +951,49 @@ static struct dnode **list_dir(const char *path, unsigned *nfiles_p) | |||
996 | } | 951 | } |
997 | 952 | ||
998 | 953 | ||
954 | static void showdirs(struct dnode **dn, int first) | ||
955 | { | ||
956 | unsigned nfiles; | ||
957 | struct dnode **subdnp; | ||
958 | |||
959 | for (; *dn; dn++) { | ||
960 | if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) { | ||
961 | if (!first) | ||
962 | bb_putchar('\n'); | ||
963 | first = 0; | ||
964 | printf("%s:\n", (*dn)->fullname); | ||
965 | } | ||
966 | subdnp = list_dir((*dn)->fullname, &nfiles); | ||
967 | #if ENABLE_DESKTOP | ||
968 | if ((all_fmt & STYLE_MASK) == STYLE_LONG) | ||
969 | printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); | ||
970 | #endif | ||
971 | if (nfiles > 0) { | ||
972 | /* list all files at this level */ | ||
973 | dnsort(subdnp, nfiles); | ||
974 | showfiles(subdnp, nfiles); | ||
975 | if (ENABLE_FEATURE_LS_RECURSIVE | ||
976 | && (all_fmt & DISP_RECURSIVE) | ||
977 | ) { | ||
978 | struct dnode **dnd; | ||
979 | unsigned dndirs; | ||
980 | /* recursive - list the sub-dirs */ | ||
981 | dnd = splitdnarray(subdnp, SPLIT_SUBDIR); | ||
982 | dndirs = count_dirs(subdnp, SPLIT_SUBDIR); | ||
983 | if (dndirs > 0) { | ||
984 | dnsort(dnd, dndirs); | ||
985 | showdirs(dnd, 0); | ||
986 | /* free the array of dnode pointers to the dirs */ | ||
987 | free(dnd); | ||
988 | } | ||
989 | } | ||
990 | /* free the dnodes and the fullname mem */ | ||
991 | dfree(subdnp); | ||
992 | } | ||
993 | } | ||
994 | } | ||
995 | |||
996 | |||
999 | int ls_main(int argc UNUSED_PARAM, char **argv) | 997 | int ls_main(int argc UNUSED_PARAM, char **argv) |
1000 | { | 998 | { |
1001 | struct dnode **dnd; | 999 | struct dnode **dnd; |