Changes in / [e435537:9904eb90] in mainline
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
re435537 r9904eb90 202 202 * 203 203 */ 204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev)204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * indev) 205 205 { 206 206 const char *name = input; 207 207 208 208 size_t found = 0; 209 210 /* 211 * Maximum Match Length: Length of longest matching common 212 * substring in case more than one match is found. 213 */ 209 /* Maximum Match Length : Length of longest matching common substring in 210 case more than one match is found */ 214 211 size_t max_match_len = size; 215 212 size_t max_match_len_tmp = size; … … 232 229 } 233 230 234 /* 235 * If the number of possible completions is more than MAX_TAB_HINTS, 236 * ask the user whether to display them or not. 237 */ 231 /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */ 238 232 if (found > MAX_TAB_HINTS) { 239 233 printf("\n"); 240 continue_showing_hints = 241 console_prompt_display_all_hints(indev, found); 234 continue_showing_hints = console_prompt_display_all_hints(indev, found); 242 235 } 243 236 … … 247 240 while (cmdtab_search_one(name, &pos)) { 248 241 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 249 242 250 243 if (continue_showing_hints) { 251 244 printf("%s (%s)\n", hlp->name, hlp->description); 252 245 --hints_to_show; 253 246 ++total_hints_shown; 254 255 if ((hints_to_show == 0) && (total_hints_shown != found)) { 256 /* Ask user to continue */ 257 continue_showing_hints = 258 console_prompt_more_hints(indev, &hints_to_show); 247 248 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */ 249 continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show); 259 250 } 260 251 } 261 252 262 253 pos = pos->next; 263 264 for (max_match_len_tmp = 0; 265 (output[max_match_len_tmp] == 266 hlp->name[input_len + max_match_len_tmp]) && 267 (max_match_len_tmp < max_match_len); ++max_match_len_tmp); 268 254 for(max_match_len_tmp = 0; output[max_match_len_tmp] == hlp->name[input_len + max_match_len_tmp] 255 && max_match_len_tmp < max_match_len; ++max_match_len_tmp); 269 256 max_match_len = max_match_len_tmp; 270 257 } 271 272 /* Keep only the characters common in all completions */ 258 /* keep only the characters common in all completions */ 273 259 output[max_match_len] = 0; 274 260 } … … 324 310 continue; 325 311 326 /* 327 * Find the beginning of the word 328 * and copy it to tmp 329 */ 312 /* Find the beginning of the word 313 and copy it to tmp */ 330 314 size_t beg; 331 315 for (beg = position - 1; (beg > 0) && (!isspace(current[beg])); … … 349 333 continue; 350 334 351 /* 352 * We have hints, possibly many. In case of more than one hint, 353 * tmp will contain the common prefix. 354 */ 335 /* We have hints, may be many. In case of more than one hint, 336 tmp will contain the common prefix. */ 355 337 size_t off = 0; 356 338 size_t i = 0; … … 358 340 if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE)) 359 341 break; 360 361 342 i++; 362 343 } -
kernel/generic/src/console/prompt.c
re435537 r9904eb90 43 43 * @param indev Where to read characters from. 44 44 * @param hints Number of hints that would be displayed. 45 *46 45 * @return Whether to print all hints. 47 *48 46 */ 49 47 bool console_prompt_display_all_hints(indev_t *indev, size_t hints) … … 51 49 ASSERT(indev); 52 50 ASSERT(hints > 0); 53 54 printf("Display all %zu possibilities? (y or n) 55 51 52 printf("Display all %zu possibilities? (y or n)", hints); 53 56 54 while (true) { 57 55 wchar_t answer = indev_pop_character(indev); 58 59 if ( (answer == 'y') || (answer == 'Y')) {60 printf(" y");56 57 if (answer == 'y' || answer == 'Y') { 58 printf(" y"); 61 59 return true; 62 60 } 63 64 if ( (answer == 'n') || (answer == 'N')) {65 printf(" n");61 62 if (answer == 'n' || answer == 'N') { 63 printf(" n"); 66 64 return false; 67 65 } … … 73 71 * When the function returns false, @p display_hints is set to zero. 74 72 * 75 * @param[in] indevWhere to read characters from.73 * @param[in] indev Where to read characters from. 76 74 * @param[out] display_hints How many hints to display. 77 *78 75 * @return Whether to display more hints. 79 *80 76 */ 81 77 bool console_prompt_more_hints(indev_t *indev, size_t *display_hints) … … 83 79 ASSERT(indev); 84 80 ASSERT(display_hints != NULL); 85 81 86 82 printf("--More--"); 87 83 while (true) { 88 84 wchar_t continue_showing_hints = indev_pop_character(indev); 89 85 /* Display a full page again? */ 90 if ( (continue_showing_hints == 'y') ||91 (continue_showing_hints == 'Y') ||92 (continue_showing_hints == ' ')) {86 if (continue_showing_hints == 'y' 87 || continue_showing_hints == 'Y' 88 || continue_showing_hints == ' ') { 93 89 *display_hints = MAX_TAB_HINTS - 1; 94 90 break; 95 91 } 96 92 97 93 /* Stop displaying hints? */ 98 if ( (continue_showing_hints == 'n') ||99 (continue_showing_hints == 'N') ||100 (continue_showing_hints == 'q') ||101 (continue_showing_hints == 'Q')) {94 if (continue_showing_hints == 'n' 95 || continue_showing_hints == 'N' 96 || continue_showing_hints == 'q' 97 || continue_showing_hints == 'Q') { 102 98 *display_hints = 0; 103 99 break; 104 100 } 105 101 106 102 /* Show one more hint? */ 107 103 if (continue_showing_hints == '\n') { … … 110 106 } 111 107 } 112 108 113 109 /* Delete the --More-- option */ 114 110 printf("\r \r"); 115 111 116 112 return *display_hints > 0; 117 113 } -
kernel/generic/src/debug/symtab.c
re435537 r9904eb90 210 210 * 211 211 */ 212 int symtab_compl(char *input, size_t size, indev_t * indev)212 int symtab_compl(char *input, size_t size, indev_t * indev) 213 213 { 214 214 #ifdef CONFIG_SYMTAB … … 227 227 const char *hint; 228 228 char output[MAX_SYMBOL_NAME]; 229 230 /* 231 * Maximum Match Length: Length of longest matching common substring in 232 * case more than one match is found. 233 */ 229 /* Maximum Match Length : Length of longest matching common substring in 230 case more than one match is found */ 234 231 size_t max_match_len = size; 235 232 size_t max_match_len_tmp = size; … … 241 238 242 239 output[0] = 0; 243 244 while ((hint = symtab_search_one(name, &pos))) 245 pos++; 246 240 241 while ((hint = symtab_search_one(name, &pos))) { 242 ++pos; 243 } 244 247 245 pos = 0; 248 246 … … 255 253 } 256 254 257 /* 258 * If the number of possible completions is more than MAX_TAB_HINTS, 259 * ask the user whether to display them or not. 260 */ 255 /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */ 261 256 if (found > MAX_TAB_HINTS) { 262 257 printf("\n"); 263 continue_showing_hints = 264 console_prompt_display_all_hints(indev, found); 258 continue_showing_hints = console_prompt_display_all_hints(indev, found); 265 259 } 266 260 … … 271 265 sym_name = symbol_table[pos].symbol_name; 272 266 pos++; 273 274 if (continue_showing_hints) { 275 /* We are still showing hints */ 267 268 if (continue_showing_hints) { /* We are still showing hints */ 276 269 printf("%s\n", sym_name); 277 270 --hints_to_show; 278 271 ++total_hints_shown; 279 280 if ((hints_to_show == 0) && (total_hints_shown != found)) { 281 /* Ask the user to continue */ 282 continue_showing_hints = 283 console_prompt_more_hints(indev, &hints_to_show); 272 273 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */ 274 continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show); 284 275 } 285 276 } 286 287 for (max_match_len_tmp = 0; 288 (output[max_match_len_tmp] == 289 sym_name[input_len + max_match_len_tmp]) && 290 (max_match_len_tmp < max_match_len); ++max_match_len_tmp); 291 277 278 for(max_match_len_tmp = 0; output[max_match_len_tmp] == sym_name[input_len + max_match_len_tmp] 279 && max_match_len_tmp < max_match_len; ++max_match_len_tmp); 292 280 max_match_len = max_match_len_tmp; 293 281 } 294 295 /* Keep only the characters common in all completions */ 282 /* keep only the characters common in all completions */ 296 283 output[max_match_len] = 0; 297 284 } -
uspace/app/bdsh/cmds/modules/cat/cat.c
re435537 r9904eb90 176 176 177 177 bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0); 178 178 179 179 if (reading_stdin) { 180 180 fd = fileno(stdin); 181 181 /* Allow storing the whole UTF-8 character. */ 182 182 blen = STR_BOUNDS(1); 183 } else 183 } else { 184 184 fd = open(fname, O_RDONLY); 185 185 } 186 186 if (fd < 0) { 187 187 printf("Unable to open %s\n", fname); … … 222 222 bytes_to_read = 1; 223 223 } else { 224 if ((length != CAT_FULL_FILE) &&225 (length - (off64_t)count <= (off64_t)(blen - copied_bytes))) {224 if ((length != CAT_FULL_FILE) 225 && (length - (off64_t)count <= (off64_t)(blen - copied_bytes))) { 226 226 bytes_to_read = (size_t) (length - count); 227 227 } else { … … 229 229 } 230 230 } 231 232 231 bytes = read(fd, buff + copied_bytes, bytes_to_read); 233 232 bytes += copied_bytes; … … 262 261 reads++; 263 262 } 264 265 if (reading_stdin) 263 264 if (reading_stdin) { 266 265 fflush(stdout); 266 } 267 267 } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE)); 268 268 -
uspace/srv/hid/console/console.c
re435537 r9904eb90 617 617 618 618 size_t pos = 0; 619 619 620 620 /* 621 621 * Read input from keyboard and copy it to the buffer. … … 628 628 buf[pos] = cons->char_remains[0]; 629 629 pos++; 630 631 630 /* Unshift the array. */ 632 for (size_t i = 1; i < cons->char_remains_len; i++) 631 for (size_t i = 1; i < cons->char_remains_len; i++) { 633 632 cons->char_remains[i - 1] = cons->char_remains[i]; 634 633 } 635 634 cons->char_remains_len--; 636 635 } 637 638 636 /* Still not enough? Then get another key from the queue. */ 639 637 if (pos < size) { 640 638 link_t *link = prodcons_consume(&cons->input_pc); 641 639 kbd_event_t *event = list_get_instance(link, kbd_event_t, link); 642 640 643 641 /* Accept key presses of printable chars only. */ 644 642 if ((event->type == KEY_PRESS) && (event->c != 0)) { … … 647 645 cons->char_remains_len = str_size(cons->char_remains); 648 646 } 649 647 650 648 free(event); 651 649 }
Note:
See TracChangeset
for help on using the changeset viewer.