MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / process_input

Function process_input

modules/dasSQLITE/sqlite/shell.c:26532–26640  ·  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

26530** Return the number of errors.
26531*/
26532static int process_input(ShellState *p){
26533 char *zLine = 0; /* A single input line */
26534 char *zSql = 0; /* Accumulated SQL text */
26535 i64 nLine; /* Length of current line */
26536 i64 nSql = 0; /* Bytes of zSql[] used */
26537 i64 nAlloc = 0; /* Allocated zSql[] space */
26538 int rc; /* Error code */
26539 int errCnt = 0; /* Number of errors seen */
26540 i64 startline = 0; /* Line number for start of current input */
26541 QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
26542
26543 if( p->inputNesting==MAX_INPUT_NESTING ){
26544 /* This will be more informative in a later version. */
26545 utf8_printf(stderr,"Input nesting limit (%d) reached at line %d."
26546 " Check recursion.\n", MAX_INPUT_NESTING, p->lineno);
26547 return 1;
26548 }
26549 ++p->inputNesting;
26550 p->lineno = 0;
26551 CONTINUE_PROMPT_RESET;
26552 while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
26553 fflush(p->out);
26554 zLine = one_input_line(p->in, zLine, nSql>0);
26555 if( zLine==0 ){
26556 /* End of input */
26557 if( p->in==0 && stdin_is_interactive ) printf("\n");
26558 break;
26559 }
26560 if( seenInterrupt ){
26561 if( p->in!=0 ) break;
26562 seenInterrupt = 0;
26563 }
26564 p->lineno++;
26565 if( QSS_INPLAIN(qss)
26566 && line_is_command_terminator(zLine)
26567 && line_is_complete(zSql, nSql) ){
26568 memcpy(zLine,";",2);
26569 }
26570 qss = quickscan(zLine, qss, CONTINUE_PROMPT_PSTATE);
26571 if( QSS_PLAINWHITE(qss) && nSql==0 ){
26572 /* Just swallow single-line whitespace */
26573 echo_group_input(p, zLine);
26574 qss = QSS_Start;
26575 continue;
26576 }
26577 if( zLine && (zLine[0]=='.' || zLine[0]=='#') && nSql==0 ){
26578 CONTINUE_PROMPT_RESET;
26579 echo_group_input(p, zLine);
26580 if( zLine[0]=='.' ){
26581 rc = do_meta_command(zLine, p);
26582 if( rc==2 ){ /* exit requested */
26583 break;
26584 }else if( rc ){
26585 errCnt++;
26586 }
26587 }
26588 qss = QSS_Start;
26589 continue;

Callers 4

do_meta_commandFunction · 0.85
process_sqlitercFunction · 0.85
wmainFunction · 0.85
fiddle_execFunction · 0.85

Calls 15

utf8_printfFunction · 0.85
one_input_lineFunction · 0.85
printfFunction · 0.85
line_is_completeFunction · 0.85
quickscanFunction · 0.85
echo_group_inputFunction · 0.85
do_meta_commandFunction · 0.85
shell_check_oomFunction · 0.85
IsSpaceFunction · 0.85
assertFunction · 0.85
runOneSqlLineFunction · 0.85

Tested by

no test coverage detected