Fossil SCM

Show the correct hash algorithm name in the Overview section of the /info webpage. (Originally committed to the wrong branch.)

drh 2017-03-01 17:14 trunk
Commit 26dac28eec3dddb11833daf202715c95827a3bc0
3 files changed +10 +2 -1 +2 -1
+10
--- src/hname.c
+++ src/hname.c
@@ -48,10 +48,20 @@
4848
** The number of distinct hash algorithms:
4949
*/
5050
#define HNAME_COUNT 2 /* Just SHA1 and SHA3-256. Let's keep it that way! */
5151
5252
#endif /* INTERFACE */
53
+
54
+/*
55
+** Return a human-readable name for the hash algorithm given a hash with
56
+** a length of nHash hexadecimal digits.
57
+*/
58
+const char *hname_alg(int nHash){
59
+ if( nHash==HNAME_LEN_SHA1 ) return "SHA1";
60
+ if( nHash==HNAME_LEN_K256 ) return "SHA3-256";
61
+ return "?";
62
+}
5363
5464
/*
5565
** Return the integer hash algorithm code number (ex: HNAME_K224) for
5666
** the hash string provided. Or return HNAME_ERROR (0) if the input string
5767
** is not a valid artifact hash string.
5868
--- src/hname.c
+++ src/hname.c
@@ -48,10 +48,20 @@
48 ** The number of distinct hash algorithms:
49 */
50 #define HNAME_COUNT 2 /* Just SHA1 and SHA3-256. Let's keep it that way! */
51
52 #endif /* INTERFACE */
 
 
 
 
 
 
 
 
 
 
53
54 /*
55 ** Return the integer hash algorithm code number (ex: HNAME_K224) for
56 ** the hash string provided. Or return HNAME_ERROR (0) if the input string
57 ** is not a valid artifact hash string.
58
--- src/hname.c
+++ src/hname.c
@@ -48,10 +48,20 @@
48 ** The number of distinct hash algorithms:
49 */
50 #define HNAME_COUNT 2 /* Just SHA1 and SHA3-256. Let's keep it that way! */
51
52 #endif /* INTERFACE */
53
54 /*
55 ** Return a human-readable name for the hash algorithm given a hash with
56 ** a length of nHash hexadecimal digits.
57 */
58 const char *hname_alg(int nHash){
59 if( nHash==HNAME_LEN_SHA1 ) return "SHA1";
60 if( nHash==HNAME_LEN_K256 ) return "SHA3-256";
61 return "?";
62 }
63
64 /*
65 ** Return the integer hash algorithm code number (ex: HNAME_K224) for
66 ** the hash string provided. Or return HNAME_ERROR (0) if the input string
67 ** is not a valid artifact hash string.
68
+2 -1
--- src/info.c
+++ src/info.c
@@ -572,10 +572,11 @@
572572
rid, rid
573573
);
574574
sideBySide = !is_false(PD("sbs","1"));
575575
if( db_step(&q1)==SQLITE_ROW ){
576576
const char *zUuid = db_column_text(&q1, 0);
577
+ int nUuid = db_column_bytes(&q1, 0);
577578
char *zEUser, *zEComment;
578579
const char *zUser;
579580
const char *zComment;
580581
const char *zDate;
581582
const char *zOrigDate;
@@ -593,11 +594,11 @@
593594
zComment = db_column_text(&q1, 3);
594595
zDate = db_column_text(&q1,1);
595596
zOrigDate = db_column_text(&q1, 4);
596597
@ <div class="section">Overview</div>
597598
@ <table class="label-value">
598
- @ <tr><th>SHA1&nbsp;Hash:</th><td>%s(zUuid)
599
+ @ <tr><th>%s(hname_alg(nUuid)):</th><td>%s(zUuid)
599600
if( g.perm.Setup ){
600601
@ (Record ID: %d(rid))
601602
}
602603
@ </td></tr>
603604
@ <tr><th>Date:</th><td>
604605
--- src/info.c
+++ src/info.c
@@ -572,10 +572,11 @@
572 rid, rid
573 );
574 sideBySide = !is_false(PD("sbs","1"));
575 if( db_step(&q1)==SQLITE_ROW ){
576 const char *zUuid = db_column_text(&q1, 0);
 
577 char *zEUser, *zEComment;
578 const char *zUser;
579 const char *zComment;
580 const char *zDate;
581 const char *zOrigDate;
@@ -593,11 +594,11 @@
593 zComment = db_column_text(&q1, 3);
594 zDate = db_column_text(&q1,1);
595 zOrigDate = db_column_text(&q1, 4);
596 @ <div class="section">Overview</div>
597 @ <table class="label-value">
598 @ <tr><th>SHA1&nbsp;Hash:</th><td>%s(zUuid)
599 if( g.perm.Setup ){
600 @ (Record ID: %d(rid))
601 }
602 @ </td></tr>
603 @ <tr><th>Date:</th><td>
604
--- src/info.c
+++ src/info.c
@@ -572,10 +572,11 @@
572 rid, rid
573 );
574 sideBySide = !is_false(PD("sbs","1"));
575 if( db_step(&q1)==SQLITE_ROW ){
576 const char *zUuid = db_column_text(&q1, 0);
577 int nUuid = db_column_bytes(&q1, 0);
578 char *zEUser, *zEComment;
579 const char *zUser;
580 const char *zComment;
581 const char *zDate;
582 const char *zOrigDate;
@@ -593,11 +594,11 @@
594 zComment = db_column_text(&q1, 3);
595 zDate = db_column_text(&q1,1);
596 zOrigDate = db_column_text(&q1, 4);
597 @ <div class="section">Overview</div>
598 @ <table class="label-value">
599 @ <tr><th>%s(hname_alg(nUuid)):</th><td>%s(zUuid)
600 if( g.perm.Setup ){
601 @ (Record ID: %d(rid))
602 }
603 @ </td></tr>
604 @ <tr><th>Date:</th><td>
605
+2 -1
--- src/info.c
+++ src/info.c
@@ -572,10 +572,11 @@
572572
rid, rid
573573
);
574574
sideBySide = !is_false(PD("sbs","1"));
575575
if( db_step(&q1)==SQLITE_ROW ){
576576
const char *zUuid = db_column_text(&q1, 0);
577
+ int nUuid = db_column_bytes(&q1, 0);
577578
char *zEUser, *zEComment;
578579
const char *zUser;
579580
const char *zComment;
580581
const char *zDate;
581582
const char *zOrigDate;
@@ -593,11 +594,11 @@
593594
zComment = db_column_text(&q1, 3);
594595
zDate = db_column_text(&q1,1);
595596
zOrigDate = db_column_text(&q1, 4);
596597
@ <div class="section">Overview</div>
597598
@ <table class="label-value">
598
- @ <tr><th>SHA1&nbsp;Hash:</th><td>%s(zUuid)
599
+ @ <tr><th>%s(hname_alg(nUuid)):</th><td>%s(zUuid)
599600
if( g.perm.Setup ){
600601
@ (Record ID: %d(rid))
601602
}
602603
@ </td></tr>
603604
@ <tr><th>Date:</th><td>
604605
--- src/info.c
+++ src/info.c
@@ -572,10 +572,11 @@
572 rid, rid
573 );
574 sideBySide = !is_false(PD("sbs","1"));
575 if( db_step(&q1)==SQLITE_ROW ){
576 const char *zUuid = db_column_text(&q1, 0);
 
577 char *zEUser, *zEComment;
578 const char *zUser;
579 const char *zComment;
580 const char *zDate;
581 const char *zOrigDate;
@@ -593,11 +594,11 @@
593 zComment = db_column_text(&q1, 3);
594 zDate = db_column_text(&q1,1);
595 zOrigDate = db_column_text(&q1, 4);
596 @ <div class="section">Overview</div>
597 @ <table class="label-value">
598 @ <tr><th>SHA1&nbsp;Hash:</th><td>%s(zUuid)
599 if( g.perm.Setup ){
600 @ (Record ID: %d(rid))
601 }
602 @ </td></tr>
603 @ <tr><th>Date:</th><td>
604
--- src/info.c
+++ src/info.c
@@ -572,10 +572,11 @@
572 rid, rid
573 );
574 sideBySide = !is_false(PD("sbs","1"));
575 if( db_step(&q1)==SQLITE_ROW ){
576 const char *zUuid = db_column_text(&q1, 0);
577 int nUuid = db_column_bytes(&q1, 0);
578 char *zEUser, *zEComment;
579 const char *zUser;
580 const char *zComment;
581 const char *zDate;
582 const char *zOrigDate;
@@ -593,11 +594,11 @@
594 zComment = db_column_text(&q1, 3);
595 zDate = db_column_text(&q1,1);
596 zOrigDate = db_column_text(&q1, 4);
597 @ <div class="section">Overview</div>
598 @ <table class="label-value">
599 @ <tr><th>%s(hname_alg(nUuid)):</th><td>%s(zUuid)
600 if( g.perm.Setup ){
601 @ (Record ID: %d(rid))
602 }
603 @ </td></tr>
604 @ <tr><th>Date:</th><td>
605

Keyboard Shortcuts

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