** 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
| 569 | ** zPrior argument for reuse. |
| 570 | */ |
| 571 | char *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 |
nothing calls this directly
no test coverage detected