Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | On the printf extension converters (ex: %T, %w) the "alternate form flag" (ex: %#T, %#w) means first read an integer from the argument list and then only process that number of characters from the string or blob that is read next from the argument list. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
8c3ec00311d4641ac2bb9f9fd537cb4a |
| User & Date: | drh 2008-02-04 19:07:58.000 |
Context
|
2008-02-04
| ||
| 19:08 | Hyperlinks to directory browser pages on the pathname in the title of the file history viewer, finfo. check-in: a20dcb5c26 user: drh tags: trunk | |
| 19:07 | On the printf extension converters (ex: %T, %w) the "alternate form flag" (ex: %#T, %#w) means first read an integer from the argument list and then only process that number of characters from the string or blob that is read next from the argument list. check-in: 8c3ec00311 user: drh tags: trunk | |
| 18:28 | Add support for annotation in the web interface. check-in: eae7ddfa4e user: drh tags: trunk | |
Changes
Changes to src/printf.c.
| ︙ | ︙ | |||
144 145 146 147 148 149 150 151 152 153 154 155 156 157 | return digit; } /* ** Size of temporary conversion buffer. */ #define etBUFSIZE 500 /* ** The root program. All variations call this core. ** ** INPUTS: ** func This is a pointer to a function taking three arguments ** 1. A pointer to anything. Same as the "arg" parameter. | > > > > > > > > > > > > > | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
return digit;
}
/*
** Size of temporary conversion buffer.
*/
#define etBUFSIZE 500
/*
** Find the length of a string as long as that length does not
** exceed N bytes. If no zero terminator is seen in the first
** N bytes then return N. If N is negative, then this routine
** is an alias for strlen().
*/
static int strnlen(const char *z, int N){
int n = 0;
while( (N-- != 0) && *(z++)!=0 ){ n++; }
return n;
}
/*
** The root program. All variations call this core.
**
** INPUTS:
** func This is a pointer to a function taking three arguments
** 1. A pointer to anything. Same as the "arg" parameter.
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 552 553 |
}else{
length =1;
}
bufpt = buf;
break;
case etPATH: {
int i;
char *e = va_arg(ap,char*);
if( e==0 ){e="";}
| > | | > | > > > > > > > | | | | > | > | > | > | > | | 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
}else{
length =1;
}
bufpt = buf;
break;
case etPATH: {
int i;
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *e = va_arg(ap,char*);
if( e==0 ){e="";}
length = strnlen(e, limit);
zExtra = bufpt = malloc(length+1);
for( i=0; i<length; i++ ){
if( e[i]=='\\' ){
bufpt[i]='/';
}else{
bufpt[i]=e[i];
}
}
bufpt[length]='\0';
break;
}
case etSTRING:
case etDYNSTRING: {
int limit = flag_alternateform ? va_arg(ap,int) : -1;
bufpt = va_arg(ap,char*);
if( bufpt==0 ){
bufpt = "";
}else if( xtype==etDYNSTRING ){
zExtra = bufpt;
}
length = strnlen(bufpt, limit);
if( precision>=0 && precision<length ) length = precision;
break;
}
case etBLOB: {
int limit = flag_alternateform ? va_arg(ap, int) : -1;
Blob *pBlob = va_arg(ap, Blob*);
bufpt = blob_buffer(pBlob);
length = blob_size(pBlob);
if( limit>=0 && limit<length ) length = limit;
break;
}
case etBLOBSQL: {
int limit = flag_alternateform ? va_arg(ap, int) : -1;
Blob *pBlob = va_arg(ap, Blob*);
char *zOrig = blob_buffer(pBlob);
int i, j, n, cnt;
n = blob_size(pBlob);
if( limit>=0 && limit<n ) n = limit;
for(cnt=i=0; i<n; i++){ if( zOrig[i]=='\'' ) cnt++; }
if( n+cnt+2 > etBUFSIZE ){
bufpt = zExtra = malloc( n + cnt + 2 );
}else{
bufpt = buf;
}
bufpt[0] = '\'';
for(i=0, j=1; i<n; i++, j++){
if( zOrig[i]=='\'' ){ bufpt[j++] = '\''; }
bufpt[j] = zOrig[i];
}
bufpt[j++] = '\'';
length = j;
assert( length==n+cnt+2 );
break;
}
case etSQLESCAPE:
case etSQLESCAPE2: {
int i, j, n, ch, isnull;
int needQuote;
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *escarg = va_arg(ap,char*);
isnull = escarg==0;
if( isnull ) escarg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)");
if( limit<0 ) limit = strlen(escarg);
for(i=n=0; i<limit; i++){
if( escarg[i]=='\'' ) n++;
}
needQuote = !isnull && xtype==etSQLESCAPE2;
n += i + 1 + needQuote*2;
if( n>etBUFSIZE ){
bufpt = zExtra = malloc( n );
if( bufpt==0 ) return -1;
}else{
bufpt = buf;
}
j = 0;
if( needQuote ) bufpt[j++] = '\'';
for(i=0; i<limit; i++){
bufpt[j++] = ch = escarg[i];
if( ch=='\'' ) bufpt[j++] = ch;
}
if( needQuote ) bufpt[j++] = '\'';
bufpt[j] = 0;
length = j;
if( precision>=0 && precision<length ) length = precision;
break;
}
case etHTMLIZE: {
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *zMem = va_arg(ap,char*);
if( zMem==0 ) zMem = "";
zExtra = bufpt = htmlize(zMem, limit);
length = strlen(bufpt);
if( precision>=0 && precision<length ) length = precision;
break;
}
case etHTTPIZE: {
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *zMem = va_arg(ap,char*);
if( zMem==0 ) zMem = "";
zExtra = bufpt = httpize(zMem, limit);
length = strlen(bufpt);
if( precision>=0 && precision<length ) length = precision;
break;
}
case etURLIZE: {
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *zMem = va_arg(ap,char*);
if( zMem==0 ) zMem = "";
zExtra = bufpt = urlize(zMem, limit);
length = strlen(bufpt);
if( precision>=0 && precision<length ) length = precision;
break;
}
case etFOSSILIZE: {
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *zMem = va_arg(ap,char*);
if( zMem==0 ) zMem = "";
zExtra = bufpt = fossilize(zMem, limit);
length = strlen(bufpt);
if( precision>=0 && precision<length ) length = precision;
break;
}
case etWIKISTR: {
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *zWiki = va_arg(ap, char*);
Blob wiki;
blob_init(&wiki, zWiki, limit);
wiki_convert(&wiki, pBlob, WIKI_INLINE);
blob_reset(&wiki);
length = width = 0;
break;
}
case etWIKIBLOB: {
Blob *pWiki = va_arg(ap, Blob*);
|
| ︙ | ︙ |