On Fri, Aug 31, 2018 at 09:43:03AM +0200, Martijn van Duren wrote:
> part 3
> 
> OK?

ok stsp@

> 
> martijn@
> 
> diff --git cp.c cp.c
> index fbf924c..2ccef08 100644
> --- cp.c
> +++ cp.c
> @@ -434,7 +434,7 @@ copy(char *argv[], enum op type, int fts_options)
>                                   !fts_dne(curr))) == 1)
>                                       rval = 1;
>                       } else {
> -                             cval = copy_file(curr, fts_dne(curr));
> +                             cval = copy_file(curr, !fts_dne(curr));
>                               if (cval == 1)
>                                       rval = 1;
>                       }
> @@ -449,7 +449,7 @@ copy(char *argv[], enum op type, int fts_options)
>                                   !fts_dne(curr))) == 1)
>                                       rval = 1;
>                       } else {
> -                             cval = copy_file(curr, fts_dne(curr));
> +                             cval = copy_file(curr, !fts_dne(curr));
>                               if (cval == 1)
>                                       rval = 1;
>                       }
> @@ -462,7 +462,7 @@ copy(char *argv[], enum op type, int fts_options)
>                       warnc(EOPNOTSUPP, "%s", curr->fts_path);
>                       break;
>               default:
> -                     if ((cval = copy_file(curr, fts_dne(curr))) == 1)
> +                     if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
>                               rval = 1;
>                       if (!cval && vflag)
>                               (void)fprintf(stdout, "%s -> %s\n",
> diff --git utils.c utils.c
> index 4a9219c..0f44bbf 100644
> --- utils.c
> +++ utils.c
> @@ -50,7 +50,7 @@
>  int copy_overwrite(void);
>  
>  int
> -copy_file(FTSENT *entp, int dne)
> +copy_file(FTSENT *entp, int exists)
>  {
>       static char *buf;
>       static char *zeroes;
> @@ -82,7 +82,7 @@ copy_file(FTSENT *entp, int dne)
>        * In -f (force) mode, we always unlink the destination first
>        * if it exists.  Note that -i and -f are mutually exclusive.
>        */
> -     if (!dne && fflag)
> +     if (exists && fflag)
>               (void)unlink(to.p_path);
>  
>       /*
> @@ -92,7 +92,7 @@ copy_file(FTSENT *entp, int dne)
>        * other choice is 666 or'ed with the execute bits on the from file
>        * modified by the umask.)
>        */
> -     if (!dne && !fflag) {
> +     if (exists && !fflag) {
>               if (!copy_overwrite()) {
>                       (void)close(from_fd);
>                       return 2;
> @@ -174,7 +174,7 @@ copy_file(FTSENT *entp, int dne)
>        */
>  #define      RETAINBITS \
>       (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
> -     if (!pflag && dne &&
> +     if (!pflag && !exists &&
>           fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) {
>               if (fstat(to_fd, &to_stat)) {
>                       warn("%s", to.p_path);
> 

Reply via email to