Fossil SCM

Use the same algorithm for event-id's for UUID's as in other UI locations: Make sure that the UUID contains at least a single lower-case digit, with a minimum of length 10.

jan.nijtmans 2014-06-30 09:13 UTC trunk
Commit 734d4299401357a56768106350c6b766a1441524
2 files changed +5 -4 +2 -24
+5 -4
--- src/printf.c
+++ src/printf.c
@@ -608,22 +608,23 @@
608608
case etROOT: {
609609
bufpt = g.zTop ? g.zTop : "";
610610
length = (int)strlen(bufpt);
611611
break;
612612
}
613
- case etSTRINGID: {
614
- precision = 16;
615
- /* Fall through */
616
- }
613
+ case etSTRINGID:
617614
case etSTRING:
618615
case etDYNSTRING: {
619616
int limit = flag_alternateform ? va_arg(ap,int) : -1;
620617
bufpt = va_arg(ap,char*);
621618
if( bufpt==0 ){
622619
bufpt = "";
623620
}else if( xtype==etDYNSTRING ){
624621
zExtra = bufpt;
622
+ }else if( xtype==etSTRINGID ){
623
+ precision = 0;
624
+ while( fossil_isdigit(bufpt[precision++]) ){};
625
+ if( precision<10 ) precision=10;
625626
}
626627
length = StrNLen32(bufpt, limit);
627628
if( precision>=0 && precision<length ) length = precision;
628629
break;
629630
}
630631
--- src/printf.c
+++ src/printf.c
@@ -608,22 +608,23 @@
608 case etROOT: {
609 bufpt = g.zTop ? g.zTop : "";
610 length = (int)strlen(bufpt);
611 break;
612 }
613 case etSTRINGID: {
614 precision = 16;
615 /* Fall through */
616 }
617 case etSTRING:
618 case etDYNSTRING: {
619 int limit = flag_alternateform ? va_arg(ap,int) : -1;
620 bufpt = va_arg(ap,char*);
621 if( bufpt==0 ){
622 bufpt = "";
623 }else if( xtype==etDYNSTRING ){
624 zExtra = bufpt;
 
 
 
 
625 }
626 length = StrNLen32(bufpt, limit);
627 if( precision>=0 && precision<length ) length = precision;
628 break;
629 }
630
--- src/printf.c
+++ src/printf.c
@@ -608,22 +608,23 @@
608 case etROOT: {
609 bufpt = g.zTop ? g.zTop : "";
610 length = (int)strlen(bufpt);
611 break;
612 }
613 case etSTRINGID:
 
 
 
614 case etSTRING:
615 case etDYNSTRING: {
616 int limit = flag_alternateform ? va_arg(ap,int) : -1;
617 bufpt = va_arg(ap,char*);
618 if( bufpt==0 ){
619 bufpt = "";
620 }else if( xtype==etDYNSTRING ){
621 zExtra = bufpt;
622 }else if( xtype==etSTRINGID ){
623 precision = 0;
624 while( fossil_isdigit(bufpt[precision++]) ){};
625 if( precision<10 ) precision=10;
626 }
627 length = StrNLen32(bufpt, limit);
628 if( precision>=0 && precision<length ) length = precision;
629 break;
630 }
631
+2 -24
--- src/timeline.c
+++ src/timeline.c
@@ -20,41 +20,19 @@
2020
*/
2121
#include "config.h"
2222
#include <string.h>
2323
#include <time.h>
2424
#include "timeline.h"
25
-
26
-/*
27
-** Shorten a UUID so that is the minimum length needed to contain
28
-** at least one digit in the range 'a'..'f'. The minimum length is 10.
29
-*/
30
-static void shorten_uuid(char *zDest, const char *zSrc){
31
- int i;
32
- for(i=0; i<10 && zSrc[i]<='9'; i++){}
33
- memcpy(zDest, zSrc, 10);
34
- if( i==10 && zSrc[i] ){
35
- do{
36
- zDest[i] = zSrc[i];
37
- i++;
38
- }while( zSrc[i-1]<='9' );
39
- }else{
40
- i = 10;
41
- }
42
- zDest[i] = 0;
43
-}
44
-
4525
4626
/*
4727
** Generate a hyperlink to a version.
4828
*/
4929
void hyperlink_to_uuid(const char *zUuid){
50
- char z[UUID_SIZE+1];
51
- shorten_uuid(z, zUuid);
5230
if( g.perm.Hyperlink ){
53
- @ %z(xhref("class='timelineHistLink'","%R/info/%s",zUuid))[%s(z)]</a>
31
+ @ %z(xhref("class='timelineHistLink'","%R/info/%s",zUuid))[%S(zUuid)]</a>
5432
}else{
55
- @ <span class="timelineHistDsp">[%s(z)]</span>
33
+ @ <span class="timelineHistDsp">[%S(zUuid)]</span>
5634
}
5735
}
5836
5937
/*
6038
** Generate a hyperlink to a date & time.
6139
--- src/timeline.c
+++ src/timeline.c
@@ -20,41 +20,19 @@
20 */
21 #include "config.h"
22 #include <string.h>
23 #include <time.h>
24 #include "timeline.h"
25
26 /*
27 ** Shorten a UUID so that is the minimum length needed to contain
28 ** at least one digit in the range 'a'..'f'. The minimum length is 10.
29 */
30 static void shorten_uuid(char *zDest, const char *zSrc){
31 int i;
32 for(i=0; i<10 && zSrc[i]<='9'; i++){}
33 memcpy(zDest, zSrc, 10);
34 if( i==10 && zSrc[i] ){
35 do{
36 zDest[i] = zSrc[i];
37 i++;
38 }while( zSrc[i-1]<='9' );
39 }else{
40 i = 10;
41 }
42 zDest[i] = 0;
43 }
44
45
46 /*
47 ** Generate a hyperlink to a version.
48 */
49 void hyperlink_to_uuid(const char *zUuid){
50 char z[UUID_SIZE+1];
51 shorten_uuid(z, zUuid);
52 if( g.perm.Hyperlink ){
53 @ %z(xhref("class='timelineHistLink'","%R/info/%s",zUuid))[%s(z)]</a>
54 }else{
55 @ <span class="timelineHistDsp">[%s(z)]</span>
56 }
57 }
58
59 /*
60 ** Generate a hyperlink to a date & time.
61
--- src/timeline.c
+++ src/timeline.c
@@ -20,41 +20,19 @@
20 */
21 #include "config.h"
22 #include <string.h>
23 #include <time.h>
24 #include "timeline.h"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
26 /*
27 ** Generate a hyperlink to a version.
28 */
29 void hyperlink_to_uuid(const char *zUuid){
 
 
30 if( g.perm.Hyperlink ){
31 @ %z(xhref("class='timelineHistLink'","%R/info/%s",zUuid))[%S(zUuid)]</a>
32 }else{
33 @ <span class="timelineHistDsp">[%S(zUuid)]</span>
34 }
35 }
36
37 /*
38 ** Generate a hyperlink to a date & time.
39

Keyboard Shortcuts

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