Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/edit/edit.c

    rb67c7d64 r1352fc1  
    102102#define ED_INFTY 65536
    103103
    104 /** Maximum filename length that can be entered. */
    105 #define INFNAME_MAX_LEN 128
    106 
    107104static void key_handle_unmod(console_event_t const *ev);
    108105static void key_handle_ctrl(console_event_t const *ev);
     
    334331}
    335332
     333#define INPUT_MAX_LEN 64
     334
    336335/** Ask for a file name. */
    337336static char *filename_prompt(char const *prompt, char const *init_value)
     
    339338        console_event_t ev;
    340339        char *str;
    341         wchar_t buffer[INFNAME_MAX_LEN + 1];
    342         int max_len;
     340        wchar_t buffer[INPUT_MAX_LEN + 1];
    343341        int nc;
    344342        bool done;
     
    351349        console_set_color(con, COLOR_WHITE, COLOR_BLACK, 0);
    352350
    353         max_len = min(INFNAME_MAX_LEN, scr_columns - 4 - str_length(prompt));
    354         str_to_wstr(buffer, max_len + 1, init_value);
     351        str_to_wstr(buffer, INPUT_MAX_LEN + 1, init_value);
    355352        nc = wstr_length(buffer);
    356353        done = false;
     
    379376                                        break;
    380377                                default:
    381                                         if (ev.c >= 32 && nc < max_len) {
     378                                        if (ev.c >= 32 && nc < INPUT_MAX_LEN) {
    382379                                                putchar(ev.c);
    383380                                                fflush(stdout);
     
    391388
    392389        buffer[nc] = '\0';
    393         str = wstr_to_astr(buffer);
     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);
    394396
    395397        console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0);
Note: See TracChangeset for help on using the changeset viewer.