From f3eb5dd5aba807229777740938ffab0ce9a06107 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 6 Jun 2022 22:39:30 -0500 Subject: [PATCH] Bugfix: Problems exposed by unit tests in f_conversion. The unit tests were disabled due to previous problems that are not no longer a problem. This exposed a few areas that could be improved. Rename "output" to "stream". Make sure to call ferror_unlocked() to test for error. Add loops to handle when fwrite_unlocked() doesn't write all the data but also doesn't throw an error. Use "negative_or_zero" instead of "negative" to be more verbose and less confusing. --- level_0/f_conversion/c/conversion.c | 14 +-- level_0/f_conversion/c/conversion.h | 10 +- level_0/f_conversion/c/private-conversion.c | 171 +++++++++++++++++----------- level_0/f_conversion/c/private-conversion.h | 54 ++++----- 4 files changed, 145 insertions(+), 104 deletions(-) diff --git a/level_0/f_conversion/c/conversion.c b/level_0/f_conversion/c/conversion.c index 49033e5..562be90 100644 --- a/level_0/f_conversion/c/conversion.c +++ b/level_0/f_conversion/c/conversion.c @@ -171,17 +171,17 @@ extern "C" { #endif // _di_f_conversion_character_to_octal_ #ifndef _di_f_conversion_number_signed_print_ - f_status_t f_conversion_number_signed_print(const f_number_signed_t number, const f_conversion_data_t data, FILE * const output) { + f_status_t f_conversion_number_signed_print(const f_number_signed_t number, const f_conversion_data_t data, FILE * const stream) { #ifndef _di_level_0_parameter_checking_ - if (!output) return F_status_set_error(F_parameter); + if (!stream) return F_status_set_error(F_parameter); if (data.base < 2 || data.base > 16) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (number < 0) { - return private_f_conversion_digit_to_file((f_number_unsigned_t) (0 - number), data, 1, output); + return private_f_conversion_digit_to_file((f_number_unsigned_t) (0 - number), data, 1, stream); } - return private_f_conversion_digit_to_file((f_number_unsigned_t) number, data, number ? 0 : 2, output); + return private_f_conversion_digit_to_file((f_number_unsigned_t) number, data, number ? 0 : 2, stream); } #endif // _di_f_conversion_number_signed_print_ @@ -201,13 +201,13 @@ extern "C" { #endif // _di_f_conversion_number_signed_to_string_ #ifndef _di_f_conversion_number_unsigned_print_ - f_status_t f_conversion_number_unsigned_print(const f_number_unsigned_t number, const f_conversion_data_t data, FILE * const output) { + f_status_t f_conversion_number_unsigned_print(const f_number_unsigned_t number, const f_conversion_data_t data, FILE * const stream) { #ifndef _di_level_0_parameter_checking_ - if (!output) return F_status_set_error(F_parameter); + if (!stream) return F_status_set_error(F_parameter); if (data.base < 2 || data.base > 16) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_conversion_digit_to_file(number, data, number ? 0 : 2, output); + return private_f_conversion_digit_to_file(number, data, number ? 0 : 2, stream); } #endif // _di_f_conversion_number_unsigned_print_ diff --git a/level_0/f_conversion/c/conversion.h b/level_0/f_conversion/c/conversion.h index f700c7f..2111006 100644 --- a/level_0/f_conversion/c/conversion.h +++ b/level_0/f_conversion/c/conversion.h @@ -236,7 +236,7 @@ extern "C" { * The number to convert. * @param data * The settings designating how to perform the conversion. - * @param output + * @param stream * The file stream to output to, including standard streams such as stdout and stderr. * * @return @@ -250,10 +250,11 @@ extern "C" { * F_output (with error bit) on any other file output error. * F_parameter (with error bit) if a parameter is invalid. * + * @see ferror_unlocked() * @see fwrite_unlocked() */ #ifndef _di_f_conversion_number_signed_print_ - extern f_status_t f_conversion_number_signed_print(const f_number_signed_t number, const f_conversion_data_t data, FILE * const output); + extern f_status_t f_conversion_number_signed_print(const f_number_signed_t number, const f_conversion_data_t data, FILE * const stream); #endif // _di_f_conversion_number_signed_print_ /** @@ -300,7 +301,7 @@ extern "C" { * To represent a negative number, assign the flag f_conversion_data_flag_is_negative to data.flags. * @param data * The settings designating how to perform the conversion. - * @param output + * @param stream * The file stream to output to, including standard streams such as stdout and stderr. * * @return @@ -314,10 +315,11 @@ extern "C" { * F_output (with error bit) on any other file output error. * F_parameter (with error bit) if a parameter is invalid. * + * @see ferror_unlocked() * @see fwrite_unlocked() */ #ifndef _di_f_conversion_number_unsigned_print_ - extern f_status_t f_conversion_number_unsigned_print(const f_number_unsigned_t number, const f_conversion_data_t data, FILE * const output); + extern f_status_t f_conversion_number_unsigned_print(const f_number_unsigned_t number, const f_conversion_data_t data, FILE * const stream); #endif // _di_f_conversion_number_unsigned_print_ /** diff --git a/level_0/f_conversion/c/private-conversion.c b/level_0/f_conversion/c/private-conversion.c index 189c8e7..d02b039 100644 --- a/level_0/f_conversion/c/private-conversion.c +++ b/level_0/f_conversion/c/private-conversion.c @@ -6,75 +6,76 @@ extern "C" { #endif #if !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) - f_status_t private_f_conversion_digit_to_file(const f_number_unsigned_t number, const f_conversion_data_t data, const uint8_t negative, FILE * const output) { + f_status_t private_f_conversion_digit_to_file(const f_number_unsigned_t number, const f_conversion_data_t data, const uint8_t negative_or_zero, FILE * const stream) { int digits = 0; - for (register f_number_unsigned_t remaining = number; remaining; ++digits) { - remaining /= data.base; - } // for - // A zero value should always show at least 1 zero when width is not 0. if (data.width && !number) { - ++digits; + digits = 1; + } + else { + for (register f_number_unsigned_t remaining = number; remaining; ++digits) { + remaining /= data.base; + } // for } if (data.width > digits) { if (data.flag & F_conversion_data_flag_zeros_leading_d) { - if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative_or_zero, stream))) { return F_status_set_error(F_output); } - if (F_status_is_error(private_f_conversion_digit_to_file_pad(data, f_string_ascii_0_s, data.width - digits, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_pad(data, f_string_ascii_0_s, data.width - digits, stream))) { return F_status_set_error(F_output); } - if (F_status_is_error(private_f_conversion_digit_to_file_number(data, number, digits, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_number(data, number, digits, stream))) { return F_status_set_error(F_output); } } else if (number) { - if (F_status_is_error(private_f_conversion_digit_to_file_pad(data, f_string_ascii_space_s, data.width - digits, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_pad(data, f_string_ascii_space_s, data.width - digits, stream))) { return F_status_set_error(F_output); } - if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative_or_zero, stream))) { return F_status_set_error(F_output); } - if (F_status_is_error(private_f_conversion_digit_to_file_number(data, number, digits, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_number(data, number, digits, stream))) { return F_status_set_error(F_output); } } else { - if (F_status_is_error(private_f_conversion_digit_to_file_pad(data, f_string_ascii_space_s, data.width - digits, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_pad(data, f_string_ascii_space_s, data.width - digits, stream))) { return F_status_set_error(F_output); } - if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative_or_zero, stream))) { return F_status_set_error(F_output); } - if (F_status_is_error(private_f_conversion_digit_to_file_number(data, number, digits, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_number(data, number, digits, stream))) { return F_status_set_error(F_output); } } } else if (number) { - if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative_or_zero, stream))) { return F_status_set_error(F_output); } - if (F_status_is_error(private_f_conversion_digit_to_file_number(data, number, digits, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_number(data, number, digits, stream))) { return F_status_set_error(F_output); } } else if (data.width) { - if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative, output))) { + if (F_status_is_error(private_f_conversion_digit_to_file_prefix(data, negative_or_zero, stream))) { return F_status_set_error(F_output); } - if (fwrite_unlocked(f_string_ascii_0_s.string, 1, f_string_ascii_0_s.used, output) < f_string_ascii_0_s.used) { + if (F_status_is_error(private_f_conversion_digit_to_file_number(data, number, digits, stream))) { return F_status_set_error(F_output); } } @@ -84,28 +85,36 @@ extern "C" { #endif // !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) #if !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) - f_status_t private_f_conversion_digit_to_file_number(const f_conversion_data_t data, f_number_unsigned_t number, int digits, FILE * const output) { + f_status_t private_f_conversion_digit_to_file_number(const f_conversion_data_t data, f_number_unsigned_t number, int digits, FILE * const stream) { - f_number_unsigned_t power = 1; + f_number_unsigned_t current = 0; + int power = 1; + f_number_unsigned_t work = 0; for (register uint8_t i = 1; i < digits; ++i) { power *= data.base; } // for if (data.base == 2) { - f_number_unsigned_t work = 0x1 << (digits - 1); + work = 0x1 << (digits - 1); while (digits--) { + current = 0; + if (work & number) { - if (fwrite_unlocked(f_string_ascii_1_s.string, 1, f_string_ascii_1_s.used, output) < f_string_ascii_1_s.used) { - return F_status_set_error(F_output); - } + do { + current += fwrite_unlocked(f_string_ascii_1_s.string + current, sizeof(f_char_t), f_string_ascii_1_s.used - current, stream); + if (ferror_unlocked(stream)) return F_status_set_error(F_output); + + } while (current < f_string_ascii_1_s.used); } else { - if (fwrite_unlocked(f_string_ascii_0_s.string, 1, f_string_ascii_0_s.used, output) < f_string_ascii_0_s.used) { - return F_status_set_error(F_output); - } + do { + current += fwrite_unlocked(f_string_ascii_0_s.string + current, sizeof(f_char_t), f_string_ascii_0_s.used - current, stream); + if (ferror_unlocked(stream)) return F_status_set_error(F_output); + + } while (current < f_string_ascii_0_s.used); } #ifdef _is_F_endian_big @@ -118,10 +127,12 @@ extern "C" { return F_none; } - f_number_unsigned_t current = number; - f_number_unsigned_t work = 0; + f_char_t c = 0; + size_t count = 0; - for (f_char_t c = 0; digits; --digits) { + current = number; + + for (int i = 0; i < digits; ++i) { work = current / power; current -= work * power; @@ -139,9 +150,13 @@ extern "C" { } } - if (!fwrite_unlocked(&c, 1, 1, output)) { - return F_status_set_error(F_output); - } + count = 0; + + do { + count += fwrite_unlocked(&c, 1, sizeof(f_char_t), stream); + if (ferror_unlocked(stream)) return F_status_set_error(F_output); + + } while (count < sizeof(f_char_t)); } // for return F_none; @@ -149,13 +164,17 @@ extern "C" { #endif // !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) #if !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) - f_status_t private_f_conversion_digit_to_file_pad(const f_conversion_data_t data, const f_string_static_t pad, int total, FILE * const output) { + f_status_t private_f_conversion_digit_to_file_pad(const f_conversion_data_t data, const f_string_static_t pad, int total, FILE * const stream) { - for (; total; --total) { + for (int count; total; --total) { - if (fwrite_unlocked(pad.string, 1, pad.used, output) < pad.used) { - return F_status_set_error(F_output); - } + count = 0; + + do { + count += fwrite_unlocked(pad.string + count, sizeof(f_char_t), pad.used - count, stream); + if (ferror_unlocked(stream)) return F_status_set_error(F_output); + + } while (count < pad.used); } // for return F_none; @@ -163,29 +182,49 @@ extern "C" { #endif // !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) #if !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) - f_status_t private_f_conversion_digit_to_file_prefix(const f_conversion_data_t data, const uint8_t negative, FILE * const output) { + f_status_t private_f_conversion_digit_to_file_prefix(const f_conversion_data_t data, const uint8_t negative_or_zero, FILE * const stream) { - if (negative) { - if (negative == 1) { - if (fwrite_unlocked(f_string_ascii_minus_s.string, 1, f_string_ascii_minus_s.used, output) < f_string_ascii_minus_s.used) { - return F_status_set_error(F_output); + if (negative_or_zero) { + if (negative_or_zero == 1) { + { + int count = 0; + + do { + count += fwrite_unlocked(f_string_ascii_minus_s.string + count, sizeof(f_char_t), f_string_ascii_minus_s.used - count, stream); + if (ferror_unlocked(stream)) return F_status_set_error(F_output); + + } while (count < f_string_ascii_minus_s.used); } } } else if (data.flag & F_conversion_data_flag_sign_always_d) { - if (fwrite_unlocked(f_string_ascii_plus_s.string, 1, f_string_ascii_plus_s.used, output) < f_string_ascii_plus_s.used) { - return F_status_set_error(F_output); - } + int count = 0; + + do { + count += fwrite_unlocked(f_string_ascii_plus_s.string + count, sizeof(f_char_t), f_string_ascii_plus_s.used - count, stream); + if (ferror_unlocked(stream)) return F_status_set_error(F_output); + + } while (count < f_string_ascii_plus_s.used); } else if (data.flag & F_conversion_data_flag_sign_pad_d) { - if (fwrite_unlocked(f_string_ascii_space_s.string, 1, f_string_ascii_space_s.used, output) < f_string_ascii_space_s.used) { - return F_status_set_error(F_output); - } + int count = 0; + + do { + count += fwrite_unlocked(f_string_ascii_space_s.string + count, sizeof(f_char_t), f_string_ascii_space_s.used - count, stream); + if (ferror_unlocked(stream)) return F_status_set_error(F_output); + + } while (count < f_string_ascii_space_s.used); } if (data.flag & F_conversion_data_flag_base_prepend_d) { - if (fwrite_unlocked(f_string_ascii_0_s.string, 1, f_string_ascii_0_s.used, output) < f_string_ascii_0_s.used) { - return F_status_set_error(F_output); + { + int count = 0; + + do { + count += fwrite_unlocked(f_string_ascii_0_s.string + count, sizeof(f_char_t), f_string_ascii_0_s.used - count, stream); + if (ferror_unlocked(stream)) return F_status_set_error(F_output); + + } while (count < f_string_ascii_0_s.used); } f_char_t c = 0; @@ -216,9 +255,13 @@ extern "C" { } if (c) { - if (!fwrite_unlocked(&c, 1, 1, output)) { - return F_status_set_error(F_output); - } + int count = 0; + + do { + count += fwrite_unlocked(&c, sizeof(f_char_t), sizeof(f_char_t) - count, stream); + if (ferror_unlocked(stream)) return F_status_set_error(F_output); + + } while (count < sizeof(f_char_t)); } } @@ -227,7 +270,7 @@ extern "C" { #endif // !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) #if !defined(_di_f_conversion_number_signed_to_string_) || !defined(_di_f_conversion_number_unsigned_to_string_) - f_status_t private_f_conversion_digit_to_string(const f_number_unsigned_t number, const f_conversion_data_t data, const uint8_t negative, f_string_dynamic_t * const destination) { + f_status_t private_f_conversion_digit_to_string(const f_number_unsigned_t number, const f_conversion_data_t data, const uint8_t negative_or_zero, f_string_dynamic_t * const destination) { int digits = 0; @@ -257,27 +300,27 @@ extern "C" { if (data.width > digits) { if (data.flag & F_conversion_data_flag_zeros_leading_d) { - private_f_conversion_digit_to_string_prefix(data, negative, destination); + private_f_conversion_digit_to_string_prefix(data, negative_or_zero, destination); private_f_conversion_digit_to_string_pad(data, f_string_ascii_0_s.string[0], data.width - digits, destination); private_f_conversion_digit_to_string_number(data, number, digits, destination); } else if (number) { private_f_conversion_digit_to_string_pad(data, f_string_ascii_space_s.string[0], data.width - digits, destination); - private_f_conversion_digit_to_string_prefix(data, negative, destination); + private_f_conversion_digit_to_string_prefix(data, negative_or_zero, destination); private_f_conversion_digit_to_string_number(data, number, digits, destination); } else { private_f_conversion_digit_to_string_pad(data, f_string_ascii_space_s.string[0], data.width - digits, destination); - private_f_conversion_digit_to_string_prefix(data, negative, destination); + private_f_conversion_digit_to_string_prefix(data, negative_or_zero, destination); private_f_conversion_digit_to_string_number(data, number, digits, destination); } } else if (number) { - private_f_conversion_digit_to_string_prefix(data, negative, destination); + private_f_conversion_digit_to_string_prefix(data, negative_or_zero, destination); private_f_conversion_digit_to_string_number(data, number, digits, destination); } else if (data.width) { - private_f_conversion_digit_to_string_prefix(data, negative, destination); + private_f_conversion_digit_to_string_prefix(data, negative_or_zero, destination); destination->string[destination->used++] = f_string_ascii_0_s.string[0]; } @@ -353,10 +396,10 @@ extern "C" { #endif // !defined(_di_f_conversion_number_signed_to_string_) || !defined(_di_f_conversion_number_unsigned_to_string_) #if !defined(_di_f_conversion_number_signed_to_string_) || !defined(_di_f_conversion_number_unsigned_to_string_) - void private_f_conversion_digit_to_string_prefix(const f_conversion_data_t data, const uint8_t negative, f_string_dynamic_t * const destination) { + void private_f_conversion_digit_to_string_prefix(const f_conversion_data_t data, const uint8_t negative_or_zero, f_string_dynamic_t * const destination) { - if (negative) { - if (negative == 1) { + if (negative_or_zero) { + if (negative_or_zero == 1) { destination->string[destination->used++] = f_string_ascii_minus_s.string[0]; } else if (data.flag & (F_conversion_data_flag_sign_always_d | F_conversion_data_flag_sign_pad_d)) { diff --git a/level_0/f_conversion/c/private-conversion.h b/level_0/f_conversion/c/private-conversion.h index 77c8836..5ba60b9 100644 --- a/level_0/f_conversion/c/private-conversion.h +++ b/level_0/f_conversion/c/private-conversion.h @@ -22,14 +22,13 @@ extern "C" { * The number to convert. * @param data * The settings designating how to perform the conversion. - * @param negative + * @param negative_or_zero * Designate that this number is to be represented as a negative number (or is zero). * * Set this to 0 to represent a positive number. * Set this to 1 to represent a negative number. * Set this to 2 to represent the number 0; - * @param output - * + * @param stream * The file stream to output to, including standard streams such as stdout and stderr. * * @return @@ -38,6 +37,7 @@ extern "C" { * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. * + * @see ferror_unlocked() * @see fwrite_unlocked() * * @see f_conversion_number_signed_print() @@ -48,7 +48,7 @@ extern "C" { * @see private_f_conversion_digit_to_file_prefix() */ #if !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) - extern f_status_t private_f_conversion_digit_to_file(const f_number_unsigned_t number, const f_conversion_data_t data, const uint8_t negative, FILE * const output) F_attribute_visibility_internal_d; + extern f_status_t private_f_conversion_digit_to_file(const f_number_unsigned_t number, const f_conversion_data_t data, const uint8_t negative_or_zero, FILE * const stream) F_attribute_visibility_internal_d; #endif // !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) /** @@ -62,8 +62,7 @@ extern "C" { * To represent a negative number, assign the flag f_conversion_data_flag_is_negative to data.flags. * @param digits * The number of digits the number is represented by (based on the base unit). - * @param output - * + * @param stream * The file stream to output to, including standard streams such as stdout and stderr. * * @return @@ -72,13 +71,14 @@ extern "C" { * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. * + * @see ferror_unlocked() * @see fwrite_unlocked() * * @see f_conversion_number_signed_print() * @see f_conversion_number_unsigned_print() */ #if !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) - extern f_status_t private_f_conversion_digit_to_file_number(const f_conversion_data_t data, f_number_unsigned_t number, int digits, FILE * const output) F_attribute_visibility_internal_d; + extern f_status_t private_f_conversion_digit_to_file_number(const f_conversion_data_t data, f_number_unsigned_t number, int digits, FILE * const stream) F_attribute_visibility_internal_d; #endif // !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) /** @@ -91,8 +91,7 @@ extern "C" { * Should be either f_string_ascii_space_s or f_string_ascii_0_s. * @param total * The total number of times to print the pad. - * @param output - * + * @param stream * The file stream to output to, including standard streams such as stdout and stderr. * * @return @@ -101,13 +100,14 @@ extern "C" { * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. * + * @see ferror_unlocked() * @see fwrite_unlocked() * * @see f_conversion_number_signed_print() * @see f_conversion_number_unsigned_print() */ #if !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) - extern f_status_t private_f_conversion_digit_to_file_pad(const f_conversion_data_t data, const f_string_static_t pad, int total, FILE * const output) F_attribute_visibility_internal_d; + extern f_status_t private_f_conversion_digit_to_file_pad(const f_conversion_data_t data, const f_string_static_t pad, int total, FILE * const stream) F_attribute_visibility_internal_d; #endif // !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) /** @@ -115,14 +115,13 @@ extern "C" { * * @param data * The settings designating how to perform the conversion. - * @param negative + * @param negative_or_zero * Designate that this number is to be represented as a negative number (or is zero). * * Set this to 0 to represent a positive number. * Set this to 1 to represent a negative number. * Set this to 2 to represent the number 0; - * @param output - * + * @param stream * The file stream to output to, including standard streams such as stdout and stderr. * * @return @@ -131,13 +130,14 @@ extern "C" { * F_output (with error bit) on failure. * F_parameter (with error bit) if a parameter is invalid. * + * @see ferror_unlocked() * @see fwrite_unlocked() * * @see f_conversion_number_signed_print() * @see f_conversion_number_unsigned_print() */ #if !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) - extern f_status_t private_f_conversion_digit_to_file_prefix(const f_conversion_data_t data, const uint8_t negative, FILE * const output) F_attribute_visibility_internal_d; + extern f_status_t private_f_conversion_digit_to_file_prefix(const f_conversion_data_t data, const uint8_t negative_or_zero, FILE * const stream) F_attribute_visibility_internal_d; #endif // !defined(_di_f_conversion_number_signed_print_) || !defined(_di_f_conversion_number_unsigned_print_) /** @@ -147,14 +147,13 @@ extern "C" { * The number to convert. * @param data * The settings designating how to perform the conversion. - * @param negative + * @param negative_or_zero * Designate that this number is to be represented as a negative number (or is zero). * * Set this to 0 to represent a positive number. * Set this to 1 to represent a negative number. * Set this to 2 to represent the number 0; - * @param output - * + * @param stream * The file stream to output to, including standard streams such as stdout and stderr. * * @return @@ -170,11 +169,11 @@ extern "C" { * @see private_f_conversion_digit_to_string_prefix() */ #if !defined(_di_f_conversion_number_signed_to_string_) || !defined(_di_f_conversion_number_unsigned_to_string_) - extern f_status_t private_f_conversion_digit_to_string(const f_number_unsigned_t number, const f_conversion_data_t data, const uint8_t negative, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; + extern f_status_t private_f_conversion_digit_to_string(const f_number_unsigned_t number, const f_conversion_data_t data, const uint8_t negative_or_zero, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_conversion_number_signed_to_string_) || !defined(_di_f_conversion_number_unsigned_to_string_) /** - * Helper function for printing the number to the output file. + * Helper function for printing the number to the stream file. * * @param data * The settings designating how to perform the conversion. @@ -184,8 +183,7 @@ extern "C" { * To represent a negative number, assign the flag f_conversion_data_flag_is_negative to data.flags. * @param digits * The number of digits the number is represented by (based on the base unit). - * @param output - * + * @param stream * The file stream to output to, including standard streams such as stdout and stderr. * * @see f_conversion_number_signed_to_string() @@ -205,9 +203,8 @@ extern "C" { * Should be either f_string_ascii_space_s or f_string_ascii_0_s. * @param total * The total number of times to print the pad. - * @param output - * - * The file stream to output to, including standard streams such as stdout and stderr. + * @param destination + * A string buffer to write to. * * @see f_conversion_number_signed_to_string() * @see f_conversion_number_unsigned_to_string() @@ -221,21 +218,20 @@ extern "C" { * * @param data * The settings designating how to perform the conversion. - * @param negative + * @param negative_or_zero * Designate that this number is to be represented as a negative number (or is zero). * * Set this to 0 to represent a positive number. * Set this to 1 to represent a negative number. * Set this to 2 to represent the number 0; - * @param output - * - * The file stream to output to, including standard streams such as stdout and stderr. + * @param destination + * A string buffer to write to. * * @see f_conversion_number_signed_to_string() * @see f_conversion_number_unsigned_to_string() */ #if !defined(_di_f_conversion_number_signed_to_string_) || !defined(_di_f_conversion_number_unsigned_to_string_) - extern void private_f_conversion_digit_to_string_prefix(const f_conversion_data_t data, const uint8_t negative, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; + extern void private_f_conversion_digit_to_string_prefix(const f_conversion_data_t data, const uint8_t negative_or_zero, f_string_dynamic_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_conversion_number_signed_to_string_) || !defined(_di_f_conversion_number_unsigned_to_string_) #ifdef __cplusplus -- 1.8.3.1