aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/du.c8
-rw-r--r--coreutils/ln.c2
-rw-r--r--coreutils/ls.c28
-rw-r--r--coreutils/tail.c15
4 files changed, 36 insertions, 17 deletions
diff --git a/coreutils/du.c b/coreutils/du.c
index 7151e3a9c..912605882 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -72,6 +72,10 @@ static long du(char *filename)
du_depth++;
sum = statbuf.st_blocks;
+ /* Don't add in stuff pointed to by links */
+ if (S_ISLNK(statbuf.st_mode)) {
+ return 0;
+ }
if (S_ISDIR(statbuf.st_mode)) {
DIR *dir;
struct dirent *entry;
@@ -140,7 +144,7 @@ int du_main(int argc, char **argv)
for (; i < argc; i++) {
sum = du(argv[i]);
- if ((sum) && (isDirectory(argv[i], FALSE))) {
+ if ((sum) && (isDirectory(argv[i], FALSE, NULL))) {
print_normal(sum, argv[i]);
}
}
@@ -149,4 +153,4 @@ int du_main(int argc, char **argv)
exit(0);
}
-/* $Id: du.c,v 1.11 2000/02/08 19:58:47 erik Exp $ */
+/* $Id: du.c,v 1.12 2000/02/11 21:55:04 erik Exp $ */
diff --git a/coreutils/ln.c b/coreutils/ln.c
index bc51cb0d5..0715bfaed 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -84,7 +84,7 @@ extern int ln_main(int argc, char **argv)
exit FALSE;
}
- linkIntoDirFlag = isDirectory(linkName, TRUE);
+ linkIntoDirFlag = isDirectory(linkName, TRUE, NULL);
if ((argc > 3) && !linkIntoDirFlag) {
fprintf(stderr, not_a_directory, "ln", linkName);
diff --git a/coreutils/ls.c b/coreutils/ls.c
index f23c1e086..c2266f533 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -29,10 +29,10 @@
* it more portable.
*
* KNOWN BUGS:
- * 1. messy output if you mix files and directories on the command line
- * 2. ls -l of a directory doesn't give "total <blocks>" header
- * 3. ls of a symlink to a directory doesn't list directory contents
- * 4. hidden files can make column width too large
+ * 1. ls -l of a directory doesn't give "total <blocks>" header
+ * 2. ls of a symlink to a directory doesn't list directory contents
+ * 3. hidden files can make column width too large
+ *
* NON-OPTIMAL BEHAVIOUR:
* 1. autowidth reads directories twice
* 2. if you do a short directory listing without filetype characters
@@ -100,7 +100,9 @@ static unsigned short opts = 0;
static unsigned short column = 0;
#ifdef BB_FEATURE_AUTOWIDTH
-static unsigned short terminal_width = 0, column_width = 0;
+static unsigned short terminal_width = 0;
+static unsigned short column_width = 0;
+static unsigned short toplevel_column_width = 0;
#else
#define terminal_width TERMINAL_WIDTH
#define column_width COLUMN_WIDTH
@@ -349,6 +351,9 @@ static int list_item(const char *name)
goto listerr;
if (!S_ISDIR(info.st_mode) || (opts & DIR_NOLIST)) {
+#ifdef BB_FEATURE_AUTOWIDTH
+ column_width = toplevel_column_width;
+#endif
list_single(name, &info, name);
return 0;
}
@@ -407,6 +412,15 @@ static int list_item(const char *name)
list_single(entry->d_name, &info, fullname);
}
closedir(dir);
+
+ if (opts & DISP_DIRNAME) { /* separate the directory */
+ if (column) {
+ wr("\n", 1);
+ }
+ wr("\n", 1);
+ column = 0;
+ }
+
return 0;
direrr:
@@ -530,8 +544,8 @@ extern int ls_main(int argc, char **argv)
for (i = argi; i < argc; i++) {
int len = strlen(argv[i]);
- if (column_width < len)
- column_width = len;
+ if (toplevel_column_width < len)
+ toplevel_column_width = len;
}
#endif
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 31705afa2..821244f9e 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -1,5 +1,6 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
+
/* This file contains _two_ implementations of tail. One is
* a bit more full featured, but costs 6k. The other (i.e. the
* SIMPLE_TAIL one) is less capable, but is good enough for about
@@ -51,7 +52,7 @@
#define XWRITE(fd, buffer, n_bytes) \
do { \
if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \
- error("write error"); \
+ errorMsg("write error"); \
} while (0)
/* Number of items to tail. */
@@ -117,7 +118,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos)
lseek(fd, pos, SEEK_SET);
bytes_read = fullRead(fd, buffer, bytes_read);
if (bytes_read == -1)
- error("read error");
+ errorMsg("read error");
/* Count the incomplete line on files that don't end with a newline. */
if (bytes_read && buffer[bytes_read - 1] != '\n')
@@ -147,7 +148,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos)
}
while ((bytes_read = fullRead(fd, buffer, BUFSIZ)) > 0);
if (bytes_read == -1)
- error("read error");
+ errorMsg("read error");
return 0;
}
@@ -209,7 +210,7 @@ static int pipe_lines(const char *filename, int fd, long int n_lines)
}
}
if (tmp->nbytes == -1)
- error("read error");
+ errorMsg("read error");
free((char *) tmp);
@@ -272,7 +273,7 @@ static long dump_remainder(const char *filename, int fd)
total += bytes_read;
}
if (bytes_read == -1)
- error("read error");
+ errorMsg("read error");
if (forever) {
fflush(stdout);
sleep(1);
@@ -294,7 +295,7 @@ static int tail_lines(const char *filename, int fd, long int n_lines)
write_header(filename);
if (fstat(fd, &stats))
- error("fstat error");
+ errorMsg("fstat error");
/* Use file_lines only if FD refers to a regular file with
its file pointer positioned at beginning of file. */
@@ -329,7 +330,7 @@ static int tail_file(const char *filename, off_t n_units)
/* Not standard input. */
fd = open(filename, O_RDONLY);
if (fd == -1)
- error("open error");
+ errorMsg("open error");
errors = tail_lines(filename, fd, (long) n_units);
close(fd);