/* UI_FILE - a generic STDIO like output stream.
- Copyright (C) 1999-2021 Free Software Foundation, Inc.
+ Copyright (C) 1999-2022 Free Software Foundation, Inc.
This file is part of GDB.
void printf (const char *, ...) ATTRIBUTE_PRINTF (2, 3);
- /* Print a string whose delimiter is QUOTER. Note that these
- routines should only be called for printing things which are
- independent of the language of the program being debugged. */
+ /* Print a NUL-terminated string whose delimiter is QUOTER. Note
+ that these routines should only be called for printing things
+ which are independent of the language of the program being
+ debugged.
+
+ This will normally escape backslashes and instances of QUOTER.
+ If QUOTER is 0, it won't escape backslashes or any quoting
+ character. As a side effect, if you pass the backslash character
+ as the QUOTER, this will escape backslashes as usual, but not any
+ other quoting character. */
void putstr (const char *str, int quoter);
- void putstrn (const char *str, int n, int quoter);
+ /* Like putstr, but only print the first N characters of STR. If
+ ASYNC_SAFE is true, then the output is done via the
+ write_async_safe method. */
+ void putstrn (const char *str, int n, int quoter, bool async_safe = false);
int putc (int c);
Otherwise, return -1. */
virtual int fd () const
{ return -1; }
+
+ /* Return true if this object supports paging, false otherwise. */
+ virtual bool can_page () const
+ {
+ /* Almost no file supports paging, which is why this is the
+ default. */
+ return false;
+ }
+
+private:
+
+ /* Helper function for putstr and putstrn. Print the character C on
+ this stream as part of the contents of a literal string whose
+ delimiter is QUOTER. */
+ void printchar (int c, int quoter, bool async_safe);
};
typedef std::unique_ptr<ui_file> ui_file_up;
int fd () const override
{ return m_fd; }
+ virtual bool can_page () const override
+ {
+ return m_file == stdout;
+ }
+
private:
/* Sets the internal stream to FILE, and saves the FILE's file
descriptor in M_FD. */
bool can_emit_style_escape () override;
void flush () override;
+ virtual bool can_page () const override
+ {
+ /* If one of the underlying files can page, then we allow it
+ here. */
+ return m_one->can_page () || m_two->can_page ();
+ }
+
private:
/* The two underlying ui_files. */
ui_file *m_one;