Changeset ac2caecb in mainline for uspace/app/bdsh/compl.c
- Timestamp:
- 2018-12-15T20:29:21Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7f7817a9
- Parents:
- 3301452
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/compl.c
r3301452 rac2caecb 35 35 #include <vfs/vfs.h> 36 36 #include <str.h> 37 37 #include <adt/odict.h> 38 39 #include "scli.h" 38 40 #include "cmds/cmds.h" 39 41 #include "compl.h" … … 62 64 /** Length of string prefix (number of characters) */ 63 65 size_t prefix_len; 66 67 /* Pointer to the current alias */ 68 odlink_t *alias_link; 64 69 65 70 /** Pointer inside list of modules */ … … 227 232 } else if (cs->is_command) { 228 233 /* Command without path */ 234 cs->alias_link = odict_first(&alias_dict); 229 235 cs->module = modules; 230 236 cs->builtin = builtins; … … 305 311 } 306 312 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); 319 cs->last_compl = *compl; 320 if (*compl == NULL) 321 return ENOMEM; 322 } 323 cs->alias_link = odict_next(cs->alias_link, &alias_dict); 324 } 325 } 326 307 327 /* Modules */ 308 328 if (cs->module != NULL) { 309 329 while (*compl == NULL && cs->module->name != NULL) { 330 /* prevents multiple listing of an overriden cmd */ 310 331 if (compl_match_prefix(cs, cs->module->name)) { 311 asprintf(compl, "%s ", cs->module->name); 312 cs->last_compl = *compl; 313 if (*compl == NULL) 314 return ENOMEM; 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 } 315 339 } 316 340 cs->module++; … … 322 346 while (*compl == NULL && cs->builtin->name != NULL) { 323 347 if (compl_match_prefix(cs, cs->builtin->name)) { 324 asprintf(compl, "%s ", cs->builtin->name); 325 cs->last_compl = *compl; 326 if (*compl == NULL) 327 return ENOMEM; 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 } 328 356 } 329 357 cs->builtin++; … … 373 401 free(ent_path); 374 402 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 375 411 asprintf(compl, "%s%c", dent->d_name, 376 412 ent_stat.is_directory ? '/' : ' ');
Note:
See TracChangeset
for help on using the changeset viewer.