]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/mi/mi-console.c
Implement putstr and putstrn in ui_file
[thirdparty/binutils-gdb.git] / gdb / mi / mi-console.c
index 157154b361ccd42de706671bf01e9398c2b94ce1..9db87fe180c2f8b421223d998ac6f619ee8e0931 100644 (file)
@@ -48,16 +48,6 @@ mi_console_file::write (const char *buf, long length_buf)
     this->flush ();
 }
 
-/* Write C to STREAM's in an async-safe way.  */
-
-static int
-do_fputc_async_safe (int c, ui_file *stream)
-{
-  char ch = c;
-  stream->write_async_safe (&ch, 1);
-  return c;
-}
-
 void
 mi_console_file::write_async_safe (const char *buf, long length_buf)
 {
@@ -65,12 +55,11 @@ mi_console_file::write_async_safe (const char *buf, long length_buf)
   if (m_quote)
     {
       m_raw->write_async_safe (&m_quote, 1);
-      fputstrn_unfiltered (buf, length_buf, m_quote, do_fputc_async_safe,
-                          m_raw);
+      m_raw->putstrn (buf, length_buf, m_quote, true);
       m_raw->write_async_safe (&m_quote, 1);
     }
   else
-    fputstrn_unfiltered (buf, length_buf, 0, do_fputc_async_safe, m_raw);
+    m_raw->putstrn (buf, length_buf, 0, true);
 
   char nl = '\n';
   m_raw->write_async_safe (&nl, 1);
@@ -91,14 +80,13 @@ mi_console_file::flush ()
       if (m_quote)
        {
          fputc_unfiltered (m_quote, m_raw);
-         fputstrn_unfiltered (buf, length_buf, m_quote, fputc_unfiltered,
-                              m_raw);
+         m_raw->putstrn (buf, length_buf, m_quote);
          fputc_unfiltered (m_quote, m_raw);
          fputc_unfiltered ('\n', m_raw);
        }
       else
        {
-         fputstrn_unfiltered (buf, length_buf, 0, fputc_unfiltered, m_raw);
+         m_raw->putstrn (buf, length_buf, 0);
          fputc_unfiltered ('\n', m_raw);
        }
       gdb_flush (m_raw);