From 0d4af7a462906cd92b053148a9ab59c2003d754a Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Sun, 21 Jan 2018 18:10:42 +0000 Subject: [PATCH] Resolve further error message and warning idiosyncrasies --- backend/library.c | 39 ++++++++++++++++++++++++++++++++------- backend_qt/qzint.cpp | 2 +- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/backend/library.c b/backend/library.c index f2d93749..5c258fc1 100644 --- a/backend/library.c +++ b/backend/library.c @@ -1282,25 +1282,36 @@ int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) { int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle) { int error_number; + int first_err; error_number = ZBarcode_Encode(symbol, input, length); - if (error_number != 0) { + if (error_number >= 5) { return error_number; } + first_err = error_number; error_number = ZBarcode_Print(symbol, rotate_angle); + if (error_number == 0) { + error_number = first_err; + } return error_number; } int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle) { int error_number; + int first_err; error_number = ZBarcode_Encode(symbol, input, length); - if (error_number != 0) { + if (error_number >= 5) { return error_number; } + first_err = error_number; error_number = ZBarcode_Buffer(symbol, rotate_angle); + if (error_number == 0) { + error_number = first_err; + } + return error_number; } @@ -1365,24 +1376,38 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename) { int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle) { int error_number; + int first_err; error_number = ZBarcode_Encode_File(symbol, filename); - if (error_number != 0) { + if (error_number >= 5) { return error_number; } - - return ZBarcode_Print(symbol, rotate_angle); + + first_err = error_number; + error_number = ZBarcode_Print(symbol, rotate_angle); + if (error_number == 0) { + error_number = first_err; + } + + return error_number; } int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle) { int error_number; + int first_err; error_number = ZBarcode_Encode_File(symbol, filename); - if (error_number != 0) { + if (error_number >= 5) { return error_number; } + + first_err = error_number; + error_number = ZBarcode_Buffer(symbol, rotate_angle); + if (error_number == 0) { + error_number = first_err; + } - return ZBarcode_Buffer(symbol, rotate_angle); + return error_number; } /* diff --git a/backend_qt/qzint.cpp b/backend_qt/qzint.cpp index d7222ed3..5a984119 100644 --- a/backend_qt/qzint.cpp +++ b/backend_qt/qzint.cpp @@ -279,7 +279,7 @@ namespace Zint { strcpy(m_zintSymbol->fgcolour, fgcol.data()); strcpy(m_zintSymbol->bgcolour, bgcol.data()); m_error = ZBarcode_Encode_and_Print(m_zintSymbol, (unsigned char*) bstr.data(), bstr.length(), 0); - if (m_error != 0) { + if (m_error >= 5) { m_lastError = m_zintSymbol->errtxt; return false; } else {