From 01024f57cb18b5d47ee318e034a96644cd761963 Mon Sep 17 00:00:00 2001 From: Christopher Gautier Date: Sun, 21 Jun 2015 17:20:05 +0200 Subject: [PATCH] Fix the '-p' command-line switch --- tools/dis/dis.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index 55550735f..7d606f306 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -114,16 +114,17 @@ int main(int argc, char **argv) { error = spvExtInstTableGet(&extInstTable); spvCheck(error, fprintf(stderr, "error: Internal malfunction.\n")); + bool option_print = spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_PRINT, options); spv_text text; spv_diagnostic diagnostic = nullptr; error = spvBinaryToText(&binary, options, opcodeTable, operandTable, - extInstTable, &text, &diagnostic); + extInstTable, + option_print ? NULL : &text, + &diagnostic); spvCheck(error, spvDiagnosticPrint(diagnostic); spvDiagnosticDestroy(diagnostic); return error); - if (spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_PRINT, options)) { - printf("%s", text->str); - } else { + if (!option_print) { if (FILE *fp = fopen(outFile, "w")) { size_t written = fwrite(text->str, sizeof(char), (size_t)text->length, fp); if (text->length != written) { @@ -138,7 +139,5 @@ int main(int argc, char **argv) { } } - spvTextDestroy(text); - return 0; }