summaryrefslogtreecommitdiff
path: root/dmake/path.c
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2007-07-03 10:29:59 +0000
committerRüdiger Timm <rt@openoffice.org>2007-07-03 10:29:59 +0000
commit04db1cda4e0b153851ad630870335805255c4c13 (patch)
tree4f5a1c2369285d3efe7419deddb2d68d487d9b04 /dmake/path.c
parent6d37867654a6c54c8bdc1db87fd5355d80d045fd (diff)
INTEGRATION: CWS dmake49 (1.3.2); FILE MERGED
2007/06/20 22:26:11 vq 1.3.2.1: #i74700# Add a new special macro OOODMAKEMODE that is used to toggle OOo build specific behavior. If OOODMAKEMODE is set (i.e. it begins with y) the leading ./ of a path will no longer be removed. This patch also fixes iz78061.
Diffstat (limited to 'dmake/path.c')
-rw-r--r--dmake/path.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/dmake/path.c b/dmake/path.c
index b37938f0dbdc..4c6bf6ac2d4c 100644
--- a/dmake/path.c
+++ b/dmake/path.c
@@ -1,4 +1,4 @@
-/* RCS $Id: path.c,v 1.3 2007-06-12 06:06:38 obo Exp $
+/* RCS $Id: path.c,v 1.4 2007-07-03 11:29:59 rt Exp $
--
-- SYNOPSIS
-- Pathname manipulation code
@@ -166,12 +166,14 @@ char *path;
register char *p;
register char *q;
char *tpath;
+ int hasdriveletter = 0;
+
+ DB_ENTER( "Clean_path" );
/* Skip the root part. */
tpath=path;
+
#ifdef HAVE_DRIVE_LETTERS
- if( *tpath && tpath[1] == ':' && isalpha(*tpath) )
- tpath+=2;
/* Change all occurences from DirBrkStr to *DirSepStr. */
#if __CYGWIN__
@@ -181,7 +183,28 @@ char *path;
for( q = tpath; (q = strchr(q, '/')) != NIL(char); )
*q = *DirSepStr;
#endif
+ /* The following dosn't trigger often because _normalize_path() uses
+ * a cygwin function and bypasses Clean_path() if it encounters a path
+ * with a drive letter. */
+ if( *tpath && tpath[1] == ':' && isalpha(*tpath) ) {
+ hasdriveletter = 1;
+ tpath+=2;
+ if( *tpath != *DirSepStr )
+ Warning("Malformed DOS path %s", path);
+ }
+
#endif
+
+ /* Collapse > 2 ( > 1 if its an absolute DOS path ) into one slash.
+ * Keep // as it is reserved in posix. */
+ q = tpath;
+ for( ; *q == *DirSepStr ; ++q )
+ ;
+ if( q - tpath > 2 - hasdriveletter ) {
+ strcpy(tpath+1, q);
+ }
+
+ /* Set tpath after leading slash / drive letter. */
for( ; *tpath == *DirSepStr ; ++tpath )
;
q = tpath;
@@ -204,8 +227,9 @@ char *path;
continue;
}
- /* Remove './' */
- if ( p-q == 1 && *q == '.' ) {
+ /* Remove './'. If OOODMAKEMODE is set do this only if it is not at
+ * the start of the path. */
+ if ( p-q == 1 && *q == '.' && (q != path || !STOBOOL(OOoDmMode)) ) {
strcpy(q,p+1);
q = tpath;
continue;
@@ -230,6 +254,7 @@ char *path;
q = p+1;
}
- DB_PRINT( "path", ("path: %s", path ));
- return;
+ DB_PRINT( "path", ("Cleaned path: %s", path ));
+
+ DB_VOID_RETURN;
}