Overview
SHA1 Hash: | 74534cc91ecf73f73efa8f6809478042daf71d4a |
---|---|
Date: | 2009-12-18 23:09:36 |
User: | drh |
Comment: | 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. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/timeline.c from [fd4ec7f2dc] to [d9475b1de8].
@@ -28,17 +28,37 @@ #include <time.h> #include "config.h" #include "timeline.h" /* +** Shorten a UUID so that is the minimum length needed to contain +** at least one digit in the range 'a'..'f'. The minimum length is 10. +*/ +static void shorten_uuid(char *zDest, const char *zSrc){ + int i; + for(i=0; i<10 && zSrc[i]<='9'; i++){} + memcpy(zDest, zSrc, 10); + if( i==10 ){ + do{ + zDest[i] = zSrc[i]; + i++; + }while( zSrc[i-1]<='9' ); + }else{ + i = 10; + } + zDest[i] = 0; +} + + +/* ** Generate a hyperlink to a version. */ void hyperlink_to_uuid(const char *zUuid){ char zShortUuid[UUID_SIZE+1]; - sprintf(zShortUuid, "%.10s", zUuid); + shorten_uuid(zShortUuid, zUuid); if( g.okHistory ){ - @ <a href="%s(g.zBaseURL)/info/%s(zUuid)">[%s(zShortUuid)]</a> + @ <a href="%s(g.zBaseURL)/info/%s(zShortUuid)">[%s(zShortUuid)]</a> }else{ @ <b>[%s(zShortUuid)]</b> } } @@ -51,14 +71,14 @@ const char *zIn, /* Javascript proc for mouseover */ const char *zOut, /* Javascript proc for mouseout */ int id /* Argument to javascript procs */ ){ char zShortUuid[UUID_SIZE+1]; - sprintf(zShortUuid, "%.10s", zUuid); + shorten_uuid(zShortUuid, zUuid); if( g.okHistory ){ @ <a onmouseover='%s(zIn)("m%d(id)")' onmouseout='%s(zOut)("m%d(id)")' - @ href="%s(g.zBaseURL)/vinfo/%s(zUuid)">[%s(zShortUuid)]</a> + @ href="%s(g.zBaseURL)/vinfo/%s(zShortUuid)">[%s(zShortUuid)]</a> }else{ @ <b onmouseover='%s(zIn)("m%d(id)")' onmouseout='%s(zOut)("m%d(id)")'> @ [%s(zShortUuid)]</b> } } @@ -824,31 +844,10 @@ @ (SELECT count(*) FROM plink WHERE cid=blob.rid) @ FROM event, blob @ WHERE blob.rid=event.objid ; return zBaseSql; -} - -/* -** Equivalent to timeline_query_for_tty(), except that: -** -** a) accepts a the -type=XX flag to set the event type to filter on. -** The values of XX are the same as supported by the /timeline page. -** -** b) The returned string must be freed using free(). -*/ -char * timeline_query_for_tty_m(void){ - Blob bl; - char const * zType = 0; - blob_zero(&bl); - blob_append( &bl, timeline_query_for_tty(), -1 ); - zType = find_option( "type", "t", 1 ); - if( zType && *zType ) - { - blob_appendf( &bl, " AND event.type=%Q", zType ); - } - return blob_buffer(&bl); } /* ** Return true if the input string is a date in the ISO 8601 format: ** YYYY-MM-DD.