From: Kevin Day Date: Fri, 21 Aug 2020 02:53:30 +0000 (-0500) Subject: Update: don't tread buffer.used = 0 as error for print functions. X-Git-Tag: 0.5.0~44 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=632fb9730649c97b087602ced96f44af67b3687d;p=fll 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. --- 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. */