/ Changes On Branch string-quoting-dump
Login

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

Changes In Branch string-quoting-dump Excluding Merge-Ins

This is equivalent to a diff from 7359fcacaa to 8b2954dd83

2017-03-13
18:24
In the output of the ".dump" command in the CLI, quote newline and carriage-return characters using the char() function, so that they do not get eaten by end-of-line processing logic in the OS or in other command-line utilities and/or libraries. (check-in: 68f6dc7af1 user: drh tags: trunk)
2017-03-11
13:02
Make sure the translateColumnToCopy() routine in the query planner does not try to access an array that failed to be fully allocated due to a prior OOM. This fixes an issue discovered by OSSFuzz. (check-in: 3299a26160 user: drh tags: trunk)
01:56
The output of the ".dump" command in the CLI quotes newline and carriage-return characters using "char(10)" and "char(13)". (Closed-Leaf check-in: 8b2954dd83 user: drh tags: string-quoting-dump)
00:46
Increase the number of significant digits in floating point literals on ".dump" output from the shell. (check-in: 7359fcacaa user: drh tags: trunk)
2017-03-10
18:36
Remove the rbu_round_trip.tcl script. It is now part of project "test-dbs". (check-in: b5bf295767 user: dan tags: trunk)

Changes to src/shell.c.

1486
1487
1488
1489
1490
1491
1492



1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504

1505

1506
1507


1508
1509
1510

1511
1512




1513


1514



1515
1516




1517


1518
1519
1520
1521
1522
1523
1524
1525
  raw_printf(out,"X'");
  for(i=0; i<nBlob; i++){ raw_printf(out,"%02x",zBlob[i]&0xff); }
  raw_printf(out,"'");
}

/*
** Output the given string as a quoted string using SQL quoting conventions.



*/
static void output_quoted_string(FILE *out, const char *z){
  int i;
  int nSingle = 0;
  setBinaryMode(out, 1);
  for(i=0; z[i]; i++){
    if( z[i]=='\'' ) nSingle++;
  }
  if( nSingle==0 ){
    utf8_printf(out,"'%s'",z);
  }else{
    raw_printf(out,"'");

    while( *z ){

      for(i=0; z[i] && z[i]!='\''; i++){}
      if( i==0 ){


        raw_printf(out,"''");
        z++;
      }else if( z[i]=='\'' ){

        utf8_printf(out,"%.*s''",i,z);
        z += i+1;




      }else{


        utf8_printf(out,"%s",z);



        break;
      }




    }


    raw_printf(out,"'");
  }
  setTextMode(out, 1);
}

/*
** Output the given string as a quoted according to C or TCL quoting rules.
*/







>
>
>



|

|
<
<
|


|
>

>
|
|
>
>
|
<
|
>
|
|
>
>
>
>
|
>
>
|
>
>
>


>
>
>
>
|
>
>
|







1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501


1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513

1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
  raw_printf(out,"X'");
  for(i=0; i<nBlob; i++){ raw_printf(out,"%02x",zBlob[i]&0xff); }
  raw_printf(out,"'");
}

/*
** Output the given string as a quoted string using SQL quoting conventions.
**
** The "\n" and "\r" characters are converted to char(10) and char(13)
** to prevent them from being transformed by end-of-line translators.
*/
static void output_quoted_string(FILE *out, const char *z){
  int i;
  char c;
  setBinaryMode(out, 1);
  for(i=0; (c = z[i])!=0 && c!='\'' && c!='\n' && c!='\r'; i++){}


  if( c==0 ){
    utf8_printf(out,"'%s'",z);
  }else{
    int inQuote = 0;
    int bStarted = 0;
    while( *z ){
      for(i=0; (c = z[i])!=0 && c!='\n' && c!='\r' && c!='\''; i++){}
      if( c=='\'' ) i++;
      if( i ){
        if( !inQuote ){
          if( bStarted ) raw_printf(out, "||");
          raw_printf(out, "'");

          inQuote = 1;
        }
        utf8_printf(out, "%.*s", i, z);
        z += i;
        bStarted = 1;
      }
      if( c=='\'' ){
        raw_printf(out, "'");
        continue;
      }
      if( inQuote ){
        raw_printf(out, "'");
        inQuote = 0;
      }
      if( c==0 ){
        break;
      }
      for(i=0; (c = z[i])=='\r' || c=='\n'; i++){
        if( bStarted ) raw_printf(out, "||");
        raw_printf(out, "char(%d)", c);
        bStarted = 1;
      }
      z += i;
    }
    if( inQuote ) raw_printf(out, "'");
  }
  setTextMode(out, 1);
}

/*
** Output the given string as a quoted according to C or TCL quoting rules.
*/