Fossil SCM
Bug-fix in file_relative_name(): If filename is a super-directory of the current directory then the final slash is missing. Test-case: "fossil test-relative-name /home/ --slash". Result "../../.." should be "../../../". This bugfix is needed for my next commit.
Commit
add752453332cdc3bc72ef19be3ce8b491dbdb2d
Parent
e6ced76797733d2…
1 file changed
+7
-3
+7
-3
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -877,21 +877,25 @@ | ||
| 877 | 877 | while( zPath[i] && fossil_tolower(zPwd[i])==fossil_tolower(zPath[i]) ) i++; |
| 878 | 878 | #else |
| 879 | 879 | while( zPath[i] && zPwd[i]==zPath[i] ) i++; |
| 880 | 880 | #endif |
| 881 | 881 | if( zPath[i]==0 ){ |
| 882 | - blob_reset(pOut); | |
| 882 | + memcpy(&tmp, pOut, sizeof(tmp)); | |
| 883 | 883 | if( zPwd[i]==0 ){ |
| 884 | - blob_append(pOut, ".", 1); | |
| 884 | + blob_set(pOut, "."); | |
| 885 | 885 | }else{ |
| 886 | - blob_append(pOut, "..", 2); | |
| 886 | + blob_set(pOut, ".."); | |
| 887 | 887 | for(j=i+1; zPwd[j]; j++){ |
| 888 | 888 | if( zPwd[j]=='/' ){ |
| 889 | 889 | blob_append(pOut, "/..", 3); |
| 890 | 890 | } |
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | + if( slash && i>0 && zPath[strlen(zPath)-1]=='/'){ | |
| 894 | + blob_append(pOut, "/", 1); | |
| 895 | + } | |
| 896 | + blob_reset(&tmp); | |
| 893 | 897 | return; |
| 894 | 898 | } |
| 895 | 899 | if( zPwd[i]==0 && zPath[i]=='/' ){ |
| 896 | 900 | memcpy(&tmp, pOut, sizeof(tmp)); |
| 897 | 901 | blob_set(pOut, "./"); |
| 898 | 902 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -877,21 +877,25 @@ | |
| 877 | while( zPath[i] && fossil_tolower(zPwd[i])==fossil_tolower(zPath[i]) ) i++; |
| 878 | #else |
| 879 | while( zPath[i] && zPwd[i]==zPath[i] ) i++; |
| 880 | #endif |
| 881 | if( zPath[i]==0 ){ |
| 882 | blob_reset(pOut); |
| 883 | if( zPwd[i]==0 ){ |
| 884 | blob_append(pOut, ".", 1); |
| 885 | }else{ |
| 886 | blob_append(pOut, "..", 2); |
| 887 | for(j=i+1; zPwd[j]; j++){ |
| 888 | if( zPwd[j]=='/' ){ |
| 889 | blob_append(pOut, "/..", 3); |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | return; |
| 894 | } |
| 895 | if( zPwd[i]==0 && zPath[i]=='/' ){ |
| 896 | memcpy(&tmp, pOut, sizeof(tmp)); |
| 897 | blob_set(pOut, "./"); |
| 898 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -877,21 +877,25 @@ | |
| 877 | while( zPath[i] && fossil_tolower(zPwd[i])==fossil_tolower(zPath[i]) ) i++; |
| 878 | #else |
| 879 | while( zPath[i] && zPwd[i]==zPath[i] ) i++; |
| 880 | #endif |
| 881 | if( zPath[i]==0 ){ |
| 882 | memcpy(&tmp, pOut, sizeof(tmp)); |
| 883 | if( zPwd[i]==0 ){ |
| 884 | blob_set(pOut, "."); |
| 885 | }else{ |
| 886 | blob_set(pOut, ".."); |
| 887 | for(j=i+1; zPwd[j]; j++){ |
| 888 | if( zPwd[j]=='/' ){ |
| 889 | blob_append(pOut, "/..", 3); |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | if( slash && i>0 && zPath[strlen(zPath)-1]=='/'){ |
| 894 | blob_append(pOut, "/", 1); |
| 895 | } |
| 896 | blob_reset(&tmp); |
| 897 | return; |
| 898 | } |
| 899 | if( zPwd[i]==0 && zPath[i]=='/' ){ |
| 900 | memcpy(&tmp, pOut, sizeof(tmp)); |
| 901 | blob_set(pOut, "./"); |
| 902 |