Skip to content

Commit

Permalink
patch 8.2.3960: error messages are spread out
Browse files Browse the repository at this point in the history
Problem:    Error messages are spread out.
Solution:   Move more errors to errors.h.
  • Loading branch information
brammool committed Dec 31, 2021
1 parent 6d05701 commit f1474d8
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/alloc.c
Expand Up @@ -224,7 +224,7 @@ lalloc(size_t size, int message)
{
// Don't hide this message
emsg_silent = 0;
iemsg(_("E341: Internal error: lalloc(0, )"));
iemsg(_(e_internal_error_lalloc_zero));
return NULL;
}

Expand Down Expand Up @@ -339,7 +339,7 @@ do_outofmem_msg(size_t size)
// message fails, e.g. when setting v:errmsg.
did_outofmem_msg = TRUE;

semsg(_("E342: Out of memory! (allocating %lu bytes)"), (long_u)size);
semsg(_(e_out_of_memory_allocating_nr_bytes), (long_u)size);

if (starting == NO_SCREEN)
// Not even finished with initializations and already out of
Expand Down
4 changes: 2 additions & 2 deletions src/arglist.c
Expand Up @@ -839,7 +839,7 @@ ex_argdelete(exarg_T *eap)
{
if (curwin->w_arg_idx >= ARGCOUNT)
{
emsg(_("E610: No argument to delete"));
emsg(_(e_no_argument_to_delete));
return;
}
eap->line1 = eap->line2 = curwin->w_arg_idx + 1;
Expand Down Expand Up @@ -1129,7 +1129,7 @@ do_arg_all(
else if (wpnext->w_frame->fr_parent
!= curwin->w_frame->fr_parent)
{
emsg(_("E249: window layout changed unexpectedly"));
emsg(_(e_window_layout_changed_unexpectedly));
i = count;
break;
}
Expand Down
7 changes: 3 additions & 4 deletions src/autocmd.c
Expand Up @@ -515,9 +515,9 @@ au_del_group(char_u *name)

i = au_find_group(name);
if (i == AUGROUP_ERROR) // the group doesn't exist
semsg(_("E367: No such group: \"%s\""), name);
semsg(_(e_no_such_group_str), name);
else if (i == current_augroup)
emsg(_("E936: Cannot delete the current group"));
emsg(_(e_cannot_delete_current_group));
else
{
event_T event;
Expand Down Expand Up @@ -1205,8 +1205,7 @@ do_autocmd_event(
if (is_buflocal && (buflocal_nr == 0
|| buflist_findnr(buflocal_nr) == NULL))
{
semsg(_("E680: <buffer=%d>: invalid buffer number "),
buflocal_nr);
semsg(_(e_buffer_nr_invalid_buffer_number), buflocal_nr);
return FAIL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/blob.c
Expand Up @@ -399,7 +399,7 @@ blob_set_range(blob_T *dest, long n1, long n2, typval_T *src)

if (n2 - n1 + 1 != blob_len(src->vval.v_blob))
{
emsg(_("E972: Blob value does not have the right number of bytes"));
emsg(_(e_blob_value_does_not_have_right_number_of_bytes));
return FAIL;
}

Expand Down
10 changes: 5 additions & 5 deletions src/blowfish.c
Expand Up @@ -416,7 +416,7 @@ bf_key_init(
keylen = (int)STRLEN(key) / 2;
if (keylen == 0)
{
iemsg(_("E831: bf_key_init() called with empty password"));
iemsg(_(e_bf_key_init_called_with_empty_password));
return;
}
for (i = 0; i < keylen; i++)
Expand Down Expand Up @@ -519,7 +519,7 @@ bf_self_test(void)
// warning.
if (ui != 0xffffffffUL || ui + 1 != 0) {
err++;
emsg(_("E820: sizeof(uint32_t) != 4"));
emsg(_(e_sizeof_uint32_isnot_four));
}

if (!bf_check_tables(pax_init, sbx_init, 0x6ffa520a))
Expand All @@ -540,7 +540,7 @@ bf_self_test(void)
if (memcmp(bk.uc, bf_test_data[i].cryptxt, 8) != 0)
{
if (err == 0 && memcmp(bk.uc, bf_test_data[i].badcryptxt, 8) == 0)
emsg(_("E817: Blowfish big/little endian use wrong"));
emsg(_(e_blowfish_big_little_endian_use_wrong));
err++;
}
}
Expand Down Expand Up @@ -672,12 +672,12 @@ blowfish_self_test(void)
{
if (sha256_self_test() == FAIL)
{
emsg(_("E818: sha256 test failed"));
emsg(_(e_sha256_test_failed));
return FAIL;
}
if (bf_self_test() == FAIL)
{
emsg(_("E819: Blowfish test failed"));
emsg(_(e_blowfish_test_failed));
return FAIL;
}
return OK;
Expand Down
20 changes: 9 additions & 11 deletions src/buffer.c
Expand Up @@ -63,7 +63,6 @@ static void clear_wininfo(buf_T *buf);
static char *msg_loclist = N_("[Location List]");
static char *msg_qflist = N_("[Quickfix List]");
#endif
static char *e_auabort = N_("E855: Autocommands caused command to abort");

// Number of times free_buffer() was called.
static int buf_free_count = 0;
Expand Down Expand Up @@ -427,7 +426,7 @@ buf_hashtab_add(buf_T *buf)
{
sprintf((char *)buf->b_key, "%x", buf->b_fnum);
if (hash_add(&buf_hashtab, buf->b_key) == FAIL)
emsg(_("E931: Buffer cannot be registered"));
emsg(_(e_buffer_cannot_be_registered));
}

static void
Expand Down Expand Up @@ -461,8 +460,7 @@ can_unload_buffer(buf_T *buf)
}
}
if (!can_unload)
semsg(_("E937: Attempt to delete a buffer that is in use: %s"),
buf->b_fname);
semsg(_(e_attempt_to_delete_buffer_that_is_in_use_str), buf->b_fname);
return can_unload;
}

Expand Down Expand Up @@ -594,7 +592,7 @@ close_buffer(
{
// Autocommands deleted the buffer.
aucmd_abort:
emsg(_(e_auabort));
emsg(_(e_autocommands_caused_command_to_abort));
return FALSE;
}
--buf->b_locked;
Expand Down Expand Up @@ -1660,11 +1658,11 @@ do_bufdel(
if (deleted == 0)
{
if (command == DOBUF_UNLOAD)
STRCPY(IObuff, _("E515: No buffers were unloaded"));
STRCPY(IObuff, _(e_no_buffers_were_unloaded));
else if (command == DOBUF_DEL)
STRCPY(IObuff, _("E516: No buffers were deleted"));
STRCPY(IObuff, _(e_no_buffers_were_deleted));
else
STRCPY(IObuff, _("E517: No buffers were wiped out"));
STRCPY(IObuff, _(e_no_buffers_were_wiped_out));
errormsg = (char *)IObuff;
}
else if (deleted >= p_report)
Expand Down Expand Up @@ -1905,7 +1903,7 @@ no_write_message(void)
{
#ifdef FEAT_TERMINAL
if (term_job_running(curbuf->b_term))
emsg(_("E948: Job still running (add ! to end the job)"));
emsg(_(e_job_still_running_add_bang_to_end_the_job));
else
#endif
emsg(_(e_no_write_since_last_change_add_bang_to_override));
Expand All @@ -1916,7 +1914,7 @@ no_write_message_nobang(buf_T *buf UNUSED)
{
#ifdef FEAT_TERMINAL
if (term_job_running(buf->b_term))
emsg(_("E948: Job still running"));
emsg(_(e_job_still_running));
else
#endif
emsg(_(e_no_write_since_last_change));
Expand Down Expand Up @@ -5661,7 +5659,7 @@ bt_dontwrite_msg(buf_T *buf)
{
if (bt_dontwrite(buf))
{
emsg(_("E382: Cannot write, 'buftype' option is set"));
emsg(_(e_cannot_write_buftype_option_is_set));
return TRUE;
}
return FALSE;
Expand Down
43 changes: 21 additions & 22 deletions src/bufwrite.c
Expand Up @@ -667,7 +667,6 @@ buf_write(
int prev_got_int = got_int;
int checking_conversion;
int file_readonly = FALSE; // overwritten file is read-only
static char *err_readonly = "is read-only (cannot override: \"W\" in 'cpoptions')";
#if defined(UNIX) // XXX fix me sometime?
int made_writable = FALSE; // 'w' bit has been set
#endif
Expand Down Expand Up @@ -897,7 +896,7 @@ buf_write(
--no_wait_return;
msg_scroll = msg_save;
if (nofile_err)
emsg(_("E676: No matching autocommands for acwrite buffer"));
emsg(_(e_no_matching_autocommands_for_acwrite_buffer));

if (nofile_err
#ifdef FEAT_EVAL
Expand Down Expand Up @@ -995,15 +994,15 @@ buf_write(
else
{
errnum = (char_u *)"E656: ";
errmsg = (char_u *)_("NetBeans disallows writes of unmodified buffers");
errmsg = (char_u *)_(e_netbeans_disallows_writes_of_unmodified_buffers);
buffer = NULL;
goto fail;
}
}
else
{
errnum = (char_u *)"E657: ";
errmsg = (char_u *)_("Partial writes disallowed for NetBeans buffers");
errmsg = (char_u *)_(e_partial_writes_disallowed_for_netbeans_buffers);
buffer = NULL;
goto fail;
}
Expand Down Expand Up @@ -1050,13 +1049,13 @@ buf_write(
if (S_ISDIR(st_old.st_mode))
{
errnum = (char_u *)"E502: ";
errmsg = (char_u *)_("is a directory");
errmsg = (char_u *)_(e_is_a_directory);
goto fail;
}
if (mch_nodetype(fname) != NODE_WRITABLE)
{
errnum = (char_u *)"E503: ";
errmsg = (char_u *)_("is not a file or writable device");
errmsg = (char_u *)_(e_is_not_file_or_writable_device);
goto fail;
}
// It's a device of some kind (or a fifo) which we can write to
Expand All @@ -1072,7 +1071,7 @@ buf_write(
if (c == NODE_OTHER)
{
errnum = (char_u *)"E503: ";
errmsg = (char_u *)_("is not a file or writable device");
errmsg = (char_u *)_(e_is_not_file_or_writable_device);
goto fail;
}
if (c == NODE_WRITABLE)
Expand All @@ -1083,7 +1082,7 @@ buf_write(
if (!p_odev)
{
errnum = (char_u *)"E796: ";
errmsg = (char_u *)_("writing to device disabled with 'opendevice' option");
errmsg = (char_u *)_(e_writing_to_device_disabled_with_opendevice_option);
goto fail;
}
# endif
Expand All @@ -1099,7 +1098,7 @@ buf_write(
else if (mch_isdir(fname))
{
errnum = (char_u *)"E502: ";
errmsg = (char_u *)_("is a directory");
errmsg = (char_u *)_(e_is_a_directory);
goto fail;
}
if (overwriting)
Expand All @@ -1118,12 +1117,12 @@ buf_write(
if (vim_strchr(p_cpo, CPO_FWRITE) != NULL)
{
errnum = (char_u *)"E504: ";
errmsg = (char_u *)_(err_readonly);
errmsg = (char_u *)_(e_is_read_only_cannot_override_W_in_cpoptions);
}
else
{
errnum = (char_u *)"E505: ";
errmsg = (char_u *)_("is read-only (add ! to override)");
errmsg = (char_u *)_(e_is_read_only_add_bang_to_override);
}
goto fail;
}
Expand Down Expand Up @@ -1477,7 +1476,7 @@ buf_write(
{
if (buf_write_bytes(&write_info) == FAIL)
{
errmsg = (char_u *)_("E506: Can't write to backup file (add ! to override)");
errmsg = (char_u *)_(e_canot_write_to_backup_file_add_bang_to_override);
break;
}
ui_breakcheck();
Expand All @@ -1489,9 +1488,9 @@ buf_write(
}

if (close(bfd) < 0 && errmsg == NULL)
errmsg = (char_u *)_("E507: Close error for backup file (add ! to override)");
errmsg = (char_u *)_(e_close_error_for_backup_file_add_bang_to_write_anyway);
if (write_info.bw_len < 0)
errmsg = (char_u *)_("E508: Can't read file for backup (add ! to override)");
errmsg = (char_u *)_(e_cant_read_file_for_backup_add_bang_to_write_anyway);
#ifdef UNIX
set_file_time(backup, st_old.st_atime, st_old.st_mtime);
#endif
Expand All @@ -1513,7 +1512,7 @@ buf_write(
vim_free(copybuf);

if (backup == NULL && errmsg == NULL)
errmsg = (char_u *)_("E509: Cannot create backup file (add ! to override)");
errmsg = (char_u *)_(e_cannot_create_backup_file_add_bang_to_write_anyway);
// ignore errors when forceit is TRUE
if ((some_error || errmsg != NULL) && !forceit)
{
Expand All @@ -1536,7 +1535,7 @@ buf_write(
if (file_readonly && vim_strchr(p_cpo, CPO_FWRITE) != NULL)
{
errnum = (char_u *)"E504: ";
errmsg = (char_u *)_(err_readonly);
errmsg = (char_u *)_(e_is_read_only_cannot_override_W_in_cpoptions);
goto fail;
}

Expand Down Expand Up @@ -1608,7 +1607,7 @@ buf_write(
}
if (backup == NULL && !forceit)
{
errmsg = (char_u *)_("E510: Can't make backup file (add ! to override)");
errmsg = (char_u *)_(e_cant_make_backup_file_add_bang_to_write_anyway);
goto fail;
}
}
Expand Down Expand Up @@ -1903,7 +1902,7 @@ buf_write(
&& st.st_ino != st_old.st_ino)
{
close(fd);
errmsg = (char_u *)_("E949: File changed while writing");
errmsg = (char_u *)_(e_file_changed_while_writing);
goto fail;
}
}
Expand Down Expand Up @@ -2229,7 +2228,7 @@ buf_write(
#endif
if (close(fd) != 0)
{
errmsg = (char_u *)_("E512: Close failed");
errmsg = (char_u *)_(e_close_failed);
end = 0;
}

Expand Down Expand Up @@ -2286,19 +2285,19 @@ buf_write(
if (write_info.bw_conv_error)
{
if (write_info.bw_conv_error_lnum == 0)
errmsg = (char_u *)_("E513: write error, conversion failed (make 'fenc' empty to override)");
errmsg = (char_u *)_(e_write_error_conversion_failed_make_fenc_empty_to_override);
else
{
errmsg_allocated = TRUE;
errmsg = alloc(300);
vim_snprintf((char *)errmsg, 300, _("E513: write error, conversion failed in line %ld (make 'fenc' empty to override)"),
vim_snprintf((char *)errmsg, 300, _(e_write_error_conversion_failed_in_line_nr_make_fenc_empty_to_override),
(long)write_info.bw_conv_error_lnum);
}
}
else if (got_int)
errmsg = (char_u *)_(e_interr);
else
errmsg = (char_u *)_("E514: write error (file system full?)");
errmsg = (char_u *)_(e_write_error_file_system_full);
}

// If we have a backup file, try to put it in place of the new file,
Expand Down

0 comments on commit f1474d8

Please sign in to comment.