Ignore:
Timestamp:
2018-03-02T20:34:50Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

File:
1 edited

Legend:

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

    r3061bc1 r8565a42  
    211211        if (str == NULL)
    212212                return printf_putnchars(nullstr, str_size(nullstr), ps);
    213        
     213
    214214        return ps->str_write((void *) str, str_size(str), ps->data);
    215215}
     
    227227        if (!ascii_check(ch))
    228228                return ps->str_write((void *) &invalch, 1, ps->data);
    229        
     229
    230230        return ps->str_write(&ch, 1, ps->data);
    231231}
     
    243243        if (!chr_check(ch))
    244244                return ps->str_write((void *) &invalch, 1, ps->data);
    245        
     245
    246246        return ps->wstr_write(&ch, sizeof(wchar_t), ps->data);
    247247}
     
    269269                }
    270270        }
    271        
     271
    272272        if (printf_putchar(ch, ps) > 0)
    273273                counter++;
    274        
     274
    275275        while (--width > 0) {
    276276                /*
     
    281281                        counter++;
    282282        }
    283        
     283
    284284        return (int) (counter);
    285285}
     
    307307                }
    308308        }
    309        
     309
    310310        if (printf_putwchar(ch, ps) > 0)
    311311                counter++;
    312        
     312
    313313        while (--width > 0) {
    314314                /*
     
    319319                        counter++;
    320320        }
    321        
     321
    322322        return (int) (counter);
    323323}
     
    337337        if (str == NULL)
    338338                return printf_putstr(nullstr, ps);
    339        
     339
    340340        size_t strw = str_length(str);
    341341
     
    343343        if ((precision == 0) || (precision > strw))
    344344                precision = strw;
    345        
     345
    346346        /* Left padding */
    347347        size_t counter = 0;
     
    353353                }
    354354        }
    355        
     355
    356356        /* Part of @a str fitting into the alloted space. */
    357357        int retval;
     
    386386        if (str == NULL)
    387387                return printf_putstr(nullstr, ps);
    388        
     388
    389389        size_t strw = wstr_length(str);
    390390
     
    392392        if ((precision == 0) || (precision > strw))
    393393                precision = strw;
    394        
     394
    395395        /* Left padding */
    396396        size_t counter = 0;
     
    402402                }
    403403        }
    404        
     404
    405405        /* Part of @a wstr fitting into the alloted space. */
    406406        int retval;
     
    408408        if ((retval = printf_wputnchars(str, size, ps)) < 0)
    409409                return -counter;
    410        
     410
    411411        counter += retval;
    412        
     412
    413413        /* Right padding */
    414414        while (width-- > 0) {
     
    440440                precision = 0;
    441441        }
    442        
     442
    443443        const char *digits;
    444444        if (flags & __PRINTF_FLAG_BIGCHARS)
     
    446446        else
    447447                digits = digits_small;
    448        
     448
    449449        char data[PRINT_NUMBER_BUFFER_SIZE];
    450450        char *ptr = &data[PRINT_NUMBER_BUFFER_SIZE - 1];
    451        
     451
    452452        /* Size of number with all prefixes and signs */
    453453        int size = 0;
    454        
     454
    455455        /* Put zero at end of string */
    456456        *ptr-- = 0;
    457        
     457
    458458        if (num == 0) {
    459459                *ptr-- = '0';
     
    465465                } while (num /= base);
    466466        }
    467        
     467
    468468        /* Size of plain number */
    469469        int number_size = size;
    470        
     470
    471471        /*
    472472         * Collect the sum of all prefixes/signs/etc. to calculate padding and
     
    487487                }
    488488        }
    489        
     489
    490490        char sgn = 0;
    491491        if (flags & __PRINTF_FLAG_SIGNED) {
     
    501501                }
    502502        }
    503        
     503
    504504        if (flags & __PRINTF_FLAG_LEFTALIGNED)
    505505                flags &= ~__PRINTF_FLAG_ZEROPADDED;
    506        
     506
    507507        /*
    508508         * If the number is left-aligned or precision is specified then
     
    513513                        precision = width - size + number_size;
    514514        }
    515        
     515
    516516        /* Print leading spaces */
    517517        if (number_size > precision) {
     
    519519                precision = number_size;
    520520        }
    521        
     521
    522522        width -= precision + size - number_size;
    523523        size_t counter = 0;
    524        
     524
    525525        if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
    526526                while (width-- > 0) {
     
    529529                }
    530530        }
    531        
     531
    532532        /* Print sign */
    533533        if (sgn) {
     
    535535                        counter++;
    536536        }
    537        
     537
    538538        /* Print prefix */
    539539        if (flags & __PRINTF_FLAG_PREFIX) {
     
    568568                }
    569569        }
    570        
     570
    571571        /* Print leading zeroes */
    572572        precision -= number_size;
     
    575575                        counter++;
    576576        }
    577        
     577
    578578        /* Print the number itself */
    579579        int retval;
    580580        if ((retval = printf_putstr(++ptr, ps)) > 0)
    581581                counter += retval;
    582        
     582
    583583        /* Print trailing spaces */
    584        
     584
    585585        while (width-- > 0) {
    586586                if (printf_putchar(' ', ps) == 1)
    587587                        counter++;
    588588        }
    589        
     589
    590590        return ((int) counter);
    591591}
     
    601601        const int str_len = 3;
    602602        const char *str;
    603        
     603
    604604        if (flags & __PRINTF_FLAG_BIGCHARS) {
    605605                str = val.is_infinity ? "INF" : "NAN";
     
    624624                if ((ret = ps->str_write(&sign, 1, ps->data)) < 0)
    625625                        return -1;
    626                
     626
    627627                counter += ret;
    628628        }
     
    630630        if ((ret = ps->str_write(str, str_len, ps->data)) < 0)
    631631                return -1;
    632        
     632
    633633        counter += ret;
    634634
     
    751751                if ((ret = ps->str_write(&sign, 1, ps->data)) < 0)
    752752                        return -1;
    753                
     753
    754754                counter += ret;
    755755        }
     
    783783
    784784        counter += ret;
    785        
     785
    786786        /* Print the decimal point and the fractional part. */
    787787        if (has_decimal_pt) {
     
    790790                if ((ret = ps->str_write(&ch, 1, ps->data)) < 0)
    791791                        return -1;
    792                
     792
    793793                counter += ret;
    794794
     
    885885                /* Let the implementation figure out the proper precision. */
    886886                val_str.len = double_to_short_str(val, buf, buf_size, &val_str.dec_exp);
    887                
     887
    888888                /* Precision needed for the last significant digit. */
    889889                precision = max(0, -val_str.dec_exp);
     
    903903        if ((ret = ps->str_write(&exp_ch, 1, ps->data)) < 0)
    904904                return -1;
    905        
     905
    906906        counter += ret;
    907907
     
    915915        /* Print the exponent. */
    916916        exp_val = abs(exp_val);
    917        
     917
    918918        char exp_str[4] = { 0 };
    919919
     
    921921        exp_str[1] = '0' + (exp_val % 100) / 10 ;
    922922        exp_str[2] = '0' + (exp_val % 10);
    923        
     923
    924924        int exp_len = (exp_str[0] == '0') ? 2 : 3;
    925925        const char *exp_str_start = &exp_str[3] - exp_len;
     
    981981                if ((ret = ps->str_write(&sign, 1, ps->data)) < 0)
    982982                        return -1;
    983                
     983
    984984                counter += ret;
    985985        }
     
    10041004                if ((ret = ps->str_write(&ch, 1, ps->data)) < 0)
    10051005                        return -1;
    1006                
     1006
    10071007                counter += ret;
    10081008
     
    11041104                /* Let the implementation figure out the proper precision. */
    11051105                val_str.len = double_to_short_str(val, buf, buf_size, &val_str.dec_exp);
    1106                
     1106
    11071107                /* Use all produced digits. */
    11081108                precision = val_str.len - 1;
     
    12231223                precision = (precision < 0) ? 6 : precision;
    12241224                return print_double_fixed(g, precision, width, flags, ps);
    1225        
     1225
    12261226        case 'E':
    12271227                flags |= __PRINTF_FLAG_BIGCHARS;
     
    12301230                precision = (precision < 0) ? 6 : precision;
    12311231                return print_double_scientific(g, precision, width, flags, ps);
    1232        
     1232
    12331233        case 'G':
    12341234                flags |= __PRINTF_FLAG_BIGCHARS;
     
    12361236        case 'g':
    12371237                return print_double_generic(g, precision, width, flags, ps);
    1238        
     1238
    12391239        default:
    12401240                assert(false);
     
    13371337        size_t nxt = 0;  /* Index of the next character from fmt */
    13381338        size_t j = 0;    /* Index to the first not printed nonformating character */
    1339        
     1339
    13401340        size_t counter = 0;   /* Number of characters printed */
    13411341        int retval;           /* Return values from nested functions */
    1342        
     1342
    13431343        while (true) {
    13441344                i = nxt;
    13451345                wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
    1346                
     1346
    13471347                if (uc == 0)
    13481348                        break;
    1349                
     1349
    13501350                /* Control character */
    13511351                if (uc == '%') {
     
    13591359                                counter += retval;
    13601360                        }
    1361                        
     1361
    13621362                        j = i;
    1363                        
     1363
    13641364                        /* Parse modifiers */
    13651365                        uint32_t flags = 0;
    13661366                        bool end = false;
    1367                        
     1367
    13681368                        do {
    13691369                                i = nxt;
     
    13901390                                };
    13911391                        } while (!end);
    1392                        
     1392
    13931393                        /* Width & '*' operator */
    13941394                        int width = 0;
     
    13971397                                        width *= 10;
    13981398                                        width += uc - '0';
    1399                                        
     1399
    14001400                                        i = nxt;
    14011401                                        uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
     
    14161416                                }
    14171417                        }
    1418                        
     1418
    14191419                        /* Precision and '*' operator */
    14201420                        int precision = -1;
     
    14271427                                                precision *= 10;
    14281428                                                precision += uc - '0';
    1429                                                
     1429
    14301430                                                i = nxt;
    14311431                                                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
     
    14461446                                }
    14471447                        }
    1448                        
     1448
    14491449                        qualifier_t qualifier;
    1450                        
     1450
    14511451                        switch (uc) {
    14521452                        case 't':
     
    14951495                                qualifier = PrintfQualifierInt;
    14961496                        }
    1497                        
     1497
    14981498                        unsigned int base = 10;
    1499                        
     1499
    15001500                        switch (uc) {
    15011501                        /*
     
    15041504                        case 's':
    15051505                                precision = max(0,  precision);
    1506                                
     1506
    15071507                                if (qualifier == PrintfQualifierLong)
    15081508                                        retval = print_wstr(va_arg(ap, wchar_t *), width, precision, flags, ps);
    15091509                                else
    15101510                                        retval = print_str(va_arg(ap, char *), width, precision, flags, ps);
    1511                                
     1511
    15121512                                if (retval < 0) {
    15131513                                        counter = -counter;
    15141514                                        goto out;
    15151515                                }
    1516                                
     1516
    15171517                                counter += retval;
    15181518                                j = nxt;
     
    15231523                                else
    15241524                                        retval = print_char(va_arg(ap, unsigned int), width, flags, ps);
    1525                                
     1525
    15261526                                if (retval < 0) {
    15271527                                        counter = -counter;
    15281528                                        goto out;
    15291529                                };
    1530                                
     1530
    15311531                                counter += retval;
    15321532                                j = nxt;
    15331533                                goto next_char;
    1534                                
     1534
    15351535                        /*
    15361536                         * Floating point values
     
    15441544                                retval = print_double(va_arg(ap, double), uc, precision,
    15451545                                        width, flags, ps);
    1546                                
     1546
    15471547                                if (retval < 0) {
    15481548                                        counter = -counter;
    15491549                                        goto out;
    15501550                                }
    1551                                
     1551
    15521552                                counter += retval;
    15531553                                j = nxt;
    15541554                                goto next_char;
    1555                        
     1555
    15561556                        /*
    15571557                         * Integer values
     
    15851585                                base = 16;
    15861586                                break;
    1587                        
     1587
    15881588                        /* Percentile itself */
    15891589                        case '%':
    15901590                                j = i;
    15911591                                goto next_char;
    1592                        
     1592
    15931593                        /*
    15941594                         * Bad formatting.
     
    16011601                                goto next_char;
    16021602                        }
    1603                        
     1603
    16041604                        /* Print integers */
    16051605                        size_t size;
    16061606                        uint64_t number;
    1607                        
     1607
    16081608                        switch (qualifier) {
    16091609                        case PrintfQualifierByte:
     
    16451645                                goto out;
    16461646                        }
    1647                        
     1647
    16481648                        if ((retval = print_number(number, width, precision,
    16491649                            base, flags, ps)) < 0) {
     
    16511651                                goto out;
    16521652                        }
    1653                        
     1653
    16541654                        counter += retval;
    16551655                        j = nxt;
     
    16581658                ;
    16591659        }
    1660        
     1660
    16611661        if (i > j) {
    16621662                if ((retval = printf_putnchars(&fmt[j], i - j, ps)) < 0) {
     
    16671667                counter += retval;
    16681668        }
    1669        
     1669
    16701670out:
    16711671        return ((int) counter);
Note: See TracChangeset for help on using the changeset viewer.