Diff
Not logged in

Differences From:

File src/timeline.c part of check-in [02920e92b5] - Minor cleanup to the implementation of command-line "timeline". by drh on 2009-12-18 22:16:55. [view]

To:

File src/timeline.c part of check-in [74534cc91e] - 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. by drh on 2009-12-18 23:09:36. [view]

@@ -29,15 +29,35 @@
 #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>
   }
 }
@@ -52,12 +72,12 @@
   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>
   }
@@ -825,29 +845,8 @@
     @ 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: