** Set the destination table field of the ShellState structure to ** the name of the table given. Escape any quote characters in the ** table name. */
| 12581 | ** table name. |
| 12582 | */ |
| 12583 | static void set_table_name(ShellState *p, const char *zName){ |
| 12584 | int i, n; |
| 12585 | char cQuote; |
| 12586 | char *z; |
| 12587 | |
| 12588 | if( p->zDestTable ){ |
| 12589 | free(p->zDestTable); |
| 12590 | p->zDestTable = 0; |
| 12591 | } |
| 12592 | if( zName==0 ) return; |
| 12593 | cQuote = quoteChar(zName); |
| 12594 | n = strlen30(zName); |
| 12595 | if( cQuote ) n += n+2; |
| 12596 | z = p->zDestTable = malloc( n+1 ); |
| 12597 | if( z==0 ) shell_out_of_memory(); |
| 12598 | n = 0; |
| 12599 | if( cQuote ) z[n++] = cQuote; |
| 12600 | for(i=0; zName[i]; i++){ |
| 12601 | z[n++] = zName[i]; |
| 12602 | if( zName[i]==cQuote ) z[n++] = cQuote; |
| 12603 | } |
| 12604 | if( cQuote ) z[n++] = cQuote; |
| 12605 | z[n] = 0; |
| 12606 | } |
| 12607 | |
| 12608 | |
| 12609 | /* |
no test coverage detected