Changeset 8565a42 in mainline for kernel/generic/src/printf


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.

Location:
kernel/generic/src/printf
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/printf/printf.c

    r3061bc1 r8565a42  
    4040        int ret;
    4141        va_list args;
    42        
     42
    4343        va_start(args, fmt);
    44        
     44
    4545        ret = vprintf(fmt, args);
    46        
     46
    4747        va_end(args);
    48        
     48
    4949        return ret;
    5050}
  • kernel/generic/src/printf/printf_core.c

    r3061bc1 r8565a42  
    157157        if (str == NULL)
    158158                return printf_putnchars(nullstr, str_size(nullstr), ps);
    159        
     159
    160160        return ps->str_write((void *) str, str_size(str), ps->data);
    161161}
     
    173173        if (!ascii_check(ch))
    174174                return ps->str_write((void *) &invalch, 1, ps->data);
    175        
     175
    176176        return ps->str_write(&ch, 1, ps->data);
    177177}
     
    189189        if (!chr_check(ch))
    190190                return ps->str_write((void *) &invalch, 1, ps->data);
    191        
     191
    192192        return ps->wstr_write(&ch, sizeof(wchar_t), ps->data);
    193193}
     
    215215                }
    216216        }
    217        
     217
    218218        if (printf_putchar(ch, ps) > 0)
    219219                counter++;
    220        
     220
    221221        while (--width > 0) {
    222222                /*
     
    227227                        counter++;
    228228        }
    229        
     229
    230230        return (int) (counter);
    231231}
     
    253253                }
    254254        }
    255        
     255
    256256        if (printf_putwchar(ch, ps) > 0)
    257257                counter++;
    258        
     258
    259259        while (--width > 0) {
    260260                /*
     
    265265                        counter++;
    266266        }
    267        
     267
    268268        return (int) (counter);
    269269}
     
    283283        if (str == NULL)
    284284                return printf_putstr(nullstr, ps);
    285        
     285
    286286        /* Print leading spaces. */
    287287        size_t strw = str_length(str);
    288288        if ((precision == 0) || (precision > strw))
    289289                precision = strw;
    290        
     290
    291291        /* Left padding */
    292292        size_t counter = 0;
     
    298298                }
    299299        }
    300        
     300
    301301        /* Part of @a str fitting into the alloted space. */
    302302        int retval;
     
    331331        if (str == NULL)
    332332                return printf_putstr(nullstr, ps);
    333        
     333
    334334        /* Print leading spaces. */
    335335        size_t strw = wstr_length(str);
    336336        if ((precision == 0) || (precision > strw))
    337337                precision = strw;
    338        
     338
    339339        /* Left padding */
    340340        size_t counter = 0;
     
    346346                }
    347347        }
    348        
     348
    349349        /* Part of @a wstr fitting into the alloted space. */
    350350        int retval;
     
    352352        if ((retval = printf_wputnchars(str, size, ps)) < 0)
    353353                return -counter;
    354        
     354
    355355        counter += retval;
    356        
     356
    357357        /* Right padding */
    358358        while (width-- > 0) {
     
    385385        else
    386386                digits = digits_small;
    387        
     387
    388388        char data[PRINT_NUMBER_BUFFER_SIZE];
    389389        char *ptr = &data[PRINT_NUMBER_BUFFER_SIZE - 1];
    390        
     390
    391391        /* Size of number with all prefixes and signs */
    392392        int size = 0;
    393        
     393
    394394        /* Put zero at end of string */
    395395        *ptr-- = 0;
    396        
     396
    397397        if (num == 0) {
    398398                *ptr-- = '0';
     
    404404                } while (num /= base);
    405405        }
    406        
     406
    407407        /* Size of plain number */
    408408        int number_size = size;
    409        
     409
    410410        /*
    411411         * Collect the sum of all prefixes/signs/etc. to calculate padding and
     
    426426                }
    427427        }
    428        
     428
    429429        char sgn = 0;
    430430        if (flags & __PRINTF_FLAG_SIGNED) {
     
    440440                }
    441441        }
    442        
     442
    443443        if (flags & __PRINTF_FLAG_LEFTALIGNED)
    444444                flags &= ~__PRINTF_FLAG_ZEROPADDED;
    445        
     445
    446446        /*
    447447         * If the number is left-aligned or precision is specified then
     
    452452                        precision = width - size + number_size;
    453453        }
    454        
     454
    455455        /* Print leading spaces */
    456456        if (number_size > precision) {
     
    458458                precision = number_size;
    459459        }
    460        
     460
    461461        width -= precision + size - number_size;
    462462        size_t counter = 0;
    463        
     463
    464464        if (!(flags & __PRINTF_FLAG_LEFTALIGNED)) {
    465465                while (width-- > 0) {
     
    468468                }
    469469        }
    470        
     470
    471471        /* Print sign */
    472472        if (sgn) {
     
    474474                        counter++;
    475475        }
    476        
     476
    477477        /* Print prefix */
    478478        if (flags & __PRINTF_FLAG_PREFIX) {
     
    507507                }
    508508        }
    509        
     509
    510510        /* Print leading zeroes */
    511511        precision -= number_size;
     
    514514                        counter++;
    515515        }
    516        
     516
    517517        /* Print the number itself */
    518518        int retval;
    519519        if ((retval = printf_putstr(++ptr, ps)) > 0)
    520520                counter += retval;
    521        
     521
    522522        /* Print trailing spaces */
    523        
     523
    524524        while (width-- > 0) {
    525525                if (printf_putchar(' ', ps) == 1)
    526526                        counter++;
    527527        }
    528        
     528
    529529        return ((int) counter);
    530530}
     
    624624        size_t nxt = 0;  /* Index of the next character from fmt */
    625625        size_t j = 0;    /* Index to the first not printed nonformating character */
    626        
     626
    627627        size_t counter = 0;   /* Number of characters printed */
    628628        int retval;           /* Return values from nested functions */
    629        
     629
    630630        while (true) {
    631631                i = nxt;
    632632                wchar_t uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
    633                
     633
    634634                if (uc == 0)
    635635                        break;
    636                
     636
    637637                /* Control character */
    638638                if (uc == '%') {
     
    646646                                counter += retval;
    647647                        }
    648                        
     648
    649649                        j = i;
    650                        
     650
    651651                        /* Parse modifiers */
    652652                        uint32_t flags = 0;
    653653                        bool end = false;
    654                        
     654
    655655                        do {
    656656                                i = nxt;
     
    676676                                };
    677677                        } while (!end);
    678                        
     678
    679679                        /* Width & '*' operator */
    680680                        int width = 0;
     
    683683                                        width *= 10;
    684684                                        width += uc - '0';
    685                                        
     685
    686686                                        i = nxt;
    687687                                        uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
     
    702702                                }
    703703                        }
    704                        
     704
    705705                        /* Precision and '*' operator */
    706706                        int precision = 0;
     
    712712                                                precision *= 10;
    713713                                                precision += uc - '0';
    714                                                
     714
    715715                                                i = nxt;
    716716                                                uc = str_decode(fmt, &nxt, STR_NO_LIMIT);
     
    731731                                }
    732732                        }
    733                        
     733
    734734                        qualifier_t qualifier;
    735                        
     735
    736736                        switch (uc) {
    737737                        case 't':
     
    780780                                qualifier = PrintfQualifierInt;
    781781                        }
    782                        
     782
    783783                        unsigned int base = 10;
    784                        
     784
    785785                        switch (uc) {
    786786                        /*
     
    792792                                else
    793793                                        retval = print_str(va_arg(ap, char *), width, precision, flags, ps);
    794                                
     794
    795795                                if (retval < 0) {
    796796                                        counter = -counter;
    797797                                        goto out;
    798798                                }
    799                                
     799
    800800                                counter += retval;
    801801                                j = nxt;
     
    806806                                else
    807807                                        retval = print_char(va_arg(ap, unsigned int), width, flags, ps);
    808                                
     808
    809809                                if (retval < 0) {
    810810                                        counter = -counter;
    811811                                        goto out;
    812812                                };
    813                                
     813
    814814                                counter += retval;
    815815                                j = nxt;
    816816                                goto next_char;
    817                        
     817
    818818                        /*
    819819                         * Integer values
     
    847847                                base = 16;
    848848                                break;
    849                        
     849
    850850                        /* Percentile itself */
    851851                        case '%':
    852852                                j = i;
    853853                                goto next_char;
    854                        
     854
    855855                        /*
    856856                         * Bad formatting.
     
    863863                                goto next_char;
    864864                        }
    865                        
     865
    866866                        /* Print integers */
    867867                        size_t size;
    868868                        uint64_t number;
    869                        
     869
    870870                        switch (qualifier) {
    871871                        case PrintfQualifierByte:
     
    907907                                goto out;
    908908                        }
    909                        
     909
    910910                        if ((retval = print_number(number, width, precision,
    911911                            base, flags, ps)) < 0) {
     
    913913                                goto out;
    914914                        }
    915                        
     915
    916916                        counter += retval;
    917917                        j = nxt;
     
    920920                ;
    921921        }
    922        
     922
    923923        if (i > j) {
    924924                if ((retval = printf_putnchars(&fmt[j], i - j, ps)) < 0) {
     
    929929                counter += retval;
    930930        }
    931        
     931
    932932out:
    933933        return ((int) counter);
  • kernel/generic/src/printf/snprintf.c

    r3061bc1 r8565a42  
    4040        int ret;
    4141        va_list args;
    42        
     42
    4343        va_start(args, fmt);
    4444        ret = vsnprintf(str, size, fmt, args);
    45        
     45
    4646        va_end(args);
    47        
     47
    4848        return ret;
    4949}
  • kernel/generic/src/printf/vprintf.c

    r3061bc1 r8565a42  
    4545        size_t offset = 0;
    4646        size_t chars = 0;
    47        
     47
    4848        while (offset < size) {
    4949                putchar(str_decode(str, &offset, size));
    5050                chars++;
    5151        }
    52        
     52
    5353        return chars;
    5454}
     
    5858        size_t offset = 0;
    5959        size_t chars = 0;
    60        
     60
    6161        while (offset < size) {
    6262                putchar(str[chars]);
     
    6464                offset += sizeof(wchar_t);
    6565        }
    66        
     66
    6767        return chars;
    6868}
     
    7373        size_t chars = 0;
    7474        wchar_t uc;
    75        
     75
    7676        while ((uc = str_decode(str, &offset, STR_NO_LIMIT)) != 0) {
    7777                putchar(uc);
    7878                chars++;
    7979        }
    80        
     80
    8181        return chars;
    8282}
     
    8989                NULL
    9090        };
    91        
     91
    9292        return printf_core(fmt, &ps, ap);
    9393}
  • kernel/generic/src/printf/vsnprintf.c

    r3061bc1 r8565a42  
    6565{
    6666        size_t left = data->size - data->len;
    67        
     67
    6868        if (left == 0)
    6969                return ((int) size);
    70        
     70
    7171        if (left == 1) {
    7272                /* We have only one free byte left in buffer
     
    7777                return ((int) size);
    7878        }
    79        
     79
    8080        if (left <= size) {
    8181                /* We do not have enough space for the whole string
     
    8484                 */
    8585                size_t index = 0;
    86                
     86
    8787                while (index < size) {
    8888                        wchar_t uc = str_decode(str, &index, size);
    89                        
     89
    9090                        if (chr_encode(uc, data->dst, &data->len, data->size - 1) != EOK)
    9191                                break;
    9292                }
    93                
     93
    9494                /* Put trailing zero at end, but not count it
    9595                 * into data->len so it could be rewritten next time
    9696                 */
    9797                data->dst[data->len] = 0;
    98                
     98
    9999                return ((int) size);
    100100        }
    101        
     101
    102102        /* Buffer is big enough to print the whole string */
    103103        memcpy((void *)(data->dst + data->len), (void *) str, size);
    104104        data->len += size;
    105        
     105
    106106        /* Put trailing zero at end, but not count it
    107107         * into data->len so it could be rewritten next time
    108108         */
    109109        data->dst[data->len] = 0;
    110        
     110
    111111        return ((int) size);
    112112}
     
    132132{
    133133        size_t index = 0;
    134        
     134
    135135        while (index < (size / sizeof(wchar_t))) {
    136136                size_t left = data->size - data->len;
    137                
     137
    138138                if (left == 0)
    139139                        return ((int) size);
    140                
     140
    141141                if (left == 1) {
    142142                        /* We have only one free byte left in buffer
     
    147147                        return ((int) size);
    148148                }
    149                
     149
    150150                if (chr_encode(str[index], data->dst, &data->len, data->size - 1) != EOK)
    151151                        break;
    152                
     152
    153153                index++;
    154154        }
    155        
     155
    156156        /* Put trailing zero at end, but not count it
    157157         * into data->len so it could be rewritten next time
    158158         */
    159159        data->dst[data->len] = 0;
    160        
     160
    161161        return ((int) size);
    162162}
     
    174174                &data
    175175        };
    176        
     176
    177177        /* Print 0 at end of string - fix the case that nothing will be printed */
    178178        if (size > 0)
    179179                str[0] = 0;
    180        
     180
    181181        /* vsnprintf_write ensures that str will be terminated by zero. */
    182182        return printf_core(fmt, &ps, ap);
Note: See TracChangeset for help on using the changeset viewer.