Fossil SCM

Calculate hash lengths with skipped directory slashes.

florian 2019-01-29 14:09 reconstruct-sha3
Commit c47adb9148576228c297b2c134cd0b5408eb2e1be1dce565a9a5c0be4975dd70
1 file changed +9 -5
+9 -5
--- src/rebuild.c
+++ src/rebuild.c
@@ -1044,18 +1044,22 @@
10441044
10451045
void recon_set_hash_policy(
10461046
const int cchPathPrefix, /* Directory prefix length for zUuidAsFilePath */
10471047
const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */
10481048
){
1049
- int cchTotal, cchHashPart;
1049
+ int cchUuidAsFilePath;
1050
+ const char *zHashPart;
1051
+ int cchHashPart = 0;
10501052
int new_eHashPolicy = -1;
10511053
assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */
10521054
if( zUuidAsFilePath==0 ) return;
1053
- cchTotal = strlen(zUuidAsFilePath);
1054
- if( cchTotal==0 ) return;
1055
- if( cchPathPrefix>=cchTotal ) return;
1056
- cchHashPart = cchTotal - cchPathPrefix;
1055
+ cchUuidAsFilePath = strlen(zUuidAsFilePath);
1056
+ if( cchUuidAsFilePath==0 ) return;
1057
+ if( cchPathPrefix>=cchUuidAsFilePath ) return;
1058
+ for( zHashPart = zUuidAsFilePath + cchPathPrefix; *zHashPart; zHashPart++ ){
1059
+ if( *zHashPart!='/' ) cchHashPart++;
1060
+ }
10571061
if( cchHashPart>=HNAME_LEN_K256 ){
10581062
new_eHashPolicy = HPOLICY_SHA3;
10591063
}else if( cchHashPart>=HNAME_LEN_SHA1 ){
10601064
new_eHashPolicy = HPOLICY_SHA1;
10611065
}
10621066
--- src/rebuild.c
+++ src/rebuild.c
@@ -1044,18 +1044,22 @@
1044
1045 void recon_set_hash_policy(
1046 const int cchPathPrefix, /* Directory prefix length for zUuidAsFilePath */
1047 const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */
1048 ){
1049 int cchTotal, cchHashPart;
 
 
1050 int new_eHashPolicy = -1;
1051 assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */
1052 if( zUuidAsFilePath==0 ) return;
1053 cchTotal = strlen(zUuidAsFilePath);
1054 if( cchTotal==0 ) return;
1055 if( cchPathPrefix>=cchTotal ) return;
1056 cchHashPart = cchTotal - cchPathPrefix;
 
 
1057 if( cchHashPart>=HNAME_LEN_K256 ){
1058 new_eHashPolicy = HPOLICY_SHA3;
1059 }else if( cchHashPart>=HNAME_LEN_SHA1 ){
1060 new_eHashPolicy = HPOLICY_SHA1;
1061 }
1062
--- src/rebuild.c
+++ src/rebuild.c
@@ -1044,18 +1044,22 @@
1044
1045 void recon_set_hash_policy(
1046 const int cchPathPrefix, /* Directory prefix length for zUuidAsFilePath */
1047 const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */
1048 ){
1049 int cchUuidAsFilePath;
1050 const char *zHashPart;
1051 int cchHashPart = 0;
1052 int new_eHashPolicy = -1;
1053 assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */
1054 if( zUuidAsFilePath==0 ) return;
1055 cchUuidAsFilePath = strlen(zUuidAsFilePath);
1056 if( cchUuidAsFilePath==0 ) return;
1057 if( cchPathPrefix>=cchUuidAsFilePath ) return;
1058 for( zHashPart = zUuidAsFilePath + cchPathPrefix; *zHashPart; zHashPart++ ){
1059 if( *zHashPart!='/' ) cchHashPart++;
1060 }
1061 if( cchHashPart>=HNAME_LEN_K256 ){
1062 new_eHashPolicy = HPOLICY_SHA3;
1063 }else if( cchHashPart>=HNAME_LEN_SHA1 ){
1064 new_eHashPolicy = HPOLICY_SHA1;
1065 }
1066

Keyboard Shortcuts

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