Changeset 00aece0 in mainline for uspace/app/bdsh/compl.c
- Timestamp:
- 2012-02-18T16:47:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/compl.c
rbd5f3b7 r00aece0 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; 95 int retval; 96 97 token_t *tokens = calloc(WORD_MAX, sizeof(token_t)); 98 if (tokens == NULL) { 99 retval = ENOMEM; 100 goto error; 101 } 102 103 size_t pref_size; 96 104 char *rpath_sep; 97 105 static const char *dirlist_arg[] = { ".", NULL }; 98 int retval;99 106 tokenizer_t tok; 100 token_t tokens[WORD_MAX]; 101 int current_token; 107 ssize_t current_token; 102 108 size_t tokens_length; 103 109 104 110 cs = calloc(1, sizeof(compl_t)); 105 111 if (!cs) { … … 107 113 goto error; 108 114 } 109 115 110 116 /* Convert text buffer to string */ 111 117 stext = wstr_to_astr(text); … … 127 133 128 134 /* Find the current token */ 129 for (current_token = 0; current_token < ( int) tokens_length;135 for (current_token = 0; current_token < (ssize_t) tokens_length; 130 136 current_token++) { 131 137 token_t *t = &tokens[current_token]; 132 138 size_t end = t->char_start + t->char_length; 133 /* Check if the caret lies inside the token or immediately 139 140 /* 141 * Check if the caret lies inside the token or immediately 134 142 * after it 135 143 */ … … 138 146 } 139 147 } 140 if (tokens_length == 0) current_token = -1; 141 142 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)) 143 153 *cstart = tokens[current_token].char_start; 144 } 145 else { 154 else 146 155 *cstart = pos; 147 }148 149 /* Extract the prefix being completed156 157 /* 158 * Extract the prefix being completed 150 159 * XXX: handle strings, etc. 151 160 */ … … 170 179 171 180 /* Skip any whitespace before current token */ 172 int prev_token = current_token - 1;173 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)) 174 183 prev_token--; 175 } 176 184 177 185 /* 178 186 * It is a command if it is the first token or if it immediately 179 187 * follows a pipe token. 180 188 */ 181 if ( prev_token < 0 || tokens[prev_token].type == TOKTYPE_SPACE)189 if ((prev_token < 0) || (tokens[prev_token].type == TOKTYPE_SPACE)) 182 190 cs->is_command = true; 183 191 else … … 254 262 if (cs != NULL) 255 263 free(cs); 264 if (tokens != NULL) 265 free(tokens); 256 266 257 267 return retval;
Note:
See TracChangeset
for help on using the changeset viewer.