diff options
-rw-r--r-- | src/evalfunc.c | 11 | ||||
-rw-r--r-- | src/fold.c | 12 | ||||
-rw-r--r-- | src/os_win32.c | 15 | ||||
-rw-r--r-- | src/screen.c | 2 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim.h | 5 |
6 files changed, 37 insertions, 10 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 68a8b1641..b6f05b14c 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3448,6 +3448,7 @@ f_foldtext(typval_T *argvars UNUSED, typval_T *rettv) char_u *r; int len; char *txt; + long count; #endif rettv->v_type = VAR_STRING; @@ -3478,14 +3479,15 @@ f_foldtext(typval_T *argvars UNUSED, typval_T *rettv) s = skipwhite(s + 1); } } - txt = _("+-%s%3ld lines: "); + count = (long)(foldend - foldstart + 1); + txt = ngettext("+-%s%3ld line: ", "+-%s%3ld lines: ", count); r = alloc((unsigned)(STRLEN(txt) + STRLEN(dashes) /* for %s */ + 20 /* for %3ld */ + STRLEN(s))); /* concatenated */ if (r != NULL) { - sprintf((char *)r, txt, dashes, (long)(foldend - foldstart + 1)); + sprintf((char *)r, txt, dashes, count); len = (int)STRLEN(r); STRCAT(r, s); /* remove 'foldmarker' and 'commentstring' */ @@ -3505,7 +3507,7 @@ f_foldtextresult(typval_T *argvars UNUSED, typval_T *rettv) #ifdef FEAT_FOLDING linenr_T lnum; char_u *text; - char_u buf[51]; + char_u buf[FOLD_TEXT_LEN]; foldinfo_T foldinfo; int fold_count; #endif @@ -3520,8 +3522,7 @@ f_foldtextresult(typval_T *argvars UNUSED, typval_T *rettv) fold_count = foldedCount(curwin, lnum, &foldinfo); if (fold_count > 0) { - text = get_foldtext(curwin, lnum, lnum + fold_count - 1, - &foldinfo, buf); + text = get_foldtext(curwin, lnum, lnum + fold_count - 1, &foldinfo, buf); if (text == buf) text = vim_strsave(text); rettv->vval.v_string = text; diff --git a/src/fold.c b/src/fold.c index 35ceceb4a..1eaad192b 100644 --- a/src/fold.c +++ b/src/fold.c @@ -1853,8 +1853,8 @@ foldDelMarker(linenr_T lnum, char_u *marker, int markerlen) /* get_foldtext() {{{2 */ /* * Return the text for a closed fold at line "lnum", with last line "lnume". - * When 'foldtext' isn't set puts the result in "buf[51]". Otherwise the - * result is in allocated memory. + * When 'foldtext' isn't set puts the result in "buf[FOLD_TEXT_LEN]". + * Otherwise the result is in allocated memory. */ char_u * get_foldtext( @@ -1960,8 +1960,12 @@ get_foldtext( if (text == NULL) #endif { - sprintf((char *)buf, _("+--%3ld lines folded "), - (long)(lnume - lnum + 1)); + long count = (long)(lnume - lnum + 1); + + vim_snprintf((char *)buf, FOLD_TEXT_LEN, + ngettext("+--%3ld line folded ", + "+--%3ld lines folded ", count), + count); text = buf; } return text; diff --git a/src/os_win32.c b/src/os_win32.c index 54f2e887f..9fe43218d 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -472,12 +472,15 @@ vimLoadLib(char *name) # endif /* Dummy functions */ static char *null_libintl_gettext(const char *); +static char *null_libintl_ngettext(const char *, const char *, unsigned long n); static char *null_libintl_textdomain(const char *); static char *null_libintl_bindtextdomain(const char *, const char *); static char *null_libintl_bind_textdomain_codeset(const char *, const char *); static HINSTANCE hLibintlDLL = NULL; char *(*dyn_libintl_gettext)(const char *) = null_libintl_gettext; +char *(*dyn_libintl_ngettext)(const char *, const char *, unsigned long n) + = null_libintl_ngettext; char *(*dyn_libintl_textdomain)(const char *) = null_libintl_textdomain; char *(*dyn_libintl_bindtextdomain)(const char *, const char *) = null_libintl_bindtextdomain; @@ -495,6 +498,7 @@ dyn_libintl_init(void) } libintl_entry[] = { {"gettext", (FARPROC*)&dyn_libintl_gettext}, + {"ngettext", (FARPROC*)&dyn_libintl_ngettext}, {"textdomain", (FARPROC*)&dyn_libintl_textdomain}, {"bindtextdomain", (FARPROC*)&dyn_libintl_bindtextdomain}, {NULL, NULL} @@ -553,6 +557,7 @@ dyn_libintl_end(void) FreeLibrary(hLibintlDLL); hLibintlDLL = NULL; dyn_libintl_gettext = null_libintl_gettext; + dyn_libintl_ngettext = null_libintl_ngettext; dyn_libintl_textdomain = null_libintl_textdomain; dyn_libintl_bindtextdomain = null_libintl_bindtextdomain; dyn_libintl_bind_textdomain_codeset = null_libintl_bind_textdomain_codeset; @@ -567,6 +572,16 @@ null_libintl_gettext(const char *msgid) /*ARGSUSED*/ static char * +null_libintl_ngettext( + const char *msgid, + const char *msgid_plural, + unsigned long n) +{ + return n == 1 ? msgid : msgid_plural; +} + +/*ARGSUSED*/ + static char * null_libintl_bindtextdomain(const char *domainname, const char *dirname) { return NULL; diff --git a/src/screen.c b/src/screen.c index b16bd87c7..f8d283fa2 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2424,7 +2424,7 @@ fold_line( linenr_T lnum, int row) { - char_u buf[51]; + char_u buf[FOLD_TEXT_LEN]; pos_T *top, *bot; linenr_T lnume = lnum + fold_count - 1; int len; diff --git a/src/version.c b/src/version.c index 9af79c6b7..e69b355c5 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2152, +/**/ 2151, /**/ 2150, @@ -561,6 +561,7 @@ typedef unsigned long u8char_T; /* long should be 32 bits or more */ # endif /* These are in os_win32.c */ extern char *(*dyn_libintl_gettext)(const char *msgid); +extern char *(*dyn_libintl_ngettext)(const char *msgid, const char *msgid_plural, unsigned long n); extern char *(*dyn_libintl_bindtextdomain)(const char *domainname, const char *dirname); extern char *(*dyn_libintl_bind_textdomain_codeset)(const char *domainname, const char *codeset); extern char *(*dyn_libintl_textdomain)(const char *domainname); @@ -574,6 +575,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname); #ifdef FEAT_GETTEXT # ifdef DYNAMIC_GETTEXT # define _(x) (*dyn_libintl_gettext)((char *)(x)) +# define ngettext(x, xs, n) (*dyn_libintl_ngettext)((char *)(x), (char *)(xs), (n)) # define N_(x) x # define bindtextdomain(domain, dir) (*dyn_libintl_bindtextdomain)((domain), (dir)) # define bind_textdomain_codeset(domain, codeset) (*dyn_libintl_bind_textdomain_codeset)((domain), (codeset)) @@ -592,6 +594,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname); # endif #else # define _(x) ((char *)(x)) +# define ngettext(x, xs, n) (((n) == 1) ? (char *)(x) : (char *)(xs)) # define N_(x) x # ifdef bindtextdomain # undef bindtextdomain @@ -1501,6 +1504,8 @@ typedef UINT32_TYPEDEF UINT32_T; # define MSG_BUF_CLEN MSG_BUF_LEN /* cell length */ #endif +#define FOLD_TEXT_LEN 51 /* buffer size for get_foldtext() */ + /* Size of the buffer used for tgetent(). Unfortunately this is largely * undocumented, some systems use 1024. Using a buffer that is too small * causes a buffer overrun and a crash. Use the maximum known value to stay |