Changeset 5935c079 in mainline
- Timestamp:
- 2011-08-21T14:13:01Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7ce7cfb, ec7f8b1
- Parents:
- f90eb75
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/compl.c
rf90eb75 r5935c079 90 90 { 91 91 compl_t *cs = NULL; 92 size_t pref_size;93 92 char *stext = NULL; 94 93 char *prefix = NULL; 95 94 char *dirname = NULL; 96 char *rpath_sep;97 static const char *dirlist_arg[] = { ".", NULL };98 95 int retval; 99 tokenizer_t tok;96 100 97 token_t *tokens = calloc(WORD_MAX, sizeof(token_t)); 101 98 if (tokens == NULL) { … … 103 100 goto error; 104 101 } 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; 106 108 size_t tokens_length; 107 109 108 110 cs = calloc(1, sizeof(compl_t)); 109 111 if (!cs) { … … 111 113 goto error; 112 114 } 113 115 114 116 /* Convert text buffer to string */ 115 117 stext = wstr_to_astr(text); … … 131 133 132 134 /* 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; 134 136 current_token++) { 135 137 token_t *t = &tokens[current_token]; 136 138 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 138 142 * after it 139 143 */ … … 142 146 } 143 147 } 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)) 147 153 *cstart = tokens[current_token].char_start; 148 } 149 else { 154 else 150 155 *cstart = pos; 151 }152 153 /* Extract the prefix being completed156 157 /* 158 * Extract the prefix being completed 154 159 * XXX: handle strings, etc. 155 160 */ … … 174 179 175 180 /* 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)) 178 183 prev_token--; 179 } 180 184 181 185 /* 182 186 * It is a command if it is the first token or if it immediately 183 187 * follows a pipe token. 184 188 */ 185 if ( prev_token < 0 || tokens[prev_token].type == TOKTYPE_SPACE)189 if ((prev_token < 0) || (tokens[prev_token].type == TOKTYPE_SPACE)) 186 190 cs->is_command = true; 187 191 else
Note:
See TracChangeset
for help on using the changeset viewer.