Changes in uspace/app/bdsh/compl.c [ac2caecb:587867a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/compl.c
rac2caecb r587867a 35 35 #include <vfs/vfs.h> 36 36 #include <str.h> 37 #include <adt/odict.h> 38 39 #include "scli.h" 37 40 38 #include "cmds/cmds.h" 41 39 #include "compl.h" 42 40 #include "exec.h" 43 41 #include "tok.h" 42 #include "util.h" 44 43 45 44 static errno_t compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state); … … 64 63 /** Length of string prefix (number of characters) */ 65 64 size_t prefix_len; 66 67 /* Pointer to the current alias */68 odlink_t *alias_link;69 65 70 66 /** Pointer inside list of modules */ … … 214 210 } 215 211 *cstart += rpath_sep + 1 - prefix; 216 free(prefix);217 prefix = NULL;218 212 219 213 cs->path_list = malloc(sizeof(char *) * 2); … … 222 216 goto error; 223 217 } 224 cs->path_list[0] = dirname; 218 219 if (!is_path(prefix) && cs->is_command) { 220 cs->path_list[0] = malloc(sizeof(char) * PATH_MAX); 221 if (cs->path_list[0] == NULL) { 222 retval = ENOMEM; 223 goto error; 224 } 225 226 int ret = snprintf(cs->path_list[0], PATH_MAX, "%s/%s", search_dir[0], dirname); 227 if (ret < 0 || ret >= PATH_MAX) { 228 retval = ENOMEM; 229 goto error; 230 } 231 } else { 232 cs->path_list[0] = dirname; 233 } 234 235 free(prefix); 225 236 cs->path_list[1] = NULL; 226 237 /* … … 232 243 } else if (cs->is_command) { 233 244 /* Command without path */ 234 cs->alias_link = odict_first(&alias_dict);235 245 cs->module = modules; 236 246 cs->builtin = builtins; … … 311 321 } 312 322 313 /* Alias */ 314 if (cs->alias_link != NULL) { 315 while (*compl == NULL && cs->alias_link != NULL) { 316 alias_t *data = odict_get_instance(cs->alias_link, alias_t, odict); 317 if (compl_match_prefix(cs, data->name)) { 318 asprintf(compl, "%s ", data->name); 323 /* Modules */ 324 if (cs->module != NULL) { 325 while (*compl == NULL && cs->module->name != NULL) { 326 if (compl_match_prefix(cs, cs->module->name)) { 327 asprintf(compl, "%s ", cs->module->name); 319 328 cs->last_compl = *compl; 320 329 if (*compl == NULL) 321 330 return ENOMEM; 322 }323 cs->alias_link = odict_next(cs->alias_link, &alias_dict);324 }325 }326 327 /* Modules */328 if (cs->module != NULL) {329 while (*compl == NULL && cs->module->name != NULL) {330 /* prevents multiple listing of an overriden cmd */331 if (compl_match_prefix(cs, cs->module->name)) {332 odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)cs->module->name, NULL);333 if (alias_link == NULL) {334 asprintf(compl, "%s ", cs->module->name);335 cs->last_compl = *compl;336 if (*compl == NULL)337 return ENOMEM;338 }339 331 } 340 332 cs->module++; … … 346 338 while (*compl == NULL && cs->builtin->name != NULL) { 347 339 if (compl_match_prefix(cs, cs->builtin->name)) { 348 /* prevents multiple listing of an overriden cmd */ 349 odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)cs->module->name, NULL); 350 if (alias_link == NULL) { 351 asprintf(compl, "%s ", cs->builtin->name); 352 cs->last_compl = *compl; 353 if (*compl == NULL) 354 return ENOMEM; 355 } 340 asprintf(compl, "%s ", cs->builtin->name); 341 cs->last_compl = *compl; 342 if (*compl == NULL) 343 return ENOMEM; 356 344 } 357 345 cs->builtin++; … … 401 389 free(ent_path); 402 390 403 /* prevents multiple listing of an overriden cmd */404 if (cs->is_command && !ent_stat.is_directory) {405 odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)dent->d_name, NULL);406 if (alias_link != NULL) {407 continue;408 }409 }410 411 391 asprintf(compl, "%s%c", dent->d_name, 412 392 ent_stat.is_directory ? '/' : ' ');
Note:
See TracChangeset
for help on using the changeset viewer.