X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FLineEditor%2FLineEditor.cpp;h=a50ccc388f154a2c22235fb65cd3be6a8d2f54dd;hb=12af22e8cc217827cf4f118b0f5e4ebbda9925ae;hp=80c8080020239439e99bc00d1b1f4efd27004cd4;hpb=878ca661e63c960b17b8be05a6f7311306ce41dc;p=oota-llvm.git diff --git a/lib/LineEditor/LineEditor.cpp b/lib/LineEditor/LineEditor.cpp index 80c80800202..a50ccc388f1 100644 --- a/lib/LineEditor/LineEditor.cpp +++ b/lib/LineEditor/LineEditor.cpp @@ -102,6 +102,8 @@ struct LineEditor::InternalData { unsigned PrevCount; std::string ContinuationOutput; + + FILE *Out; }; static const char *ElGetPromptFn(EditLine *EL) { @@ -120,9 +122,7 @@ static unsigned char ElCompletionFn(EditLine *EL, int ch) { if (el_get(EL, EL_CLIENTDATA, &Data) == 0) { if (!Data->ContinuationOutput.empty()) { // This is the continuation of the AK_ShowCompletions branch below. - FILE *Out; - if (::el_get(EL, EL_GETFP, 1, &Out) != 0) - return CC_ERROR; + FILE *Out = Data->Out; // Print the required output (see below). ::fwrite(Data->ContinuationOutput.c_str(), @@ -198,6 +198,7 @@ LineEditor::LineEditor(StringRef ProgName, StringRef HistoryPath, FILE *In, this->HistoryPath = getDefaultHistoryPath(ProgName); Data->LE = this; + Data->Out = Out; Data->Hist = ::history_init(); assert(Data->Hist); @@ -228,15 +229,9 @@ LineEditor::LineEditor(StringRef ProgName, StringRef HistoryPath, FILE *In, LineEditor::~LineEditor() { saveHistory(); - FILE *Out; - if (::el_get(Data->EL, EL_GETFP, 1, &Out) != 0) - Out = 0; - ::history_end(Data->Hist); ::el_end(Data->EL); - - if (Out) - ::fwrite("\n", 1, 1, Out); + ::fwrite("\n", 1, 1, Data->Out); } void LineEditor::saveHistory() {