Skip to content

Commit f3f6922

Browse files
committed
ddbg: avoid emitting extraneous newlines after plain/HTML/RTF conversion
1 parent 2e85ad1 commit f3f6922

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tools/ddbg.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,10 @@ static int do_process_2(std::string_view &&data, const char *str)
513513
if (html_to_plain(data.data(), data.size(), CP_OEMCP, out) < 0) {
514514
fprintf(stderr, "html-to_plain failed\n");
515515
return -1;
516+
} else if (HXio_fullwrite(STDOUT_FILENO, out.data(), out.size()) < 0) {
517+
perror("write");
518+
return 01;
516519
}
517-
puts(out.c_str());
518520
return 0;
519521
}
520522
case CM_LZXDEC:
@@ -540,17 +542,21 @@ static int do_process_2(std::string_view &&data, const char *str)
540542
if (!rtf_to_html(data.data(), data.size(), "utf-8", out, at)) {
541543
fprintf(stderr, "rtf_to_html failed\n");
542544
return -1;
545+
} else if (HXio_fullwrite(STDOUT_FILENO, out.data(), out.size()) < 0) {
546+
perror("write");
547+
return -1;
543548
}
544-
puts(out.c_str());
545549
return 0;
546550
}
547551
case CM_TEXTTOHTML: {
548552
std::unique_ptr<char[], stdlib_delete> out(plain_to_html(str));
549553
if (out == nullptr) {
550554
fprintf(stderr, "Out of memory\n");
551555
return -1;
556+
} else if (HXio_fullwrite(STDOUT_FILENO, out.get(), strlen(out.get())) < 0) {
557+
perror("write");
558+
return -1;
552559
}
553-
puts(out.get());
554560
return 0;
555561
}
556562
case CM_UNRTFCP: {

0 commit comments

Comments
 (0)