diff options
author | Denys Vlasenko | 2011-05-13 17:27:36 +0200 |
---|---|---|
committer | Denys Vlasenko | 2011-05-13 17:27:36 +0200 |
commit | 66ca241dcae32d7932c58398d27945d43702fc4e (patch) | |
tree | dc5a9f0d16761070475d345d820a2478e9338569 /coreutils | |
parent | d27ac299eb34fc2be3038d029e8cd581138d0a06 (diff) | |
download | busybox-66ca241dcae32d7932c58398d27945d43702fc4e.zip busybox-66ca241dcae32d7932c58398d27945d43702fc4e.tar.gz |
ls: avoid forward declaration. No code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-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 0914d75..46abb62 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -890,51 +890,6 @@ static off_t calculate_blocks(struct dnode **dn) #endif -static struct dnode **list_dir(const char *, unsigned *); - -static void showdirs(struct dnode **dn, int first) -{ - unsigned nfiles; - struct dnode **subdnp; - - for (; *dn; dn++) { - if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) { - if (!first) - bb_putchar('\n'); - first = 0; - printf("%s:\n", (*dn)->fullname); - } - subdnp = list_dir((*dn)->fullname, &nfiles); -#if ENABLE_DESKTOP - if ((all_fmt & STYLE_MASK) == STYLE_LONG) - printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); -#endif - if (nfiles > 0) { - /* list all files at this level */ - dnsort(subdnp, nfiles); - showfiles(subdnp, nfiles); - if (ENABLE_FEATURE_LS_RECURSIVE - && (all_fmt & DISP_RECURSIVE) - ) { - struct dnode **dnd; - unsigned dndirs; - /* recursive - list the sub-dirs */ - dnd = splitdnarray(subdnp, SPLIT_SUBDIR); - dndirs = count_dirs(subdnp, SPLIT_SUBDIR); - if (dndirs > 0) { - dnsort(dnd, dndirs); - showdirs(dnd, 0); - /* free the array of dnode pointers to the dirs */ - free(dnd); - } - } - /* free the dnodes and the fullname mem */ - dfree(subdnp); - } - } -} - - /* Returns NULL-terminated malloced vector of pointers (or NULL) */ static struct dnode **list_dir(const char *path, unsigned *nfiles_p) { @@ -996,6 +951,49 @@ static struct dnode **list_dir(const char *path, unsigned *nfiles_p) } +static void showdirs(struct dnode **dn, int first) +{ + unsigned nfiles; + struct dnode **subdnp; + + for (; *dn; dn++) { + if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) { + if (!first) + bb_putchar('\n'); + first = 0; + printf("%s:\n", (*dn)->fullname); + } + subdnp = list_dir((*dn)->fullname, &nfiles); +#if ENABLE_DESKTOP + if ((all_fmt & STYLE_MASK) == STYLE_LONG) + printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp)); +#endif + if (nfiles > 0) { + /* list all files at this level */ + dnsort(subdnp, nfiles); + showfiles(subdnp, nfiles); + if (ENABLE_FEATURE_LS_RECURSIVE + && (all_fmt & DISP_RECURSIVE) + ) { + struct dnode **dnd; + unsigned dndirs; + /* recursive - list the sub-dirs */ + dnd = splitdnarray(subdnp, SPLIT_SUBDIR); + dndirs = count_dirs(subdnp, SPLIT_SUBDIR); + if (dndirs > 0) { + dnsort(dnd, dndirs); + showdirs(dnd, 0); + /* free the array of dnode pointers to the dirs */ + free(dnd); + } + } + /* free the dnodes and the fullname mem */ + dfree(subdnp); + } + } +} + + int ls_main(int argc UNUSED_PARAM, char **argv) { struct dnode **dnd; |