Changes in uspace/app/bdsh/compl.c [5935c079:f737c1d5] in mainline
- File:
-
- 1 edited
-
uspace/app/bdsh/compl.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/compl.c
r5935c079 rf737c1d5 90 90 { 91 91 compl_t *cs = NULL; 92 size_t pref_size; 92 93 char *stext = NULL; 93 94 char *prefix = NULL; 94 95 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;104 96 char *rpath_sep; 105 97 static const char *dirlist_arg[] = { ".", NULL }; 98 int retval; 106 99 tokenizer_t tok; 107 ssize_t current_token; 100 token_t tokens[WORD_MAX]; 101 int current_token; 108 102 size_t tokens_length; 109 103 110 104 cs = calloc(1, sizeof(compl_t)); 111 105 if (!cs) { … … 113 107 goto error; 114 108 } 115 109 116 110 /* Convert text buffer to string */ 117 111 stext = wstr_to_astr(text); … … 133 127 134 128 /* Find the current token */ 135 for (current_token = 0; current_token < ( ssize_t) tokens_length;129 for (current_token = 0; current_token < (int) tokens_length; 136 130 current_token++) { 137 131 token_t *t = &tokens[current_token]; 138 132 size_t end = t->char_start + t->char_length; 139 140 /* 141 * Check if the caret lies inside the token or immediately 133 /* Check if the caret lies inside the token or immediately 142 134 * after it 143 135 */ … … 146 138 } 147 139 } 148 149 if (tokens_length == 0) 150 current_token = -1; 151 152 if ((current_token >= 0) && (tokens[current_token].type != TOKTYPE_SPACE)) 140 if (tokens_length == 0) current_token = -1; 141 142 if (current_token >= 0 && tokens[current_token].type != TOKTYPE_SPACE) { 153 143 *cstart = tokens[current_token].char_start; 154 else 144 } 145 else { 155 146 *cstart = pos; 156 157 /*158 * Extract the prefix being completed147 } 148 149 /* Extract the prefix being completed 159 150 * XXX: handle strings, etc. 160 151 */ … … 179 170 180 171 /* Skip any whitespace before current token */ 181 ssize_t prev_token = current_token - 1;182 if ( (prev_token >= 0) && (tokens[prev_token].type == TOKTYPE_SPACE))172 int prev_token = current_token - 1; 173 if (prev_token >= 0 && tokens[prev_token].type == TOKTYPE_SPACE) { 183 174 prev_token--; 184 175 } 176 185 177 /* 186 178 * It is a command if it is the first token or if it immediately 187 179 * follows a pipe token. 188 180 */ 189 if ( (prev_token < 0) || (tokens[prev_token].type == TOKTYPE_SPACE))181 if (prev_token < 0 || tokens[prev_token].type == TOKTYPE_SPACE) 190 182 cs->is_command = true; 191 183 else … … 262 254 if (cs != NULL) 263 255 free(cs); 264 if (tokens != NULL)265 free(tokens);266 256 267 257 return retval;
Note:
See TracChangeset
for help on using the changeset viewer.
