On Sun, May 27, 2018 at 11:31 AM, Dominique Pellé
<[email protected]> wrote:
> Sergey Alyoshin <[email protected]> wrote:
>
>> On Sat, May 26, 2018 at 7:01 PM, Ken Takata <[email protected]>
> wrote:
>> > Hi,
>> >
>> > In ex_docmd.c:
>> >
>> >  #endif
>> > -           if (n == 1)
>> > -               EMSG(_("E173: 1 more file to edit"));
>> > -           else
>> > -               EMSGN(_("E173: %ld more files to edit"), n);
>> > +           EMSGN(NGETTEXT("E173: %d more file to edit",
>> > +                       "E173: %d more files to edit", n), n);
>> >             quitmore = 2;           /* next try to quit is allowed */
>> >         }
>> >         return FAIL;
>> >
>> > Why you changed "%ld" to "%d" here?
>> > Is it just a mistake or intentional?
>> >
>
>> It is intentional, n is int and in upper before&now n usage it is also
> "%d":
>
> EMSGN(...) calls emsgn(char_u *s, long n) which prints a 'long'
> so the format in the message should definitely be "%ld":
>
> vim.h:
> 1620 #define EMSGN(s, n)            emsgn((char_u *)(s), (long)(n))
>
> message.c:
>   742 /*
>   743  * Print an error message with one "%ld" and one long int argument.
>   744  * This is not in message.c to avoid a warning for prototypes.
>   745  */
>   746     int
>   747 emsgn(char_u *s, long n)
>   748 {
>   749     if (emsg_not_now())
>   750         return TRUE;            /* no error messages at the moment */
>   751     vim_snprintf((char *)IObuff, IOSIZE, (char *)s, n);
>   752     return emsg(IObuff);
>   753 }

Right. Updated patch with "%ld" is attached.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
From 33ff08e081cc659fb51197a4f33eba9163f56e39 Mon Sep 17 00:00:00 2001
From: Sergey Alyoshin <[email protected]>
Date: Fri, 25 May 2018 21:43:55 +0300
Subject: [PATCH] Using ngettext() for plural form

---
 src/buffer.c   | 26 ++++++++---------------
 src/ex_cmds.c  | 30 ++++++++++----------------
 src/ex_docmd.c | 16 +++++---------
 src/fileio.c   | 13 ++++--------
 src/misc1.c    | 22 +++++---------------
 src/ops.c      | 66 +++++++++++++++++++---------------------------------------
 6 files changed, 55 insertions(+), 118 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index e3cbdac1e..f16d86f9b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1176,24 +1176,18 @@ do_bufdel(
 	{
 	    if (command == DOBUF_UNLOAD)
 	    {
-		if (deleted == 1)
-		    MSG(_("1 buffer unloaded"));
-		else
-		    smsg((char_u *)_("%d buffers unloaded"), deleted);
+		smsg((char_u *)NGETTEXT("%d buffer unloaded",
+			    "%d buffers unloaded", deleted), deleted);
 	    }
 	    else if (command == DOBUF_DEL)
 	    {
-		if (deleted == 1)
-		    MSG(_("1 buffer deleted"));
-		else
-		    smsg((char_u *)_("%d buffers deleted"), deleted);
+		smsg((char_u *)NGETTEXT("%d buffer deleted",
+			    "%d buffers deleted", deleted), deleted);
 	    }
 	    else
 	    {
-		if (deleted == 1)
-		    MSG(_("1 buffer wiped out"));
-		else
-		    smsg((char_u *)_("%d buffers wiped out"), deleted);
+		smsg((char_u *)NGETTEXT("%d buffer wiped out",
+			    "%d buffers wiped out", deleted), deleted);
 	    }
 	}
     }
@@ -3480,11 +3474,9 @@ fileinfo(
     else if (p_ru)
     {
 	/* Current line and column are already on the screen -- webb */
-	if (curbuf->b_ml.ml_line_count == 1)
-	    vim_snprintf_add((char *)buffer, IOSIZE, _("1 line --%d%%--"), n);
-	else
-	    vim_snprintf_add((char *)buffer, IOSIZE, _("%ld lines --%d%%--"),
-					 (long)curbuf->b_ml.ml_line_count, n);
+	vim_snprintf_add((char *)buffer, IOSIZE,
+		NGETTEXT("%ld line --%d%%--", "%ld lines --%d%%--",
+		    curbuf->b_ml.ml_line_count), curbuf->b_ml.ml_line_count, n);
     }
 #endif
     else
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 111fe01d2..f2005f339 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -903,12 +903,8 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
 	ml_delete(line1 + extra, TRUE);
 
     if (!global_busy && num_lines > p_report)
-    {
-	if (num_lines == 1)
-	    MSG(_("1 line moved"));
-	else
-	    smsg((char_u *)_("%ld lines moved"), num_lines);
-    }
+	smsg((char_u *)NGETTEXT("%ld line moved", "%ld lines moved", num_lines),
+			num_lines);
 
     /*
      * Leave the cursor on the last of the moved lines.
@@ -5854,19 +5850,15 @@ do_sub_msg(
 	    STRCPY(msg_buf, _("(Interrupted) "));
 	else
 	    *msg_buf = NUL;
-	if (sub_nsubs == 1)
-	    vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
-		    "%s", count_only ? _("1 match") : _("1 substitution"));
-	else
-	    vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
-		    count_only ? _("%ld matches") : _("%ld substitutions"),
-								   sub_nsubs);
-	if (sub_nlines == 1)
-	    vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
-		    "%s", _(" on 1 line"));
-	else
-	    vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
-		    _(" on %ld lines"), (long)sub_nlines);
+
+	vim_snprintf_add((char *)msg_buf, sizeof(msg_buf), count_only ?
+		NGETTEXT("%ld match", "%ld matches", sub_nsubs) :
+		NGETTEXT("%ld substitution", "%ld substitutions", sub_nsubs),
+		sub_nsubs);
+	vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
+		NGETTEXT(" on %ld line", " on %ld lines", sub_nlines),
+		(long)sub_nlines);
+
 	if (msg(msg_buf))
 	    /* save message to display it after redraw */
 	    set_keep_msg(msg_buf, 0);
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 82dd0491d..28b940b4e 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -5675,22 +5675,16 @@ check_more(
 	    {
 		char_u	buff[DIALOG_MSG_SIZE];
 
-		if (n == 1)
-		    vim_strncpy(buff,
-			    (char_u *)_("1 more file to edit.  Quit anyway?"),
-							 DIALOG_MSG_SIZE - 1);
-		else
-		    vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
-			      _("%d more files to edit.  Quit anyway?"), n);
+		vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
+			NGETTEXT("%d more file to edit.  Quit anyway?",
+			    "%d more files to edit.  Quit anyway?", n), n);
 		if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES)
 		    return OK;
 		return FAIL;
 	    }
 #endif
-	    if (n == 1)
-		EMSG(_("E173: 1 more file to edit"));
-	    else
-		EMSGN(_("E173: %ld more files to edit"), n);
+	    EMSGN(NGETTEXT("E173: %ld more file to edit",
+			"E173: %ld more files to edit", n), n);
 	    quitmore = 2;	    /* next try to quit is allowed */
 	}
 	return FAIL;
diff --git a/src/fileio.c b/src/fileio.c
index d34605ca7..5f7f3e64f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5335,16 +5335,11 @@ msg_add_lines(
 		"%ldL, %lldC", lnum, (long long)nchars);
     else
     {
-	if (lnum == 1)
-	    STRCPY(p, _("1 line, "));
-	else
-	    sprintf((char *)p, _("%ld lines, "), lnum);
+	sprintf((char *)p, NGETTEXT("%ld line, ", "%ld lines, ", lnum), lnum);
 	p += STRLEN(p);
-	if (nchars == 1)
-	    STRCPY(p, _("1 character"));
-	else
-	    vim_snprintf((char *)p, IOSIZE - (p - IObuff),
-		    _("%lld characters"), (long long)nchars);
+	vim_snprintf((char *)p, IOSIZE - (p - IObuff),
+		NGETTEXT("%lld character", "%lld characters", nchars),
+		(long long)nchars);
     }
 }
 
diff --git a/src/misc1.c b/src/misc1.c
index 76f50258a..88ae1404b 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -3643,24 +3643,12 @@ msgmore(long n)
 
     if (pn > p_report)
     {
-	if (pn == 1)
-	{
-	    if (n > 0)
-		vim_strncpy(msg_buf, (char_u *)_("1 more line"),
-							     MSG_BUF_LEN - 1);
-	    else
-		vim_strncpy(msg_buf, (char_u *)_("1 line less"),
-							     MSG_BUF_LEN - 1);
-	}
+	if (n > 0)
+	    vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
+		    NGETTEXT("%ld more line", "%ld more lines", pn), pn);
 	else
-	{
-	    if (n > 0)
-		vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
-						     _("%ld more lines"), pn);
-	    else
-		vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
-						    _("%ld fewer lines"), pn);
-	}
+	    vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
+		    NGETTEXT("%ld line less", "%ld fewer lines", pn), pn);
 	if (got_int)
 	    vim_strcat(msg_buf, (char_u *)_(" (Interrupted)"), MSG_BUF_LEN);
 	if (msg(msg_buf))
diff --git a/src/ops.c b/src/ops.c
index 9af466b3f..b6621b522 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -231,7 +231,6 @@ 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),
@@ -285,25 +284,13 @@ op_shift(oparg_T *oap, int curs_top, int amount)
     if (oap->line_count > p_report)
     {
 	if (oap->op_type == OP_RSHIFT)
-	    s = (char_u *)">";
+	    sprintf((char *)IObuff, NGETTEXT("%ld line >ed ", "%ld lines >ed ",
+			oap->line_count), oap->line_count);
 	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, _("%ld lines %sed 1 time"),
-							  oap->line_count, s);
-	    else
-		sprintf((char *)IObuff, _("%ld lines %sed %d times"),
-						  oap->line_count, s, amount);
-	}
+	    sprintf((char *)IObuff, NGETTEXT("%ld line <ed ", "%ld lines <ed ",
+			oap->line_count), oap->line_count);
+	sprintf((char *)IObuff + STRLEN(IObuff), NGETTEXT("%d time",
+		    "%d times", amount), amount);
 	msg(IObuff);
     }
 
@@ -768,10 +755,8 @@ op_reindent(oparg_T *oap, int (*how)(void))
     if (oap->line_count > p_report)
     {
 	i = oap->line_count - (i + 1);
-	if (i == 1)
-	    MSG(_("1 line indented "));
-	else
-	    smsg((char_u *)_("%ld lines indented "), i);
+	smsg((char_u *)NGETTEXT("%ld line indented ",
+		    "%ld lines indented ", i), i);
     }
     /* set '[ and '] marks */
     curbuf->b_op_start = oap->start;
@@ -2489,12 +2474,8 @@ 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((char_u *)_("%ld lines changed"), oap->line_count);
-    }
+	smsg((char_u *)NGETTEXT("%ld line changed", "%ld lines changed",
+		    oap->line_count), oap->line_count);
 }
 
 /*
@@ -3308,19 +3289,18 @@ op_yank(oparg_T *oap, int deleting, int mess)
 
 	    /* redisplay now, so message is not deleted */
 	    update_topline_redraw();
-	    if (yanklines == 1)
+	    if (oap->block_mode)
 	    {
-		if (oap->block_mode)
-		    smsg((char_u *)_("block of 1 line yanked%s"), namebuf);
-		else
-		    smsg((char_u *)_("1 line yanked%s"), namebuf);
+		smsg((char_u *)NGETTEXT("block of %ld line yanked%s",
+			    "block of %ld lines yanked%s", yanklines),
+			yanklines, namebuf);
 	    }
-	    else if (oap->block_mode)
-		smsg((char_u *)_("block of %ld lines yanked%s"),
-		     yanklines, namebuf);
 	    else
-		smsg((char_u *)_("%ld lines yanked%s"), yanklines,
-		     namebuf);
+	    {
+		smsg((char_u *)NGETTEXT("%ld line yanked%s",
+			    "%ld lines yanked%s", yanklines),
+			yanklines, namebuf);
+	    }
 	}
     }
 
@@ -5603,12 +5583,8 @@ op_addsub(
 	    curbuf->b_op_start = startpos;
 
 	if (change_cnt > p_report)
-	{
-	    if (change_cnt == 1)
-		MSG(_("1 line changed"));
-	    else
-		smsg((char_u *)_("%ld lines changed"), change_cnt);
-	}
+	    smsg((char_u *)NGETTEXT("%ld line changed", "%ld lines changed",
+			change_cnt), change_cnt);
     }
 }
 
-- 
2.14.2

Raspunde prin e-mail lui