diff options
-rw-r--r-- | src/nvim/main.c | 18 | ||||
-rw-r--r-- | src/nvim/message.c | 10 |
2 files changed, 12 insertions, 16 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index 8114164158..efe7944fa4 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1049,11 +1049,10 @@ static void command_line_scan(mparm_T *parmp) case 's': /* "-s {scriptin}" read from script file */ if (scriptin[0] != NULL) { scripterror: - mch_errmsg(_("Attempt to open script file again: \"")); - mch_errmsg(argv[-1]); - mch_errmsg(" "); - mch_errmsg(argv[0]); - mch_errmsg("\"\n"); + vim_snprintf((char *)IObuff, IOSIZE, + _("Attempt to open script file again: \"%s %s\"\n"), + argv[-1], argv[0]); + mch_errmsg((const char *)IObuff); mch_exit(2); } int error; @@ -1065,11 +1064,10 @@ scripterror: scriptin[0] = stdin_dup; } else if ((scriptin[0] = file_open_new( &error, argv[0], kFileReadOnly|kFileNonBlocking, 0)) == NULL) { - mch_errmsg(_("Cannot open for reading: \"")); - mch_errmsg(argv[0]); - mch_errmsg("\": "); - mch_errmsg(os_strerror(error)); - mch_errmsg("\n"); + vim_snprintf((char *)IObuff, IOSIZE, + _("Cannot open for reading: \"%s\": %s\n"), + argv[0], os_strerror(error)); + mch_errmsg((const char *)IObuff); mch_exit(2); } save_typebuf(); diff --git a/src/nvim/message.c b/src/nvim/message.c index 4cd0db21e8..c970f92666 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2245,10 +2245,9 @@ static int do_more_prompt(int typed_char) * yet. When stderr can't be used, collect error messages until the GUI has * started and they can be displayed in a message box. */ -void mch_errmsg(char *str) +void mch_errmsg(const char *const str) + FUNC_ATTR_NONNULL_ALL { - int len; - #ifdef UNIX /* On Unix use stderr if it's a tty. * When not going to start the GUI also use stderr. @@ -2262,14 +2261,13 @@ void mch_errmsg(char *str) /* avoid a delay for a message that isn't there */ emsg_on_display = FALSE; - len = (int)STRLEN(str) + 1; + const size_t len = strlen(str) + 1; if (error_ga.ga_data == NULL) { ga_set_growsize(&error_ga, 80); error_ga.ga_itemsize = 1; } ga_grow(&error_ga, len); - memmove((char_u *)error_ga.ga_data + error_ga.ga_len, - (char_u *)str, len); + memmove(error_ga.ga_data + error_ga.ga_len, str, len); #ifdef UNIX /* remove CR characters, they are displayed */ { |