From 66ca241dcae32d7932c58398d27945d43702fc4e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 13 May 2011 17:27:36 +0200 Subject: ls: avoid forward declaration. No code changes Signed-off-by: Denys Vlasenko --- coreutils/ls.c | 88 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 43 insertions(+), 45 deletions(-) (limited to 'coreutils') 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) #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; -- cgit v1.2.3