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

Function process_input

ThirdParty/sqlite/vtksqlite/shell.c:32143–32251  ·  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

32141** Return the number of errors.
32142*/
32143static int process_input(ShellState *p){
32144 char *zLine = 0; /* A single input line */
32145 char *zSql = 0; /* Accumulated SQL text */
32146 i64 nLine; /* Length of current line */
32147 i64 nSql = 0; /* Bytes of zSql[] used */
32148 i64 nAlloc = 0; /* Allocated zSql[] space */
32149 int rc; /* Error code */
32150 int errCnt = 0; /* Number of errors seen */
32151 i64 startline = 0; /* Line number for start of current input */
32152 QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
32153
32154 if( p->inputNesting==MAX_INPUT_NESTING ){
32155 /* This will be more informative in a later version. */
32156 sqlite3_fprintf(stderr,"Input nesting limit (%d) reached at line %d."
32157 " Check recursion.\n", MAX_INPUT_NESTING, p->lineno);
32158 return 1;
32159 }
32160 ++p->inputNesting;
32161 p->lineno = 0;
32162 CONTINUE_PROMPT_RESET;
32163 while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
32164 fflush(p->out);
32165 zLine = one_input_line(p->in, zLine, nSql>0);
32166 if( zLine==0 ){
32167 /* End of input */
32168 if( p->in==0 && stdin_is_interactive ) sqlite3_fputs("\n", p->out);
32169 break;
32170 }
32171 if( seenInterrupt ){
32172 if( p->in!=0 ) break;
32173 seenInterrupt = 0;
32174 }
32175 p->lineno++;
32176 if( QSS_INPLAIN(qss)
32177 && line_is_command_terminator(zLine)
32178 && line_is_complete(zSql, nSql) ){
32179 memcpy(zLine,";",2);
32180 }
32181 qss = quickscan(zLine, qss, CONTINUE_PROMPT_PSTATE);
32182 if( QSS_PLAINWHITE(qss) && nSql==0 ){
32183 /* Just swallow single-line whitespace */
32184 echo_group_input(p, zLine);
32185 qss = QSS_Start;
32186 continue;
32187 }
32188 if( zLine && (zLine[0]=='.' || zLine[0]=='#') && nSql==0 ){
32189 CONTINUE_PROMPT_RESET;
32190 echo_group_input(p, zLine);
32191 if( zLine[0]=='.' ){
32192 rc = do_meta_command(zLine, p);
32193 if( rc==2 ){ /* exit requested */
32194 break;
32195 }else if( rc ){
32196 errCnt++;
32197 }
32198 }
32199 qss = QSS_Start;
32200 continue;

Callers 5

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

Calls 13

sqlite3_fprintfFunction · 0.85
one_input_lineFunction · 0.85
sqlite3_fputsFunction · 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
runOneSqlLineFunction · 0.85
output_resetFunction · 0.85
clearTempFileFunction · 0.85

Tested by

no test coverage detected