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/posix/src/stdlib/strtold.c

    r3061bc1 ra35b458  
    141141                return mant;
    142142        }
    143        
     143
    144144        if (abs(exp) >> (MAX_POW5 + 1) != 0) {
    145145                /* Too large exponent. */
     
    147147                return exp < 0 ? LDBL_MIN : HUGE_VALL;
    148148        }
    149        
     149
    150150        if (exp < 0) {
    151151                exp = abs(exp);
     
    175175                }
    176176        }
    177        
     177
    178178        return mant;
    179179}
     
    191191                return mant;
    192192        }
    193        
     193
    194194        if (exp > LDBL_MAX_EXP || exp < LDBL_MIN_EXP) {
    195195                errno = ERANGE;
    196196                return exp < 0 ? LDBL_MIN : HUGE_VALL;
    197197        }
    198        
     198
    199199        if (exp < 0) {
    200200                exp = abs(exp);
     
    220220                }
    221221        }
    222        
     222
    223223        return mant;
    224224}
     
    242242        assert(sptr != NULL);
    243243        assert (*sptr != NULL);
    244        
     244
    245245        const int DEC_BASE = 10;
    246246        const char DECIMAL_POINT = '.';
    247247        const char EXPONENT_MARK = 'e';
    248        
     248
    249249        const char *str = *sptr;
    250250        long double significand = 0;
    251251        long exponent = 0;
    252        
     252
    253253        /* number of digits parsed so far */
    254254        int parsed_digits = 0;
    255255        bool after_decimal = false;
    256        
     256
    257257        while (isdigit(*str) || (!after_decimal && *str == DECIMAL_POINT)) {
    258258                if (*str == DECIMAL_POINT) {
     
    261261                        continue;
    262262                }
    263                
     263
    264264                if (parsed_digits == 0 && *str == '0') {
    265265                        /* Nothing, just skip leading zeros. */
     
    270270                        exponent++;
    271271                }
    272                
     272
    273273                if (after_decimal) {
    274274                        /* Decrement exponent if we are parsing the fractional part. */
    275275                        exponent--;
    276276                }
    277                
     277
    278278                str++;
    279279        }
    280        
     280
    281281        /* exponent */
    282282        if (tolower(*str) == EXPONENT_MARK) {
    283283                str++;
    284                
     284
    285285                /* Returns MIN/MAX value on error, which is ok. */
    286286                long exp = strtol(str, (char **) &str, DEC_BASE);
    287                
     287
    288288                if (exponent > 0 && exp > LONG_MAX - exponent) {
    289289                        exponent = LONG_MAX;
     
    294294                }
    295295        }
    296        
     296
    297297        *sptr = str;
    298        
     298
    299299        /* Return multiplied by a power of ten. */
    300300        return mul_pow2(mul_pow5(significand, exponent), exponent);
     
    330330{
    331331        assert(sptr != NULL && *sptr != NULL);
    332        
     332
    333333        const int DEC_BASE = 10;
    334334        const int HEX_BASE = 16;
    335335        const char DECIMAL_POINT = '.';
    336336        const char EXPONENT_MARK = 'p';
    337        
     337
    338338        const char *str = *sptr;
    339339        long double significand = 0;
    340340        long exponent = 0;
    341        
     341
    342342        /* number of bits parsed so far */
    343343        int parsed_bits = 0;
    344344        bool after_decimal = false;
    345        
     345
    346346        while (isxdigit(*str) || (!after_decimal && *str == DECIMAL_POINT)) {
    347347                if (*str == DECIMAL_POINT) {
     
    350350                        continue;
    351351                }
    352                
     352
    353353                if (parsed_bits == 0 && *str == '0') {
    354354                        /* Nothing, just skip leading zeros. */
     
    359359                        exponent += 4;
    360360                }
    361                
     361
    362362                if (after_decimal) {
    363363                        exponent -= 4;
    364364                }
    365                
     365
    366366                str++;
    367367        }
    368        
     368
    369369        /* exponent */
    370370        if (tolower(*str) == EXPONENT_MARK) {
    371371                str++;
    372                
     372
    373373                /* Returns MIN/MAX value on error, which is ok. */
    374374                long exp = strtol(str, (char **) &str, DEC_BASE);
    375                
     375
    376376                if (exponent > 0 && exp > LONG_MAX - exponent) {
    377377                        exponent = LONG_MAX;
     
    382382                }
    383383        }
    384        
     384
    385385        *sptr = str;
    386        
     386
    387387        /* Return multiplied by a power of two. */
    388388        return mul_pow2(significand, exponent);
     
    407407{
    408408        assert(nptr != NULL);
    409        
     409
    410410        const int RADIX = '.';
    411        
     411
    412412        /* minus sign */
    413413        bool negative = false;
    414414        /* current position in the string */
    415415        int i = 0;
    416        
     416
    417417        /* skip whitespace */
    418418        while (isspace(nptr[i])) {
    419419                i++;
    420420        }
    421        
     421
    422422        /* parse sign */
    423423        switch (nptr[i]) {
     
    428428                i++;
    429429        }
    430        
     430
    431431        /* check for NaN */
    432432        if (strncasecmp(&nptr[i], "nan", 3) == 0) {
    433433                // FIXME: return NaN
    434434                // TODO: handle the parenthesised case
    435                
     435
    436436                if (endptr != NULL) {
    437437                        *endptr = (char *) nptr;
     
    440440                return 0;
    441441        }
    442        
     442
    443443        /* check for Infinity */
    444444        if (strncasecmp(&nptr[i], "inf", 3) == 0) {
     
    447447                        i += 5;
    448448                }
    449                
     449
    450450                if (endptr != NULL) {
    451451                        *endptr = (char *) &nptr[i];
     
    459459            (nptr[i + 2] == RADIX && isxdigit(nptr[i + 3])))) {
    460460                i += 2;
    461                
     461
    462462                const char *ptr = &nptr[i];
    463463                /* this call sets errno if appropriate. */
     
    468468                return negative ? -result : result;
    469469        }
    470        
     470
    471471        /* check for a decimal number */
    472472        if (isdigit(nptr[i]) || (nptr[i] == RADIX && isdigit(nptr[i + 1]))) {
     
    479479                return negative ? -result : result;
    480480        }
    481        
     481
    482482        /* nothing to parse */
    483483        if (endptr != NULL) {
Note: See TracChangeset for help on using the changeset viewer.