Changeset e866806 in mainline for uspace/app/edit/edit.c
- Timestamp:
- 2009-11-30T20:07:07Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4a2aa91b, 8b5001b
- Parents:
- 1df977c (diff), b67c7d64 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
r1df977c re866806 102 102 #define ED_INFTY 65536 103 103 104 /** Maximum filename length that can be entered. */ 105 #define INFNAME_MAX_LEN 128 106 104 107 static void key_handle_unmod(console_event_t const *ev); 105 108 static void key_handle_ctrl(console_event_t const *ev); … … 331 334 } 332 335 333 #define INPUT_MAX_LEN 64334 335 336 /** Ask for a file name. */ 336 337 static char *filename_prompt(char const *prompt, char const *init_value) … … 338 339 console_event_t ev; 339 340 char *str; 340 wchar_t buffer[INPUT_MAX_LEN + 1]; 341 wchar_t buffer[INFNAME_MAX_LEN + 1]; 342 int max_len; 341 343 int nc; 342 344 bool done; … … 349 351 console_set_color(con, COLOR_WHITE, COLOR_BLACK, 0); 350 352 351 str_to_wstr(buffer, INPUT_MAX_LEN + 1, init_value); 353 max_len = min(INFNAME_MAX_LEN, scr_columns - 4 - str_length(prompt)); 354 str_to_wstr(buffer, max_len + 1, init_value); 352 355 nc = wstr_length(buffer); 353 356 done = false; … … 376 379 break; 377 380 default: 378 if (ev.c >= 32 && nc < INPUT_MAX_LEN) {381 if (ev.c >= 32 && nc < max_len) { 379 382 putchar(ev.c); 380 383 fflush(stdout); … … 388 391 389 392 buffer[nc] = '\0'; 390 391 str = malloc(STR_BOUNDS(wstr_length(buffer)) + 1); 392 if (str == NULL) 393 return NULL; 394 395 wstr_nstr(str, buffer, STR_BOUNDS(wstr_length(buffer)) + 1); 393 str = wstr_to_astr(buffer); 396 394 397 395 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0);
Note:
See TracChangeset
for help on using the changeset viewer.