From 632fb9730649c97b087602ced96f44af67b3687d Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 20 Aug 2020 21:53:30 -0500 Subject: [PATCH] Update: don't tread buffer.used = 0 as error for print functions. Instead, return F_data_not without error bit to default as not an error while still allowing the caller to consider the situation. --- level_0/f_print/c/print.c | 10 +++++----- level_0/f_print/c/print.h | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/level_0/f_print/c/print.c b/level_0/f_print/c/print.c index 3499922..2cf4529 100644 --- a/level_0/f_print/c/print.c +++ b/level_0/f_print/c/print.c @@ -8,9 +8,10 @@ extern "C" { f_return_status f_print_string(FILE *output, const f_string string, const f_string_length length) { #ifndef _di_level_0_parameter_checking_ if (string == 0) return F_status_set_error(F_parameter); - if (length < 1) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (length == 0) return F_data_not; + register f_string_length i = 0; for (; i < length; i++) { @@ -27,9 +28,7 @@ extern "C" { #ifndef _di_f_print_string_dynamic_ f_return_status f_print_string_dynamic(FILE *output, const f_string_static buffer) { - #ifndef _di_level_0_parameter_checking_ - if (buffer.used == 0) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ + if (buffer.used == 0) return F_data_not; register f_string_length i = 0; @@ -50,11 +49,12 @@ extern "C" { #ifndef _di_level_0_parameter_checking_ if (range.start < 0) return F_status_set_error(F_parameter); if (range.start > range.stop) return F_status_set_error(F_parameter); - if (buffer.used == 0) return F_status_set_error(F_parameter); if (range.start >= buffer.used) return F_status_set_error(F_parameter); if (range.stop >= buffer.used) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (buffer.used == 0) return F_data_not; + register f_string_length i = range.start; for (; i <= range.stop; i++) { diff --git a/level_0/f_print/c/print.h b/level_0/f_print/c/print.h index 47da122..167bbae 100644 --- a/level_0/f_print/c/print.h +++ b/level_0/f_print/c/print.h @@ -45,6 +45,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if length is 0. * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. */ @@ -68,6 +69,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if buffer.used is 0. * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. */ @@ -93,6 +95,7 @@ extern "C" { * * @return * F_none on success. + * F_data_not if buffer.used is 0. * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. */ -- 1.8.3.1