--- ./main_loop.c 2019/04/15 15:00:20 1.1 +++ ./main_loop.c 2019/04/15 15:03:52 @@ -29,7 +29,8 @@ static char def_filename[1024] = ""; /* default filename */ static char errmsg[80] = ""; /* error message buffer */ -static char prompt_str[80] = "*"; /* command prompt */ +static char default_prompt_str[2] = "*"; /* default command prompt */ +static char * prompt_str = default_prompt_str; /* command prompt */ static int first_addr = 0, second_addr = 0; static bool prompt_on = false; /* if set, show command prompt */ static bool verbose = false; /* if set, print all error messages */ @@ -50,9 +51,16 @@ void set_prompt( const char * const s ) { + size_t new_len; + char * new_prompt; prompt_on = true; - strncpy( prompt_str, s, sizeof prompt_str ); - prompt_str[sizeof(prompt_str)-1] = 0; + new_len = strlen(s) + 1; + if ((new_prompt = malloc(new_len))) + if (strcpy(new_prompt, s)) + { + if (prompt_str != default_prompt_str) free(prompt_str); + prompt_str = new_prompt; + } } void set_verbose( void ) { verbose = true; }