Changeset a35b458 in mainline for uspace/app/bdsh/compl.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/compl.c
r3061bc1 ra35b458 95 95 char *dirname = NULL; 96 96 errno_t retval; 97 97 98 98 token_t *tokens = calloc(WORD_MAX, sizeof(token_t)); 99 99 if (tokens == NULL) { … … 101 101 goto error; 102 102 } 103 103 104 104 size_t pref_size; 105 105 char *rpath_sep; … … 108 108 ssize_t current_token; 109 109 size_t tokens_length; 110 110 111 111 cs = calloc(1, sizeof(compl_t)); 112 112 if (!cs) { … … 114 114 goto error; 115 115 } 116 116 117 117 /* Convert text buffer to string */ 118 118 stext = wstr_to_astr(text); … … 121 121 goto error; 122 122 } 123 123 124 124 /* Tokenize the input string */ 125 125 retval = tok_init(&tok, stext, tokens, WORD_MAX); … … 127 127 goto error; 128 128 } 129 129 130 130 retval = tok_tokenize(&tok, &tokens_length); 131 131 if (retval != EOK) { 132 132 goto error; 133 133 } 134 134 135 135 /* Find the current token */ 136 136 for (current_token = 0; current_token < (ssize_t) tokens_length; … … 138 138 token_t *t = &tokens[current_token]; 139 139 size_t end = t->char_start + t->char_length; 140 140 141 141 /* 142 142 * Check if the caret lies inside the token or immediately … … 147 147 } 148 148 } 149 149 150 150 if (tokens_length == 0) 151 151 current_token = -1; 152 152 153 153 if ((current_token >= 0) && (tokens[current_token].type != TOKTYPE_SPACE)) 154 154 *cstart = tokens[current_token].char_start; 155 155 else 156 156 *cstart = pos; 157 157 158 158 /* 159 159 * Extract the prefix being completed … … 183 183 if ((prev_token >= 0) && (tokens[prev_token].type == TOKTYPE_SPACE)) 184 184 prev_token--; 185 185 186 186 /* 187 187 * It is a command if it is the first token or if it immediately … … 236 236 237 237 cs->prefix_len = str_length(cs->prefix); 238 238 239 239 tok_fini(&tok); 240 240 … … 244 244 error: 245 245 /* Error cleanup */ 246 246 247 247 tok_fini(&tok); 248 248 … … 258 258 if ((cs != NULL) && (cs->prefix != NULL)) 259 259 free(cs->prefix); 260 260 261 261 if (dirname != NULL) 262 262 free(dirname); 263 263 264 264 if (prefix != NULL) 265 265 free(prefix); 266 266 267 267 if (stext != NULL) 268 268 free(stext); 269 269 270 270 if (cs != NULL) 271 271 free(cs); 272 272 273 273 if (tokens != NULL) 274 274 free(tokens);
Note:
See TracChangeset
for help on using the changeset viewer.