Skip to content

Commit b3281dd

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents a1fea82 + ee695f7 commit b3281dd

File tree

7 files changed

+43
-11
lines changed

7 files changed

+43
-11
lines changed

src/evalfunc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3448,6 +3448,7 @@ f_foldtext(typval_T *argvars UNUSED, typval_T *rettv)
34483448
char_u *r;
34493449
int len;
34503450
char *txt;
3451+
long count;
34513452
#endif
34523453

34533454
rettv->v_type = VAR_STRING;
@@ -3478,14 +3479,15 @@ f_foldtext(typval_T *argvars UNUSED, typval_T *rettv)
34783479
s = skipwhite(s + 1);
34793480
}
34803481
}
3481-
txt = _("+-%s%3ld lines: ");
3482+
count = (long)(foldend - foldstart + 1);
3483+
txt = ngettext("+-%s%3ld line: ", "+-%s%3ld lines: ", count);
34823484
r = alloc((unsigned)(STRLEN(txt)
34833485
+ STRLEN(dashes) /* for %s */
34843486
+ 20 /* for %3ld */
34853487
+ STRLEN(s))); /* concatenated */
34863488
if (r != NULL)
34873489
{
3488-
sprintf((char *)r, txt, dashes, (long)(foldend - foldstart + 1));
3490+
sprintf((char *)r, txt, dashes, count);
34893491
len = (int)STRLEN(r);
34903492
STRCAT(r, s);
34913493
/* remove 'foldmarker' and 'commentstring' */
@@ -3505,7 +3507,7 @@ f_foldtextresult(typval_T *argvars UNUSED, typval_T *rettv)
35053507
#ifdef FEAT_FOLDING
35063508
linenr_T lnum;
35073509
char_u *text;
3508-
char_u buf[51];
3510+
char_u buf[FOLD_TEXT_LEN];
35093511
foldinfo_T foldinfo;
35103512
int fold_count;
35113513
#endif
@@ -3520,8 +3522,7 @@ f_foldtextresult(typval_T *argvars UNUSED, typval_T *rettv)
35203522
fold_count = foldedCount(curwin, lnum, &foldinfo);
35213523
if (fold_count > 0)
35223524
{
3523-
text = get_foldtext(curwin, lnum, lnum + fold_count - 1,
3524-
&foldinfo, buf);
3525+
text = get_foldtext(curwin, lnum, lnum + fold_count - 1, &foldinfo, buf);
35253526
if (text == buf)
35263527
text = vim_strsave(text);
35273528
rettv->vval.v_string = text;

src/fold.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,8 +1853,8 @@ foldDelMarker(linenr_T lnum, char_u *marker, int markerlen)
18531853
/* get_foldtext() {{{2 */
18541854
/*
18551855
* Return the text for a closed fold at line "lnum", with last line "lnume".
1856-
* When 'foldtext' isn't set puts the result in "buf[51]". Otherwise the
1857-
* result is in allocated memory.
1856+
* When 'foldtext' isn't set puts the result in "buf[FOLD_TEXT_LEN]".
1857+
* Otherwise the result is in allocated memory.
18581858
*/
18591859
char_u *
18601860
get_foldtext(
@@ -1960,8 +1960,12 @@ get_foldtext(
19601960
if (text == NULL)
19611961
#endif
19621962
{
1963-
sprintf((char *)buf, _("+--%3ld lines folded "),
1964-
(long)(lnume - lnum + 1));
1963+
long count = (long)(lnume - lnum + 1);
1964+
1965+
vim_snprintf((char *)buf, FOLD_TEXT_LEN,
1966+
ngettext("+--%3ld line folded ",
1967+
"+--%3ld lines folded ", count),
1968+
count);
19651969
text = buf;
19661970
}
19671971
return text;

src/os_win32.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,15 @@ vimLoadLib(char *name)
472472
# endif
473473
/* Dummy functions */
474474
static char *null_libintl_gettext(const char *);
475+
static char *null_libintl_ngettext(const char *, const char *, unsigned long n);
475476
static char *null_libintl_textdomain(const char *);
476477
static char *null_libintl_bindtextdomain(const char *, const char *);
477478
static char *null_libintl_bind_textdomain_codeset(const char *, const char *);
478479

479480
static HINSTANCE hLibintlDLL = NULL;
480481
char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext;
482+
char *(*dyn_libintl_ngettext)(const char *, const char *, unsigned long n)
483+
= null_libintl_ngettext;
481484
char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain;
482485
char *(*dyn_libintl_bindtextdomain)(const char *, const char *)
483486
= null_libintl_bindtextdomain;
@@ -495,6 +498,7 @@ dyn_libintl_init(void)
495498
} libintl_entry[] =
496499
{
497500
{"gettext", (FARPROC*)&dyn_libintl_gettext},
501+
{"ngettext", (FARPROC*)&dyn_libintl_ngettext},
498502
{"textdomain", (FARPROC*)&dyn_libintl_textdomain},
499503
{"bindtextdomain", (FARPROC*)&dyn_libintl_bindtextdomain},
500504
{NULL, NULL}
@@ -553,6 +557,7 @@ dyn_libintl_end(void)
553557
FreeLibrary(hLibintlDLL);
554558
hLibintlDLL = NULL;
555559
dyn_libintl_gettext = null_libintl_gettext;
560+
dyn_libintl_ngettext = null_libintl_ngettext;
556561
dyn_libintl_textdomain = null_libintl_textdomain;
557562
dyn_libintl_bindtextdomain = null_libintl_bindtextdomain;
558563
dyn_libintl_bind_textdomain_codeset = null_libintl_bind_textdomain_codeset;
@@ -565,6 +570,16 @@ null_libintl_gettext(const char *msgid)
565570
return (char*)msgid;
566571
}
567572

573+
/*ARGSUSED*/
574+
static char *
575+
null_libintl_ngettext(
576+
const char *msgid,
577+
const char *msgid_plural,
578+
unsigned long n)
579+
{
580+
return n == 1 ? msgid : msgid_plural;
581+
}
582+
568583
/*ARGSUSED*/
569584
static char *
570585
null_libintl_bindtextdomain(const char *domainname, const char *dirname)
@@ -4212,7 +4227,7 @@ mch_system_classic(char *cmd, int options)
42124227
* process. This way avoid to hang up vim totally if the children
42134228
* process take a long time to process the lines.
42144229
*/
4215-
static DWORD WINAPI
4230+
static unsigned int __stdcall
42164231
sub_process_writer(LPVOID param)
42174232
{
42184233
HANDLE g_hChildStd_IN_Wr = param;

src/screen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2424,7 +2424,7 @@ fold_line(
24242424
linenr_T lnum,
24252425
int row)
24262426
{
2427-
char_u buf[51];
2427+
char_u buf[FOLD_TEXT_LEN];
24282428
pos_T *top, *bot;
24292429
linenr_T lnume = lnum + fold_count - 1;
24302430
int len;

src/testdir/test_quickfix.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ endfunction
407407

408408
function Test_helpgrep()
409409
call s:test_xhelpgrep('c')
410+
helpclose
410411
call s:test_xhelpgrep('l')
411412
endfunc
412413

src/version.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,12 @@ static char *(features[]) =
778778

779779
static int included_patches[] =
780780
{ /* Add new patch number below this line */
781+
/**/
782+
2152,
783+
/**/
784+
2151,
785+
/**/
786+
2150,
781787
/**/
782788
2149,
783789
/**/

src/vim.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ typedef unsigned long u8char_T; /* long should be 32 bits or more */
563563
# endif
564564
/* These are in os_win32.c */
565565
extern char *(*dyn_libintl_gettext)(const char *msgid);
566+
extern char *(*dyn_libintl_ngettext)(const char *msgid, const char *msgid_plural, unsigned long n);
566567
extern char *(*dyn_libintl_bindtextdomain)(const char *domainname, const char *dirname);
567568
extern char *(*dyn_libintl_bind_textdomain_codeset)(const char *domainname, const char *codeset);
568569
extern char *(*dyn_libintl_textdomain)(const char *domainname);
@@ -576,6 +577,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
576577
#ifdef FEAT_GETTEXT
577578
# ifdef DYNAMIC_GETTEXT
578579
# define _(x) (*dyn_libintl_gettext)((char *)(x))
580+
# define ngettext(x, xs, n) (*dyn_libintl_ngettext)((char *)(x), (char *)(xs), (n))
579581
# define N_(x) x
580582
# define bindtextdomain(domain, dir) (*dyn_libintl_bindtextdomain)((domain), (dir))
581583
# define bind_textdomain_codeset(domain, codeset) (*dyn_libintl_bind_textdomain_codeset)((domain), (codeset))
@@ -594,6 +596,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
594596
# endif
595597
#else
596598
# define _(x) ((char *)(x))
599+
# define ngettext(x, xs, n) (((n) == 1) ? (char *)(x) : (char *)(xs))
597600
# define N_(x) x
598601
# ifdef bindtextdomain
599602
# undef bindtextdomain
@@ -1504,6 +1507,8 @@ typedef UINT32_TYPEDEF UINT32_T;
15041507
# define MSG_BUF_CLEN MSG_BUF_LEN /* cell length */
15051508
#endif
15061509

1510+
#define FOLD_TEXT_LEN 51 /* buffer size for get_foldtext() */
1511+
15071512
/* Size of the buffer used for tgetent(). Unfortunately this is largely
15081513
* undocumented, some systems use 1024. Using a buffer that is too small
15091514
* causes a buffer overrun and a crash. Use the maximum known value to stay

0 commit comments

Comments
 (0)