[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] fts: reduce two or more trailing spaces to just one, usually
From: |
Eric Blake |
Subject: |
Re: [PATCH] fts: reduce two or more trailing spaces to just one, usually |
Date: |
Tue, 04 Sep 2012 04:57:27 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 |
On 09/04/2012 04:24 AM, Jim Meyering wrote:
>>From 99376a06eed07ded17919384cf1d633e43ad1bd0 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <address@hidden>
> Date: Tue, 4 Sep 2012 11:36:38 +0200
> Subject: [PATCH] fts: reduce two or more trailing spaces to just one, usually
>
> * lib/fts.c (fts_open): Upon initialization, if a name ends in two
> or more slashes, trim all but the final one. But if a name consists
> solely of two or more slashes, reduce it to "//", not to "/".
>
For two slashes, that is correct. But trimming "///" to "//" is a
violation of POSIX and fails on cygwin; "///" must be the same as "/",
not "///".
> +++ b/lib/fts.c
> @@ -487,6 +487,14 @@ fts_open (char * const *argv,
> for (root = NULL, nitems = 0; *argv != NULL; ++argv, ++nitems) {
> /* *Do* allow zero-length file names. */
> size_t len = strlen(*argv);
> +
> + /* If there are two or more trailing slashes, trim all but
> one,
> + but don't change "//" to "/". */
> + char const *v = *argv;
> + if (2 < len && v[len - 1] == '/')
> + while (2 < len && v[len - 2] == '/')
> + --len;
In other words, this code is incorrect.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature