Fossil SCM

Allow backslash in filenames on UNIX (experiment)

jan.nijtmans 2012-12-20 22:59 UTC allow-backslash-on-unix
Commit c3d74f4f633e4b28adb4e18baaee78a6482ed4c8
1 file changed +4 -4
+4 -4
--- src/file.c
+++ src/file.c
@@ -523,12 +523,10 @@
523523
/* Unicode character in the range U+D800 - U+DFFF are for
524524
* surrogate pairs, they shouldn't occur in filenames. */
525525
return 0;
526526
}
527527
}
528
- }else if( c=='\\' ){
529
- return 0;
530528
}
531529
}
532530
if( c=='/' ){
533531
if( z[i+1]=='/' ) return 0;
534532
if( z[i+1]=='.' ){
@@ -769,12 +767,12 @@
769767
}
770768
771769
/*
772770
** Return TRUE if the given filename is canonical.
773771
**
774
-** Canonical names are full pathnames using "/" not "\" and which
775
-** contain no "/./" or "/../" terms.
772
+** Canonical names are full pathnames using "/" not "\" (on Windows)
773
+** and which contain no "/./" or "/../" terms.
776774
*/
777775
int file_is_canonical(const char *z){
778776
int i;
779777
if( z[0]!='/'
780778
#if defined(_WIN32)
@@ -781,11 +779,13 @@
781779
&& (z[0]==0 || z[1]!=':' || z[2]!='/')
782780
#endif
783781
) return 0;
784782
785783
for(i=0; z[i]; i++){
784
+#if defined(_WIN32)
786785
if( z[i]=='\\' ) return 0;
786
+#endif
787787
if( z[i]=='/' ){
788788
if( z[i+1]=='.' ){
789789
if( z[i+2]=='/' || z[i+2]==0 ) return 0;
790790
if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
791791
}
792792
--- src/file.c
+++ src/file.c
@@ -523,12 +523,10 @@
523 /* Unicode character in the range U+D800 - U+DFFF are for
524 * surrogate pairs, they shouldn't occur in filenames. */
525 return 0;
526 }
527 }
528 }else if( c=='\\' ){
529 return 0;
530 }
531 }
532 if( c=='/' ){
533 if( z[i+1]=='/' ) return 0;
534 if( z[i+1]=='.' ){
@@ -769,12 +767,12 @@
769 }
770
771 /*
772 ** Return TRUE if the given filename is canonical.
773 **
774 ** Canonical names are full pathnames using "/" not "\" and which
775 ** contain no "/./" or "/../" terms.
776 */
777 int file_is_canonical(const char *z){
778 int i;
779 if( z[0]!='/'
780 #if defined(_WIN32)
@@ -781,11 +779,13 @@
781 && (z[0]==0 || z[1]!=':' || z[2]!='/')
782 #endif
783 ) return 0;
784
785 for(i=0; z[i]; i++){
 
786 if( z[i]=='\\' ) return 0;
 
787 if( z[i]=='/' ){
788 if( z[i+1]=='.' ){
789 if( z[i+2]=='/' || z[i+2]==0 ) return 0;
790 if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
791 }
792
--- src/file.c
+++ src/file.c
@@ -523,12 +523,10 @@
523 /* Unicode character in the range U+D800 - U+DFFF are for
524 * surrogate pairs, they shouldn't occur in filenames. */
525 return 0;
526 }
527 }
 
 
528 }
529 }
530 if( c=='/' ){
531 if( z[i+1]=='/' ) return 0;
532 if( z[i+1]=='.' ){
@@ -769,12 +767,12 @@
767 }
768
769 /*
770 ** Return TRUE if the given filename is canonical.
771 **
772 ** Canonical names are full pathnames using "/" not "\" (on Windows)
773 ** and which contain no "/./" or "/../" terms.
774 */
775 int file_is_canonical(const char *z){
776 int i;
777 if( z[0]!='/'
778 #if defined(_WIN32)
@@ -781,11 +779,13 @@
779 && (z[0]==0 || z[1]!=':' || z[2]!='/')
780 #endif
781 ) return 0;
782
783 for(i=0; z[i]; i++){
784 #if defined(_WIN32)
785 if( z[i]=='\\' ) return 0;
786 #endif
787 if( z[i]=='/' ){
788 if( z[i+1]=='.' ){
789 if( z[i+2]=='/' || z[i+2]==0 ) return 0;
790 if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
791 }
792

Keyboard Shortcuts

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