Fossil SCM

Fix the /dir webpages to that it treats folders whos names differ only in case as the same folder when case-sensitive is off.

drh 2012-04-13 22:42 trunk
Commit 4290a801a095aa84e3bf07d81612511cc909eb5c
+12
--- src/add.c
+++ src/add.c
@@ -373,10 +373,22 @@
373373
** "COLLATE nocase" if filenames are not case sensitive.
374374
*/
375375
const char *filename_collation(void){
376376
return filenames_are_case_sensitive() ? "" : "COLLATE nocase";
377377
}
378
+
379
+/*
380
+** Do a strncmp() operation which is either case-sensitive or not
381
+** depending on the setting of filenames_are_case_sensitive().
382
+*/
383
+int filenames_strncmp(const char *zA, const char *zB, int nByte){
384
+ if( filenames_are_case_sensitive() ){
385
+ return fossil_strncmp(zA,zB,nByte);
386
+ }else{
387
+ return fossil_strnicmp(zA,zB,nByte);
388
+ }
389
+}
378390
379391
/*
380392
** COMMAND: addremove
381393
**
382394
** Usage: %fossil addremove ?OPTIONS?
383395
--- src/add.c
+++ src/add.c
@@ -373,10 +373,22 @@
373 ** "COLLATE nocase" if filenames are not case sensitive.
374 */
375 const char *filename_collation(void){
376 return filenames_are_case_sensitive() ? "" : "COLLATE nocase";
377 }
 
 
 
 
 
 
 
 
 
 
 
 
378
379 /*
380 ** COMMAND: addremove
381 **
382 ** Usage: %fossil addremove ?OPTIONS?
383
--- src/add.c
+++ src/add.c
@@ -373,10 +373,22 @@
373 ** "COLLATE nocase" if filenames are not case sensitive.
374 */
375 const char *filename_collation(void){
376 return filenames_are_case_sensitive() ? "" : "COLLATE nocase";
377 }
378
379 /*
380 ** Do a strncmp() operation which is either case-sensitive or not
381 ** depending on the setting of filenames_are_case_sensitive().
382 */
383 int filenames_strncmp(const char *zA, const char *zB, int nByte){
384 if( filenames_are_case_sensitive() ){
385 return fossil_strncmp(zA,zB,nByte);
386 }else{
387 return fossil_strnicmp(zA,zB,nByte);
388 }
389 }
390
391 /*
392 ** COMMAND: addremove
393 **
394 ** Usage: %fossil addremove ?OPTIONS?
395
+3 -2
--- src/browse.c
+++ src/browse.c
@@ -212,16 +212,17 @@
212212
"INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)"
213213
);
214214
manifest_file_rewind(pM);
215215
while( (pFile = manifest_file_next(pM,0))!=0 ){
216216
if( nD>0
217
- && (memcmp(pFile->zName, zD, nD-1)!=0 || pFile->zName[nD-1]!='/')
217
+ && (filenames_strncmp(pFile->zName, zD, nD-1)!=0
218
+ || pFile->zName[nD-1]!='/')
218219
){
219220
continue;
220221
}
221222
if( pPrev
222
- && memcmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0
223
+ && filenames_strncmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0
223224
&& (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/')
224225
){
225226
continue;
226227
}
227228
db_bind_text(&ins, ":x", &pFile->zName[nD]);
228229
--- src/browse.c
+++ src/browse.c
@@ -212,16 +212,17 @@
212 "INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)"
213 );
214 manifest_file_rewind(pM);
215 while( (pFile = manifest_file_next(pM,0))!=0 ){
216 if( nD>0
217 && (memcmp(pFile->zName, zD, nD-1)!=0 || pFile->zName[nD-1]!='/')
 
218 ){
219 continue;
220 }
221 if( pPrev
222 && memcmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0
223 && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/')
224 ){
225 continue;
226 }
227 db_bind_text(&ins, ":x", &pFile->zName[nD]);
228
--- src/browse.c
+++ src/browse.c
@@ -212,16 +212,17 @@
212 "INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)"
213 );
214 manifest_file_rewind(pM);
215 while( (pFile = manifest_file_next(pM,0))!=0 ){
216 if( nD>0
217 && (filenames_strncmp(pFile->zName, zD, nD-1)!=0
218 || pFile->zName[nD-1]!='/')
219 ){
220 continue;
221 }
222 if( pPrev
223 && filenames_strncmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0
224 && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/')
225 ){
226 continue;
227 }
228 db_bind_text(&ins, ":x", &pFile->zName[nD]);
229
+17
--- src/printf.c
+++ src/printf.c
@@ -862,10 +862,27 @@
862862
a = *zA++;
863863
b = *zB++;
864864
}while( a==b && a!=0 );
865865
return ((unsigned char)a) - (unsigned char)b;
866866
}
867
+}
868
+int fossil_strncmp(const char *zA, const char *zB, int nByte){
869
+ if( zA==0 ){
870
+ if( zB==0 ) return 0;
871
+ return -1;
872
+ }else if( zB==0 ){
873
+ return +1;
874
+ }else if( nByte>0 ){
875
+ int a, b;
876
+ do{
877
+ a = *zA++;
878
+ b = *zB++;
879
+ }while( a==b && a!=0 && (--nByte)>0 );
880
+ return ((unsigned char)a) - (unsigned char)b;
881
+ }else{
882
+ return 0;
883
+ }
867884
}
868885
869886
/*
870887
** Case insensitive string comparison.
871888
*/
872889
--- src/printf.c
+++ src/printf.c
@@ -862,10 +862,27 @@
862 a = *zA++;
863 b = *zB++;
864 }while( a==b && a!=0 );
865 return ((unsigned char)a) - (unsigned char)b;
866 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
867 }
868
869 /*
870 ** Case insensitive string comparison.
871 */
872
--- src/printf.c
+++ src/printf.c
@@ -862,10 +862,27 @@
862 a = *zA++;
863 b = *zB++;
864 }while( a==b && a!=0 );
865 return ((unsigned char)a) - (unsigned char)b;
866 }
867 }
868 int fossil_strncmp(const char *zA, const char *zB, int nByte){
869 if( zA==0 ){
870 if( zB==0 ) return 0;
871 return -1;
872 }else if( zB==0 ){
873 return +1;
874 }else if( nByte>0 ){
875 int a, b;
876 do{
877 a = *zA++;
878 b = *zB++;
879 }while( a==b && a!=0 && (--nByte)>0 );
880 return ((unsigned char)a) - (unsigned char)b;
881 }else{
882 return 0;
883 }
884 }
885
886 /*
887 ** Case insensitive string comparison.
888 */
889

Keyboard Shortcuts

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