Re: [PATCH] Use strdup in dd to avoid changing argv elements
From:
Jim Meyering
Subject:
Re: [PATCH] Use strdup in dd to avoid changing argv elements
Date:
Wed, 30 Jan 2008 07:35:22 +0100
Paul Eggert <address@hidden> wrote:
> As Andreas points out, there's no need to change dd here; it conforms
> to POSIX. However, as a nicety, it's better not to muck with argv,
> all other things being equal. Here's a patch to do this without
> invoking malloc, so we don't need to worry about exhausting storage.
> This patch causes my copy of the 'dd' executable to be 0.4% smaller
> (Debian stable x86, GCC 4.2.2), so that's a small win too.
>
> This patch does cause dd to issue a different diagnostic in one case.
> Currently, "dd abc=def" says this:
>
> dd: unrecognized operand `abc'=`def'
>
> The patch causes "dd abc=def" to say this instead:
>
> dd: unrecognized operand `abc=def'
>
> I prefer the new behavior, though I don't think the change is
> important either way.
>
> 2008-01-29 Paul Eggert <address@hidden>
>
> Don't modify argv in dd.
> * src/dd.c (operand_is): New function.
> (scanargs): Use it so that we don't need to modify argv, as a nicety.
> Problem reported by Adam Goode in
> <http://lists.gnu.org/archive/html/bug-coreutils/2008-01/msg00264.html>.
Nice. Applied.
Thanks!