From 684640f5518a483cf2bc48efc8f68449379cef69 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 23 Oct 2021 15:10:28 -0400 Subject: vim-patch:8.1.0306: plural messages are not translated properly Problem: Plural messages are not translated properly. Solution: Add more usage of NGETTEXT(). (Sergey Alyoshin) https://github.com/vim/vim/commit/da6e8919e75fa8f961d1b805e877c8a92e76dafb --- src/nvim/ops.c | 68 ++++++++++++++++++++++------------------------------------ 1 file changed, 26 insertions(+), 42 deletions(-) (limited to 'src/nvim/ops.c') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 36a5e1e7e8..d995a2b75b 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -210,7 +210,6 @@ void op_shift(oparg_T *oap, int curs_top, int amount) { long i; int first_char; - char_u *s; int block_col = 0; if (u_save((linenr_T)(oap->start.lnum - 1), @@ -249,26 +248,20 @@ void op_shift(oparg_T *oap, int curs_top, int amount) foldOpenCursor(); if (oap->line_count > p_report) { + char *op; if (oap->op_type == OP_RSHIFT) { - s = (char_u *)">"; + op = ">"; } else { - s = (char_u *)"<"; - } - if (oap->line_count == 1) { - if (amount == 1) { - sprintf((char *)IObuff, _("1 line %sed 1 time"), s); - } else { - sprintf((char *)IObuff, _("1 line %sed %d times"), s, amount); - } - } else { - if (amount == 1) { - sprintf((char *)IObuff, _("%" PRId64 " lines %sed 1 time"), - (int64_t)oap->line_count, s); - } else { - sprintf((char *)IObuff, _("%" PRId64 " lines %sed %d times"), - (int64_t)oap->line_count, s, amount); - } + op = "<"; } + + char *msg_line_single = NGETTEXT("%" PRId64 " line %sed %d time", + "%" PRId64 " line %sed %d times", amount); + char *msg_line_plural = NGETTEXT("%" PRId64 " lines %sed %d time", + "%" PRId64 " lines %sed %d times", amount); + vim_snprintf((char *)IObuff, IOSIZE, + NGETTEXT(msg_line_single, msg_line_plural, oap->line_count), + (int64_t)oap->line_count, op, amount); msg_attr_keep(IObuff, 0, true, false); } @@ -695,11 +688,9 @@ void op_reindent(oparg_T *oap, Indenter how) if (oap->line_count > p_report) { i = oap->line_count - (i + 1); - if (i == 1) { - MSG(_("1 line indented ")); - } else { - smsg(_("%" PRId64 " lines indented "), (int64_t)i); - } + smsg(NGETTEXT("%" PRId64 " line indented ", + "%" PRId64 " lines indented ", i), + (int64_t)i); } // set '[ and '] marks curbuf->b_op_start = oap->start; @@ -2073,11 +2064,9 @@ void op_tilde(oparg_T *oap) curbuf->b_op_end = oap->end; if (oap->line_count > p_report) { - if (oap->line_count == 1) { - MSG(_("1 line changed")); - } else { - smsg(_("%" PRId64 " lines changed"), (int64_t)oap->line_count); - } + smsg(NGETTEXT("%" PRId64 " line changed", + "%" PRId64 " lines changed", oap->line_count), + (int64_t)oap->line_count); } } @@ -2732,17 +2721,14 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) // redisplay now, so message is not deleted update_topline_redraw(); - if (yanklines == 1) { - if (yank_type == kMTBlockWise) { - smsg(_("block of 1 line yanked%s"), namebuf); - } else { - smsg(_("1 line yanked%s"), namebuf); - } - } else if (yank_type == kMTBlockWise) { - smsg(_("block of %" PRId64 " lines yanked%s"), + if (yank_type == kMTBlockWise) { + smsg(NGETTEXT("block of %" PRId64 " line yanked%s", + "block of %" PRId64 " lines yanked%s", yanklines), (int64_t)yanklines, namebuf); } else { - smsg(_("%" PRId64 " lines yanked%s"), (int64_t)yanklines, namebuf); + smsg(NGETTEXT("%" PRId64 " line yanked%s", + "%" PRId64 " lines yanked%s", yanklines), + (int64_t)yanklines, namebuf); } } } @@ -4808,11 +4794,9 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd) } if (change_cnt > p_report) { - if (change_cnt == 1) { - MSG(_("1 line changed")); - } else { - smsg(_("%" PRId64 " lines changed"), (int64_t)change_cnt); - } + smsg(NGETTEXT("%" PRId64 " lines changed", + "%" PRId64 " lines changed", change_cnt), + (int64_t)change_cnt); } } } -- cgit From efa924f66b183d9cf2404ce91c4f009c27e0515a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Oct 2021 09:08:46 -0400 Subject: vim-patch:8.1.0743: giving error messages is not flexible Problem: Giving error messages is not flexible. Solution: Add semsg(). Change argument from "char_u *" to "char *", also for msg() and get rid of most MSG macros. (Ozaki Kiichi, closes vim/vim#3302) Also make emsg() accept a "char *" argument. Get rid of an enormous number of type casts. https://github.com/vim/vim/commit/f9e3e09fdc93be9f0d47afbc6c7df1188c2a5a0d --- src/nvim/ops.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/nvim/ops.c') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index d995a2b75b..1805d62e9c 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -633,7 +633,7 @@ void op_reindent(oparg_T *oap, Indenter how) // Don't even try when 'modifiable' is off. if (!MODIFIABLE(curbuf)) { - EMSG(_(e_modifiable)); + emsg(_(e_modifiable)); return; } @@ -1009,7 +1009,7 @@ int do_execreg(int regname, int colon, int addcr, int silent) if (regname == '@') { // repeat previous one if (execreg_lastc == NUL) { - EMSG(_("E748: No previously used register")); + emsg(_("E748: No previously used register")); return FAIL; } regname = execreg_lastc; @@ -1027,7 +1027,7 @@ int do_execreg(int regname, int colon, int addcr, int silent) if (regname == ':') { // use last command line if (last_cmdline == NULL) { - EMSG(_(e_nolastcmd)); + emsg(_(e_nolastcmd)); return FAIL; } // don't keep the cmdline containing @: @@ -1057,7 +1057,7 @@ int do_execreg(int regname, int colon, int addcr, int silent) } else if (regname == '.') { // use last inserted text p = get_last_insert_save(); if (p == NULL) { - EMSG(_(e_noinstext)); + emsg(_(e_noinstext)); return FAIL; } retval = put_in_typebuf(p, false, colon, silent); @@ -1282,14 +1282,14 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg) case ':': // last command line if (last_cmdline == NULL && errmsg) { - EMSG(_(e_nolastcmd)); + emsg(_(e_nolastcmd)); } *argp = last_cmdline; return true; case '/': // last search-pattern if (last_search_pat() == NULL && errmsg) { - EMSG(_(e_noprevre)); + emsg(_(e_noprevre)); } *argp = last_search_pat(); return true; @@ -1298,7 +1298,7 @@ bool get_spec_reg(int regname, char_u **argp, bool *allocated, bool errmsg) *argp = get_last_insert_save(); *allocated = true; if (*argp == NULL && errmsg) { - EMSG(_(e_noinstext)); + emsg(_(e_noinstext)); } return true; @@ -1415,7 +1415,7 @@ int op_delete(oparg_T *oap) } if (!MODIFIABLE(curbuf)) { - EMSG(_(e_modifiable)); + emsg(_(e_modifiable)); return FAIL; } @@ -3075,7 +3075,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) } if (y_size == 0 || y_array == NULL) { - EMSG2(_("E353: Nothing in register %s"), + semsg(_("E353: Nothing in register %s"), regname == 0 ? (char_u *)"\"" : transchar(regname)); goto end; } @@ -5383,7 +5383,7 @@ void write_reg_contents_lst(int name, char_u **strings, bool must_append, Motion if (strings[0] == NULL) { s = (char_u *)""; } else if (strings[1] != NULL) { - EMSG(_("E883: search pattern and expression register may not " + emsg(_("E883: search pattern and expression register may not " "contain two or more lines")); return; } @@ -5445,7 +5445,7 @@ void write_reg_contents_ex(int name, const char_u *str, ssize_t len, bool must_a buf = buflist_findnr(num); if (buf == NULL) { - EMSGN(_(e_nobufnr), (long)num); + semsg(_(e_nobufnr), (int64_t)num); } } else { buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str), @@ -6185,7 +6185,7 @@ err: reg->additional_data = NULL; reg->timestamp = 0; if (errmsg) { - EMSG("clipboard: provider returned invalid data"); + emsg("clipboard: provider returned invalid data"); } *target = reg; return false; -- cgit From e6ff154be6da8bd53b604fb6e38686acae75b24f Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 23 Oct 2021 16:04:37 -0400 Subject: vim-patch:8.1.0779: argument for message functions is inconsistent Problem: Argument for message functions is inconsistent. Solution: Make first argument to msg() "char *". https://github.com/vim/vim/commit/32526b3c1846025f0e655f41efd4e5428da16b6c --- src/nvim/ops.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/nvim/ops.c') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 1805d62e9c..a4b554601e 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -262,7 +262,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount) vim_snprintf((char *)IObuff, IOSIZE, NGETTEXT(msg_line_single, msg_line_plural, oap->line_count), (int64_t)oap->line_count, op, amount); - msg_attr_keep(IObuff, 0, true, false); + msg_attr_keep((char *)IObuff, 0, true, false); } /* @@ -921,7 +921,7 @@ int do_record(int c) if (ui_has(kUIMessages)) { showmode(); } else { - MSG(""); + msg(""); } p = get_recorded(); if (p == NULL) { @@ -3694,12 +3694,12 @@ void ex_display(exarg_T *eap) msg_puts(" "); msg_putchar('"'); msg_putchar(name); - MSG_PUTS(" "); + msg_puts(" "); int n = Columns - 11; for (size_t j = 0; j < yb->y_size && n > 1; j++) { if (j) { - MSG_PUTS_ATTR("^J", attr); + msg_puts_attr("^J", attr); n -= 2; } for (p = yb->y_array[j]; *p && (n -= ptr2cells(p)) >= 0; p++) { // -V1019 NOLINT(whitespace/line_length) @@ -3709,7 +3709,7 @@ void ex_display(exarg_T *eap) } } if (n > 1 && yb->y_type == kMTLineWise) { - MSG_PUTS_ATTR("^J", attr); + msg_puts_attr("^J", attr); } ui_flush(); // show one line at a time } @@ -5687,7 +5687,7 @@ void cursor_pos_info(dict_T *dict) // Compute the length of the file in characters. if (curbuf->b_ml.ml_flags & ML_EMPTY) { if (dict == NULL) { - MSG(_(no_lines_msg)); + msg(_(no_lines_msg)); return; } } else { @@ -5885,7 +5885,7 @@ void cursor_pos_info(dict_T *dict) // Don't shorten this message, the user asked for it. p = p_shm; p_shm = (char_u *)""; - msg(IObuff); + msg((char *)IObuff); p_shm = p; } } @@ -5947,7 +5947,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) clipboard_didwarn = true; // Do NOT error (emsg()) here--if it interrupts :redir we get into // a weird state, stuck in "redirect mode". - msg((char_u *)MSG_NO_CLIP); + msg(MSG_NO_CLIP); } // ... else, be silent (don't flood during :while, :redir, etc.). goto end; -- cgit