git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] mingw: allow absolute paths without drive prefix

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 11, 2018, 11:25 UTC
Message-ID
<nycvar.QRO.7.76.6.1812111134250.43@tvgsbejvaqbjf.bet>
In-Reply-To
<11b17e5d-e843-463b-77da-263e8e3b7598@kdbg.org>
Hi Hannes,
On Mon, 10 Dec 2018, Johannes Sixt wrote:
Show 21 quoted lines
> > diff --git a/compat/mingw.c b/compat/mingw.c
> > index 34b3880b29..4d009901d8 100644
> > --- a/compat/mingw.c
> > +++ b/compat/mingw.c
> > @@ -928,11 +928,19 @@ unsigned int sleep (unsigned int seconds)
> >   char *mingw_mktemp(char *template)
> >   {
> >   	wchar_t wtemplate[MAX_PATH];
> > +	int offset = 0;
> > +
> >    if (xutftowcs_path(wtemplate, template) < 0)
> >   		return NULL;
> > +
> > +	if (is_dir_sep(template[0]) && !is_dir_sep(template[1]) &&
> > +	    iswalpha(wtemplate[0]) && wtemplate[1] == L':') {
> > +		/* We have an absolute path missing the drive prefix */
> 
> This comment is true for the source part, template, but I can't find
> where the destination, wtemplate, suddenly gets the drive prefix. As far
> as I can see, xutftowcs_path() just does a plain textual conversion
> without any interpretation of the text as path. Can you explain it?

It is legal on Windows for such a path to lack the drive prefix, also in the wide-character version. So the explanation is: even `wtemplate` won't get the drive prefix. It does not need to.

> BTW, iswalpha() is not restricted to ASCII letters, I would rewrite it
> as (wtemplate[0] <= 127 && isalpha(wtemplate[0]).
Very good point! Will fix.

Thanks, Dscho

Previous: Johannes SixtNext: Johannes Sixt
Message 4 of 10 in “mingw: support absolute paths without a drive prefix”
  1. 0/2 mingw: support absolute paths without a drive prefixJohannes Schindelin via GitGitGadget, Dec 10, 2018
  2. 2/2 mingw: allow absolute paths without drive prefixJohannes Schindelin via GitGitGadget, Dec 10, 2018
  3. Johannes SixtDec 10, 2018
  4. Johannes SchindelinDec 11, 2018
  5. Johannes SixtDec 11, 2018
  6. Junio C HamanoDec 13, 2018
  7. Johannes SixtDec 13, 2018
  8. Johannes SixtDec 13, 2018
  9. Johannes SchindelinDec 14, 2018
  10. 1/2 mingw: demonstrate a problem with certain absolute pathsJohannes Schindelin via GitGitGadget, Dec 10, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.