diff options
author | Tom Tromey <tom@tromey.com> | 2021-12-31 10:40:02 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-01-05 11:01:02 -0700 |
commit | d53fd721a18f8c827aa69ffbd15abd99641b5e20 (patch) | |
tree | 436641845129a7eb9eb38733a456656da9312366 /gdb/ui-file.h | |
parent | 28a4e64dd1b17b0d9f267c3466d7da3e8a41afd8 (diff) | |
download | binutils-d53fd721a18f8c827aa69ffbd15abd99641b5e20.zip binutils-d53fd721a18f8c827aa69ffbd15abd99641b5e20.tar.gz binutils-d53fd721a18f8c827aa69ffbd15abd99641b5e20.tar.bz2 |
Implement putstr and putstrn in ui_file
In my tour of the ui_file subsystem, I found that fputstr and fputstrn
can be simplified. The _filtered forms are never used (and IMO
unlikely to ever be used) and so can be removed. And, the interface
can be simplified by removing a callback function and moving the
implementation directly to ui_file.
A new self-test is included. Previously, I think nothing was testing
this code.
Regression tested on x86-64 Fedora 34.
Diffstat (limited to 'gdb/ui-file.h')
-rw-r--r-- | gdb/ui-file.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/gdb/ui-file.h b/gdb/ui-file.h index 89f249e..c097abf 100644 --- a/gdb/ui-file.h +++ b/gdb/ui-file.h @@ -34,12 +34,22 @@ public: 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); @@ -96,6 +106,13 @@ public: 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; |