Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5935c079 in mainline


Ignore:
Timestamp:
2011-08-21T14:13:01Z (9 years ago)
Author:
Martin Decky <martin@…>
Branches:
master
Children:
7ce7cfb, ec7f8b1
Parents:
f90eb75
Message:

preferably use ssize_t for signed size values
cstyle

File:
1 edited

Legend:

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

    rf90eb75 r5935c079  
    9090{
    9191        compl_t *cs = NULL;
    92         size_t pref_size;
    9392        char *stext = NULL;
    9493        char *prefix = NULL;
    9594        char *dirname = NULL;
    96         char *rpath_sep;
    97         static const char *dirlist_arg[] = { ".", NULL };
    9895        int retval;
    99         tokenizer_t tok;
     96       
    10097        token_t *tokens = calloc(WORD_MAX, sizeof(token_t));
    10198        if (tokens == NULL) {
     
    103100                goto error;
    104101        }
    105         int current_token;
     102       
     103        size_t pref_size;
     104        char *rpath_sep;
     105        static const char *dirlist_arg[] = { ".", NULL };
     106        tokenizer_t tok;
     107        ssize_t current_token;
    106108        size_t tokens_length;
    107 
     109       
    108110        cs = calloc(1, sizeof(compl_t));
    109111        if (!cs) {
     
    111113                goto error;
    112114        }
    113 
     115       
    114116        /* Convert text buffer to string */
    115117        stext = wstr_to_astr(text);
     
    131133       
    132134        /* Find the current token */
    133         for (current_token = 0; current_token < (int) tokens_length;
     135        for (current_token = 0; current_token < (ssize_t) tokens_length;
    134136            current_token++) {
    135137                token_t *t = &tokens[current_token];
    136138                size_t end = t->char_start + t->char_length;
    137                 /* Check if the caret lies inside the token or immediately
     139               
     140                /*
     141                 * Check if the caret lies inside the token or immediately
    138142                 * after it
    139143                 */
     
    142146                }
    143147        }
    144         if (tokens_length == 0) current_token = -1;
    145        
    146         if (current_token >= 0 && tokens[current_token].type != TOKTYPE_SPACE) {
     148       
     149        if (tokens_length == 0)
     150                current_token = -1;
     151       
     152        if ((current_token >= 0) && (tokens[current_token].type != TOKTYPE_SPACE))
    147153                *cstart = tokens[current_token].char_start;
    148         }
    149         else {
     154        else
    150155                *cstart = pos;
    151         }
    152        
    153         /* Extract the prefix being completed
     156       
     157        /*
     158         * Extract the prefix being completed
    154159         * XXX: handle strings, etc.
    155160         */
     
    174179
    175180        /* Skip any whitespace before current token */
    176         int prev_token = current_token - 1;
    177         if (prev_token >= 0 && tokens[prev_token].type == TOKTYPE_SPACE) {
     181        ssize_t prev_token = current_token - 1;
     182        if ((prev_token >= 0) && (tokens[prev_token].type == TOKTYPE_SPACE))
    178183                prev_token--;
    179         }
    180 
     184       
    181185        /*
    182186         * It is a command if it is the first token or if it immediately
    183187         * follows a pipe token.
    184188         */
    185         if (prev_token < 0 || tokens[prev_token].type == TOKTYPE_SPACE)
     189        if ((prev_token < 0) || (tokens[prev_token].type == TOKTYPE_SPACE))
    186190                cs->is_command = true;
    187191        else
Note: See TracChangeset for help on using the changeset viewer.