[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: make check under Cygwin
From: |
Pavel Fedin |
Subject: |
RE: make check under Cygwin |
Date: |
Thu, 26 Sep 2013 10:47:15 +0400 |
Hello
> I just don't like the way you suggested to fix that.
> Maintaining 2 separate branches for this, and a configure-time test on
> top of that, is not my idea of a clean and elegant fix.
You can do without configure test if you want. You could just have
something like this in the code:
--- cut ---
#ifdef _WIN32
#define NATIVE_DOS_PATHS 1
#endif
#ifdef __MSDOS__
#define NATIVE_DOS_PATHS 1
#endif
--- cut ---
But i suggested that this can be unreliable and may lie in some exotic
cases about which i don't know.
> 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.
Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia