Changeset a35b458 in mainline for uspace/lib/c/generic/io/vsnprintf.c


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
  • uspace/lib/c/generic/io/vsnprintf.c

    r3061bc1 ra35b458  
    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.