[Lldb-commits] [lldb] r201092 - Host: unconstify editline paramters

Saleem Abdulrasool compnerd at compnerd.org
Mon Feb 10 08:10:42 PST 2014


Author: compnerd
Date: Mon Feb 10 10:10:42 2014
New Revision: 201092

URL: http://llvm.org/viewvc/llvm-project?rev=201092&view=rev
Log:
Host: unconstify editline paramters

Although the interface to el_push should be a constant parameter (as it is on
Darwin), certain Linux distributions currently ship a header which does not
provide proper const correctness.  This causes compilation failures on Linux.
Strip the constness on the parameter, which whilst incorrect, is mostly
harmless.  The parameter will not be changed by the interface and so it is
acceptable to do this.  When distributions have updated to a more correct
declaration, it would be nice to revert this change.

Addresses PR18784.

Modified:
    lldb/trunk/source/Host/common/Editline.cpp

Modified: lldb/trunk/source/Host/common/Editline.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Editline.cpp?rev=201092&r1=201091&r2=201092&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Editline.cpp (original)
+++ lldb/trunk/source/Host/common/Editline.cpp Mon Feb 10 10:10:42 2014
@@ -264,7 +264,8 @@ Editline::Push (const char *bytes, size_
     {
         // Must NULL terminate the string for el_push() so we stick it
         // into a std::string first
-        ::el_push(m_editline, std::string (bytes, len).c_str());
+        ::el_push(m_editline,
+                  const_cast<char*>(std::string (bytes, len).c_str()));
         return len;
     }
     return 0;
@@ -340,7 +341,8 @@ Editline::GetLines(const std::string &en
                         // we were editing previous lines, then populate the line
                         // with the appropriate contents
                         if (line_idx+1 < lines.GetSize() && !lines[line_idx+1].empty())
-                            ::el_push (m_editline, lines[line_idx+1].c_str());
+                            ::el_push (m_editline,
+                                       const_cast<char*>(lines[line_idx+1].c_str()));
                     }
                     else if (line_status == LineStatus::Error)
                     {
@@ -356,7 +358,8 @@ Editline::GetLines(const std::string &en
                         //::fprintf (out_file, "\033[1A\033[%uD\033[2K", (uint32_t)(m_lines_prompt.size() + lines[line_idx].size())); // Make cursor go up a line and clear that line
                         ::fprintf (out_file, "\033[1A\033[1000D\033[2K");
                         if (!lines[line_idx-1].empty())
-                            ::el_push (m_editline, lines[line_idx-1].c_str());
+                            ::el_push (m_editline,
+                                       const_cast<char*>(lines[line_idx-1].c_str()));
                         --m_lines_curr_line;
                     }
                     break;
@@ -366,7 +369,8 @@ Editline::GetLines(const std::string &en
                     //::fprintf (out_file, "\033[1B\033[%uD\033[2K", (uint32_t)(m_lines_prompt.size() + lines[line_idx].size()));
                     ::fprintf (out_file, "\033[1B\033[1000D\033[2K");
                     if (line_idx+1 < lines.GetSize() && !lines[line_idx+1].empty())
-                        ::el_push (m_editline, lines[line_idx+1].c_str());
+                        ::el_push (m_editline,
+                                   const_cast<char*>(lines[line_idx+1].c_str()));
                     break;
             }
         }





More information about the lldb-commits mailing list