Changeset a35b458 in mainline for uspace/app/bdsh/tok.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (6 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/app/bdsh/tok.c

    r3061bc1 ra35b458  
    5959        tok->in_char_offset = 0;
    6060        tok->last_in_char_offset = 0;
    61        
     61
    6262        tok->outtok = out_tokens;
    6363        tok->outtok_offset = 0;
    6464        tok->outtok_size = max_tokens;
    65        
     65
    6666        /* Prepare a buffer where all the token strings will be stored */
    6767        size_t len = str_size(input) + max_tokens + 1;
    6868        char *tmp = malloc(len);
    69        
     69
    7070        if (tmp == NULL) {
    7171                return ENOMEM;
    7272        }
    73        
     73
    7474        tok->outbuf = tmp;
    7575        tok->outbuf_offset = 0;
    7676        tok->outbuf_size = len;
    7777        tok->outbuf_last_start = 0;
    78        
     78
    7979        return EOK;
    8080}
     
    9393        errno_t rc;
    9494        wchar_t next_char;
    95        
     95
    9696        /* Read the input line char by char and append tokens */
    9797        while ((next_char = tok_look_char(tok)) != 0) {
     
    113113                        }
    114114                        tok_push_token(tok);
    115                        
     115
    116116                }
    117117                else if (next_char == '|') {
     
    125125                                }
    126126                        }
    127                        
     127
    128128                        tok_start_token(tok, TOKTYPE_PIPE);
    129                        
     129
    130130                        rc = tok_push_char(tok, tok_get_char(tok));
    131131                        if (rc != EOK) {
    132132                                return rc;
    133133                        }
    134                        
     134
    135135                        rc = tok_push_token(tok);
    136136                        if (rc != EOK) {
     
    163163                }
    164164        }
    165        
     165
    166166        /* Push the last token */
    167167        if (tok_pending_chars(tok)) {
     
    171171                }
    172172        }
    173        
     173
    174174        *tokens_length = tok->outtok_offset;
    175        
     175
    176176        return EOK;
    177177}
     
    182182        errno_t rc;
    183183        wchar_t next_char;
    184        
     184
    185185        while ((next_char = tok_look_char(tok)) != 0) {
    186186                if (next_char == '\'') {
     
    193193                                        return rc;
    194194                                }
    195                                
     195
    196196                                /* Swallow the additional one in the input */
    197197                                tok_get_char(tok);
     
    209209                }
    210210        }
    211        
     211
    212212        /* If we are here, the string run to the end without being closed */
    213213        return EINVAL;
     
    249249                return EOVERFLOW;
    250250        }
    251        
     251
    252252        if (tok->outbuf_offset >= tok->outbuf_size) {
    253253                return EOVERFLOW;
    254254        }
    255        
     255
    256256        tok->outbuf[tok->outbuf_offset++] = 0;
    257257        token_t *tokinfo = &tok->outtok[tok->outtok_offset++];
     
    263263        tokinfo->char_length = tok->in_char_offset - tok->last_in_char_offset;
    264264        tok->outbuf_last_start = tok->outbuf_offset;
    265        
     265
    266266        /* We have consumed the first char of the next token already */
    267267        tok->last_in_offset = tok->in_offset;
    268268        tok->last_in_char_offset = tok->in_char_offset;
    269        
     269
    270270        return EOK;
    271271}
Note: See TracChangeset for help on using the changeset viewer.