> From: Pavel Fedin <p.fe...@samsung.com> > Cc: bug-...@denis-excoffier.org, bug-make@gnu.org > Date: Thu, 26 Sep 2013 10:47:15 +0400 > > > There must be a better way, since the only difference between Posix and > Windows file > > names is the X: prefix of every absolute file name. > > Yes. But in certain cases (Cygwin and may be EMX) absolute file names can > take both forms. For example: > > 1. /foo/bar - absolute POSIX path. But NOT absolute on a pure Windows, would > be transformed to X:/foo/bar. > 2. C:/foo/bar - absolute Windows path, nonsense for POSIX. But still > perfectly valid on Cygwin. > 3. foo/bar - non-absolute path. Should be converted to absolute. > > Consequently, Cygwin version should recognize both (1) and (2) as absolute > paths. This is why i made two branches. The idea is: > > #ifdef HAVE_NATIVE_DOS_PATHS > > ... DOS absolute path recognition. Included into DOS, Windows and Cygwin > versions ... > > #endif > #ifndef NATIVE_DOS_PATHS > > ... POSIX absolute path recognition. Included into UNIX and Cygwin versions > ... > > #endif > > On Cygwin both branches should coexist, hence the original section: > --- cut --- > strncpy (apath, name, root_len); > apath[root_len] = '\0'; > dest = apath + root_len; > /* Get past the root, since we already copied it. */ > name += root_len; > --- cut --- > got duplicated. It just got a bit transformed for root_len = 1 (strncpy > turned into single assignment). > > Well, perhaps it's really possible to permute some parts in order to move > final: > --- cut --- > dest = apath + root_len; > name += root_len; > --- cut --- > out of #ifdef's... But, oops, you can screw up "if (DOS absolute) ... else > if (POSIX absolute) ... else (relative)" sequence. Perhaps does not worth > it. Actually when i made my implementation i took care about making the code > clear to read and understand since it can be tricky.
Please take a look at the change I made, it takes care of all those things at a price of only 5 changed lines. _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make