diff options
author | Steve Gonczi <steve.gonczi@delphix.com> | 2016-11-25 17:37:18 -0600 |
---|---|---|
committer | Matthew Ahrens <mahrens@delphix.com> | 2016-11-26 13:36:58 -0600 |
commit | 218912f6649942e736d5234e96f1a5c6367713d1 (patch) | |
tree | 6cfcf0da64f09855e317b36727a2bbf5b18ad8d1 | |
parent | 99aa8b55058e512798eafbd71f72f916bdc10181 (diff) | |
download | illumos-joyent-218912f6649942e736d5234e96f1a5c6367713d1.tar.gz |
7575 mdb autoformatter emits an unexpected leading \n when printing large, formatted strings
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_io.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_io.c b/usr/src/cmd/mdb/common/mdb/mdb_io.c index 8b4f1aaaef..84e7c92784 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_io.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_io.c @@ -25,6 +25,7 @@ /* * Copyright (c) 2012, Joyent, Inc. All rights reserved. + * Copyright (c) 2016 by Delphix. All rights reserved. */ /* @@ -1513,7 +1514,17 @@ iob_doprnt(mdb_iob_t *iob, const char *format, varglist_t *ap) /* * If the string and the option altstr won't fit on this line * and auto-wrap is set (default), skip to the next line. + * If the string contains \n, and the \n terminated substring + * + altstr is shorter than the above, use the shorter lf_len. */ + if (u.str != NULL) { + char *np = strchr(u.str, '\n'); + if (np != NULL) { + int lf_len = (np - u.str) + altlen; + if (lf_len < width) + width = lf_len; + } + } if (IOB_WRAPNOW(iob, width)) mdb_iob_nl(iob); |