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.
Commit
74534cc91ecf73f73efa8f6809478042daf71d4a
Parent
02920e92b50bdaf…
1 file changed
+24
-25
+24
-25
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -26,19 +26,39 @@ | ||
| 26 | 26 | */ |
| 27 | 27 | #include <string.h> |
| 28 | 28 | #include <time.h> |
| 29 | 29 | #include "config.h" |
| 30 | 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 | + | |
| 31 | 51 | |
| 32 | 52 | /* |
| 33 | 53 | ** Generate a hyperlink to a version. |
| 34 | 54 | */ |
| 35 | 55 | void hyperlink_to_uuid(const char *zUuid){ |
| 36 | 56 | char zShortUuid[UUID_SIZE+1]; |
| 37 | - sprintf(zShortUuid, "%.10s", zUuid); | |
| 57 | + shorten_uuid(zShortUuid, zUuid); | |
| 38 | 58 | 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> | |
| 40 | 60 | }else{ |
| 41 | 61 | @ <b>[%s(zShortUuid)]</b> |
| 42 | 62 | } |
| 43 | 63 | } |
| 44 | 64 | |
| @@ -51,14 +71,14 @@ | ||
| 51 | 71 | const char *zIn, /* Javascript proc for mouseover */ |
| 52 | 72 | const char *zOut, /* Javascript proc for mouseout */ |
| 53 | 73 | int id /* Argument to javascript procs */ |
| 54 | 74 | ){ |
| 55 | 75 | char zShortUuid[UUID_SIZE+1]; |
| 56 | - sprintf(zShortUuid, "%.10s", zUuid); | |
| 76 | + shorten_uuid(zShortUuid, zUuid); | |
| 57 | 77 | if( g.okHistory ){ |
| 58 | 78 | @ <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> | |
| 60 | 80 | }else{ |
| 61 | 81 | @ <b onmouseover='%s(zIn)("m%d(id)")' onmouseout='%s(zOut)("m%d(id)")'> |
| 62 | 82 | @ [%s(zShortUuid)]</b> |
| 63 | 83 | } |
| 64 | 84 | } |
| @@ -826,31 +846,10 @@ | ||
| 826 | 846 | @ WHERE blob.rid=event.objid |
| 827 | 847 | ; |
| 828 | 848 | return zBaseSql; |
| 829 | 849 | } |
| 830 | 850 | |
| 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 | 851 | /* |
| 853 | 852 | ** Return true if the input string is a date in the ISO 8601 format: |
| 854 | 853 | ** YYYY-MM-DD. |
| 855 | 854 | */ |
| 856 | 855 | static int isIsoDate(const char *z){ |
| 857 | 856 |
| --- 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 |