MCPcopy Create free account
hub / github.com/audacity/audacity / process_input

Function process_input

lib-src/sqlite/shell.c:20650–20734  ·  view source on GitHub ↗

** Read input from *in and process it. If *in==0 then input ** is interactive - the user is typing it it. Otherwise, input ** is coming from a file or device. A prompt is issued and history ** is saved only if input is interactive. An interrupt signal will ** cause this routine to exit immediately, unless input is interactive. ** ** Return the number of errors. */

Source from the content-addressed store, hash-verified

20648** Return the number of errors.
20649*/
20650static int process_input(ShellState *p){
20651 char *zLine = 0; /* A single input line */
20652 char *zSql = 0; /* Accumulated SQL text */
20653 int nLine; /* Length of current line */
20654 int nSql = 0; /* Bytes of zSql[] used */
20655 int nAlloc = 0; /* Allocated zSql[] space */
20656 int nSqlPrior = 0; /* Bytes of zSql[] used by prior line */
20657 int rc; /* Error code */
20658 int errCnt = 0; /* Number of errors seen */
20659 int startline = 0; /* Line number for start of current input */
20660
20661 p->lineno = 0;
20662 while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
20663 fflush(p->out);
20664 zLine = one_input_line(p->in, zLine, nSql>0);
20665 if( zLine==0 ){
20666 /* End of input */
20667 if( p->in==0 && stdin_is_interactive ) printf("\n");
20668 break;
20669 }
20670 if( seenInterrupt ){
20671 if( p->in!=0 ) break;
20672 seenInterrupt = 0;
20673 }
20674 p->lineno++;
20675 if( nSql==0 && _all_whitespace(zLine) ){
20676 if( ShellHasFlag(p, SHFLG_Echo) ) printf("%s\n", zLine);
20677 continue;
20678 }
20679 if( zLine && (zLine[0]=='.' || zLine[0]=='#') && nSql==0 ){
20680 if( ShellHasFlag(p, SHFLG_Echo) ) printf("%s\n", zLine);
20681 if( zLine[0]=='.' ){
20682 rc = do_meta_command(zLine, p);
20683 if( rc==2 ){ /* exit requested */
20684 break;
20685 }else if( rc ){
20686 errCnt++;
20687 }
20688 }
20689 continue;
20690 }
20691 if( line_is_command_terminator(zLine) && line_is_complete(zSql, nSql) ){
20692 memcpy(zLine,";",2);
20693 }
20694 nLine = strlen30(zLine);
20695 if( nSql+nLine+2>=nAlloc ){
20696 nAlloc = nSql+nLine+100;
20697 zSql = realloc(zSql, nAlloc);
20698 if( zSql==0 ) shell_out_of_memory();
20699 }
20700 nSqlPrior = nSql;
20701 if( nSql==0 ){
20702 int i;
20703 for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}
20704 assert( nAlloc>0 && zSql!=0 );
20705 memcpy(zSql, zLine+i, nLine+1-i);
20706 startline = p->lineno;
20707 nSql = nLine-i;

Callers 3

do_meta_commandFunction · 0.85
process_sqlitercFunction · 0.85
wmainFunction · 0.85

Calls 12

one_input_lineFunction · 0.85
_all_whitespaceFunction · 0.85
do_meta_commandFunction · 0.85
line_is_completeFunction · 0.85
strlen30Function · 0.85
shell_out_of_memoryFunction · 0.85
line_contains_semicolonFunction · 0.85
runOneSqlLineFunction · 0.85
output_resetFunction · 0.85
clearTempFileFunction · 0.85
freeFunction · 0.85

Tested by

no test coverage detected