[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
minor code cleanup from using stat-macros.h
From: |
Paul Eggert |
Subject: |
minor code cleanup from using stat-macros.h |
Date: |
Mon, 28 Aug 2006 16:29:35 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
I installed this:
2006-08-28 Paul Eggert <address@hidden>
* src/copy.c (copy_internal): Don't test whether macros like
S_ISLNK are defined, since they're always defined now.
* src/cp.c (main): Likewise.
* src/ln.c (main): Likewise.
* src/ls.c (get_link_name, make_link_name): Likewise.
* src/mkfifo.c (usage): Likewise.
* src/who.c (S_IWGRP): Likewise.
Index: src/copy.c
===================================================================
RCS file: /fetish/cu/src/copy.c,v
retrieving revision 1.209
diff -p -u -r1.209 copy.c
--- src/copy.c 27 Aug 2006 19:41:04 -0000 1.209
+++ src/copy.c 28 Aug 2006 23:25:06 -0000
@@ -1558,7 +1558,6 @@ copy_internal (char const *src_name, cha
delayed_ok = false;
}
}
-#ifdef S_ISLNK
else if (x->symbolic_link)
{
preserve_metadata = false;
@@ -1597,7 +1596,6 @@ copy_internal (char const *src_name, cha
goto un_backup;
}
}
-#endif
else if (x->hard_link
#ifdef LINK_FOLLOWS_SYMLINKS
@@ -1632,9 +1630,7 @@ copy_internal (char const *src_name, cha
if (! copy_reg (src_name, dst_name, x, src_mode, &new_dst, &src_sb))
goto un_backup;
}
- else
-#ifdef S_ISFIFO
- if (S_ISFIFO (src_type))
+ else if (S_ISFIFO (src_type))
{
if (mkfifo (dst_name, src_mode))
{
@@ -1642,10 +1638,7 @@ copy_internal (char const *src_name, cha
goto un_backup;
}
}
- else
-#endif
- if (S_ISBLK (src_type) || S_ISCHR (src_type)
- || S_ISSOCK (src_type))
+ else if (S_ISBLK (src_type) || S_ISCHR (src_type) || S_ISSOCK (src_type))
{
if (mknod (dst_name, src_mode, src_sb.st_rdev))
{
@@ -1654,9 +1647,7 @@ copy_internal (char const *src_name, cha
goto un_backup;
}
}
- else
-#ifdef S_ISLNK
- if (S_ISLNK (src_type))
+ else if (S_ISLNK (src_type))
{
char *src_link_val = xreadlink (src_name, src_sb.st_size);
if (src_link_val == NULL)
@@ -1700,7 +1691,7 @@ copy_internal (char const *src_name, cha
{
/* Preserve the owner and group of the just-`copied'
symbolic link, if possible. */
-# if HAVE_LCHOWN
+#if HAVE_LCHOWN
if (lchown (dst_name, src_sb.st_uid, src_sb.st_gid) != 0
&& ! chown_failure_ok (x))
{
@@ -1708,16 +1699,15 @@ copy_internal (char const *src_name, cha
dst_name);
goto un_backup;
}
-# else
+#else
/* Can't preserve ownership of symlinks.
FIXME: maybe give a warning or even error for symlinks
in directories with the sticky bit set -- there, not
preserving owner/group is a potential security problem. */
-# endif
+#endif
}
}
else
-#endif
{
error (0, 0, _("%s has unknown file type"), quote (src_name));
goto un_backup;
Index: src/cp.c
===================================================================
RCS file: /fetish/cu/src/cp.c,v
retrieving revision 1.221
diff -p -u -r1.221 cp.c
--- src/cp.c 15 May 2006 20:19:02 -0000 1.221
+++ src/cp.c 28 Aug 2006 23:25:07 -0000
@@ -957,12 +957,7 @@ main (int argc, char **argv)
break;
case 's':
-#ifdef S_ISLNK
x.symbolic_link = true;
-#else
- error (EXIT_FAILURE, 0,
- _("symbolic links are not supported on this system"));
-#endif
break;
case 't':
Index: src/ln.c
===================================================================
RCS file: /fetish/cu/src/ln.c,v
retrieving revision 1.158
diff -p -u -r1.158 ln.c
--- src/ln.c 1 Jul 2006 07:04:52 -0000 1.158
+++ src/ln.c 28 Aug 2006 23:25:07 -0000
@@ -428,12 +428,7 @@ main (int argc, char **argv)
dereference_dest_dir_symlinks = false;
break;
case 's':
-#ifdef S_ISLNK
symbolic_link = true;
-#else
- error (EXIT_FAILURE, 0,
- _("symbolic links are not supported on this system"));
-#endif
break;
case 't':
if (target_directory)
Index: src/ls.c
===================================================================
RCS file: /fetish/cu/src/ls.c,v
retrieving revision 1.440
diff -p -u -r1.440 ls.c
--- src/ls.c 27 Aug 2006 19:34:28 -0000 1.440
+++ src/ls.c 28 Aug 2006 23:25:08 -0000
@@ -2760,9 +2760,6 @@ is_directory (const struct fileinfo *f)
return f->filetype == directory || f->filetype == arg_directory;
}
-
-#ifdef S_ISLNK
-
/* Put the name of the file that FILENAME is a symbolic link to
into the LINKNAME field of `f'. COMMAND_LINE_ARG indicates whether
FILENAME is a command-line argument. */
@@ -2805,7 +2802,6 @@ make_link_name (char const *name, char c
strcpy (linkbuf + bufsiz, linkname);
return linkbuf;
}
-#endif
/* Return true if the last component of NAME is `.' or `..'
This is so we don't try to recurse on `././././. ...' */
Index: src/mkfifo.c
===================================================================
RCS file: /fetish/cu/src/mkfifo.c,v
retrieving revision 1.82
diff -p -u -r1.82 mkfifo.c
--- src/mkfifo.c 17 Jul 2006 03:10:29 -0000 1.82
+++ src/mkfifo.c 28 Aug 2006 23:25:08 -0000
@@ -43,7 +43,6 @@ static struct option const longopts[] =
{NULL, 0, NULL, 0}
};
-#ifdef S_ISFIFO
void
usage (int status)
{
@@ -69,7 +68,6 @@ Mandatory arguments to long options are
}
exit (status);
}
-#endif
int
main (int argc, char **argv)
@@ -87,9 +85,6 @@ main (int argc, char **argv)
atexit (close_stdout);
-#ifndef S_ISFIFO
- error (EXIT_FAILURE, 0, _("fifo files not supported"));
-#else
while ((optc = getopt_long (argc, argv, "m:", longopts, NULL)) != -1)
{
switch (optc)
@@ -131,5 +126,4 @@ main (int argc, char **argv)
}
exit (exit_status);
-#endif
}
Index: src/who.c
===================================================================
RCS file: /fetish/cu/src/who.c,v
retrieving revision 1.112
diff -p -u -r1.112 who.c
--- src/who.c 15 Oct 2005 15:01:22 -0000 1.112
+++ src/who.c 28 Aug 2006 23:25:08 -0000
@@ -1,5 +1,5 @@
/* GNU's who.
- Copyright (C) 1992-2005 Free Software Foundation, Inc.
+ Copyright (C) 1992-2006 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
@@ -48,10 +48,6 @@
# define MAXHOSTNAMELEN 64
#endif
-#ifndef S_IWGRP
-# define S_IWGRP 020
-#endif
-
#ifdef RUN_LVL
# define UT_TYPE_RUN_LVL(U) UT_TYPE_EQ (U, RUN_LVL)
#else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- minor code cleanup from using stat-macros.h,
Paul Eggert <=