/ Check-in [3375571a]
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 | SQL 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
Context
2013-12-17
16:10
Add the printf() SQL function. check-in: a1bb62f9 user: drh tags: trunk
15:58
Fix the formatting of %c in the printf() SQL function. Closed-Leaf check-in: 3375571a user: drh tags: printf-sql-function
15:03
Add the printf() SQL function. check-in: 6db7052e user: drh tags: printf-sql-function
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/printf.c.

   602    602             i = prefix!=0;
   603    603             while( nPad-- ) bufpt[i++] = '0';
   604    604             length = width;
   605    605           }
   606    606   #endif /* !defined(SQLITE_OMIT_FLOATING_POINT) */
   607    607           break;
   608    608         case etSIZE:
   609         -        if( !bArgList ) *(va_arg(ap,int*)) = pAccum->nChar;
          609  +        if( !bArgList ){
          610  +          *(va_arg(ap,int*)) = pAccum->nChar;
          611  +        }
   610    612           length = width = 0;
   611    613           break;
   612    614         case etPERCENT:
   613    615           buf[0] = '%';
   614    616           bufpt = buf;
   615    617           length = 1;
   616    618           break;
   617    619         case etCHARX:
   618    620           if( bArgList ){
   619         -          c = (int)getIntArg(pArgList);
          621  +          bufpt = getTextArg(pArgList);
          622  +          c = bufpt ? bufpt[0] : 0;
   620    623           }else{
   621    624             c = va_arg(ap,int);
   622    625           }
   623    626           buf[0] = (char)c;
   624    627           if( precision>=0 ){
   625    628             for(idx=1; idx<precision; idx++) buf[idx] = (char)c;
   626    629             length = precision;

Changes to test/printf2.test.

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