Fossil SCM

Fix file_simplify_name and file_is_absolute_path for cygwin

jan.nijtmans 2013-01-27 21:56 UTC ticket-d17d6e5b17
Commit b293b744db4fc5cb37e4e654f5882c866fe28910
1 file changed +6 -4
+6 -4
--- src/file.c
+++ src/file.c
@@ -577,11 +577,11 @@
577577
}
578578
579579
/*
580580
** Simplify a filename by
581581
**
582
-** * Convert all \ into / on windows
582
+** * Convert all \ into / on windows and cygwin
583583
** * removing any trailing and duplicate /
584584
** * removing /./
585585
** * removing /A/../
586586
**
587587
** Changes are made in-place. Return the new name length.
@@ -590,12 +590,12 @@
590590
*/
591591
int file_simplify_name(char *z, int n, int slash){
592592
int i, j;
593593
if( n<0 ) n = strlen(z);
594594
595
- /* On windows convert all \ characters to / */
596
-#if defined(_WIN32)
595
+ /* On windows/cygwin convert all \ characters to / */
596
+#if defined(_WIN32) || defined(__CYGWIN__)
597597
for(i=0; i<n; i++){
598598
if( z[i]=='\\' ) z[i] = '/';
599599
}
600600
#endif
601601
@@ -702,11 +702,13 @@
702702
** Return true if zPath is an absolute pathname. Return false
703703
** if it is relative.
704704
*/
705705
int file_is_absolute_path(const char *zPath){
706706
if( zPath[0]=='/'
707
-#if defined(_WIN32)
707
+#if defined(__CYGWIN__)
708
+ || zPath[0]=='\\'
709
+#elif defined(_WIN32)
708710
|| zPath[0]=='\\'
709711
|| (strlen(zPath)>3 && zPath[1]==':'
710712
&& (zPath[2]=='\\' || zPath[2]=='/'))
711713
#endif
712714
){
713715
--- src/file.c
+++ src/file.c
@@ -577,11 +577,11 @@
577 }
578
579 /*
580 ** Simplify a filename by
581 **
582 ** * Convert all \ into / on windows
583 ** * removing any trailing and duplicate /
584 ** * removing /./
585 ** * removing /A/../
586 **
587 ** Changes are made in-place. Return the new name length.
@@ -590,12 +590,12 @@
590 */
591 int file_simplify_name(char *z, int n, int slash){
592 int i, j;
593 if( n<0 ) n = strlen(z);
594
595 /* On windows convert all \ characters to / */
596 #if defined(_WIN32)
597 for(i=0; i<n; i++){
598 if( z[i]=='\\' ) z[i] = '/';
599 }
600 #endif
601
@@ -702,11 +702,13 @@
702 ** Return true if zPath is an absolute pathname. Return false
703 ** if it is relative.
704 */
705 int file_is_absolute_path(const char *zPath){
706 if( zPath[0]=='/'
707 #if defined(_WIN32)
 
 
708 || zPath[0]=='\\'
709 || (strlen(zPath)>3 && zPath[1]==':'
710 && (zPath[2]=='\\' || zPath[2]=='/'))
711 #endif
712 ){
713
--- src/file.c
+++ src/file.c
@@ -577,11 +577,11 @@
577 }
578
579 /*
580 ** Simplify a filename by
581 **
582 ** * Convert all \ into / on windows and cygwin
583 ** * removing any trailing and duplicate /
584 ** * removing /./
585 ** * removing /A/../
586 **
587 ** Changes are made in-place. Return the new name length.
@@ -590,12 +590,12 @@
590 */
591 int file_simplify_name(char *z, int n, int slash){
592 int i, j;
593 if( n<0 ) n = strlen(z);
594
595 /* On windows/cygwin convert all \ characters to / */
596 #if defined(_WIN32) || defined(__CYGWIN__)
597 for(i=0; i<n; i++){
598 if( z[i]=='\\' ) z[i] = '/';
599 }
600 #endif
601
@@ -702,11 +702,13 @@
702 ** Return true if zPath is an absolute pathname. Return false
703 ** if it is relative.
704 */
705 int file_is_absolute_path(const char *zPath){
706 if( zPath[0]=='/'
707 #if defined(__CYGWIN__)
708 || zPath[0]=='\\'
709 #elif defined(_WIN32)
710 || zPath[0]=='\\'
711 || (strlen(zPath)>3 && zPath[1]==':'
712 && (zPath[2]=='\\' || zPath[2]=='/'))
713 #endif
714 ){
715

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button