From 1bd399d3a0fc94b4c291d511c6ed7447e62b60ea Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 9 Nov 2020 20:15:20 -0600 Subject: [PATCH] Update: relax parameter restrictions in f_iki_read(). Return f_data_not, F_data_not_stop, or F_data_not_eos if there is no data instead of F_parameter with an error bit. --- level_0/f_iki/c/iki.c | 15 ++++++++++++--- level_0/f_iki/c/iki.h | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/level_0/f_iki/c/iki.c b/level_0/f_iki/c/iki.c index 0c5e1ef..c4db092 100644 --- a/level_0/f_iki/c/iki.c +++ b/level_0/f_iki/c/iki.c @@ -59,15 +59,24 @@ extern "C" { f_return_status f_iki_read(f_string_static_t *buffer, f_string_range_t *range, f_iki_variable_t *variable, f_iki_vocabulary_t *vocabulary, f_iki_content_t *content) { #ifndef _di_level_0_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); - if (!buffer->used) return F_status_set_error(F_parameter); if (!range) return F_status_set_error(F_parameter); if (!variable) return F_status_set_error(F_parameter); if (!vocabulary) return F_status_set_error(F_parameter); if (!content) return F_status_set_error(F_parameter); - if (range->start > range->stop) return F_status_set_error(F_parameter); - if (range->start >= buffer->used) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ + if (!buffer->used) { + return F_data_not; + } + + if (range->start > range->stop) { + return F_data_not_stop; + } + + if (range->start >= buffer->used) { + return F_data_not_eos; + } + f_status_t status = F_none; f_string_length_t width_max = 0; diff --git a/level_0/f_iki/c/iki.h b/level_0/f_iki/c/iki.h index 7a5d00b..4f7475a 100644 --- a/level_0/f_iki/c/iki.h +++ b/level_0/f_iki/c/iki.h @@ -134,8 +134,9 @@ extern "C" { * F_none on success and an IKI vocabulary name was found. * F_none_eos on success and an IKI vocabulary name was found and end of string was reached. * F_none_stop on success and an IKI vocabulary name was found and stop point was reached. - * F_data_not_eos on success and EOS was reached, but there were no IKI vocabularie names found. - * F_data_not_stop on success and stop point was reached, but there were no IKI vocabularie names found. + * F_data_not on success, but there were no IKI vocabulary names found. + * F_data_not_eos on success and EOS was reached, but there were no IKI vocabulary names found. + * F_data_not_stop on success and stop point was reached, but there were no IKI vocabulary names found. * F_memory_reallocation (with error bit) on memory reallocation error. * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if a string length is too large to store in the buffer. -- 1.8.3.1