SCCS-vsn: bin/ls/ls.c 5.20
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)ls.c 5.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)ls.c 5.20 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
{
LS local, *stats;
int num;
{
LS local, *stats;
int num;
(void)fprintf(stderr, "ls: .: %s\n", strerror(errno));
exit(1);
}
(void)fprintf(stderr, "ls: .: %s\n", strerror(errno));
exit(1);
}
- if (num = buildstats(&local, &stats, &names))
- ls(stats, num);
+ if (num = tabdir(&local, &stats, &names))
+ displaydir(stats, num);
}
static char path[MAXPATHLEN + 1];
static char *endofpath = path;
}
static char path[MAXPATHLEN + 1];
static char *endofpath = path;
if (regcnt) {
/*
* for -f flag -- switch above treats all -f operands as
if (regcnt) {
/*
* for -f flag -- switch above treats all -f operands as
- * regular files; this code uses buildstats() to read
+ * regular files; this code uses tabdir() to read
* them as directories.
*/
if (f_specialdir) {
for (cnt = regcnt; cnt--;) {
* them as directories.
*/
if (f_specialdir) {
for (cnt = regcnt; cnt--;) {
- if (num = buildstats(rstats++, &stats, &names))
- ls(stats, num);
+ if (num = tabdir(rstats++, &stats, &names))
+ displaydir(stats, num);
(void)free((char *)stats);
(void)free((char *)names);
}
} else
(void)free((char *)stats);
(void)free((char *)names);
}
} else
+ displaydir(rstats, regcnt);
}
/* display directories */
if (dircnt) {
}
/* display directories */
if (dircnt) {
for (cnt = 0; cnt < dircnt; ++dstats) {
for (endofpath = path, p = dstats->name;
*endofpath = *p++; ++endofpath);
for (cnt = 0; cnt < dircnt; ++dstats) {
for (endofpath = path, p = dstats->name;
*endofpath = *p++; ++endofpath);
- ls_dir(dstats, regcnt, regcnt || dircnt > 1);
+ subdir(dstats, regcnt, regcnt || dircnt > 1);
if (++cnt < dircnt && chdir(top)) {
(void)fprintf(stderr, "ls: %s: %s\n",
top, strerror(errno));
if (++cnt < dircnt && chdir(top)) {
(void)fprintf(stderr, "ls: %s: %s\n",
top, strerror(errno));
LS *stats;
register int num;
{
LS *stats;
register int num;
{
if (endofpath != path && endofpath[-1] != '/')
*endofpath++ = '/';
for (; *endofpath = *p++; ++endofpath);
if (endofpath != path && endofpath[-1] != '/')
*endofpath++ = '/';
for (; *endofpath = *p++; ++endofpath);
*(endofpath = savedpath) = '\0';
}
}
}
*(endofpath = savedpath) = '\0';
}
}
}
-ls_dir(lp, newline, tag)
+subdir(lp, newline, tag)
LS *lp;
int newline, tag;
{
LS *lp;
int newline, tag;
{
lp->name, strerror(errno));
return;
}
lp->name, strerror(errno));
return;
}
- if (num = buildstats(lp, &stats, &names))
- ls(stats, num);
+ if (num = tabdir(lp, &stats, &names))
+ displaydir(stats, num);
(void)free((char *)stats);
(void)free((char *)names);
if (chdir("..")) {
(void)free((char *)stats);
(void)free((char *)names);
if (chdir("..")) {
-buildstats(lp, s_stats, s_names)
+tabdir(lp, s_stats, s_names)
LS *lp, **s_stats;
char **s_names;
{
LS *lp, **s_stats;
char **s_names;
{