aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c93
1 files changed, 44 insertions, 49 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 370584b095..863e44ed9c 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -28,6 +28,7 @@
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/fold.h"
+#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/hashtab.h"
#include "nvim/iconv.h"
@@ -2106,6 +2107,7 @@ void set_forced_fenc(exarg_T *eap)
* When *pp is not set to NULL, the result is in allocated memory.
*/
static char_u *next_fenc(char_u **pp)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
{
char_u *p;
char_u *r;
@@ -2125,10 +2127,6 @@ static char_u *next_fenc(char_u **pp)
free(r);
r = p;
}
- if (r == NULL) { /* out of memory */
- r = (char_u *)"";
- *pp = NULL;
- }
return r;
}
@@ -4923,54 +4921,51 @@ buf_check_timestamp (
if (mesg != NULL) {
path = home_replace_save(buf, buf->b_fname);
- if (path != NULL) {
- if (!helpmesg)
- mesg2 = "";
- tbuf = xmalloc(STRLEN(path) + STRLEN(mesg) + STRLEN(mesg2) + 2);
- sprintf((char *)tbuf, mesg, path);
- /* Set warningmsg here, before the unimportant and output-specific
- * mesg2 has been appended. */
- set_vim_var_string(VV_WARNINGMSG, tbuf, -1);
- if (can_reload) {
- if (*mesg2 != NUL) {
- STRCAT(tbuf, "\n");
- STRCAT(tbuf, mesg2);
- }
- if (do_dialog(VIM_WARNING, (char_u *)_("Warning"), tbuf,
- (char_u *)_("&OK\n&Load File"), 1, NULL, TRUE) == 2)
- reload = TRUE;
- } else if (State > NORMAL_BUSY || (State & CMDLINE) ||
- already_warned) {
- if (*mesg2 != NUL) {
- STRCAT(tbuf, "; ");
- STRCAT(tbuf, mesg2);
- }
- EMSG(tbuf);
- retval = 2;
- } else {
- if (!autocmd_busy) {
- msg_start();
- msg_puts_attr(tbuf, hl_attr(HLF_E) + MSG_HIST);
- if (*mesg2 != NUL)
- msg_puts_attr((char_u *)mesg2,
- hl_attr(HLF_W) + MSG_HIST);
- msg_clr_eos();
- (void)msg_end();
- if (emsg_silent == 0) {
- out_flush();
- /* give the user some time to think about it */
- os_delay(1000L, true);
-
- /* don't redraw and erase the message */
- redraw_cmdline = FALSE;
- }
- }
- already_warned = TRUE;
+ if (!helpmesg)
+ mesg2 = "";
+ tbuf = xmalloc(STRLEN(path) + STRLEN(mesg) + STRLEN(mesg2) + 2);
+ sprintf((char *)tbuf, mesg, path);
+ /* Set warningmsg here, before the unimportant and output-specific
+ * mesg2 has been appended. */
+ set_vim_var_string(VV_WARNINGMSG, tbuf, -1);
+ if (can_reload) {
+ if (*mesg2 != NUL) {
+ STRCAT(tbuf, "\n");
+ STRCAT(tbuf, mesg2);
+ }
+ if (do_dialog(VIM_WARNING, (char_u *)_("Warning"), tbuf,
+ (char_u *)_("&OK\n&Load File"), 1, NULL, TRUE) == 2)
+ reload = TRUE;
+ } else if (State > NORMAL_BUSY || (State & CMDLINE) || already_warned) {
+ if (*mesg2 != NUL) {
+ STRCAT(tbuf, "; ");
+ STRCAT(tbuf, mesg2);
}
+ EMSG(tbuf);
+ retval = 2;
+ } else {
+ if (!autocmd_busy) {
+ msg_start();
+ msg_puts_attr(tbuf, hl_attr(HLF_E) + MSG_HIST);
+ if (*mesg2 != NUL)
+ msg_puts_attr((char_u *)mesg2,
+ hl_attr(HLF_W) + MSG_HIST);
+ msg_clr_eos();
+ (void)msg_end();
+ if (emsg_silent == 0) {
+ out_flush();
+ /* give the user some time to think about it */
+ os_delay(1000L, true);
- free(path);
- free(tbuf);
+ /* don't redraw and erase the message */
+ redraw_cmdline = FALSE;
+ }
+ }
+ already_warned = TRUE;
}
+
+ free(path);
+ free(tbuf);
}
if (reload) {