Fossil SCM

Remove dead code from timeline.c. Make sure all shortened UUIDs have at least one hexadecimal digit greater than '9' to avoid confusing them with decimal numbers.

drh 2009-12-18 23:09 trunk
Commit 74534cc91ecf73f73efa8f6809478042daf71d4a
1 file changed +24 -25
+24 -25
--- src/timeline.c
+++ src/timeline.c
@@ -26,19 +26,39 @@
2626
*/
2727
#include <string.h>
2828
#include <time.h>
2929
#include "config.h"
3030
#include "timeline.h"
31
+
32
+/*
33
+** Shorten a UUID so that is the minimum length needed to contain
34
+** at least one digit in the range 'a'..'f'. The minimum length is 10.
35
+*/
36
+static void shorten_uuid(char *zDest, const char *zSrc){
37
+ int i;
38
+ for(i=0; i<10 && zSrc[i]<='9'; i++){}
39
+ memcpy(zDest, zSrc, 10);
40
+ if( i==10 ){
41
+ do{
42
+ zDest[i] = zSrc[i];
43
+ i++;
44
+ }while( zSrc[i-1]<='9' );
45
+ }else{
46
+ i = 10;
47
+ }
48
+ zDest[i] = 0;
49
+}
50
+
3151
3252
/*
3353
** Generate a hyperlink to a version.
3454
*/
3555
void hyperlink_to_uuid(const char *zUuid){
3656
char zShortUuid[UUID_SIZE+1];
37
- sprintf(zShortUuid, "%.10s", zUuid);
57
+ shorten_uuid(zShortUuid, zUuid);
3858
if( g.okHistory ){
39
- @ <a href="%s(g.zBaseURL)/info/%s(zUuid)">[%s(zShortUuid)]</a>
59
+ @ <a href="%s(g.zBaseURL)/info/%s(zShortUuid)">[%s(zShortUuid)]</a>
4060
}else{
4161
@ <b>[%s(zShortUuid)]</b>
4262
}
4363
}
4464
@@ -51,14 +71,14 @@
5171
const char *zIn, /* Javascript proc for mouseover */
5272
const char *zOut, /* Javascript proc for mouseout */
5373
int id /* Argument to javascript procs */
5474
){
5575
char zShortUuid[UUID_SIZE+1];
56
- sprintf(zShortUuid, "%.10s", zUuid);
76
+ shorten_uuid(zShortUuid, zUuid);
5777
if( g.okHistory ){
5878
@ <a onmouseover='%s(zIn)("m%d(id)")' onmouseout='%s(zOut)("m%d(id)")'
59
- @ href="%s(g.zBaseURL)/vinfo/%s(zUuid)">[%s(zShortUuid)]</a>
79
+ @ href="%s(g.zBaseURL)/vinfo/%s(zShortUuid)">[%s(zShortUuid)]</a>
6080
}else{
6181
@ <b onmouseover='%s(zIn)("m%d(id)")' onmouseout='%s(zOut)("m%d(id)")'>
6282
@ [%s(zShortUuid)]</b>
6383
}
6484
}
@@ -826,31 +846,10 @@
826846
@ WHERE blob.rid=event.objid
827847
;
828848
return zBaseSql;
829849
}
830850
831
-/*
832
-** Equivalent to timeline_query_for_tty(), except that:
833
-**
834
-** a) accepts a the -type=XX flag to set the event type to filter on.
835
-** The values of XX are the same as supported by the /timeline page.
836
-**
837
-** b) The returned string must be freed using free().
838
-*/
839
-char * timeline_query_for_tty_m(void){
840
- Blob bl;
841
- char const * zType = 0;
842
- blob_zero(&bl);
843
- blob_append( &bl, timeline_query_for_tty(), -1 );
844
- zType = find_option( "type", "t", 1 );
845
- if( zType && *zType )
846
- {
847
- blob_appendf( &bl, " AND event.type=%Q", zType );
848
- }
849
- return blob_buffer(&bl);
850
-}
851
-
852851
/*
853852
** Return true if the input string is a date in the ISO 8601 format:
854853
** YYYY-MM-DD.
855854
*/
856855
static int isIsoDate(const char *z){
857856
--- src/timeline.c
+++ src/timeline.c
@@ -26,19 +26,39 @@
26 */
27 #include <string.h>
28 #include <time.h>
29 #include "config.h"
30 #include "timeline.h"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
32 /*
33 ** Generate a hyperlink to a version.
34 */
35 void hyperlink_to_uuid(const char *zUuid){
36 char zShortUuid[UUID_SIZE+1];
37 sprintf(zShortUuid, "%.10s", zUuid);
38 if( g.okHistory ){
39 @ <a href="%s(g.zBaseURL)/info/%s(zUuid)">[%s(zShortUuid)]</a>
40 }else{
41 @ <b>[%s(zShortUuid)]</b>
42 }
43 }
44
@@ -51,14 +71,14 @@
51 const char *zIn, /* Javascript proc for mouseover */
52 const char *zOut, /* Javascript proc for mouseout */
53 int id /* Argument to javascript procs */
54 ){
55 char zShortUuid[UUID_SIZE+1];
56 sprintf(zShortUuid, "%.10s", zUuid);
57 if( g.okHistory ){
58 @ <a onmouseover='%s(zIn)("m%d(id)")' onmouseout='%s(zOut)("m%d(id)")'
59 @ href="%s(g.zBaseURL)/vinfo/%s(zUuid)">[%s(zShortUuid)]</a>
60 }else{
61 @ <b onmouseover='%s(zIn)("m%d(id)")' onmouseout='%s(zOut)("m%d(id)")'>
62 @ [%s(zShortUuid)]</b>
63 }
64 }
@@ -826,31 +846,10 @@
826 @ WHERE blob.rid=event.objid
827 ;
828 return zBaseSql;
829 }
830
831 /*
832 ** Equivalent to timeline_query_for_tty(), except that:
833 **
834 ** a) accepts a the -type=XX flag to set the event type to filter on.
835 ** The values of XX are the same as supported by the /timeline page.
836 **
837 ** b) The returned string must be freed using free().
838 */
839 char * timeline_query_for_tty_m(void){
840 Blob bl;
841 char const * zType = 0;
842 blob_zero(&bl);
843 blob_append( &bl, timeline_query_for_tty(), -1 );
844 zType = find_option( "type", "t", 1 );
845 if( zType && *zType )
846 {
847 blob_appendf( &bl, " AND event.type=%Q", zType );
848 }
849 return blob_buffer(&bl);
850 }
851
852 /*
853 ** Return true if the input string is a date in the ISO 8601 format:
854 ** YYYY-MM-DD.
855 */
856 static int isIsoDate(const char *z){
857
--- src/timeline.c
+++ src/timeline.c
@@ -26,19 +26,39 @@
26 */
27 #include <string.h>
28 #include <time.h>
29 #include "config.h"
30 #include "timeline.h"
31
32 /*
33 ** Shorten a UUID so that is the minimum length needed to contain
34 ** at least one digit in the range 'a'..'f'. The minimum length is 10.
35 */
36 static void shorten_uuid(char *zDest, const char *zSrc){
37 int i;
38 for(i=0; i<10 && zSrc[i]<='9'; i++){}
39 memcpy(zDest, zSrc, 10);
40 if( i==10 ){
41 do{
42 zDest[i] = zSrc[i];
43 i++;
44 }while( zSrc[i-1]<='9' );
45 }else{
46 i = 10;
47 }
48 zDest[i] = 0;
49 }
50
51
52 /*
53 ** Generate a hyperlink to a version.
54 */
55 void hyperlink_to_uuid(const char *zUuid){
56 char zShortUuid[UUID_SIZE+1];
57 shorten_uuid(zShortUuid, zUuid);
58 if( g.okHistory ){
59 @ <a href="%s(g.zBaseURL)/info/%s(zShortUuid)">[%s(zShortUuid)]</a>
60 }else{
61 @ <b>[%s(zShortUuid)]</b>
62 }
63 }
64
@@ -51,14 +71,14 @@
71 const char *zIn, /* Javascript proc for mouseover */
72 const char *zOut, /* Javascript proc for mouseout */
73 int id /* Argument to javascript procs */
74 ){
75 char zShortUuid[UUID_SIZE+1];
76 shorten_uuid(zShortUuid, zUuid);
77 if( g.okHistory ){
78 @ <a onmouseover='%s(zIn)("m%d(id)")' onmouseout='%s(zOut)("m%d(id)")'
79 @ href="%s(g.zBaseURL)/vinfo/%s(zShortUuid)">[%s(zShortUuid)]</a>
80 }else{
81 @ <b onmouseover='%s(zIn)("m%d(id)")' onmouseout='%s(zOut)("m%d(id)")'>
82 @ [%s(zShortUuid)]</b>
83 }
84 }
@@ -826,31 +846,10 @@
846 @ WHERE blob.rid=event.objid
847 ;
848 return zBaseSql;
849 }
850
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
851 /*
852 ** Return true if the input string is a date in the ISO 8601 format:
853 ** YYYY-MM-DD.
854 */
855 static int isIsoDate(const char *z){
856

Keyboard Shortcuts

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