Check-in [1d49b5ad91]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Coding style fixes.
Timelines: family | ancestors | descendants | both | reconstruct-sha3
Files: files | file ages | folders
SHA3-256:1d49b5ad9118d0ab0c7ea9359fef0f68fa4d5e899a9cfa26dedb8a3be1abfbcc
User & Date: florian 2019-01-29 14:01:00
Context
2019-01-29
14:09
Calculate hash lengths with skipped directory slashes. check-in: c47adb9148 user: florian tags: reconstruct-sha3
14:01
Coding style fixes. check-in: 1d49b5ad91 user: florian tags: reconstruct-sha3
2019-01-28
14:02
Fix an oversight from the previous check-in: add the short form of the command-line option. check-in: a90d0617d7 user: florian tags: reconstruct-sha3
Changes

Changes to src/rebuild.c.

1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071

1072
1073
1074
1075
1076
1077
1078
}

/*
** Helper functions called from recon_read_dir() to set and restore the correct
** hash policy for an artifact read from disk, inferred from the length of the
** path name.
*/
#define HPOLICY_NOTDEFINED -1
static int saved_eHashPolicy = HPOLICY_NOTDEFINED;

void recon_set_hash_policy(
  const int cchPathPrefix,    /* Directory prefix length for zUuidAsFilePath */
  const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */
){
  int cchTotal, cchHashPart;
  int new_eHashPolicy = HPOLICY_NOTDEFINED;
  assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */
  if( zUuidAsFilePath==0 ) return;
  cchTotal = strlen(zUuidAsFilePath);
  if( cchTotal==0 ) return;
  if( cchPathPrefix>=cchTotal) return;
  cchHashPart = cchTotal - cchPathPrefix;
  if( cchHashPart>=HNAME_LEN_K256 ){
    new_eHashPolicy = HPOLICY_SHA3;
  }else if( cchHashPart>=HNAME_LEN_SHA1 ){
    new_eHashPolicy = HPOLICY_SHA1;
  }
  if( new_eHashPolicy!=HPOLICY_NOTDEFINED ){
    saved_eHashPolicy = g.eHashPolicy;
    g.eHashPolicy = new_eHashPolicy;
  }
}

void recon_restore_hash_policy(){
  if( saved_eHashPolicy!=HPOLICY_NOTDEFINED ){
    g.eHashPolicy = saved_eHashPolicy;

  }
}

/*
** COMMAND: reconstruct*
**
** Usage: %fossil reconstruct ?OPTIONS? FILENAME DIRECTORY







<
|






|




|






|






|

>







1036
1037
1038
1039
1040
1041
1042

1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
}

/*
** Helper functions called from recon_read_dir() to set and restore the correct
** hash policy for an artifact read from disk, inferred from the length of the
** path name.
*/

static int saved_eHashPolicy = -1;

void recon_set_hash_policy(
  const int cchPathPrefix,    /* Directory prefix length for zUuidAsFilePath */
  const char *zUuidAsFilePath /* Relative, well-formed, from recon_read_dir() */
){
  int cchTotal, cchHashPart;
  int new_eHashPolicy = -1;
  assert( HNAME_COUNT==2 ); /* Review function if new hashes are implemented. */
  if( zUuidAsFilePath==0 ) return;
  cchTotal = strlen(zUuidAsFilePath);
  if( cchTotal==0 ) return;
  if( cchPathPrefix>=cchTotal ) return;
  cchHashPart = cchTotal - cchPathPrefix;
  if( cchHashPart>=HNAME_LEN_K256 ){
    new_eHashPolicy = HPOLICY_SHA3;
  }else if( cchHashPart>=HNAME_LEN_SHA1 ){
    new_eHashPolicy = HPOLICY_SHA1;
  }
  if( new_eHashPolicy!=-1 ){
    saved_eHashPolicy = g.eHashPolicy;
    g.eHashPolicy = new_eHashPolicy;
  }
}

void recon_restore_hash_policy(){
  if( saved_eHashPolicy!=-1 ){
    g.eHashPolicy = saved_eHashPolicy;
    saved_eHashPolicy = -1;
  }
}

/*
** COMMAND: reconstruct*
**
** Usage: %fossil reconstruct ?OPTIONS? FILENAME DIRECTORY