Changeset a6480d5 in mainline for uspace/app/bdsh/compl.c


Ignore:
Timestamp:
2011-08-21T11:44:59Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
25c1b2c, bd5f3b7, d1e196f7
Parents:
c22531fc (diff), 1877128 (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:
Martin Sucha <> (2011-08-21 11:44:59)
git-committer:
Martin Decky <martin@…> (2011-08-21 11:44:59)
Message:

merge Martin Sucha's fixes and improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/compl.c

    rc22531fc ra6480d5  
    9999        tokenizer_t tok;
    100100        token_t tokens[WORD_MAX];
    101         unsigned int current_token;
     101        int current_token;
    102102        size_t tokens_length;
    103103
     
    127127       
    128128        /* Find the current token */
    129         for (current_token = 0; current_token < tokens_length; current_token++) {
     129        for (current_token = 0; current_token < (int) tokens_length;
     130            current_token++) {
    130131                token_t *t = &tokens[current_token];
    131132                size_t end = t->char_start + t->char_length;
     
    137138                }
    138139        }
    139        
    140         if (tokens[current_token].type != TOKTYPE_SPACE) {
     140        if (tokens_length == 0) current_token = -1;
     141       
     142        if (current_token >= 0 && tokens[current_token].type != TOKTYPE_SPACE) {
    141143                *cstart = tokens[current_token].char_start;
    142144        }
     
    154156                goto error;
    155157        }
    156 
    157         str_ncpy(prefix, pref_size + 1, stext +
    158             tokens[current_token].byte_start, pref_size);
     158        prefix[pref_size] = 0;
     159
     160        if (current_token >= 0) {
     161                str_ncpy(prefix, pref_size + 1, stext +
     162                    tokens[current_token].byte_start, pref_size);
     163        }
    159164
    160165        /*
     
    166171        /* Skip any whitespace before current token */
    167172        int prev_token = current_token - 1;
    168         if (prev_token != -1 && tokens[prev_token].type == TOKTYPE_SPACE) {
     173        if (prev_token >= 0 && tokens[prev_token].type == TOKTYPE_SPACE) {
    169174                prev_token--;
    170175        }
     
    174179         * follows a pipe token.
    175180         */
    176         if (prev_token == -1 || tokens[prev_token].type == TOKTYPE_SPACE)
     181        if (prev_token < 0 || tokens[prev_token].type == TOKTYPE_SPACE)
    177182                cs->is_command = true;
    178183        else
Note: See TracChangeset for help on using the changeset viewer.