Ignore:
Timestamp:
2018-02-28T17:52:03Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3061bc1
Parents:
df6ded8
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:26:03)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:52:03)
Message:

style: Remove trailing whitespace on non-empty lines, in certain file types.

Command used: tools/srepl '\([^[:space:]]\)\s\+$' '\1' -- *.c *.h *.py *.sh *.s *.S *.ag

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/printf_core.c

    rdf6ded8 r1b20da0  
    592592
    593593/** Prints a special double (ie NaN, infinity) padded to width characters. */
    594 static int print_special(ieee_double_t val, int width, uint32_t flags, 
     594static int print_special(ieee_double_t val, int width, uint32_t flags,
    595595        printf_spec_t *ps)
    596596{
     
    615615        /* Leading padding. */
    616616        if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
    617                 if ((ret = print_padding(' ', padding_len, ps)) < 0) 
     617                if ((ret = print_padding(' ', padding_len, ps)) < 0)
    618618                        return -1;
    619619
     
    636636        /* Trailing padding. */
    637637        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
    638                 if ((ret = print_padding(' ', padding_len, ps)) < 0) 
     638                if ((ret = print_padding(' ', padding_len, ps)) < 0)
    639639                        return -1;
    640640
     
    698698
    699699
    700 /** Format and print the double string repressentation according 
    701  *  to the %f specifier. 
    702  */
    703 static int print_double_str_fixed(double_str_t *val_str, int precision, int width, 
     700/** Format and print the double string repressentation according
     701 *  to the %f specifier.
     702 */
     703static int print_double_str_fixed(double_str_t *val_str, int precision, int width,
    704704        uint32_t flags, printf_spec_t *ps)
    705705{
     
    742742
    743743        if (!(flags & (__PRINTF_FLAG_LEFTALIGNED | __PRINTF_FLAG_ZEROPADDED))) {
    744                 if ((ret = print_padding(' ', padding_len, ps)) < 0) 
     744                if ((ret = print_padding(' ', padding_len, ps)) < 0)
    745745                        return -1;
    746746
     
    749749
    750750        if (sign) {
    751                 if ((ret = ps->str_write(&sign, 1, ps->data)) < 0) 
     751                if ((ret = ps->str_write(&sign, 1, ps->data)) < 0)
    752752                        return -1;
    753753               
     
    756756
    757757        if (flags & __PRINTF_FLAG_ZEROPADDED) {
    758                 if ((ret = print_padding('0', padding_len, ps)) < 0) 
     758                if ((ret = print_padding('0', padding_len, ps)) < 0)
    759759                        return -1;
    760760
     
    767767
    768768        if (0 < buf_int_len) {
    769                 if ((ret = ps->str_write(buf, buf_int_len, ps->data)) < 0) 
     769                if ((ret = ps->str_write(buf, buf_int_len, ps->data)) < 0)
    770770                        return -1;
    771771
     
    773773
    774774                /* Print trailing zeros of the integral part of the number. */
    775                 if ((ret = print_padding('0', int_len - buf_int_len, ps)) < 0) 
     775                if ((ret = print_padding('0', int_len - buf_int_len, ps)) < 0)
    776776                        return -1;
    777777        } else {
    778778                /* Single leading integer 0. */
    779779                char ch = '0';
    780                 if ((ret = ps->str_write(&ch, 1, ps->data)) < 0) 
     780                if ((ret = ps->str_write(&ch, 1, ps->data)) < 0)
    781781                        return -1;
    782782        }
     
    788788                char ch = '.';
    789789
    790                 if ((ret = ps->str_write(&ch, 1, ps->data)) < 0) 
     790                if ((ret = ps->str_write(&ch, 1, ps->data)) < 0)
    791791                        return -1;
    792792               
     
    794794
    795795                /* Print leading zeros of the fractional part of the number. */
    796                 if ((ret = print_padding('0', leading_frac_zeros, ps)) < 0) 
     796                if ((ret = print_padding('0', leading_frac_zeros, ps)) < 0)
    797797                        return -1;
    798798
     
    801801                /* Print significant digits of the fractional part of the number. */
    802802                if (0 < signif_frac_figs) {
    803                         if ((ret = ps->str_write(buf_frac, signif_frac_figs, ps->data)) < 0) 
     803                        if ((ret = ps->str_write(buf_frac, signif_frac_figs, ps->data)) < 0)
    804804                                return -1;
    805805
     
    808808
    809809                /* Print trailing zeros of the fractional part of the number. */
    810                 if ((ret = print_padding('0', trailing_frac_zeros, ps)) < 0) 
     810                if ((ret = print_padding('0', trailing_frac_zeros, ps)) < 0)
    811811                        return -1;
    812812
     
    816816        /* Trailing padding. */
    817817        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
    818                 if ((ret = print_padding(' ', padding_len, ps)) < 0) 
     818                if ((ret = print_padding(' ', padding_len, ps)) < 0)
    819819                        return -1;
    820820
     
    826826
    827827
    828 /** Convert, format and print a double according to the %f specifier. 
     828/** Convert, format and print a double according to the %f specifier.
    829829 *
    830830 * @param g     Double to print.
     
    832832 *              decimal point will be printed unless the flag
    833833 *              __PRINTF_FLAG_DECIMALPT is specified.
    834  * @param width Minimum number of characters to display. Pads 
     834 * @param width Minimum number of characters to display. Pads
    835835 *              with '0' or ' ' depending on the set flags;
    836836 * @param flags Printf flags.
     
    839839 * @return The number of characters printed; negative on failure.
    840840 */
    841 static int print_double_fixed(double g, int precision, int width, uint32_t flags, 
     841static int print_double_fixed(double g, int precision, int width, uint32_t flags,
    842842        printf_spec_t *ps)
    843843{
     
    854854        if (val.is_special) {
    855855                return print_special(val, width, flags, ps);
    856         } 
     856        }
    857857
    858858        char buf[MAX_DOUBLE_STR_BUF_SIZE];
     
    864864
    865865        if (0 <= precision) {
    866                 /* 
     866                /*
    867867                 * Request one more digit so we can round the result. The last
    868                  * digit it returns may have an error of at most +/- 1. 
     868                 * digit it returns may have an error of at most +/- 1.
    869869                 */
    870                 val_str.len = double_to_fixed_str(val, -1, precision + 1, buf, buf_size, 
     870                val_str.len = double_to_fixed_str(val, -1, precision + 1, buf, buf_size,
    871871                        &val_str.dec_exp);
    872872
    873                 /* 
    874                  * Round using the last digit to produce precision fractional digits. 
    875                  * If less than precision+1 fractional digits were output the last 
    876                  * digit is definitely inaccurate so also round to get rid of it. 
     873                /*
     874                 * Round using the last digit to produce precision fractional digits.
     875                 * If less than precision+1 fractional digits were output the last
     876                 * digit is definitely inaccurate so also round to get rid of it.
    877877                 */
    878878                fp_round_up(buf, &val_str.len, &val_str.dec_exp);
     
    901901        char exp_ch = (flags & __PRINTF_FLAG_BIGCHARS) ? 'E' : 'e';
    902902
    903         if ((ret = ps->str_write(&exp_ch, 1, ps->data)) < 0) 
     903        if ((ret = ps->str_write(&exp_ch, 1, ps->data)) < 0)
    904904                return -1;
    905905       
     
    925925        const char *exp_str_start = &exp_str[3] - exp_len;
    926926
    927         if ((ret = ps->str_write(exp_str_start, exp_len, ps->data)) < 0) 
     927        if ((ret = ps->str_write(exp_str_start, exp_len, ps->data)) < 0)
    928928                return -1;
    929929
     
    934934
    935935
    936 /** Format and print the double string repressentation according 
    937  *  to the %e specifier. 
    938  */
    939 static int print_double_str_scient(double_str_t *val_str, int precision, 
     936/** Format and print the double string repressentation according
     937 *  to the %e specifier.
     938 */
     939static int print_double_str_scient(double_str_t *val_str, int precision,
    940940        int width, uint32_t flags, printf_spec_t *ps)
    941941{
     
    972972
    973973        if (!(flags & (__PRINTF_FLAG_LEFTALIGNED | __PRINTF_FLAG_ZEROPADDED))) {
    974                 if ((ret = print_padding(' ', padding_len, ps)) < 0) 
     974                if ((ret = print_padding(' ', padding_len, ps)) < 0)
    975975                        return -1;
    976976
     
    979979
    980980        if (sign) {
    981                 if ((ret = ps->str_write(&sign, 1, ps->data)) < 0) 
     981                if ((ret = ps->str_write(&sign, 1, ps->data)) < 0)
    982982                        return -1;
    983983               
     
    986986
    987987        if (flags & __PRINTF_FLAG_ZEROPADDED) {
    988                 if ((ret = print_padding('0', padding_len, ps)) < 0) 
     988                if ((ret = print_padding('0', padding_len, ps)) < 0)
    989989                        return -1;
    990990
     
    993993
    994994        /* Single leading integer. */
    995         if ((ret = ps->str_write(buf, 1, ps->data)) < 0) 
     995        if ((ret = ps->str_write(buf, 1, ps->data)) < 0)
    996996                return -1;
    997997
     
    10021002                char ch = '.';
    10031003
    1004                 if ((ret = ps->str_write(&ch, 1, ps->data)) < 0) 
     1004                if ((ret = ps->str_write(&ch, 1, ps->data)) < 0)
    10051005                        return -1;
    10061006               
     
    10091009                /* Print significant digits of the fractional part of the number. */
    10101010                if (0 < signif_frac_figs) {
    1011                         if ((ret = ps->str_write(buf + 1, signif_frac_figs, ps->data)) < 0) 
     1011                        if ((ret = ps->str_write(buf + 1, signif_frac_figs, ps->data)) < 0)
    10121012                                return -1;
    10131013
     
    10161016
    10171017                /* Print trailing zeros of the fractional part of the number. */
    1018                 if ((ret = print_padding('0', trailing_frac_zeros, ps)) < 0) 
     1018                if ((ret = print_padding('0', trailing_frac_zeros, ps)) < 0)
    10191019                        return -1;
    10201020
     
    10231023
    10241024        /* Print the exponent. */
    1025         if ((ret = print_exponent(exp_val, flags, ps)) < 0) 
     1025        if ((ret = print_exponent(exp_val, flags, ps)) < 0)
    10261026                return -1;
    10271027
     
    10291029
    10301030        if (flags & __PRINTF_FLAG_LEFTALIGNED) {
    1031                 if ((ret = print_padding(' ', padding_len, ps)) < 0) 
     1031                if ((ret = print_padding(' ', padding_len, ps)) < 0)
    10321032                        return -1;
    10331033
     
    10391039
    10401040
    1041 /** Convert, format and print a double according to the %e specifier. 
    1042  *
    1043  * Note that if g is large, the output may be huge (3e100 prints 
     1041/** Convert, format and print a double according to the %e specifier.
     1042 *
     1043 * Note that if g is large, the output may be huge (3e100 prints
    10441044 * with at least 100 digits).
    10451045 *
     
    10541054 *              __PRINTF_FLAG_DECIMALPT is specified. If negative
    10551055 *              the shortest accurate number will be printed.
    1056  * @param width Minimum number of characters to display. Pads 
     1056 * @param width Minimum number of characters to display. Pads
    10571057 *              with '0' or ' ' depending on the set flags;
    10581058 * @param flags Printf flags.
     
    10611061 * @return The number of characters printed; negative on failure.
    10621062 */
    1063 static int print_double_scientific(double g, int precision, int width, 
     1063static int print_double_scientific(double g, int precision, int width,
    10641064        uint32_t flags, printf_spec_t *ps)
    10651065{
     
    10721072        if (val.is_special) {
    10731073                return print_special(val, width, flags, ps);
    1074         } 
     1074        }
    10751075
    10761076        char buf[MAX_DOUBLE_STR_BUF_SIZE];
     
    10821082
    10831083        if (0 <= precision) {
    1084                 /* 
    1085                  * Request one more digit (in addition to the leading integer) 
    1086                  * so we can round the result. The last digit it returns may 
    1087                  * have an error of at most +/- 1. 
     1084                /*
     1085                 * Request one more digit (in addition to the leading integer)
     1086                 * so we can round the result. The last digit it returns may
     1087                 * have an error of at most +/- 1.
    10881088                 */
    1089                 val_str.len = double_to_fixed_str(val, precision + 2, -1, buf, buf_size, 
     1089                val_str.len = double_to_fixed_str(val, precision + 2, -1, buf, buf_size,
    10901090                        &val_str.dec_exp);
    10911091
    1092                 /* 
    1093                  * Round the extra digit to produce precision+1 significant digits. 
    1094                  * If less than precision+2 significant digits were returned the last 
    1095                  * digit is definitely inaccurate so also round to get rid of it. 
     1092                /*
     1093                 * Round the extra digit to produce precision+1 significant digits.
     1094                 * If less than precision+2 significant digits were returned the last
     1095                 * digit is definitely inaccurate so also round to get rid of it.
    10961096                 */
    10971097                fp_round_up(buf, &val_str.len, &val_str.dec_exp);
     
    11131113
    11141114
    1115 /** Convert, format and print a double according to the %g specifier. 
    1116  *
    1117  * %g style chooses between %f and %e. 
     1115/** Convert, format and print a double according to the %g specifier.
     1116 *
     1117 * %g style chooses between %f and %e.
    11181118 *
    11191119 * @param g     Double to print.
     
    11211121 *              any leading zeros from this count. If negative
    11221122 *              the shortest accurate number will be printed.
    1123  * @param width Minimum number of characters to display. Pads 
     1123 * @param width Minimum number of characters to display. Pads
    11241124 *              with '0' or ' ' depending on the set flags;
    11251125 * @param flags Printf flags.
     
    11281128 * @return The number of characters printed; negative on failure.
    11291129 */
    1130 static int print_double_generic(double g, int precision, int width, 
     1130static int print_double_generic(double g, int precision, int width,
    11311131        uint32_t flags, printf_spec_t *ps)
    11321132{
     
    11351135        if (val.is_special) {
    11361136                return print_special(val, width, flags, ps);
    1137         } 
     1137        }
    11381138
    11391139        char buf[MAX_DOUBLE_STR_BUF_SIZE];
     
    11441144        /* Honor the user requested number of significant digits. */
    11451145        if (0 <= precision) {
    1146                 /* 
    1147                  * Do a quick and dirty conversion of a single digit to determine 
     1146                /*
     1147                 * Do a quick and dirty conversion of a single digit to determine
    11481148                 * the decimal exponent.
    11491149                 */
     
    11551155                if (-4 <= dec_exp && dec_exp < precision) {
    11561156                        precision = precision - (dec_exp + 1);
    1157                         return print_double_fixed(g, precision, width, 
     1157                        return print_double_fixed(g, precision, width,
    11581158                                flags | __PRINTF_FLAG_NOFRACZEROS, ps);
    11591159                } else {
    11601160                        --precision;
    1161                         return print_double_scientific(g, precision, width, 
     1161                        return print_double_scientific(g, precision, width,
    11621162                                flags | __PRINTF_FLAG_NOFRACZEROS, ps);
    11631163                }
     
    11941194
    11951195
    1196 /** Convert, format and print a double according to the specifier. 
     1196/** Convert, format and print a double according to the specifier.
    11971197 *
    11981198 * Depending on the specifier it prints the double using the styles
     
    12061206 *              the shortest accurate number will be printed for style %g;
    12071207 *              negative precision defaults to 6 for styles %f, %e.
    1208  * @param width Minimum number of characters to display. Pads 
     1208 * @param width Minimum number of characters to display. Pads
    12091209 *              with '0' or ' ' depending on the set flags;
    12101210 * @param flags Printf flags.
     
    12131213 * @return The number of characters printed; negative on failure.
    12141214 */
    1215 static int print_double(double g, char spec, int precision, int width, 
     1215static int print_double(double g, char spec, int precision, int width,
    12161216        uint32_t flags, printf_spec_t *ps)
    12171217{
     
    15421542                        case 'E':
    15431543                        case 'e':
    1544                                 retval = print_double(va_arg(ap, double), uc, precision, 
     1544                                retval = print_double(va_arg(ap, double), uc, precision,
    15451545                                        width, flags, ps);
    15461546                               
Note: See TracChangeset for help on using the changeset viewer.