From 631e7152ee842362766711ed8867fbbf2ccda385 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 14 Mar 2022 23:38:07 -0500 Subject: [PATCH] Update: Add F_status status type and rename F_status_size_max_with_signal to F_status_size_max_with_bits_d. The max size for what is now called F_status_size_max_with_bits_d is (2^16)-1 and not 2^16. --- level_0/f_status/c/status.h | 25 +++++++++++++--------- level_0/f_status_string/c/status_string.c | 10 +++++++++ level_0/f_status_string/c/status_string.h | 6 ++++++ level_2/fll_status_string/c/status_string.c | 12 +++++++++++ .../fss_status_code/c/private-fss_status_code.c | 2 +- level_3/status_code/c/private-status_code.c | 2 +- 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/level_0/f_status/c/status.h b/level_0/f_status/c/status.h index 624ea63..9feaaa5 100644 --- a/level_0/f_status/c/status.h +++ b/level_0/f_status/c/status.h @@ -36,16 +36,22 @@ extern "C" { /** * Status masks. + * + * The f_status_t is required to be exactly 16 bits, the first two high order bits represent error and warning respectively. + * + * The F_status_set_fine() is provided to remove the error, warning, and signal bits. + * + * F_status_size_*: + * - max: Maximum valid number representing a status code (without the error, signal, or warning bits). + * - max_with_bits: Maximum valid number representing a status code including the error, signal, or warning bits. */ #ifndef _di_f_status_masks_ - - // f_status_t is required to be exactly 16 bits, the first two high order bits represent error and warning respectively. #define F_status_bit_error 0x8000 // 1000 0000 0000 0000 #define F_status_bit_signal 0xc000 // 1100 0000 0000 0000 #define F_status_bit_warning 0x4000 // 0100 0000 0000 0000 - #define F_status_mask_fine 0x3fff // 0011 1111 1111 1111 - #define F_status_mask_code 0xc000 // 1100 0000 0000 0000 + #define F_status_mask_fine 0x3fff // 0011 1111 1111 1111 + #define F_status_mask_code 0xc000 // 1100 0000 0000 0000 #define F_status_is_error(status) (status & F_status_bit_error) #define F_status_is_fine(status) ((status & F_status_mask_code) == 0) @@ -61,13 +67,10 @@ extern "C" { #define F_status_set_error(status) (status | F_status_bit_error) #define F_status_set_signal(status) (status | F_status_bit_signal) #define F_status_set_warning(status) (status | F_status_bit_warning) + #define F_status_set_fine(status) (status & F_status_mask_fine) - // Use F_status_set_fine to remove the error, warning, and signal bits. - #define F_status_set_fine(status) (status & F_status_mask_fine) - - // Maximum size of the status code. - #define F_status_size_max 0x3fff - #define F_status_size_max_with_signal 0x10000 + #define F_status_size_max_d 0x3fff + #define F_status_size_max_with_bits_d 0xffff #endif // _di_f_status_masks_ /** @@ -365,6 +368,8 @@ extern "C" { F_space_not, F_start, F_start_not, + F_status, + F_status_not, F_stop, F_stop_not, F_stream, diff --git a/level_0/f_status_string/c/status_string.c b/level_0/f_status_string/c/status_string.c index 752f9ea..c13e30d 100644 --- a/level_0/f_status_string/c/status_string.c +++ b/level_0/f_status_string/c/status_string.c @@ -283,6 +283,8 @@ extern "C" { const f_string_static_t f_status_space_not_s = macro_f_string_static_t_initialize(F_status_space_not_s, 0, F_status_space_not_s_length); const f_string_static_t f_status_start_s = macro_f_string_static_t_initialize(F_status_start_s, 0, F_status_start_s_length); const f_string_static_t f_status_start_not_s = macro_f_string_static_t_initialize(F_status_start_not_s, 0, F_status_start_not_s_length); + const f_string_static_t f_status_status_s = macro_f_string_static_t_initialize(F_status_status_s, 0, F_status_status_s_length); + const f_string_static_t f_status_status_not_s = macro_f_string_static_t_initialize(F_status_status_not_s, 0, F_status_status_not_s_length); const f_string_static_t f_status_stop_s = macro_f_string_static_t_initialize(F_status_stop_s, 0, F_status_stop_s_length); const f_string_static_t f_status_stop_not_s = macro_f_string_static_t_initialize(F_status_stop_not_s, 0, F_status_stop_not_s_length); const f_string_static_t f_status_stream_s = macro_f_string_static_t_initialize(F_status_stream_s, 0, F_status_stream_s_length); @@ -1682,6 +1684,14 @@ extern "C" { *name = f_status_start_not_s; break; + case F_status: + *name = f_status_status_s; + break; + + case F_status_not: + *name = f_status_status_not_s; + break; + case F_stop: *name = f_status_stop_s; break; diff --git a/level_0/f_status_string/c/status_string.h b/level_0/f_status_string/c/status_string.h index caaa5bd..b5bb422 100644 --- a/level_0/f_status_string/c/status_string.h +++ b/level_0/f_status_string/c/status_string.h @@ -436,6 +436,8 @@ extern "C" { #define F_status_space_not_s "F_space_not" #define F_status_start_s "F_start" #define F_status_start_not_s "F_start_not" + #define F_status_status_s "F_status" + #define F_status_status_not_s "F_status_not" #define F_status_stop_s "F_stop" #define F_status_stop_not_s "F_stop_not" #define F_status_stream_s "F_stream" @@ -684,6 +686,8 @@ extern "C" { #define F_status_space_not_s_length 11 #define F_status_start_s_length 7 #define F_status_start_not_s_length 11 + #define F_status_status_s_length 8 + #define F_status_status_not_s_length 12 #define F_status_stop_s_length 6 #define F_status_stop_not_s_length 10 #define F_status_stream_s_length 8 @@ -932,6 +936,8 @@ extern "C" { extern const f_string_static_t f_status_space_not_s; extern const f_string_static_t f_status_start_s; extern const f_string_static_t f_status_start_not_s; + extern const f_string_static_t f_status_status_s; + extern const f_string_static_t f_status_status_not_s; extern const f_string_static_t f_status_stop_s; extern const f_string_static_t f_status_stop_not_s; extern const f_string_static_t f_status_stream_s; diff --git a/level_2/fll_status_string/c/status_string.c b/level_2/fll_status_string/c/status_string.c index 21c2474..bfce301 100644 --- a/level_2/fll_status_string/c/status_string.c +++ b/level_2/fll_status_string/c/status_string.c @@ -1656,6 +1656,18 @@ extern "C" { return F_none; } + if (fl_string_dynamic_compare(name, f_status_status_s) == F_equal_to) { + *code = F_status; + + return F_none; + } + + if (fl_string_dynamic_compare(name, f_status_status_not_s) == F_equal_to) { + *code = F_status_not; + + return F_none; + } + if (fl_string_dynamic_compare(name, f_status_stop_s) == F_equal_to) { *code = F_stop; diff --git a/level_3/fss_status_code/c/private-fss_status_code.c b/level_3/fss_status_code/c/private-fss_status_code.c index 8df8ea1..1000f16 100644 --- a/level_3/fss_status_code/c/private-fss_status_code.c +++ b/level_3/fss_status_code/c/private-fss_status_code.c @@ -141,7 +141,7 @@ extern "C" { f_status_t status = fl_conversion_dynamic_to_number_unsigned(value, number); - if (*number > F_status_size_max_with_signal) { + if (*number > F_status_size_max_with_bits_d) { fl_print_format("%[out of range%]%r", main->output.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); return status; diff --git a/level_3/status_code/c/private-status_code.c b/level_3/status_code/c/private-status_code.c index 0550667..15e1229 100644 --- a/level_3/status_code/c/private-status_code.c +++ b/level_3/status_code/c/private-status_code.c @@ -133,7 +133,7 @@ extern "C" { f_status_t status = fl_conversion_dynamic_to_number_unsigned(value, number); - if (*number > F_status_size_max_with_signal) { + if (*number > F_status_size_max_with_bits_d) { fl_print_format("%[out of range%]%r", main->output.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); return status; -- 1.8.3.1