MCPcopy Create free account
hub / github.com/Kitware/VTK / appendText

Function appendText

ThirdParty/sqlite/vtksqlite/shell.c:1438–1472  ·  view source on GitHub ↗

zIn is either a pointer to a NULL-terminated string in memory obtained ** from malloc(), or a NULL pointer. The string pointed to by zAppend is ** added to zIn, and the result returned in memory obtained from malloc(). ** zIn, if it was not NULL, is freed. ** ** If the third argument, quote, is not '\0', then it is used as a ** quote character for zAppend. */

Source from the content-addressed store, hash-verified

1436** quote character for zAppend.
1437*/
1438static void appendText(ShellText *p, const char *zAppend, char quote){
1439 i64 len;
1440 i64 i;
1441 i64 nAppend = strlen30(zAppend);
1442
1443 len = nAppend+p->n+1;
1444 if( quote ){
1445 len += 2;
1446 for(i=0; i<nAppend; i++){
1447 if( zAppend[i]==quote ) len++;
1448 }
1449 }
1450
1451 if( p->z==0 || p->n+len>=p->nAlloc ){
1452 p->nAlloc = p->nAlloc*2 + len + 20;
1453 p->z = realloc(p->z, p->nAlloc);
1454 shell_check_oom(p->z);
1455 }
1456
1457 if( quote ){
1458 char *zCsr = p->z+p->n;
1459 *zCsr++ = quote;
1460 for(i=0; i<nAppend; i++){
1461 *zCsr++ = zAppend[i];
1462 if( zAppend[i]==quote ) *zCsr++ = quote;
1463 }
1464 *zCsr++ = quote;
1465 p->n = (int)(zCsr - p->z);
1466 *zCsr = '\0';
1467 }else{
1468 memcpy(p->z+p->n, zAppend, nAppend);
1469 p->n += nAppend;
1470 p->z[p->n] = '\0';
1471 }
1472}
1473
1474/*
1475** Attempt to determine if identifier zName needs to be quoted, either

Callers 4

shellFakeSchemaFunction · 0.85
captureOutputCallbackFunction · 0.85
dump_callbackFunction · 0.85
do_meta_commandFunction · 0.85

Calls 2

strlen30Function · 0.85
shell_check_oomFunction · 0.85

Tested by

no test coverage detected