aboutsummaryrefslogtreecommitdiff
path: root/coreutils/ls.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-06-30 08:04:05 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-06-30 08:04:05 +0000
commitdc757aa16ce53d9784fa3953b0c3762dfa8ccda9 (patch)
tree2eee7a83dcbd38fcfbcdbec8b5d52f4baff3326f /coreutils/ls.c
parentf7d07b1723c15ee818f0c1f5cce96c55274024a6 (diff)
downloadbusybox-dc757aa16ce53d9784fa3953b0c3762dfa8ccda9.tar.gz
introduce and use bb_basename()
function old new delta bb_basename - 26 +26 sv_main 1226 1225 -1 passwd_main 1985 1983 -2 showdirs 482 478 -4 sendCgi 1811 1807 -4 make_device 1354 1350 -4 handleIncoming 2443 2439 -4 func_name 82 78 -4 service_name 2292 2285 -7 main 909 901 -8 cmp_main 555 547 -8 test_main 434 422 -12 act 228 216 -12 find_pair 180 164 -16 rmmod_main 298 280 -18 find_pid_by_name 156 134 -22 modprobe_main 1606 1576 -30 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/16 up/down: 26/-156) Total: -130 bytes text data bss dec hex filename 734933 3028 14400 752361 b7ae9 busybox_old 734801 3028 14400 752229 b7a65 busybox_unstripped
Diffstat (limited to 'coreutils/ls.c')
-rw-r--r--coreutils/ls.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index e2ed3ee1f..a5bd0e304 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -132,8 +132,8 @@ enum { show_color = 0 };
* a directory entry and its stat info are stored here
*/
struct dnode { /* the basic node */
- char *name; /* the dir entry name */
- char *fullname; /* the dir entry name */
+ const char *name; /* the dir entry name */
+ const char *fullname; /* the dir entry name */
int allocated;
struct stat dstat; /* the file stat info */
USE_SELINUX(security_context_t sid;)
@@ -159,7 +159,7 @@ enum {
static int status = EXIT_SUCCESS;
-static struct dnode *my_stat(char *fullname, char *name, int force_follow)
+static struct dnode *my_stat(const char *fullname, const char *name, int force_follow)
{
struct stat dstat;
struct dnode *cur;
@@ -241,7 +241,7 @@ static int count_dirs(struct dnode **dn, int nfiles, int notsubdirs)
return 0;
dirs = 0;
for (i = 0; i < nfiles; i++) {
- char *name;
+ const char *name;
if (!S_ISDIR(dn[i]->dstat.st_mode))
continue;
name = dn[i]->name;
@@ -288,7 +288,7 @@ static void dfree(struct dnode **dnp, int nfiles)
for (i = 0; i < nfiles; i++) {
struct dnode *cur = dnp[i];
if (cur->allocated)
- free(cur->fullname); /* free the filename */
+ free((char*)cur->fullname); /* free the filename */
free(cur); /* free the dnode */
}
free(dnp); /* free the array holding the dnode pointers */
@@ -320,7 +320,7 @@ static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
/* copy the entrys into the file or dir array */
for (d = i = 0; i < nfiles; i++) {
if (S_ISDIR(dn[i]->dstat.st_mode)) {
- char *name;
+ const char *name;
if (!(which & (SPLIT_DIR|SPLIT_SUBDIR)))
continue;
name = dn[i]->name;
@@ -513,7 +513,7 @@ static struct dnode **list_dir(const char *path)
continue;
}
fullname = concat_path_file(path, entry->d_name);
- cur = my_stat(fullname, strrchr(fullname, '/') + 1, 0);
+ cur = my_stat(fullname, bb_basename(fullname), 0);
if (!cur) {
free(fullname);
continue;