[PATCH 2 of 4] Consider that the last '\' character might be a part of MBCS
Matt Mackall
mpm at selenic.com
Thu Jul 9 17:23:23 CDT 2009
On Thu, 2009-07-09 at 13:57 +0000, Shun-ichi Goto wrote:
> # HG changeset patch
> # User Shun-ichi GOTO <shunichi.goto at gmail.com>
> # Date 1247143158 -32400
> # Node ID aaafb9723679d3ba5e010347ac276a9037408d47
> # Parent 1ea9bcb2d34907b0de2bba4cb2ed319a5f32b829
> Consider that the last '\' character might be a part of MBCS.
> diff -r 1ea9bcb2d349 -r aaafb9723679 mercurial/osutil.c
> --- a/mercurial/osutil.c Wed Jul 08 09:48:48 2009 -0400
> +++ b/mercurial/osutil.c Thu Jul 09 21:39:18 2009 +0900
> @@ -200,6 +200,20 @@
> char c = path[plen-1];
> if (c != ':' && c != '/' && c != '\\')
> pattern[plen++] = '\\';
> + else if (c == '\\') {
> + /* Decide the last '\' character is a part of multi byte
> + character or appended path separator by converting to wide
> + character string. */
> + pattern[--plen] = '\0';
> + if (MultiByteToWideChar(CP_ACP,
> + MB_PRECOMPOSED | MB_ERR_INVALID_CHARS,
> + pattern, plen,
> + NULL, 0) == 0) {
> + /* the last '\' is a part of MBCS, so recover it. */
> + pattern[plen++] = '\\';
> + }
> + pattern[plen++] = '\\';
> + }
> }
> strcpy(pattern + plen, "*");
Yuck! Not only is this not code we'd normally want to run, looks to me
like this could have unintended effects when we're running without
win32mbcs. We can't have a hack like this outside of the extension. You
can either bypass the osutil.c function or try to fix up the results
after the fact.
--
http://selenic.com : development and support for Mercurial and Linux
More information about the Mercurial-devel
mailing list