Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/compl.c

    r28a5ebd r587867a  
    3535#include <vfs/vfs.h>
    3636#include <str.h>
    37 #include <adt/odict.h>
    38 
    39 #include "scli.h"
     37
    4038#include "cmds/cmds.h"
    4139#include "compl.h"
     
    4442#include "util.h"
    4543
    46 static errno_t compl_init(char32_t *text, size_t pos, size_t *cstart, void **state);
     44static errno_t compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state);
    4745static errno_t compl_get_next(void *state, char **compl);
    4846static void compl_fini(void *state);
     
    6664        size_t prefix_len;
    6765
    68         /* Pointer to the current alias */
    69         odlink_t *alias_link;
    70 
    7166        /** Pointer inside list of modules */
    7267        module_t *module;
     
    9489 * Set up iterators in completion object, based on current token.
    9590 */
    96 static errno_t compl_init(char32_t *text, size_t pos, size_t *cstart, void **state)
     91static errno_t compl_init(wchar_t *text, size_t pos, size_t *cstart, void **state)
    9792{
    9893        compl_t *cs = NULL;
     
    248243        } else if (cs->is_command) {
    249244                /* Command without path */
    250                 cs->alias_link = odict_first(&alias_dict);
    251245                cs->module = modules;
    252246                cs->builtin = builtins;
     
    327321        }
    328322
    329         /* Alias */
    330         if (cs->alias_link != NULL) {
    331                 while (*compl == NULL && cs->alias_link != NULL) {
    332                         alias_t *data = odict_get_instance(cs->alias_link, alias_t, odict);
    333                         if (compl_match_prefix(cs, data->name)) {
    334                                 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);
    335328                                cs->last_compl = *compl;
    336329                                if (*compl == NULL)
    337330                                        return ENOMEM;
    338                         }
    339                         cs->alias_link = odict_next(cs->alias_link, &alias_dict);
    340                 }
    341         }
    342 
    343         /* Modules */
    344         if (cs->module != NULL) {
    345                 while (*compl == NULL && cs->module->name != NULL) {
    346                         /* prevents multiple listing of an overriden cmd */
    347                         if (compl_match_prefix(cs, cs->module->name)) {
    348                                 odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)cs->module->name, NULL);
    349                                 if (alias_link == NULL) {
    350                                         asprintf(compl, "%s ", cs->module->name);
    351                                         cs->last_compl = *compl;
    352                                         if (*compl == NULL)
    353                                                 return ENOMEM;
    354                                 }
    355331                        }
    356332                        cs->module++;
     
    362338                while (*compl == NULL && cs->builtin->name != NULL) {
    363339                        if (compl_match_prefix(cs, cs->builtin->name)) {
    364                                 /* prevents multiple listing of an overriden cmd */
    365                                 odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)cs->module->name, NULL);
    366                                 if (alias_link == NULL) {
    367                                         asprintf(compl, "%s ", cs->builtin->name);
    368                                         cs->last_compl = *compl;
    369                                         if (*compl == NULL)
    370                                                 return ENOMEM;
    371                                 }
     340                                asprintf(compl, "%s ", cs->builtin->name);
     341                                cs->last_compl = *compl;
     342                                if (*compl == NULL)
     343                                        return ENOMEM;
    372344                        }
    373345                        cs->builtin++;
     
    417389                                free(ent_path);
    418390
    419                                 /* prevents multiple listing of an overriden cmd */
    420                                 if (cs->is_command && !ent_stat.is_directory) {
    421                                         odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)dent->d_name, NULL);
    422                                         if (alias_link != NULL) {
    423                                                 continue;
    424                                         }
    425                                 }
    426 
    427391                                asprintf(compl, "%s%c", dent->d_name,
    428392                                    ent_stat.is_directory ? '/' : ' ');
Note: See TracChangeset for help on using the changeset viewer.