MCPcopy Create free account
hub / github.com/duckdb/duckdb / OneInputLine

Method OneInputLine

tools/shell/shell.cpp:571–601  ·  view source on GitHub ↗

** Retrieve a single line of input text. ** ** If in==0 then read from standard input and prompt before each line. ** If isContinuation is true, then a continuation prompt is appropriate. ** If isContinuation is zero, then the main prompt should be used. ** ** If zPrior is not NULL then it is a buffer from a prior call to this ** routine that can be reused. ** ** The result is stored in space obta

Source from the content-addressed store, hash-verified

569** zPrior argument for reuse.
570*/
571char *ShellState::OneInputLine(FILE *in, char *zPrior, int isContinuation) {
572 if (in) {
573 // use local_getline when reading from a file
574 // don't print prompt in this scenario
575 return local_getline(zPrior, in);
576 }
577
578#ifdef HAVE_LINENOISE
579 if (rl_version == ReadLineVersion::LINENOISE) {
580 // use linenoise
581 string prompt_str;
582 const char *prompt_text;
583 if (!isContinuation) {
584 prompt_str = main_prompt->GeneratePrompt(*this);
585 prompt_text = prompt_str.c_str();
586 } else {
587 prompt_text = continuePrompt;
588 }
589 free(zPrior);
590 return linenoise(prompt_text);
591 }
592#endif
593 // using local_getline to read from stdin - print the prompt
594 if (!isContinuation) {
595 main_prompt->PrintPrompt(*this, PrintOutput::STDOUT);
596 } else {
597 Print(continuePrompt);
598 }
599 fflush(stdout);
600 return local_getline(zPrior, stdin);
601}
602
603/*
604** Return the value of a hexadecimal digit. Return -1 if the input

Callers

nothing calls this directly

Calls 5

local_getlineFunction · 0.85
linenoiseFunction · 0.85
GeneratePromptMethod · 0.80
c_strMethod · 0.80
PrintPromptMethod · 0.80

Tested by

no test coverage detected