Re: [PATCH] help.c: strip suffix only if the STRIP_EXTENSION defined

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

 



On Wed, Mar 16, 2016 at 9:27 PM, Alexander Kuleshov
<kuleshovmail@xxxxxxxxx> wrote:
> We stripping extension in the list_commands_in_dir() to get
> commands without '.exe' suffix. Let's do it only if STRIP_EXTENSION
> is defined to not spend time for unnecessary strip_suffix() call in
> this case.

Unless the time saving is significant, I'm against this change. It
makes it harder to spot compile bugs in #ifdef'd code that's only
active on Windows (imagine somebody renames "ent" or change its type).
If you can do something like strip_extension() in git.c, it's better.
Or maybe just refactor that function a bit and share it with help.c

> Signed-off-by: Alexander Kuleshov <kuleshovmail@xxxxxxxxx>
> ---
>  help.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/help.c b/help.c
> index 19328ea..c865991 100644
> --- a/help.c
> +++ b/help.c
> @@ -153,8 +153,9 @@ static void list_commands_in_dir(struct cmdnames *cmds,
>                         continue;
>
>                 entlen = strlen(ent);
> -               strip_suffix(ent, ".exe", &entlen);
> -
> +#ifdef STRIP_EXTENSION
> +               strip_suffix(ent, STRIP_EXTENSION, &entlen);
> +#endif
>                 add_cmdname(cmds, ent, entlen);
>         }
>         closedir(dir);
> --
> 2.8.0.rc2.216.g1477fb2.dirty
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]