# HG changeset patch # User Bram Moolenaar # Date 1640981702 -3600 # Node ID 6ee19c6ae8a2bb05a431aafe95fec5cee20da751 # Parent e91b94a101d1a32263a60a232141e64d724a85f8 patch 8.2.3960: error messages are spread out Commit: https://github.com/vim/vim/commit/f1474d801bbdb73406dd3d1f931f515f99e86dfa Author: Bram Moolenaar Date: Fri Dec 31 19:59:55 2021 +0000 patch 8.2.3960: error messages are spread out Problem: Error messages are spread out. Solution: Move more errors to errors.h. diff --git a/src/alloc.c b/src/alloc.c --- a/src/alloc.c +++ b/src/alloc.c @@ -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; } @@ -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 diff --git a/src/arglist.c b/src/arglist.c --- a/src/arglist.c +++ b/src/arglist.c @@ -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; @@ -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; } diff --git a/src/autocmd.c b/src/autocmd.c --- a/src/autocmd.c +++ b/src/autocmd.c @@ -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; @@ -1205,8 +1205,7 @@ do_autocmd_event( if (is_buflocal && (buflocal_nr == 0 || buflist_findnr(buflocal_nr) == NULL)) { - semsg(_("E680: : invalid buffer number "), - buflocal_nr); + semsg(_(e_buffer_nr_invalid_buffer_number), buflocal_nr); return FAIL; } diff --git a/src/blob.c b/src/blob.c --- a/src/blob.c +++ b/src/blob.c @@ -399,7 +399,7 @@ blob_set_range(blob_T *dest, long n1, lo 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; } diff --git a/src/blowfish.c b/src/blowfish.c --- a/src/blowfish.c +++ b/src/blowfish.c @@ -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++) @@ -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)) @@ -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++; } } @@ -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; diff --git a/src/buffer.c b/src/buffer.c --- a/src/buffer.c +++ b/src/buffer.c @@ -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; @@ -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 @@ -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; } @@ -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; @@ -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) @@ -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)); @@ -1916,7 +1914,7 @@ no_write_message_nobang(buf_T *buf UNUSE { #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)); @@ -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; diff --git a/src/bufwrite.c b/src/bufwrite.c --- a/src/bufwrite.c +++ b/src/bufwrite.c @@ -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 @@ -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 @@ -995,7 +994,7 @@ 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; } @@ -1003,7 +1002,7 @@ buf_write( 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; } @@ -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 @@ -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) @@ -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 @@ -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) @@ -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; } @@ -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(); @@ -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 @@ -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) { @@ -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; } @@ -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; } } @@ -1903,7 +1902,7 @@ restore_backup: && 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; } } @@ -2229,7 +2228,7 @@ restore_backup: #endif if (close(fd) != 0) { - errmsg = (char_u *)_("E512: Close failed"); + errmsg = (char_u *)_(e_close_failed); end = 0; } @@ -2286,19 +2285,19 @@ restore_backup: 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, diff --git a/src/errors.h b/src/errors.h --- a/src/errors.h +++ b/src/errors.h @@ -495,10 +495,22 @@ EXTERN char e_cannot_start_the_GUI[] INIT(= N_("E229: Cannot start the GUI")); +EXTERN char e_window_layout_changed_unexpectedly[] + INIT(= N_("E249: window layout changed unexpectedly")); #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) EXTERN char e_cannot_allocate_color_str[] INIT(= N_("E254: Cannot allocate color %s")); #endif + +EXTERN char e_internal_error_lalloc_zero[] + INIT(= N_("E341: Internal error: lalloc(0, )")); +EXTERN char e_out_of_memory_allocating_nr_bytes[] + INIT(= N_("E342: Out of memory! (allocating %lu bytes)")); +EXTERN char e_no_such_group_str[] + INIT(= N_("E367: No such group: \"%s\"")); +EXTERN char e_cannot_write_buftype_option_is_set[] + INIT(= N_("E382: Cannot write, 'buftype' option is set")); + EXTERN char e_ambiguous_use_of_user_defined_command[] INIT(= N_("E464: Ambiguous use of user-defined command")); EXTERN char e_invalid_command[] @@ -506,8 +518,62 @@ EXTERN char e_invalid_command[] #ifdef FEAT_EVAL EXTERN char e_invalid_command_str[] INIT(= N_("E476: Invalid command: %s")); + + // E502 +EXTERN char e_is_a_directory[] + INIT(= N_("is a directory")); + // E503 +EXTERN char e_is_not_file_or_writable_device[] + INIT(= N_("is not a file or writable device")); + + // E504 +EXTERN char e_is_read_only_cannot_override_W_in_cpoptions[] + INIT(= N_("is read-only (cannot override: \"W\" in 'cpoptions')")); + // E505 +EXTERN char e_is_read_only_add_bang_to_override[] + INIT(= N_("is read-only (add ! to override)")); +EXTERN char e_canot_write_to_backup_file_add_bang_to_override[] + INIT(= N_("E506: Can't write to backup file (add ! to override)")); +EXTERN char e_close_error_for_backup_file_add_bang_to_write_anyway[] + INIT(= N_("E507: Close error for backup file (add ! to write anyway)")); +EXTERN char e_cant_read_file_for_backup_add_bang_to_write_anyway[] + INIT(= N_("E508: Can't read file for backup (add ! to write anyway)")); +EXTERN char e_cannot_create_backup_file_add_bang_to_write_anyway[] + INIT(= N_("E509: Cannot create backup file (add ! to override)")); +EXTERN char e_cant_make_backup_file_add_bang_to_write_anyway[] + INIT(= N_("E510: Can't make backup file (add ! to write anyway)")); +EXTERN char e_close_failed[] + INIT(= N_("E512: Close failed")); +EXTERN char e_write_error_conversion_failed_make_fenc_empty_to_override[] + INIT(= N_("E513: write error, conversion failed (make 'fenc' empty to override)")); +EXTERN char e_write_error_conversion_failed_in_line_nr_make_fenc_empty_to_override[] + INIT(= N_("E513: write error, conversion failed in line %ld (make 'fenc' empty to override)")); +EXTERN char e_write_error_file_system_full[] + INIT(= N_("E514: write error (file system full?)")); +EXTERN char e_no_buffers_were_unloaded[] + INIT(= N_("E515: No buffers were unloaded")); +EXTERN char e_no_buffers_were_deleted[] + INIT(= N_("E516: No buffers were deleted")); +EXTERN char e_no_buffers_were_wiped_out[] + INIT(= N_("E517: No buffers were wiped out")); + +EXTERN char e_no_argument_to_delete[] + INIT(= N_("E610: No argument to delete")); +#ifdef FEAT_NETBEANS_INTG + // E656 +EXTERN char e_netbeans_disallows_writes_of_unmodified_buffers[] + INIT(= N_("NetBeans disallows writes of unmodified buffers")); + // E657 +EXTERN char e_partial_writes_disallowed_for_netbeans_buffers[] + INIT(= N_("Partial writes disallowed for NetBeans buffers")); +#endif +EXTERN char e_no_matching_autocommands_for_acwrite_buffer[] + INIT(= N_("E676: No matching autocommands for acwrite buffer")); +EXTERN char e_buffer_nr_invalid_buffer_number[] + INIT(= N_("E680: : invalid buffer number")); EXTERN char e_cannot_index_a_funcref[] INIT(= N_("E695: Cannot index a Funcref")); + EXTERN char e_list_value_has_more_items_than_targets[] INIT(= N_("E710: List value has more items than targets")); EXTERN char e_list_value_does_not_have_enough_items[] @@ -528,25 +594,59 @@ EXTERN char e_cannot_set_variable_in_san INIT(= N_("E794: Cannot set variable in the sandbox: \"%s\"")); EXTERN char e_cannot_delete_variable[] INIT(= N_("E795: Cannot delete variable")); + // E796 +EXTERN char e_writing_to_device_disabled_with_opendevice_option[] + INIT(= N_("writing to device disabled with 'opendevice' option")); EXTERN char e_cannot_delete_variable_str[] INIT(= N_("E795: Cannot delete variable %s")); #endif + +EXTERN char e_blowfish_big_little_endian_use_wrong[] + INIT(= N_("E817: Blowfish big/little endian use wrong")); +EXTERN char e_sha256_test_failed[] + INIT(= N_("E818: sha256 test failed")); +EXTERN char e_blowfish_test_failed[] + INIT(= N_("E819: Blowfish test failed")); +EXTERN char e_sizeof_uint32_isnot_four[] + INIT(= N_("E820: sizeof(uint32_t) != 4")); +EXTERN char e_bf_key_init_called_with_empty_password[] + INIT(= N_("E831: bf_key_init() called with empty password")); EXTERN char e_conflicts_with_value_of_listchars[] INIT(= N_("E834: Conflicts with value of 'listchars'")); EXTERN char e_conflicts_with_value_of_fillchars[] INIT(= N_("E835: Conflicts with value of 'fillchars'")); +EXTERN char e_autocommands_caused_command_to_abort[] + INIT(= N_("E855: Autocommands caused command to abort")); #ifdef FEAT_EVAL EXTERN char e_assert_fails_second_arg[] INIT(= N_("E856: \"assert_fails()\" second argument must be a string or a list with one or two strings")); + EXTERN char e_using_invalid_value_as_string_str[] INIT(= N_("E908: using an invalid value as a String: %s")); EXTERN char e_cannot_index_special_variable[] INIT(= N_("E909: Cannot index a special variable")); #endif +EXTERN char e_buffer_cannot_be_registered[] + INIT(= N_("E931: Buffer cannot be registered")); +EXTERN char e_cannot_delete_current_group[] + INIT(= N_("E936: Cannot delete the current group")); +EXTERN char e_attempt_to_delete_buffer_that_is_in_use_str[] + INIT(= N_("E937: Attempt to delete a buffer that is in use: %s")); +#ifdef FEAT_TERMINAL +EXTERN char e_job_still_running[] + INIT(= N_("E948: Job still running")); +EXTERN char e_job_still_running_add_bang_to_end_the_job[] + INIT(= N_("E948: Job still running (add ! to end the job)")); +EXTERN char e_file_changed_while_writing[] + INIT(= N_("E949: File changed while writing")); +#endif EXTERN char_u e_invalid_column_number_nr[] INIT(= N_("E964: Invalid column number: %ld")); EXTERN char_u e_invalid_line_number_nr[] INIT(= N_("E966: Invalid line number: %ld")); +EXTERN char e_blob_value_does_not_have_right_number_of_bytes[] + INIT(= N_("E972: Blob value does not have the right number of bytes")); + EXTERN char e_command_not_supported_in_vim9_script_missing_var_str[] INIT(= N_("E1100: Command not supported in Vim9 script (missing :var?): %s")); #ifdef FEAT_EVAL diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3960, +/**/ 3959, /**/ 3958,