SQLite

Check-in [3375571a5e]
Login

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

Overview
Comment:Fix the formatting of %c in the printf() SQL function.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | printf-sql-function
Files: files | file ages | folders
SHA1: 3375571a5e267744c19a7c310840256cec57a242
User & Date: drh 2013-12-17 15:58:42.950
Context
2013-12-17
16:10
Add the printf() SQL function. (check-in: a1bb62f91a user: drh tags: trunk)
15:58
Fix the formatting of %c in the printf() SQL function. (Closed-Leaf check-in: 3375571a5e user: drh tags: printf-sql-function)
15:03
Add the printf() SQL function. (check-in: 6db7052eee user: drh tags: printf-sql-function)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/printf.c.
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
          i = prefix!=0;
          while( nPad-- ) bufpt[i++] = '0';
          length = width;
        }
#endif /* !defined(SQLITE_OMIT_FLOATING_POINT) */
        break;
      case etSIZE:

        if( !bArgList ) *(va_arg(ap,int*)) = pAccum->nChar;

        length = width = 0;
        break;
      case etPERCENT:
        buf[0] = '%';
        bufpt = buf;
        length = 1;
        break;
      case etCHARX:
        if( bArgList ){
          c = (int)getIntArg(pArgList);

        }else{
          c = va_arg(ap,int);
        }
        buf[0] = (char)c;
        if( precision>=0 ){
          for(idx=1; idx<precision; idx++) buf[idx] = (char)c;
          length = precision;







>
|
>









|
>







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
          i = prefix!=0;
          while( nPad-- ) bufpt[i++] = '0';
          length = width;
        }
#endif /* !defined(SQLITE_OMIT_FLOATING_POINT) */
        break;
      case etSIZE:
        if( !bArgList ){
          *(va_arg(ap,int*)) = pAccum->nChar;
        }
        length = width = 0;
        break;
      case etPERCENT:
        buf[0] = '%';
        bufpt = buf;
        length = 1;
        break;
      case etCHARX:
        if( bArgList ){
          bufpt = getTextArg(pArgList);
          c = bufpt ? bufpt[0] : 0;
        }else{
          c = va_arg(ap,int);
        }
        buf[0] = (char)c;
        if( precision>=0 ){
          for(idx=1; idx<precision; idx++) buf[idx] = (char)c;
          length = precision;
Changes to test/printf2.test.
47
48
49
50
51
52
53



54
55
56
} {314159}
do_execsql_test printf2-1.11 {
  SELECT printf('%lld%n',314159.2653,'hi');
} {314159}
do_execsql_test printf2-1.12 {
  SELECT printf('%.*z',5,'abcdefghijklmnop');
} {abcde}





finish_test







>
>
>



47
48
49
50
51
52
53
54
55
56
57
58
59
} {314159}
do_execsql_test printf2-1.11 {
  SELECT printf('%lld%n',314159.2653,'hi');
} {314159}
do_execsql_test printf2-1.12 {
  SELECT printf('%.*z',5,'abcdefghijklmnop');
} {abcde}
do_execsql_test printf2-1.13 {
  SELECT printf('%c','abcdefghijklmnop');
} {a}


finish_test