Fix the '-p' command-line switch

This commit is contained in:
Christopher Gautier 2015-06-21 17:20:05 +02:00
parent 67b649fa01
commit 01024f57cb

View File

@ -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;
}