Fossil SCM
Fix file_simplify_name and file_is_absolute_path for cygwin
Commit
b293b744db4fc5cb37e4e654f5882c866fe28910
Parent
8df9d37834241ea…
1 file changed
+6
-4
+6
-4
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -577,11 +577,11 @@ | ||
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | /* |
| 580 | 580 | ** Simplify a filename by |
| 581 | 581 | ** |
| 582 | -** * Convert all \ into / on windows | |
| 582 | +** * Convert all \ into / on windows and cygwin | |
| 583 | 583 | ** * removing any trailing and duplicate / |
| 584 | 584 | ** * removing /./ |
| 585 | 585 | ** * removing /A/../ |
| 586 | 586 | ** |
| 587 | 587 | ** Changes are made in-place. Return the new name length. |
| @@ -590,12 +590,12 @@ | ||
| 590 | 590 | */ |
| 591 | 591 | int file_simplify_name(char *z, int n, int slash){ |
| 592 | 592 | int i, j; |
| 593 | 593 | if( n<0 ) n = strlen(z); |
| 594 | 594 | |
| 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__) | |
| 597 | 597 | for(i=0; i<n; i++){ |
| 598 | 598 | if( z[i]=='\\' ) z[i] = '/'; |
| 599 | 599 | } |
| 600 | 600 | #endif |
| 601 | 601 | |
| @@ -702,11 +702,13 @@ | ||
| 702 | 702 | ** Return true if zPath is an absolute pathname. Return false |
| 703 | 703 | ** if it is relative. |
| 704 | 704 | */ |
| 705 | 705 | int file_is_absolute_path(const char *zPath){ |
| 706 | 706 | if( zPath[0]=='/' |
| 707 | -#if defined(_WIN32) | |
| 707 | +#if defined(__CYGWIN__) | |
| 708 | + || zPath[0]=='\\' | |
| 709 | +#elif defined(_WIN32) | |
| 708 | 710 | || zPath[0]=='\\' |
| 709 | 711 | || (strlen(zPath)>3 && zPath[1]==':' |
| 710 | 712 | && (zPath[2]=='\\' || zPath[2]=='/')) |
| 711 | 713 | #endif |
| 712 | 714 | ){ |
| 713 | 715 |
| --- 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 |