Changes On Branch comma-in-stat
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch comma-in-stat Excluding Merge-Ins

This is equivalent to a diff from 82f5663270 to ef9ec5d74a

2012-04-02
01:14
Improve the readability of large sizes on the "stat" webpage. check-in: 701c8e68c6 user: drh tags: trunk
00:11
Try to make the "stat" page more readable by inserting commas in larger integers. This experiment did not work out. Closed-Leaf check-in: ef9ec5d74a user: drh tags: comma-in-stat
2012-03-31
19:15
Update to the latest SQLite code. Fix a compiler warning in style.c. check-in: 82f5663270 user: drh tags: trunk
17:13
fix for cookie mismatch for self-registered users (reported via mailing list). check-in: dc97099ac3 user: stephan tags: trunk

Changes to src/printf.c.

    45     45   #define etHTTPIZE    17 /* Make text safe for HTTP.  "/" encoded as %2f */
    46     46   #define etURLIZE     18 /* Make text safe for HTTP.  "/" not encoded */
    47     47   #define etFOSSILIZE  19 /* The fossil header encoding format. */
    48     48   #define etPATH       20 /* Path type */
    49     49   #define etWIKISTR    21 /* Wiki text rendered from a char*: %w */
    50     50   #define etWIKIBLOB   22 /* Wiki text rendered from a Blob*: %W */
    51     51   #define etSTRINGID   23 /* String with length limit for a UUID prefix: %S */
           52  +#define etCOMMA      24 /* Like %d but with commas: %D */
    52     53   
    53     54   
    54     55   /*
    55     56   ** An "etByte" is an 8-bit unsigned value.
    56     57   */
    57     58   typedef unsigned char etByte;
    58     59   
................................................................................
    88     89     {  's',  0, 4, etSTRING,     0,  0 },
    89     90     {  'g',  0, 1, etGENERIC,    30, 0 },
    90     91     {  'z',  0, 6, etDYNSTRING,  0,  0 },
    91     92     {  'q',  0, 4, etSQLESCAPE,  0,  0 },
    92     93     {  'Q',  0, 4, etSQLESCAPE2, 0,  0 },
    93     94     {  'b',  0, 2, etBLOB,       0,  0 },
    94     95     {  'B',  0, 2, etBLOBSQL,    0,  0 },
           96  +  {  'D', 10, 2, etCOMMA,      0,  0 },
    95     97     {  'w',  0, 2, etWIKISTR,    0,  0 },
    96     98     {  'W',  0, 2, etWIKIBLOB,   0,  0 },
    97     99     {  'h',  0, 4, etHTMLIZE,    0,  0 },
    98    100     {  't',  0, 4, etHTTPIZE,    0,  0 },  /* "/" -> "%2F" */
    99    101     {  'T',  0, 4, etURLIZE,     0,  0 },  /* "/" unchanged */
   100    102     {  'F',  0, 4, etFOSSILIZE,  0,  0 },
   101    103     {  'S',  0, 4, etSTRINGID,   0,  0 },
................................................................................
   239    241       if( (c=(*++fmt))==0 ){
   240    242         errorflag = 1;
   241    243         blob_append(pBlob,"%",1);
   242    244         count++;
   243    245         break;
   244    246       }
   245    247       /* Find out what flags are present */
   246         -    flag_leftjustify = flag_plussign = flag_blanksign = 
          248  +    flag_leftjustify = flag_plussign = flag_blanksign =
   247    249        flag_alternateform = flag_altform2 = flag_zeropad = 0;
   248    250       done = 0;
   249    251       do{
   250    252         switch( c ){
   251    253           case '-':   flag_leftjustify = 1;     break;
   252    254           case '+':   flag_plussign = 1;        break;
   253    255           case ' ':   flag_blanksign = 1;       break;
................................................................................
   345    347       */
   346    348       switch( xtype ){
   347    349         case etPOINTER:
   348    350           flag_longlong = sizeof(char*)==sizeof(i64);
   349    351           flag_long = sizeof(char*)==sizeof(long int);
   350    352           /* Fall through into the next case */
   351    353         case etRADIX:
          354  +      case etCOMMA:
   352    355           if( infop->flags & FLAG_SIGNED ){
   353    356             i64 v;
   354    357             if( flag_longlong )   v = va_arg(ap,i64);
   355    358             else if( flag_long )  v = va_arg(ap,long int);
   356    359             else                  v = va_arg(ap,int);
   357    360             if( v<0 ){
   358    361               longvalue = -v;
................................................................................
   385    388             }while( longvalue>0 );
   386    389           }
   387    390           length = &buf[etBUFSIZE-1]-bufpt;
   388    391           for(idx=precision-length; idx>0; idx--){
   389    392             *(--bufpt) = '0';                             /* Zero pad */
   390    393           }
   391    394           if( prefix ) *(--bufpt) = prefix;               /* Add sign */
          395  +        length = &buf[etBUFSIZE-1]-bufpt;
          396  +        if( xtype==etCOMMA && length>=4 ){
          397  +          int i, j, k;
          398  +          int nComma = (length-1)/3;
          399  +          bufpt -= nComma;
          400  +          for(i=k=0, j=nComma; i<j; i++, j++, k++){
          401  +            bufpt[i] = bufpt[j];
          402  +            if( (length-k)%3==1 ) bufpt[++i] = ',';
          403  +          }
          404  +          length += nComma;
          405  +        }
   392    406           if( flag_alternateform && infop->prefix ){      /* Add "0" or "0x" */
   393    407             const char *pre;
   394    408             char x;
   395    409             pre = &aPrefix[infop->prefix];
   396    410             if( *bufpt!=pre[0] ){
   397    411               for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;
   398    412             }
   399    413           }
   400         -        length = &buf[etBUFSIZE-1]-bufpt;
   401    414           break;
   402    415         case etFLOAT:
   403    416         case etEXP:
   404    417         case etGENERIC:
   405    418           realvalue = va_arg(ap,double);
   406    419           if( precision<0 ) precision = 6;         /* Set default precision */
   407    420           if( precision>etBUFSIZE/2-10 ) precision = etBUFSIZE/2-10;

Changes to src/stat.c.

    29     29   */
    30     30   void stat_page(void){
    31     31     i64 t, fsize;
    32     32     int n, m;
    33     33     int szMax, szAvg;
    34     34     const char *zDb;
    35     35     int brief;
    36         -  char zBuf[100];
           36  +  char *z;
           37  +  char zBuf[200];
    37     38   
    38     39     login_check_credentials();
    39     40     if( !g.perm.Read ){ login_needed(); return; }
    40     41     brief = P("brief")!=0;
    41     42     style_header("Repository Statistics");
    42     43     @ <table class="label-value">
    43     44     @ <tr><th>Repository&nbsp;Size:</th><td>
    44     45     fsize = file_size(g.zRepositoryName);
    45         -  sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", fsize);
    46         -  @ %s(zBuf) bytes
           46  +  z = mprintf("%llD", fsize);
           47  +  @ %z(z) bytes
    47     48     @ </td></tr>
    48     49     if( !brief ){
    49     50       @ <tr><th>Number&nbsp;Of&nbsp;Artifacts:</th><td>
    50     51       n = db_int(0, "SELECT count(*) FROM blob");
    51     52       m = db_int(0, "SELECT count(*) FROM delta");
    52         -    @ %d(n) (stored as %d(n-m) full text and %d(m) delta blobs)
           53  +    @ %D(n) (stored as %D(n-m) full text and %D(m) delta blobs)
    53     54       @ </td></tr>
    54     55       if( n>0 ){
    55     56         int a, b;
    56     57         Stmt q;
    57     58         @ <tr><th>Uncompressed&nbsp;Artifact&nbsp;Size:</th><td>
    58     59         db_prepare(&q, "SELECT total(size), avg(size), max(size)"
    59     60                        " FROM blob WHERE size>0");
    60     61         db_step(&q);
    61     62         t = db_column_int64(&q, 0);
    62     63         szAvg = db_column_int(&q, 1);
    63     64         szMax = db_column_int(&q, 2);
    64     65         db_finalize(&q);
    65         -      sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", t);
    66         -      @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) bytes total
           66  +      z = mprintf("%llD", t);
           67  +      @ %D(szAvg) bytes average, %D(szMax) bytes max, %z(z) bytes total
    67     68         @ </td></tr>
    68     69         @ <tr><th>Compression&nbsp;Ratio:</th><td>
    69     70         if( t/fsize < 5 ){
    70     71           b = 10;
    71     72           fsize /= 10;
    72     73         }else{
    73     74           b = 1;
................................................................................
    74     75         }
    75     76         a = t/fsize;
    76     77         @ %d(a):%d(b)
    77     78         @ </td></tr>
    78     79       }
    79     80       @ <tr><th>Number&nbsp;Of&nbsp;Check-ins:</th><td>
    80     81       n = db_int(0, "SELECT count(distinct mid) FROM mlink /*scan*/");
    81         -    @ %d(n)
           82  +    @ %D(n)
    82     83       @ </td></tr>
    83     84       @ <tr><th>Number&nbsp;Of&nbsp;Files:</th><td>
    84     85       n = db_int(0, "SELECT count(*) FROM filename /*scan*/");
    85         -    @ %d(n)
           86  +    @ %D(n)
    86     87       @ </td></tr>
    87     88       @ <tr><th>Number&nbsp;Of&nbsp;Wiki&nbsp;Pages:</th><td>
    88     89       n = db_int(0, "SELECT count(*) FROM tag  /*scan*/"
    89     90                     " WHERE +tagname GLOB 'wiki-*'");
    90         -    @ %d(n)
           91  +    @ %D(n)
    91     92       @ </td></tr>
    92     93       @ <tr><th>Number&nbsp;Of&nbsp;Tickets:</th><td>
    93     94       n = db_int(0, "SELECT count(*) FROM tag  /*scan*/"
    94     95                     " WHERE +tagname GLOB 'tkt-*'");
    95         -    @ %d(n)
           96  +    @ %D(n)
    96     97       @ </td></tr>
    97     98     }
    98     99     @ <tr><th>Duration&nbsp;Of&nbsp;Project:</th><td>
    99    100     n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
   100    101                   " + 0.99");
   101         -  @ %d(n) days
          102  +  @ %D(n) days
   102    103     sqlite3_snprintf(sizeof(zBuf), zBuf, "%.2f", n/365.24);
   103    104     @ or approximately %s(zBuf) years
   104    105     @ </td></tr>
   105    106     @ <tr><th>Project&nbsp;ID:</th><td>%h(db_get("project-code",""))</td></tr>
   106    107     @ <tr><th>Server&nbsp;ID:</th><td>%h(db_get("server-code",""))</td></tr>
   107    108   
   108    109     @ <tr><th>Fossil&nbsp;Version:</th><td>