Ignore:
Timestamp:
2018-03-02T20:10:49Z (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:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

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

    r3061bc1 ra35b458  
    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);
Note: See TracChangeset for help on using the changeset viewer.