bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coreutils-5.92 - dd skip option completely broken


From: Theodoros V. Kalamatianos
Subject: Re: coreutils-5.92 - dd skip option completely broken
Date: Mon, 31 Oct 2005 10:05:14 +0200 (EET)

On Mon, 31 Oct 2005, Theodoros V. Kalamatianos wrote:

It seems that it just reads and drops one more record than it should.

I have verified with `wc' that the characters are indeed dropped end not e.g. replaced with a null. I'll see if I can trace this bug, but it may take some time.

Ok, maybe not so much time :-) The following patch should fix this:

# diff -uNr dd.c.orig dd.c
--- dd.c.orig   2005-10-01 08:54:57.000000000 +0300
+++ dd.c        2005-10-31 09:58:00.000000000 +0200
@@ -1167,7 +1167,7 @@
          if (fdesc == STDIN_FILENO)
            advance_input_offset (nread);
        }
-      while (records-- != 0);
+      while (--records != 0);

       return records;
     }

Note that in records-- the variable is decreased _after_ it's used in the comparison, causing one additional loop iteration. By changing that to --records we avoid this.

Regards,

Theodoros Kalamatianos




reply via email to

[Prev in Thread] Current Thread [Next in Thread]