From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 1/2] mingw.h: permit arguments with side effects for is_dir_sep
Date: Mon, 22 May 2017 13:52:58 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.21.1.1705221349200.3610@virtualbox> (raw)
In-Reply-To: <69bafb7c9e08ba837a9b92573bef165a62c5bf92.1495261020.git.j6t@kdbg.org>
Hi Hannes,
On Sat, 20 May 2017, Johannes Sixt wrote:
> The implementation of is_dir_sep in git-compat-util.h uses an inline
> function. Use one also for the implementation in compat/mingw.h to support
> non-trivial argument expressions.
>
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
I was a bit confused by the oneline. Maybe something like
mingw.h: avoid side effects with is_dir_sep()'s argument
Taking git-compat-util.h's cue (which uses an inline function
to back is_dir_sep()), let's use an inline function to back
also the Windows version of is_dir_sep(); This avoids problems
when calling the function with arguments that do more than just
provide a single character, e.g. incrementing a pointer. Example:
is_dir_sep(*(p++))
> diff --git a/compat/mingw.h b/compat/mingw.h
> index cdc112526a..5e8447019b 100644
> --- a/compat/mingw.h
> +++ b/compat/mingw.h
> @@ -398,7 +398,11 @@ HANDLE winansi_get_osfhandle(int fd);
> (isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
> int mingw_skip_dos_drive_prefix(char **path);
> #define skip_dos_drive_prefix mingw_skip_dos_drive_prefix
> -#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
> +static inline int mingw_is_dir_sep(int c)
> +{
> + return c == '/' || c == '\\';
> +}
> +#define is_dir_sep mingw_is_dir_sep
> static inline char *mingw_find_last_dir_sep(const char *path)
> {
> char *ret = NULL;
The patch is very good, of course.
ACK,
Dscho
next prev parent reply other threads:[~2017-05-22 11:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-20 6:28 [PATCH 0/2] Fix warnings on access of a remote with Windows paths Johannes Sixt
2017-05-20 6:28 ` [PATCH 1/2] mingw.h: permit arguments with side effects for is_dir_sep Johannes Sixt
2017-05-22 11:52 ` Johannes Schindelin [this message]
2017-05-20 6:28 ` [PATCH 2/2] Windows: do not treat a path with backslashes as a remote's nick name Johannes Sixt
2017-05-22 11:56 ` Johannes Schindelin
2017-05-22 11:59 ` [PATCH 0/2] Fix warnings on access of a remote with Windows paths Johannes Schindelin
2017-05-22 16:36 ` Johannes Sixt
2017-05-23 10:53 ` Johannes Schindelin
2017-05-23 18:39 ` Johannes Sixt
2017-05-22 12:38 ` stefan.naewe
2017-05-22 14:01 ` Johannes Schindelin
2017-05-22 16:28 ` Johannes Sixt
2017-05-23 10:46 ` Johannes Schindelin
2017-05-23 22:08 ` Junio C Hamano
2017-05-24 5:45 ` Johannes Sixt
2017-05-25 12:00 ` [PATCH v3 2/2] Windows: do not treat a path with backslashes as a remote's nick name Johannes Sixt
2017-05-25 23:16 ` Junio C Hamano
2017-05-22 18:58 ` [PATCH v2 1/2] mingw.h: permit arguments with side effects for is_dir_sep Johannes Sixt
2017-05-22 19:01 ` [PATCH v2 2/2] Windows: do not treat a path with backslashes as a remote's nick name Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.21.1.1705221349200.3610@virtualbox \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).