[llvm] r200794 - Avoid using EL_GETFP.

Peter Collingbourne peter at pcc.me.uk
Tue Feb 4 12:04:46 PST 2014


Author: pcc
Date: Tue Feb  4 14:04:46 2014
New Revision: 200794

URL: http://llvm.org/viewvc/llvm-project?rev=200794&view=rev
Log:
Avoid using EL_GETFP.

This should fix the build against old versions of libedit.

Modified:
    llvm/trunk/lib/LineEditor/LineEditor.cpp

Modified: llvm/trunk/lib/LineEditor/LineEditor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LineEditor/LineEditor.cpp?rev=200794&r1=200793&r2=200794&view=diff
==============================================================================
--- llvm/trunk/lib/LineEditor/LineEditor.cpp (original)
+++ llvm/trunk/lib/LineEditor/LineEditor.cpp Tue Feb  4 14:04:46 2014
@@ -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(Edit
   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 ProgNam
     this->HistoryPath = getDefaultHistoryPath(ProgName);
 
   Data->LE = this;
+  Data->Out = Out;
 
   Data->Hist = ::history_init();
   assert(Data->Hist);
@@ -228,15 +229,9 @@ LineEditor::LineEditor(StringRef ProgNam
 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() {





More information about the llvm-commits mailing list