summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/ls.c b/src/ls.c
index 397e4ea9..f1ed43bd 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1,5 +1,5 @@
/* 'dir', 'vdir' and 'ls' directory listing programs for GNU.
- Copyright (C) 1985-2012 Free Software Foundation, Inc.
+ Copyright (C) 1985-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -3064,12 +3064,6 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
free (linkname);
}
- /* When not distinguishing types of symlinks, pretend we know that
- it is stat'able, so that it will be colored as a regular symlink,
- and not as an orphan. */
- if (S_ISLNK (f->stat.st_mode) && !check_symlink_color)
- f->linkok = true;
-
if (S_ISLNK (f->stat.st_mode))
f->filetype = symbolic_link;
else if (S_ISDIR (f->stat.st_mode))
@@ -3213,7 +3207,14 @@ make_link_name (char const *name, char const *linkname)
return xstrdup (linkname);
char *p = xmalloc (prefix_len + 1 + strlen (linkname) + 1);
- stpcpy (stpncpy (p, name, prefix_len + 1), linkname);
+
+ /* PREFIX_LEN usually specifies a string not ending in slash.
+ In that case, extend it by one, since the next byte *is* a slash.
+ Otherwise, the prefix is "/", so leave the length unchanged. */
+ if ( ! ISSLASH (name[prefix_len - 1]))
+ ++prefix_len;
+
+ stpcpy (stpncpy (p, name, prefix_len), linkname);
return p;
}
@@ -4286,7 +4287,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target)
/* Is this a nonexistent file? If so, linkok == -1. */
- if (linkok == -1 && color_indicator[C_MISSING].string != NULL)
+ if (linkok == -1 && is_colored (C_MISSING))
type = C_MISSING;
else if (!f->stat_ok)
{
@@ -4361,8 +4362,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target)
/* Adjust the color for orphaned symlinks. */
if (type == C_LINK && !linkok)
{
- if (color_symlink_as_referent
- || color_indicator[C_ORPHAN].string)
+ if (color_symlink_as_referent || is_colored (C_ORPHAN))
type = C_ORPHAN;
}
@@ -4721,11 +4721,10 @@ usage (int status)
fputs (_("\
List information about the FILEs (the current directory by default).\n\
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n\
-\n\
-"), stdout);
- fputs (_("\
-Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
+
+ emit_mandatory_arg_note ();
+
fputs (_("\
-a, --all do not ignore entries starting with .\n\
-A, --almost-all do not list implied . and ..\n\