[Top][All Lists]

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

Re: [PATCH] md5sum, sha*sum: only escape file names containing newlines

From: Jim Meyering
Subject: Re: [PATCH] md5sum, sha*sum: only escape file names containing newlines
Date: Fri, 1 Nov 2013 09:44:20 -0700

On Fri, Nov 1, 2013 at 9:29 AM, Pádraig Brady <address@hidden> wrote:
> This should be fully backwards and forwards compatible with previous
> escaping, since we'll never have a file name at the start of a line,
> thus '\' at the start of a line always means the file name is escaped.
> * src/md5sum.c (main): Only escape the output (with a leading '\')
> when a '\n' character is present in the file name.  There is no
> need to do this in the more likely case where a '\' character is
> present in the name.  Note this is faster also as we only scan the
> file name once (for '\n') rather than four times.
> (print_filename): Use the predetermined boolean as to whether to
> escape or not, so that in the common case we can output the
> file name directly, rather than inspecting each character.
> * tests/misc/ Adjust accordingly.
> * tests/misc/ Likewise.

Good idea.  Thanks!  I had to read through it twice to realize that
when escaping is done, backslash is still escaped.  It's just
that the trigger is now the presence of newline, not backslash.

If you say something like the following, it might be easier to understand:

Escape the output (marking with a leading '\' and backslash-escaping
both '\' and '\n') only when the file name contains a newline.
Before, we would do that for a file name containing either newline or backslash.

This probably deserves a NEWS entry, since it is user-visible.

reply via email to

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