From 6cf044c8fcd8fb67b16202d1e046a3cb2b6002de Mon Sep 17 00:00:00 2001 From: vimboss Date: Tue, 11 Nov 2008 20:57:11 +0000 Subject: [PATCH 01/18] updated for version 7.2-033 --- src/fileio.c | 5 +++-- src/testdir/test42.ok | Bin 408 -> 311 bytes src/version.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 67e8cfe439..3d473916b2 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5550,9 +5550,10 @@ check_for_bom(p, size, lenp, flags) name = "ucs-4le"; /* FF FE 00 00 */ len = 4; } - else if (flags == FIO_ALL || flags == (FIO_UCS2 | FIO_ENDIAN_L)) + else if (flags == (FIO_UCS2 | FIO_ENDIAN_L)) name = "ucs-2le"; /* FF FE */ - else if (flags == (FIO_UTF16 | FIO_ENDIAN_L)) + else if (flags == FIO_ALL || flags == (FIO_UTF16 | FIO_ENDIAN_L)) + /* utf-16le is preferred, it also works for ucs-2le text */ name = "utf-16le"; /* FF FE */ } else if (p[0] == 0xfe && p[1] == 0xff diff --git a/src/testdir/test42.ok b/src/testdir/test42.ok index 82b7c633cb6c18c914c3b069b800608f5324fe32..d9b44948a88cc1293fab073e33e897b478bd1096 100644 GIT binary patch delta 15 WcmbQiyq#&n2G)`^T|={pTbckYqXo|Z delta 113 zcmdnaG=q7<2A1SvU89Lxo09(hXDDSzW+-ORWiVpk`u`8X$ze!k-~vJhpb`e4A_kx` a2B1O)pi%|~6CegE$1afrluQLF0AT=-pB8oi diff --git a/src/version.c b/src/version.c index e21e8e218e..4fd09e2594 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 33, /**/ 32, /**/ From a53e7167fce810d1f72d089a3705808832d057c7 Mon Sep 17 00:00:00 2001 From: vimboss Date: Wed, 12 Nov 2008 11:52:19 +0000 Subject: [PATCH 02/18] updated for version 7.2-034 --- src/buffer.c | 7 +++++-- src/version.c | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 173a0f80c1..7eb3d49a98 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -647,6 +647,9 @@ free_buffer_stuff(buf, free_options) vim_free(buf->b_start_fenc); buf->b_start_fenc = NULL; #endif +#ifdef FEAT_SPELL + ga_clear(&buf->b_langp); +#endif } /* @@ -1237,7 +1240,7 @@ do_buffer(action, start, dir, count, forceit) * "buf" if one exists */ if ((swb_flags & SWB_USEOPEN) && buf_jump_open_win(buf)) return OK; - /* If 'switchbuf' contians "usetab": jump to first window in any tab + /* If 'switchbuf' contains "usetab": jump to first window in any tab * page containing "buf" if one exists */ if ((swb_flags & SWB_USETAB) && buf_jump_open_tab(buf)) return OK; @@ -3964,7 +3967,7 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar, maxwidth, hltab, t width = vim_strsize(out); if (maxwidth > 0 && width > maxwidth) { - /* Result is too long, must trunctate somewhere. */ + /* Result is too long, must truncate somewhere. */ l = 0; if (itemcnt == 0) s = out; diff --git a/src/version.c b/src/version.c index 4fd09e2594..ace1c18cc2 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 34, /**/ 33, /**/ From 81a5c6dd4eb19dfcea87a5f17184da904f8b0bc3 Mon Sep 17 00:00:00 2001 From: vimboss Date: Wed, 12 Nov 2008 12:08:45 +0000 Subject: [PATCH 03/18] updated for version 7.2-035 --- src/gui_x11.c | 2 +- src/mbyte.c | 2 +- src/misc2.c | 2 +- src/os_unix.c | 5 +++-- src/version.c | 2 ++ 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui_x11.c b/src/gui_x11.c index 2842fa092b..b56c9436c3 100644 --- a/src/gui_x11.c +++ b/src/gui_x11.c @@ -2450,7 +2450,7 @@ find_closest_color(colormap, colorPtr) *colorPtr = colortable[closest]; } - free(colortable); + vim_free(colortable); return OK; } diff --git a/src/mbyte.c b/src/mbyte.c index 923571406a..134a956004 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -5384,7 +5384,7 @@ preedit_draw_cbproc(XIC xic, XPointer client_data, XPointer call_data) draw_feedback = (char *)alloc(draw_data->chg_first + text->length); else - draw_feedback = realloc(draw_feedback, + draw_feedback = vim_realloc(draw_feedback, draw_data->chg_first + text->length); if (draw_feedback != NULL) { diff --git a/src/misc2.c b/src/misc2.c index 10c77a7529..4d40ad207e 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -873,7 +873,7 @@ lalloc(size, message) /* 3. check for available memory: call mch_avail_mem() */ if (mch_avail_mem(TRUE) < KEEP_ROOM && !releasing) { - vim_free((char *)p); /* System is low... no go! */ + free((char *)p); /* System is low... no go! */ p = NULL; } else diff --git a/src/os_unix.c b/src/os_unix.c index 1edad601a9..2191e2e8f2 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2905,7 +2905,7 @@ mch_early_init() * Ignore any errors. */ #if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK) - signal_stack = malloc(SIGSTKSZ); + signal_stack = (char *)alloc(SIGSTKSZ); init_signal_stack(); #endif } @@ -6814,7 +6814,8 @@ xsmp_close() if (xsmp_icefd != -1) { SmcCloseConnection(xsmp.smcconn, 0, NULL); - vim_free(xsmp.clientid); + if (xsmp.clientid != NULL) + free(xsmp.clientid); xsmp.clientid = NULL; xsmp_icefd = -1; } diff --git a/src/version.c b/src/version.c index ace1c18cc2..b1049255b2 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 35, /**/ 34, /**/ From a57ecd4e2eff6e2103460e8743f25c7aa59a8828 Mon Sep 17 00:00:00 2001 From: vimboss Date: Wed, 12 Nov 2008 12:36:30 +0000 Subject: [PATCH 04/18] updated for version 7.2-036 --- src/gui_riscos.c | 4 ++-- src/gui_w48.c | 11 +++++++---- src/os_vms.c | 12 ++++++------ src/os_w32exe.c | 3 ++- src/os_win16.c | 3 ++- src/version.c | 2 ++ 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/gui_riscos.c b/src/gui_riscos.c index 6adc8b77e3..90634fad76 100644 --- a/src/gui_riscos.c +++ b/src/gui_riscos.c @@ -695,7 +695,7 @@ gui_mch_set_winpos(int x, int y) gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction) int width; /* In OS units */ int height; - int min_width; /* Smallest permissable window size (ignored) */ + int min_width; /* Smallest permissible window size (ignored) */ int min_height; int base_width; /* Space for scroll bars, etc */ int base_height; @@ -863,7 +863,7 @@ zap_load_file(name, style) if (strncmp(file, "ZapFont\015", 8) == 0) return file; /* Loaded OK! */ - free(file); + vim_free(file); return NULL; /* Not a valid font file */ } diff --git a/src/gui_w48.c b/src/gui_w48.c index 8b96f2b9cc..53dbad112b 100644 --- a/src/gui_w48.c +++ b/src/gui_w48.c @@ -3335,7 +3335,7 @@ gui_mch_browseW( /* * Convert the string s to the proper format for a filter string by replacing - * the \t and \n delimeters with \0. + * the \t and \n delimiters with \0. * Returns the converted string in allocated memory. * * Keep in sync with convert_filterW() above! @@ -3674,7 +3674,8 @@ _OnScroll( * Use "prog" as the name of the program and "cmdline" as the arguments. * Copy the arguments to allocated memory. * Return the number of arguments (including program name). - * Return pointers to the arguments in "argvp". + * Return pointers to the arguments in "argvp". Memory is allocated with + * malloc(), use free() instead of vim_free(). * Return pointer to buffer in "tofree". * Returns zero when out of memory. */ @@ -3692,6 +3693,8 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree) char **argv = NULL; int round; + *tofree = NULL; + #ifdef FEAT_MBYTE /* Try using the Unicode version first, it takes care of conversion when * 'encoding' is changed. */ @@ -3802,15 +3805,15 @@ get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree) argv = (char **)malloc((argc + 1) * sizeof(char *)); if (argv == NULL ) { - vim_free(newcmdline); + free(newcmdline); return 0; /* malloc error */ } pnew = newcmdline; + *tofree = newcmdline; } } done: - argv[argc] = NULL; /* NULL-terminated list */ *argvp = argv; return argc; diff --git a/src/os_vms.c b/src/os_vms.c index 76a15ce2f5..7954294b91 100644 --- a/src/os_vms.c +++ b/src/os_vms.c @@ -228,7 +228,7 @@ mch_getenv(char_u *lognam) else if ((sbuf = getenv((char *)lognam))) { lengte = strlen(sbuf) + 1; - cp = (char_u *)malloc((size_t)lengte); + cp = (char_u *)alloc((size_t)lengte); if (cp) strcpy((char *)cp, sbuf); return cp; @@ -381,7 +381,7 @@ vms_wproc(char *name, int val) if (--vms_match_free == 0) { /* add more space to store matches */ vms_match_alloced += EXPL_ALLOC_INC; - vms_fmatch = (char_u **)realloc(vms_fmatch, + vms_fmatch = (char_u **)vim_realloc(vms_fmatch, sizeof(char **) * vms_match_alloced); if (!vms_fmatch) return 0; @@ -460,7 +460,7 @@ mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, i if (--files_free < 1) { files_alloced += EXPL_ALLOC_INC; - *file = (char_u **)realloc(*file, + *file = (char_u **)vim_realloc(*file, sizeof(char_u **) * files_alloced); if (*file == NULL) { @@ -614,14 +614,14 @@ vms_fixfilename(void *instring) { buflen = len + 128; if (buf) - buf = (char *)realloc(buf, buflen); + buf = (char *)vim_realloc(buf, buflen); else - buf = (char *)calloc(buflen, sizeof(char)); + buf = (char *)alloc(buflen * sizeof(char)); } #ifdef DEBUG char *tmpbuf = NULL; - tmpbuf = (char *)calloc(buflen, sizeof(char)); + tmpbuf = (char *)alloc(buflen * sizeof(char)); strcpy(tmpbuf, instring); #endif diff --git a/src/os_w32exe.c b/src/os_w32exe.c index 76f9332a65..93a13899c2 100644 --- a/src/os_w32exe.c +++ b/src/os_w32exe.c @@ -129,7 +129,8 @@ WinMain( errout: #endif free(argv); - free(tofree); + if (tofree != NULL) + free(tofree); #ifdef FEAT_MBYTE free_cmd_argsW(); #endif diff --git a/src/os_win16.c b/src/os_win16.c index 2afaddcba6..1cf3ff8e93 100644 --- a/src/os_win16.c +++ b/src/os_win16.c @@ -121,7 +121,8 @@ WinMain( pmain(argc, argv); free(argv); - free(tofree); + if (tofree != NULL) + free(tofree); return 0; } diff --git a/src/version.c b/src/version.c index b1049255b2..3d68f7051f 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 36, /**/ 35, /**/ From 911a34fed039a56c5ea0046408b31034b9ee1443 Mon Sep 17 00:00:00 2001 From: vimboss Date: Wed, 12 Nov 2008 13:10:15 +0000 Subject: [PATCH 05/18] updated for version 7.2-037 --- src/os_unix.c | 3 ++- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/os_unix.c b/src/os_unix.c index 2191e2e8f2..782265bd91 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2936,7 +2936,8 @@ mch_free_mem() } # endif # endif -# ifdef FEAT_X11 + /* Don't close the display for GTK 1, it is done in exit(). */ +# if defined(FEAT_X11) && (!defined(FEAT_GUI_GTK) || defined(HAVE_GTK2)) if (x11_display != NULL # ifdef FEAT_XCLIPBOARD && x11_display != xterm_dpy diff --git a/src/version.c b/src/version.c index 3d68f7051f..52385a312d 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 37, /**/ 36, /**/ From ce49edcc1e3548a1cdd83eb2298bd83a22682a8c Mon Sep 17 00:00:00 2001 From: vimboss Date: Wed, 12 Nov 2008 13:52:46 +0000 Subject: [PATCH 06/18] updated for version 7.2-038 --- src/if_xcmdsrv.c | 6 +++--- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/if_xcmdsrv.c b/src/if_xcmdsrv.c index 024bac6b2a..ff4a46f6c6 100644 --- a/src/if_xcmdsrv.c +++ b/src/if_xcmdsrv.c @@ -736,7 +736,7 @@ ServerReplyFind(w, op) + serverReply.ga_len; e.id = w; ga_init2(&e.strings, 1, 100); - memcpy(p, &e, sizeof(e)); + mch_memmove(p, &e, sizeof(e)); serverReply.ga_len++; } } @@ -1018,7 +1018,7 @@ LookupName(dpy, name, delete, loose) p++; count = numItems - (p - regProp); if (count > 0) - memcpy(entry, p, count); + mch_memmove(entry, p, count); XChangeProperty(dpy, RootWindow(dpy, 0), registryProperty, XA_STRING, 8, PropModeReplace, regProp, (int)(numItems - (p - entry))); @@ -1072,7 +1072,7 @@ DeleteAnyLingerer(dpy, win) p++; lastHalf = numItems - (p - regProp); if (lastHalf > 0) - memcpy(entry, p, lastHalf); + mch_memmove(entry, p, lastHalf); numItems = (entry - regProp) + lastHalf; p = entry; continue; diff --git a/src/version.c b/src/version.c index 52385a312d..2ca11041be 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 38, /**/ 37, /**/ From 6907698f608445b84100507ba3bfee7eaf63ab3d Mon Sep 17 00:00:00 2001 From: vimboss Date: Wed, 12 Nov 2008 14:29:28 +0000 Subject: [PATCH 07/18] updated for version 7.2-039 --- src/eval.c | 1 + src/version.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/eval.c b/src/eval.c index 5573e764d8..a3edec69ef 100644 --- a/src/eval.c +++ b/src/eval.c @@ -856,6 +856,7 @@ eval_clear() } } hash_clear(&vimvarht); + hash_init(&vimvarht); /* garbage_collect() will access it */ hash_clear(&compat_hashtab); /* script-local variables */ diff --git a/src/version.c b/src/version.c index 2ca11041be..6467146058 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 39, /**/ 38, /**/ From 5d900f6f7ec90ddfc5a961ea899938ccf991f48f Mon Sep 17 00:00:00 2001 From: vimboss Date: Wed, 12 Nov 2008 15:05:21 +0000 Subject: [PATCH 08/18] updated for version 7.2-040 --- src/fileio.c | 8 +++----- src/version.c | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 3d473916b2..a28bcd9e65 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -932,7 +932,10 @@ retry: else { if (eap != NULL && eap->force_ff != 0) + { fileformat = get_fileformat_force(curbuf, eap); + try_unix = try_dos = try_mac = FALSE; + } else if (curbuf->b_p_bin) fileformat = EOL_UNIX; /* binary: use Unix format */ else if (*p_ffs == NUL) @@ -2341,11 +2344,6 @@ failed: STRCAT(IObuff, _("[CR missing]")); c = TRUE; } - if (ff_error == EOL_MAC) - { - STRCAT(IObuff, _("[NL found]")); - c = TRUE; - } if (split) { STRCAT(IObuff, _("[long lines split]")); diff --git a/src/version.c b/src/version.c index 6467146058..4686098e44 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 40, /**/ 39, /**/ From 950ef8ff2fd920f722aa9c5ec65c6cd4af92b00c Mon Sep 17 00:00:00 2001 From: vimboss Date: Sat, 15 Nov 2008 13:12:07 +0000 Subject: [PATCH 09/18] updated for version 7.2-041 --- src/buffer.c | 76 +++++++++++++++++++++++++++++++++++-------- src/ex_cmds.c | 22 ++++++++++--- src/ex_cmds2.c | 4 +-- src/ex_docmd.c | 5 +-- src/ex_getln.c | 2 +- src/if_sniff.c | 3 +- src/main.c | 2 +- src/netbeans.c | 6 ++-- src/normal.c | 2 +- src/popupmnu.c | 2 +- src/proto/buffer.pro | 2 +- src/proto/ex_cmds.pro | 2 +- src/quickfix.c | 11 +++++-- src/version.c | 2 ++ src/window.c | 3 +- 15 files changed, 107 insertions(+), 37 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 7eb3d49a98..4104977d67 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -33,7 +33,7 @@ static char_u *buflist_match __ARGS((regprog_T *prog, buf_T *buf)); static char_u *fname_match __ARGS((regprog_T *prog, char_u *name)); #endif static void buflist_setfpos __ARGS((buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options)); -static wininfo_T *find_wininfo __ARGS((buf_T *buf)); +static wininfo_T *find_wininfo __ARGS((buf_T *buf, int skip_diff_buffer)); #ifdef UNIX static buf_T *buflist_findname_stat __ARGS((char_u *ffname, struct stat *st)); static int otherfile_buf __ARGS((buf_T *buf, char_u *ffname, struct stat *stp)); @@ -1093,7 +1093,7 @@ do_buffer(action, start, dir, count, forceit) #endif setpcmark(); retval = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, - forceit ? ECMD_FORCEIT : 0); + forceit ? ECMD_FORCEIT : 0, curwin); /* * do_ecmd() may create a new buffer, then we have to delete @@ -1316,7 +1316,7 @@ set_curbuf(buf, action) setpcmark(); if (!cmdmod.keepalt) curwin->w_alt_fnum = curbuf->b_fnum; /* remember alternate file */ - buflist_altfpos(); /* remember curpos */ + buflist_altfpos(curwin); /* remember curpos */ #ifdef FEAT_VISUAL /* Don't restart Select mode after switching to another buffer. */ @@ -2404,22 +2404,70 @@ buflist_setfpos(buf, win, lnum, col, copy_options) return; } +#ifdef FEAT_DIFF +static int wininfo_other_tab_diff __ARGS((wininfo_T *wip)); + +/* + * Return TRUE when "wip" has 'diff' set and the diff is only for another tab + * page. That's because a diff is local to a tab page. + */ + static int +wininfo_other_tab_diff(wip) + wininfo_T *wip; +{ + win_T *wp; + + if (wip->wi_opt.wo_diff) + { + for (wp = firstwin; wp != NULL; wp = wp->w_next) + /* return FALSE when it's a window in the current tab page, thus + * the buffer was in diff mode here */ + if (wip->wi_win == wp) + return FALSE; + return TRUE; + } + return FALSE; +} +#endif + /* * Find info for the current window in buffer "buf". * If not found, return the info for the most recently used window. + * When "skip_diff_buffer" is TRUE avoid windows with 'diff' set that is in + * another tab page. * Returns NULL when there isn't any info. */ +/*ARGSUSED*/ static wininfo_T * -find_wininfo(buf) +find_wininfo(buf, skip_diff_buffer) buf_T *buf; + int skip_diff_buffer; { wininfo_T *wip; for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) - if (wip->wi_win == curwin) + if (wip->wi_win == curwin +#ifdef FEAT_DIFF + && (!skip_diff_buffer || !wininfo_other_tab_diff(wip)) +#endif + ) break; - if (wip == NULL) /* if no fpos for curwin, use the first in the list */ - wip = buf->b_wininfo; + + /* If no wininfo for curwin, use the first in the list (that doesn't have + * 'diff' set and is in another tab page). */ + if (wip == NULL) + { +#ifdef FEAT_DIFF + if (skip_diff_buffer) + { + for (wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) + if (!wininfo_other_tab_diff(wip)) + break; + } + else +#endif + wip = buf->b_wininfo; + } return wip; } @@ -2440,7 +2488,7 @@ get_winopts(buf) clearFolding(curwin); #endif - wip = find_wininfo(buf); + wip = find_wininfo(buf, TRUE); if (wip != NULL && wip->wi_optset) { copy_winopt(&wip->wi_opt, &curwin->w_onebuf_opt); @@ -2472,7 +2520,7 @@ buflist_findfpos(buf) wininfo_T *wip; static pos_T no_position = {1, 0}; - wip = find_wininfo(buf); + wip = find_wininfo(buf, FALSE); if (wip != NULL) return &(wip->wi_fpos); else @@ -2793,14 +2841,14 @@ buflist_slash_adjust() #endif /* - * Set alternate cursor position for current window. + * Set alternate cursor position for the current buffer and window "win". * Also save the local window option values. */ void -buflist_altfpos() +buflist_altfpos(win) + win_T *win; { - buflist_setfpos(curbuf, curwin, curwin->w_cursor.lnum, - curwin->w_cursor.col, TRUE); + buflist_setfpos(curbuf, win, win->w_cursor.lnum, win->w_cursor.col, TRUE); } /* @@ -4492,7 +4540,7 @@ do_arg_all(count, forceit, keep_tabs) ECMD_ONE, ((P_HID(curwin->w_buffer) || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) - + ECMD_OLDBUF); + + ECMD_OLDBUF, curwin); #ifdef FEAT_AUTOCMD if (use_firstwin) ++autocmd_no_leave; diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 5d382d18ef..e3049fb058 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -3052,7 +3052,8 @@ getfile(fnum, ffname, sfname, setpm, lnum, forceit) retval = 0; /* it's in the same file */ } else if (do_ecmd(fnum, ffname, sfname, NULL, lnum, - (P_HID(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0)) == OK) + (P_HID(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0), + curwin) == OK) retval = -1; /* opened another file */ else retval = 1; /* error encountered */ @@ -3085,17 +3086,21 @@ theend: * ECMD_OLDBUF: use existing buffer if it exists * ECMD_FORCEIT: ! used for Ex command * ECMD_ADDBUF: don't edit, just add to buffer list + * oldwin: Should be "curwin" when editing a new buffer in the current + * window, NULL when splitting the window first. When not NULL info + * of the previous buffer for "oldwin" is stored. * * return FAIL for failure, OK otherwise */ int -do_ecmd(fnum, ffname, sfname, eap, newlnum, flags) +do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin) int fnum; char_u *ffname; char_u *sfname; exarg_T *eap; /* can be NULL! */ linenr_T newlnum; int flags; + win_T *oldwin; { int other_file; /* TRUE if editing another file */ int oldbuf; /* TRUE if using existing buffer */ @@ -3267,7 +3272,8 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags) { if (!cmdmod.keepalt) curwin->w_alt_fnum = curbuf->b_fnum; - buflist_altfpos(); + if (oldwin != NULL) + buflist_altfpos(oldwin); } if (fnum) @@ -3371,7 +3377,7 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags) /* close the link to the current buffer */ u_sync(FALSE); - close_buffer(curwin, curbuf, + close_buffer(oldwin, curbuf, (flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD); #ifdef FEAT_AUTOCMD @@ -5609,7 +5615,13 @@ ex_help(eap) */ alt_fnum = curbuf->b_fnum; (void)do_ecmd(0, NULL, NULL, NULL, ECMD_LASTL, - ECMD_HIDE + ECMD_SET_HELP); + ECMD_HIDE + ECMD_SET_HELP, +#ifdef FEAT_WINDOWS + NULL /* buffer is still open, don't store info */ +#else + curwin +#endif + ); if (!cmdmod.keepalt) curwin->w_alt_fnum = alt_fnum; empty_fnum = curbuf->b_fnum; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index ed3c45f6c7..2c0f80dfe7 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -2132,8 +2132,8 @@ do_argfile(eap, argn) * argument index. */ if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL, eap, ECMD_LAST, - (P_HID(curwin->w_buffer) ? ECMD_HIDE : 0) + - (eap->forceit ? ECMD_FORCEIT : 0)) == FAIL) + (P_HID(curwin->w_buffer) ? ECMD_HIDE : 0) + + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL) curwin->w_arg_idx = old_arg_idx; /* like Vi: set the mark where the cursor is in the file. */ else if (eap->cmdidx != CMD_argdo) diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 8d21ee1ebf..5a80a07c22 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -7488,7 +7488,8 @@ do_exedit(eap, old_curwin) /* ":new" or ":tabnew" without argument: edit an new empty buffer */ setpcmark(); (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE, - ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0)); + ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0), + old_curwin == NULL ? curwin : NULL); } else if ((eap->cmdidx != CMD_split #ifdef FEAT_VERTSPLIT @@ -7525,7 +7526,7 @@ do_exedit(eap, old_curwin) #ifdef FEAT_LISTCMDS + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0 ) #endif - ) == FAIL) + , old_curwin == NULL ? curwin : NULL) == FAIL) { /* Editing the file failed. If the window was split, close it. */ #ifdef FEAT_WINDOWS diff --git a/src/ex_getln.c b/src/ex_getln.c index 8855f868ec..ac801eb8b3 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -6051,7 +6051,7 @@ ex_window() cmdwin_type = '-'; /* Create the command-line buffer empty. */ - (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE); + (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL); (void)setfname(curbuf, (char_u *)"[Command Line]", NULL, TRUE); set_option_value((char_u *)"bt", 0L, (char_u *)"nofile", OPT_LOCAL); set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); diff --git a/src/if_sniff.c b/src/if_sniff.c index dea157446a..34b0128963 100644 --- a/src/if_sniff.c +++ b/src/if_sniff.c @@ -1114,7 +1114,8 @@ vi_open_file(fname) char *fname; { ++no_wait_return; - do_ecmd(0, (char_u *)fname, NULL, NULL, ECMD_ONE, ECMD_HIDE+ECMD_OLDBUF); + do_ecmd(0, (char_u *)fname, NULL, NULL, ECMD_ONE, ECMD_HIDE+ECMD_OLDBUF, + curwin); curbuf->b_sniff = TRUE; --no_wait_return; /* [ex_docmd.c] */ } diff --git a/src/main.c b/src/main.c index 53f55c0be6..17cab6d348 100644 --- a/src/main.c +++ b/src/main.c @@ -2588,7 +2588,7 @@ edit_buffers(parmp) # endif (void)do_ecmd(0, arg_idx < GARGCOUNT ? alist_name(&GARGLIST[arg_idx]) : NULL, - NULL, NULL, ECMD_LASTL, ECMD_HIDE); + NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin); # ifdef HAS_SWAP_EXISTS_ACTION if (swap_exists_did_quit) { diff --git a/src/netbeans.c b/src/netbeans.c index 80a1b43755..19c365054f 100644 --- a/src/netbeans.c +++ b/src/netbeans.c @@ -1795,7 +1795,7 @@ nb_do_cmd( buf->displayname = NULL; netbeansReadFile = 0; /* don't try to open disk file */ - do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF); + do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF, curwin); netbeansReadFile = 1; buf->bufp = curbuf; maketitle(); @@ -1960,7 +1960,7 @@ nb_do_cmd( netbeansReadFile = 0; /* don't try to open disk file */ do_ecmd(0, (char_u *)buf->displayname, 0, 0, ECMD_ONE, - ECMD_HIDE + ECMD_OLDBUF); + ECMD_HIDE + ECMD_OLDBUF, curwin); netbeansReadFile = 1; buf->bufp = curbuf; maketitle(); @@ -1979,7 +1979,7 @@ nb_do_cmd( vim_free(buf->displayname); buf->displayname = nb_unquote(args, NULL); do_ecmd(0, (char_u *)buf->displayname, NULL, NULL, ECMD_ONE, - ECMD_HIDE + ECMD_OLDBUF); + ECMD_HIDE + ECMD_OLDBUF, curwin); buf->bufp = curbuf; buf->initDone = TRUE; doupdate = 1; diff --git a/src/normal.c b/src/normal.c index d33a636745..b9071715a3 100644 --- a/src/normal.c +++ b/src/normal.c @@ -6050,7 +6050,7 @@ nv_gotofile(cap) autowrite(curbuf, FALSE); setpcmark(); (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST, - P_HID(curbuf) ? ECMD_HIDE : 0); + P_HID(curbuf) ? ECMD_HIDE : 0, curwin); if (cap->nchar == 'F' && lnum >= 0) { curwin->w_cursor.lnum = lnum; diff --git a/src/popupmnu.c b/src/popupmnu.c index 10a5edf278..5808ae19ed 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -573,7 +573,7 @@ pum_set_selected(n, repeat) { /* Don't want to sync undo in the current buffer. */ ++no_u_sync; - res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0); + res = do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, 0, NULL); --no_u_sync; if (res == OK) { diff --git a/src/proto/buffer.pro b/src/proto/buffer.pro index 509f390076..e14ee8f4c9 100644 --- a/src/proto/buffer.pro +++ b/src/proto/buffer.pro @@ -33,7 +33,7 @@ buf_T *setaltfname __ARGS((char_u *ffname, char_u *sfname, linenr_T lnum)); char_u *getaltfname __ARGS((int errmsg)); int buflist_add __ARGS((char_u *fname, int flags)); void buflist_slash_adjust __ARGS((void)); -void buflist_altfpos __ARGS((void)); +void buflist_altfpos __ARGS((win_T *win)); int otherfile __ARGS((char_u *ffname)); void buf_setino __ARGS((buf_T *buf)); void fileinfo __ARGS((int fullname, int shorthelp, int dont_truncate)); diff --git a/src/proto/ex_cmds.pro b/src/proto/ex_cmds.pro index dced028c17..1a15c88e75 100644 --- a/src/proto/ex_cmds.pro +++ b/src/proto/ex_cmds.pro @@ -27,7 +27,7 @@ void ex_wnext __ARGS((exarg_T *eap)); void do_wqall __ARGS((exarg_T *eap)); int not_writing __ARGS((void)); int getfile __ARGS((int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, int forceit)); -int do_ecmd __ARGS((int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags)); +int do_ecmd __ARGS((int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T newlnum, int flags, win_T *oldwin)); void ex_append __ARGS((exarg_T *eap)); void ex_change __ARGS((exarg_T *eap)); void ex_z __ARGS((exarg_T *eap)); diff --git a/src/quickfix.c b/src/quickfix.c index ac11416c99..5c3ae381ee 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -1420,6 +1420,7 @@ qf_jump(qi, dir, errornr, forceit) win_T *win; win_T *altwin; #endif + win_T *oldwin = curwin; int print_message = TRUE; int len; #ifdef FEAT_FOLDING @@ -1744,7 +1745,8 @@ qf_jump(qi, dir, errornr, forceit) } else ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1, - ECMD_HIDE + ECMD_SET_HELP); + ECMD_HIDE + ECMD_SET_HELP, + oldwin == curwin ? curwin : NULL); } else ok = buflist_getfile(qf_ptr->qf_fnum, @@ -2267,6 +2269,7 @@ ex_copen(eap) win_T *win; tabpage_T *prevtab = curtab; buf_T *qf_buf; + win_T *oldwin = curwin; if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow) { @@ -2326,14 +2329,16 @@ ex_copen(eap) win->w_llist->qf_refcount++; } + if (oldwin != curwin) + oldwin = NULL; /* don't store info when in another window */ if (qf_buf != NULL) /* Use the existing quickfix buffer */ (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE, - ECMD_HIDE + ECMD_OLDBUF); + ECMD_HIDE + ECMD_OLDBUF, oldwin); else { /* Create a new quickfix buffer */ - (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE); + (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin); /* switch off 'swapfile' */ set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL); set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix", diff --git a/src/version.c b/src/version.c index 4686098e44..d3ce62ae59 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 41, /**/ 40, /**/ diff --git a/src/window.c b/src/window.c index 80cbfddba7..2feb9e25b5 100644 --- a/src/window.c +++ b/src/window.c @@ -531,7 +531,8 @@ wingotofile: # ifdef FEAT_SCROLLBIND curwin->w_p_scb = FALSE; # endif - (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE); + (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, + ECMD_HIDE, NULL); if (nchar == 'F' && lnum >= 0) { curwin->w_cursor.lnum = lnum; From 9e75f31ff2a6e8a085b61cd2a8539317309a4cf9 Mon Sep 17 00:00:00 2001 From: vimboss Date: Sat, 15 Nov 2008 15:06:17 +0000 Subject: [PATCH 10/18] updated for version 7.2-042 --- src/buffer.c | 6 +++++- src/move.c | 19 ++++++++++++++----- src/structs.h | 7 ++++++- src/version.c | 2 ++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 4104977d67..741de4887a 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1401,6 +1401,9 @@ enter_buffer(buf) curwin->w_cursor.coladd = 0; #endif curwin->w_set_curswant = TRUE; +#ifdef FEAT_AUTOCMD + curwin->w_topline_was_set = FALSE; +#endif /* Make sure the buffer is loaded. */ if (curbuf->b_ml.ml_mfp == NULL) /* need to load the file */ @@ -1440,7 +1443,8 @@ enter_buffer(buf) maketitle(); #endif #ifdef FEAT_AUTOCMD - if (curwin->w_topline == 1) /* when autocmds didn't change it */ + /* when autocmds didn't change it */ + if (curwin->w_topline == 1 && !curwin->w_topline_was_set) #endif scroll_cursor_halfway(FALSE); /* redisplay at correct position */ diff --git a/src/move.c b/src/move.c index c547d9b0e9..17b16a1e89 100644 --- a/src/move.c +++ b/src/move.c @@ -280,18 +280,20 @@ update_topline() if (curwin->w_botline <= curbuf->b_ml.ml_line_count) { - if (curwin->w_cursor.lnum < curwin->w_botline - && ((long)curwin->w_cursor.lnum + if (curwin->w_cursor.lnum < curwin->w_botline) + { + if (((long)curwin->w_cursor.lnum >= (long)curwin->w_botline - p_so #ifdef FEAT_FOLDING || hasAnyFolding(curwin) #endif )) - { + { lineoff_T loff; - /* Cursor is above botline, check if there are 'scrolloff' - * window lines below the cursor. If not, need to scroll. */ + /* Cursor is (a few lines) above botline, check if there are + * 'scrolloff' window lines below the cursor. If not, need to + * scroll. */ n = curwin->w_empty_rows; loff.lnum = curwin->w_cursor.lnum; #ifdef FEAT_FOLDING @@ -317,6 +319,10 @@ update_topline() if (n >= p_so) /* sufficient context, no need to scroll */ check_botline = FALSE; + } + else + /* sufficient context, no need to scroll */ + check_botline = FALSE; } if (check_botline) { @@ -509,6 +515,9 @@ set_topline(wp, lnum) /* Approximate the value of w_botline */ wp->w_botline += lnum - wp->w_topline; wp->w_topline = lnum; +#ifdef FEAT_AUTOCMD + wp->w_topline_was_set = TRUE; +#endif #ifdef FEAT_DIFF wp->w_topfill = 0; #endif diff --git a/src/structs.h b/src/structs.h index 1ecdddbc15..329676e594 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1784,10 +1784,15 @@ struct window_S #endif /* - * The next three specify the offsets for displaying the buffer: + * "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for + * displaying the buffer. */ linenr_T w_topline; /* buffer line number of the line at the top of the window */ +#ifdef FEAT_AUTOCMD + char w_topline_was_set; /* flag set to TRUE when topline is set, + e.g. by winrestview() */ +#endif #ifdef FEAT_DIFF int w_topfill; /* number of filler lines above w_topline */ int w_old_topfill; /* w_topfill at last redraw */ diff --git a/src/version.c b/src/version.c index d3ce62ae59..6c59034366 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 42, /**/ 41, /**/ From 09c7a21e4f7f57f38d8e3adb7b76949167369e52 Mon Sep 17 00:00:00 2001 From: vimboss Date: Sat, 15 Nov 2008 15:16:46 +0000 Subject: [PATCH 11/18] fix truncation --- src/testdir/test42.ok | Bin 311 -> 409 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/testdir/test42.ok b/src/testdir/test42.ok index d9b44948a88cc1293fab073e33e897b478bd1096..183430d71cfe487b2d405dd2cde25a1eef958d74 100644 GIT binary patch delta 106 zcmdnaG?RIQIb+hl{|u!J$qdB|x(r4PT>t+eI5`Zd3|v6S093*NRKx&O#sE~v094Ar TU;@NI<=7>1fRd>o1t1InC>j$U delta 7 OcmbQqyq#%-IU@iHVgfz@ From 73827e6e15691ff01553b6a29395fc7d7e1c063f Mon Sep 17 00:00:00 2001 From: vimboss Date: Thu, 20 Nov 2008 09:27:32 +0000 Subject: [PATCH 12/18] updated for version 7.2-043 --- src/version.c | 2 ++ src/vim.h | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/version.c b/src/version.c index 6c59034366..e46b9277bf 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 43, /**/ 42, /**/ diff --git a/src/vim.h b/src/vim.h index 0421cff285..14405dc557 100644 --- a/src/vim.h +++ b/src/vim.h @@ -341,8 +341,14 @@ #ifdef BACKSLASH_IN_FILENAME # define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`%#'\"|!<") #else -# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<") -# define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&") +# ifdef VMS + /* VMS allows a lot of characters in the file name */ +# define PATH_ESC_CHARS ((char_u *)" \t\n*?{`\\%#'\"|!") +# define SHELL_ESC_CHARS ((char_u *)" \t\n*?{`\\%#'|!()&") +# else +# define PATH_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<") +# define SHELL_ESC_CHARS ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&") +# endif #endif #define NUMBUFLEN 30 /* length of a buffer to store a number in ASCII */ @@ -370,7 +376,7 @@ typedef __int64 long_i; * Define __w64 as an empty token for everything but MSVC 7.x or later. */ # if !defined(_MSC_VER) || (_MSC_VER < 1300) -# define __w64 +# define __w64 # endif typedef unsigned long __w64 long_u; typedef long __w64 long_i; From d676af07ec62781a6d2cf4f84af83409ca0e4dda Mon Sep 17 00:00:00 2001 From: vimboss Date: Thu, 20 Nov 2008 09:37:01 +0000 Subject: [PATCH 13/18] updated for version 7.2-044 --- src/auto/configure | 26 +++++++++++++++++--------- src/configure.in | 19 +++++++++++++------ src/eval.c | 5 ++++- src/version.c | 2 ++ 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/auto/configure b/src/auto/configure index cafde79def..fba78afa89 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -16819,21 +16819,29 @@ if test "x$MACARCH" = "xboth"; then LDFLAGS="$LDFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc" fi -{ $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5 -$as_echo_n "checking for GCC 3 or later... " >&6; } DEPEND_CFLAGS_FILTER= if test "$GCC" = yes; then + { $as_echo "$as_me:$LINENO: checking for GCC 3 or later" >&5 +$as_echo_n "checking for GCC 3 or later... " >&6; } gccmajor=`echo "$gccversion" | sed -e 's/^\([1-9]\)\..*$/\1/g'` if test "$gccmajor" -gt "2"; then DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'" - fi -fi -if test "$DEPEND_CFLAGS_FILTER" = ""; then - { $as_echo "$as_me:$LINENO: result: no" >&5 -$as_echo "no" >&6; } -else - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:$LINENO: result: yes" >&5 $as_echo "yes" >&6; } + else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + fi + { $as_echo "$as_me:$LINENO: checking whether we need -D_FORTIFY_SOURCE=1" >&5 +$as_echo_n "checking whether we need -D_FORTIFY_SOURCE=1... " >&6; } + if test "$gccmajor" -gt "3"; then + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=1" + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + fi fi diff --git a/src/configure.in b/src/configure.in index ad00d42b8e..b6c77da98a 100644 --- a/src/configure.in +++ b/src/configure.in @@ -3152,18 +3152,25 @@ dnl use "-isystem" instead of "-I" for all non-Vim include dirs. dnl But only when making dependencies, cproto and lint don't take "-isystem". dnl Mac gcc returns "powerpc-apple-darwin8-gcc-4.0.1 (GCC)...", need to allow dnl the number before the version number. -AC_MSG_CHECKING(for GCC 3 or later) DEPEND_CFLAGS_FILTER= if test "$GCC" = yes; then + AC_MSG_CHECKING(for GCC 3 or later) gccmajor=`echo "$gccversion" | sed -e 's/^\([[1-9]]\)\..*$/\1/g'` if test "$gccmajor" -gt "2"; then DEPEND_CFLAGS_FILTER="| sed 's+-I */+-isystem /+g'" + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + dnl -D_FORTIFY_SOURCE=2 crashes Vim on strcpy(buf, "000") when buf is + dnl declared as char x[1] but actually longer. Introduced in gcc 4.0. + AC_MSG_CHECKING(whether we need -D_FORTIFY_SOURCE=1) + if test "$gccmajor" -gt "3"; then + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=1" + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) fi -fi -if test "$DEPEND_CFLAGS_FILTER" = ""; then - AC_MSG_RESULT(no) -else - AC_MSG_RESULT(yes) fi AC_SUBST(DEPEND_CFLAGS_FILTER) diff --git a/src/eval.c b/src/eval.c index a3edec69ef..98fc8edf30 100644 --- a/src/eval.c +++ b/src/eval.c @@ -21150,8 +21150,11 @@ call_user_func(fp, argcount, argvars, rettv, firstline, lastline, selfdict) init_var_dict(&fc.l_avars, &fc.l_avars_var); add_nr_var(&fc.l_avars, &fc.fixvar[fixvar_idx++].var, "0", (varnumber_T)(argcount - fp->uf_args.ga_len)); + /* Use "name" to avoid a warning from some compiler that checks the + * destination size. */ v = &fc.fixvar[fixvar_idx++].var; - STRCPY(v->di_key, "000"); + name = v->di_key; + STRCPY(name, "000"); v->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX; hash_add(&fc.l_avars.dv_hashtab, DI2HIKEY(v)); v->di_tv.v_type = VAR_LIST; diff --git a/src/version.c b/src/version.c index e46b9277bf..a3901f4c96 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 44, /**/ 43, /**/ From ae96eb8469f6f5b5f9013355c36196f0be1d736a Mon Sep 17 00:00:00 2001 From: vimboss Date: Thu, 20 Nov 2008 10:04:53 +0000 Subject: [PATCH 14/18] updated for version 7.2-045 --- src/if_python.c | 9 ++++++++- src/version.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/if_python.c b/src/if_python.c index baf505c594..4a148840b9 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -531,6 +531,12 @@ Python_Init(void) if (PythonMod_Init()) goto fail; + /* Remove the element from sys.path that was added because of our + * argv[0] value in PythonMod_Init(). Previously we used an empty + * string, but dependinding on the OS we then get an empty entry or + * the current directory in sys.path. */ + PyRun_SimpleString("import sys; sys.path = filter(lambda x: x != '/must>not&exist', sys.path)"); + /* the first python thread is vim's, release the lock */ Python_SaveThread(); @@ -2345,7 +2351,8 @@ PythonMod_Init(void) { PyObject *mod; PyObject *dict; - static char *(argv[2]) = {"", NULL}; + /* The special value is removed from sys.path in Python_Init(). */ + static char *(argv[2]) = {"/must>not&exist/foo", NULL}; /* Fixups... */ BufferType.ob_type = &PyType_Type; diff --git a/src/version.c b/src/version.c index a3901f4c96..3529bb0846 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 45, /**/ 44, /**/ From 233164a7d2df1cd8fe4bc642a4b8cd8f58369902 Mon Sep 17 00:00:00 2001 From: vimboss Date: Thu, 20 Nov 2008 10:56:33 +0000 Subject: [PATCH 15/18] updated for version 7.2-046 --- src/mbyte.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mbyte.c b/src/mbyte.c index 134a956004..b7114e8b4f 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -3131,7 +3131,7 @@ enc_locale() else s = p + 1; } - for (i = 0; s[i] != NUL && s + i < buf + sizeof(buf) - 1; ++i) + for (i = 0; s[i] != NUL && i < sizeof(buf) - 1; ++i) { if (s[i] == '_' || s[i] == '-') buf[i] = '-'; diff --git a/src/version.c b/src/version.c index 3529bb0846..b106c951b9 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 46, /**/ 45, /**/ From d50de2f2f09b40f59ccce69130a404b0f83bdd65 Mon Sep 17 00:00:00 2001 From: vimboss Date: Thu, 20 Nov 2008 13:12:36 +0000 Subject: [PATCH 16/18] updated for version 7.2-047 --- src/main.c | 11 ++++++++++- src/version.c | 2 ++ src/vim.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 17cab6d348..a091165968 100644 --- a/src/main.c +++ b/src/main.c @@ -1510,7 +1510,8 @@ parse_command_name(parmp) early_arg_scan(parmp) mparm_T *parmp; { -#if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER) +#if defined(FEAT_XCLIPBOARD) || defined(FEAT_CLIENTSERVER) \ + || !defined(FEAT_NETBEANS_INTG) int argc = parmp->argc; char **argv = parmp->argv; int i; @@ -1582,6 +1583,14 @@ early_arg_scan(parmp) else if (STRICMP(argv[i], "--echo-wid") == 0) echo_wid_arg = TRUE; # endif +# ifndef FEAT_NETBEANS_INTG + else if (strncmp(argv[i], "-nb", (size_t)3) == 0) + { + mch_errmsg(_("'-nb' cannot be used: not enabled at compile time\n")); + mch_exit(2); + } +# endif + } #endif } diff --git a/src/version.c b/src/version.c index b106c951b9..8912575f48 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 47, /**/ 46, /**/ diff --git a/src/vim.h b/src/vim.h index 14405dc557..0a979e4e42 100644 --- a/src/vim.h +++ b/src/vim.h @@ -1986,6 +1986,9 @@ typedef int VimClipboard; /* This is required for the prototypes. */ # endif #endif +#ifndef FEAT_NETBEANS_INTG +# undef NBDEBUG +#endif #ifdef NBDEBUG /* Netbeans debugging. */ # include "nbdebug.h" #else From 1dfdf3ebaa59d75e23ee46b546cb9fe312b6a73e Mon Sep 17 00:00:00 2001 From: vimboss Date: Thu, 20 Nov 2008 15:12:02 +0000 Subject: [PATCH 17/18] updated for version 7.2-048 --- src/eval.c | 9 ++++++--- src/normal.c | 20 ++++++++++++++++++-- src/proto/eval.pro | 2 +- src/version.c | 2 ++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/eval.c b/src/eval.c index 98fc8edf30..00190b09ef 100644 --- a/src/eval.c +++ b/src/eval.c @@ -18146,14 +18146,17 @@ get_vim_var_list(idx) } /* - * Set v:count, v:count1 and v:prevcount. + * Set v:count to "count" and v:count1 to "count1". + * When "set_prevcount" is TRUE first set v:prevcount from v:count. */ void -set_vcount(count, count1) +set_vcount(count, count1, set_prevcount) long count; long count1; + int set_prevcount; { - vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr; + if (set_prevcount) + vimvars[VV_PREVCOUNT].vv_nr = vimvars[VV_COUNT].vv_nr; vimvars[VV_COUNT].vv_nr = count; vimvars[VV_COUNT1].vv_nr = count1; } diff --git a/src/normal.c b/src/normal.c index b9071715a3..0557833bae 100644 --- a/src/normal.c +++ b/src/normal.c @@ -580,6 +580,9 @@ normal_cmd(oap, toplevel) static int old_mapped_len = 0; #endif int idx; +#ifdef FEAT_EVAL + int set_prevcount = FALSE; +#endif vim_memset(&ca, 0, sizeof(ca)); /* also resets ca.retval */ ca.oap = oap; @@ -615,7 +618,12 @@ normal_cmd(oap, toplevel) /* When not finishing an operator and no register name typed, reset the * count. */ if (!finish_op && !oap->regname) + { ca.opcount = 0; +#ifdef FEAT_EVAL + set_prevcount = TRUE; +#endif + } #ifdef FEAT_AUTOCMD /* Restore counts from before receiving K_CURSORHOLD. This means after @@ -719,7 +727,15 @@ getcount: * command, so that v:count can be used in an expression mapping * right after the count. */ if (toplevel && stuff_empty()) - set_vcount(ca.count0, ca.count0 == 0 ? 1 : ca.count0); + { + long count = ca.count0; + + /* multiply with ca.opcount the same way as below */ + if (ca.opcount != 0) + count = ca.opcount * (count == 0 ? 1 : count); + set_vcount(count, count == 0 ? 1 : count, set_prevcount); + set_prevcount = FALSE; /* only set v:prevcount once */ + } #endif if (ctrl_w) { @@ -806,7 +822,7 @@ getcount: * Only set v:count when called from main() and not a stuffed command. */ if (toplevel && stuff_empty()) - set_vcount(ca.count0, ca.count1); + set_vcount(ca.count0, ca.count1, set_prevcount); #endif /* diff --git a/src/proto/eval.pro b/src/proto/eval.pro index 7aabf0ba13..362b9d90fe 100644 --- a/src/proto/eval.pro +++ b/src/proto/eval.pro @@ -61,7 +61,7 @@ void set_vim_var_nr __ARGS((int idx, long val)); long get_vim_var_nr __ARGS((int idx)); char_u *get_vim_var_str __ARGS((int idx)); list_T *get_vim_var_list __ARGS((int idx)); -void set_vcount __ARGS((long count, long count1)); +void set_vcount __ARGS((long count, long count1, int set_prevcount)); void set_vim_var_string __ARGS((int idx, char_u *val, int len)); void set_vim_var_list __ARGS((int idx, list_T *val)); void set_reg_var __ARGS((int c)); diff --git a/src/version.c b/src/version.c index 8912575f48..ee0240ef35 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 48, /**/ 47, /**/ From 09eb973f443248f8494cb6dc9e565161304cac64 Mon Sep 17 00:00:00 2001 From: vimboss Date: Thu, 20 Nov 2008 16:10:17 +0000 Subject: [PATCH 18/18] updated for version 7.2-049 --- src/gui_w32.c | 10 ++--- src/gui_w48.c | 26 ++++++------ src/mbyte.c | 8 ++-- src/misc1.c | 6 +-- src/os_mswin.c | 89 +++++++++++++++++++++++++++--------------- src/os_win32.c | 36 ++++++++--------- src/proto/os_mswin.pro | 8 ++-- src/version.c | 2 + 8 files changed, 106 insertions(+), 79 deletions(-) diff --git a/src/gui_w32.c b/src/gui_w32.c index 9b77f7d69b..a36f9766af 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -992,7 +992,7 @@ _WndProc( SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 500); - tt_text = enc_to_ucs2(str, NULL); + tt_text = enc_to_utf16(str, NULL); lpdi->lpszText = tt_text; /* can't show tooltip if failed */ } @@ -1935,7 +1935,7 @@ GetResultStr(HWND hwnd, int GCS, int *lenp) if (buf == NULL) return NULL; - convbuf = ucs2_to_enc(buf, lenp); + convbuf = utf16_to_enc(buf, lenp); pImmReleaseContext(hwnd, hIMC); vim_free(buf); return convbuf; @@ -2566,7 +2566,7 @@ gui_mch_add_menu( { /* 'encoding' differs from active codepage: convert menu name * and use wide function */ - wn = enc_to_ucs2(menu->name, NULL); + wn = enc_to_utf16(menu->name, NULL); if (wn != NULL) { MENUITEMINFOW infow; @@ -2728,7 +2728,7 @@ gui_mch_add_menu_item( { /* 'encoding' differs from active codepage: convert menu item name * and use wide function */ - wn = enc_to_ucs2(menu->name, NULL); + wn = enc_to_utf16(menu->name, NULL); if (wn != NULL) { n = InsertMenuW(parent->submenu_id, (UINT)idx, @@ -3570,7 +3570,7 @@ nCopyAnsiToWideChar( if (enc_codepage == 0 && (int)GetACP() != enc_codepage) { /* Not a codepage, use our own conversion function. */ - wn = enc_to_ucs2(lpAnsiIn, NULL); + wn = enc_to_utf16(lpAnsiIn, NULL); if (wn != NULL) { wcscpy(lpWCStr, wn); diff --git a/src/gui_w48.c b/src/gui_w48.c index 53dbad112b..08dcb2d0a2 100644 --- a/src/gui_w48.c +++ b/src/gui_w48.c @@ -547,7 +547,7 @@ char_to_string(int ch, char_u *string, int slen, int had_alt) else { len = 1; - ws = ucs2_to_enc(wstring, &len); + ws = utf16_to_enc(wstring, &len); if (ws == NULL) len = 0; else @@ -2128,7 +2128,7 @@ GetTextWidthEnc(HDC hdc, char_u *str, int len) { /* 'encoding' differs from active codepage: convert text and use wide * function */ - wstr = enc_to_ucs2(str, &wlen); + wstr = enc_to_utf16(str, &wlen); if (wstr != NULL) { n = GetTextExtentPointW(hdc, wstr, wlen, &size); @@ -2252,7 +2252,7 @@ add_tabline_popup_menu_entry(HMENU pmenu, UINT item_id, char_u *item_text) { /* 'encoding' differs from active codepage: convert menu name * and use wide function */ - wn = enc_to_ucs2(item_text, NULL); + wn = enc_to_utf16(item_text, NULL); if (wn != NULL) { MENUITEMINFOW infow; @@ -2422,7 +2422,7 @@ gui_mch_update_tabline(void) if (use_unicode) { /* Need to go through Unicode. */ - wstr = enc_to_ucs2(NameBuff, NULL); + wstr = enc_to_utf16(NameBuff, NULL); if (wstr != NULL) { TCITEMW tiw; @@ -2521,8 +2521,8 @@ set_window_title(HWND hwnd, char *title) WCHAR *wbuf; int n; - /* Convert the title from 'encoding' to ucs2. */ - wbuf = (WCHAR *)enc_to_ucs2((char_u *)title, NULL); + /* Convert the title from 'encoding' to UTF-16. */ + wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL); if (wbuf != NULL) { n = SetWindowTextW(hwnd, wbuf); @@ -3222,7 +3222,7 @@ gui_mch_browseW( char_u *initdir, char_u *filter) { - /* We always use the wide function. This means enc_to_ucs2() must work, + /* We always use the wide function. This means enc_to_utf16() must work, * otherwise it fails miserably! */ OPENFILENAMEW fileStruct; WCHAR fileBuf[MAXPATHL]; @@ -3238,7 +3238,7 @@ gui_mch_browseW( fileBuf[0] = NUL; else { - wp = enc_to_ucs2(dflt, NULL); + wp = enc_to_utf16(dflt, NULL); if (wp == NULL) fileBuf[0] = NUL; else @@ -3263,11 +3263,11 @@ gui_mch_browseW( #endif if (title != NULL) - titlep = enc_to_ucs2(title, NULL); + titlep = enc_to_utf16(title, NULL); fileStruct.lpstrTitle = titlep; if (ext != NULL) - extp = enc_to_ucs2(ext, NULL); + extp = enc_to_utf16(ext, NULL); fileStruct.lpstrDefExt = extp; fileStruct.lpstrFile = fileBuf; @@ -3278,7 +3278,7 @@ gui_mch_browseW( if (initdir != NULL && *initdir != NUL) { /* Must have backslashes here, no matter what 'shellslash' says */ - initdirp = enc_to_ucs2(initdir, NULL); + initdirp = enc_to_utf16(initdir, NULL); if (initdirp != NULL) { for (wp = initdirp; *wp != NUL; ++wp) @@ -3318,7 +3318,7 @@ gui_mch_browseW( vim_free(extp); /* Convert from UCS2 to 'encoding'. */ - p = ucs2_to_enc(fileBuf, NULL); + p = utf16_to_enc(fileBuf, NULL); if (p != NULL) /* when out of memory we get garbage for non-ASCII chars */ STRCPY(fileBuf, p); @@ -3518,7 +3518,7 @@ _OnDropFiles( { #ifdef FEAT_MBYTE if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0) - fnames[i] = ucs2_to_enc(wszFile, NULL); + fnames[i] = utf16_to_enc(wszFile, NULL); else #endif { diff --git a/src/mbyte.c b/src/mbyte.c index b7114e8b4f..a2ffd7e5f9 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -6101,7 +6101,7 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp) /* 1. codepage/UTF-8 -> ucs-2. */ if (vcp->vc_cpfrom == 0) - tmp_len = utf8_to_ucs2(ptr, len, NULL, NULL); + tmp_len = utf8_to_utf16(ptr, len, NULL, NULL); else tmp_len = MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, 0, 0); @@ -6109,13 +6109,13 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp) if (tmp == NULL) break; if (vcp->vc_cpfrom == 0) - utf8_to_ucs2(ptr, len, tmp, unconvlenp); + utf8_to_utf16(ptr, len, tmp, unconvlenp); else MultiByteToWideChar(vcp->vc_cpfrom, 0, ptr, len, tmp, tmp_len); /* 2. ucs-2 -> codepage/UTF-8. */ if (vcp->vc_cpto == 0) - retlen = ucs2_to_utf8(tmp, tmp_len, NULL); + retlen = utf16_to_utf8(tmp, tmp_len, NULL); else retlen = WideCharToMultiByte(vcp->vc_cpto, 0, tmp, tmp_len, 0, 0, 0, 0); @@ -6123,7 +6123,7 @@ string_convert_ext(vcp, ptr, lenp, unconvlenp) if (retval != NULL) { if (vcp->vc_cpto == 0) - ucs2_to_utf8(tmp, tmp_len, retval); + utf16_to_utf8(tmp, tmp_len, retval); else WideCharToMultiByte(vcp->vc_cpto, 0, tmp, tmp_len, retval, retlen, 0, 0); diff --git a/src/misc1.c b/src/misc1.c index 727951febe..0487290247 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -8728,7 +8728,7 @@ dos_expandpath( /* The active codepage differs from 'encoding'. Attempt using the * wide function. If it fails because it is not implemented fall back * to the non-wide version (for Windows 98) */ - wn = enc_to_ucs2(buf, NULL); + wn = enc_to_utf16(buf, NULL); if (wn != NULL) { hFind = FindFirstFileW(wn, &wfb); @@ -8756,7 +8756,7 @@ dos_expandpath( #ifdef WIN3264 # ifdef FEAT_MBYTE if (wn != NULL) - p = ucs2_to_enc(wfb.cFileName, NULL); /* p is allocated here */ + p = utf16_to_enc(wfb.cFileName, NULL); /* p is allocated here */ else # endif p = (char_u *)fb.cFileName; @@ -8830,7 +8830,7 @@ dos_expandpath( if (wn != NULL) { vim_free(wn); - wn = enc_to_ucs2(buf, NULL); + wn = enc_to_utf16(buf, NULL); if (wn != NULL) hFind = FindFirstFileW(wn, &wfb); } diff --git a/src/os_mswin.c b/src/os_mswin.c index b2eee923c8..32a068f6bb 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -309,7 +309,7 @@ mch_settitle( if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { /* Convert the title from 'encoding' to the active codepage. */ - WCHAR *wp = enc_to_ucs2(title, NULL); + WCHAR *wp = enc_to_utf16(title, NULL); int n; if (wp != NULL) @@ -406,10 +406,10 @@ mch_FullName( * - invoke _wfullpath() * - convert the result from UCS2 to 'encoding'. */ - wname = enc_to_ucs2(fname, NULL); + wname = enc_to_utf16(fname, NULL); if (wname != NULL && _wfullpath(wbuf, wname, MAX_PATH - 1) != NULL) { - cname = ucs2_to_enc((short_u *)wbuf, NULL); + cname = utf16_to_enc((short_u *)wbuf, NULL); if (cname != NULL) { vim_strncpy(buf, cname, len - 1); @@ -507,7 +507,7 @@ vim_stat(const char *name, struct stat *stp) # endif ) { - WCHAR *wp = enc_to_ucs2(buf, NULL); + WCHAR *wp = enc_to_utf16(buf, NULL); int n; if (wp != NULL) @@ -668,7 +668,7 @@ mch_chdir(char *path) #ifdef FEAT_MBYTE if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - WCHAR *p = enc_to_ucs2(path, NULL); + WCHAR *p = enc_to_utf16(path, NULL); int n; if (p != NULL) @@ -891,19 +891,20 @@ mch_libcall( #if defined(FEAT_MBYTE) || defined(PROTO) /* - * Convert an UTF-8 string to UCS-2. + * Convert an UTF-8 string to UTF-16. * "instr[inlen]" is the input. "inlen" is in bytes. - * When "outstr" is NULL only return the number of UCS-2 words produced. + * When "outstr" is NULL only return the number of UTF-16 words produced. * Otherwise "outstr" must be a buffer of sufficient size. - * Returns the number of UCS-2 words produced. + * Returns the number of UTF-16 words produced. */ int -utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp) +utf8_to_utf16(char_u *instr, int inlen, short_u *outstr, int *unconvlenp) { int outlen = 0; char_u *p = instr; int todo = inlen; int l; + int ch; while (todo > 0) { @@ -917,8 +918,19 @@ utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp) break; } - if (outstr != NULL) - *outstr++ = utf_ptr2char(p); + ch = utf_ptr2char(p); + if (ch >= 0x10000) + { + /* non-BMP character, encoding with surrogate pairs */ + ++outlen; + if (outstr != NULL) + { + *outstr++ = (0xD800 - (0x10000 >> 10)) + (ch >> 10); + *outstr++ = 0xDC00 | (ch & 0x3FF); + } + } + else if (outstr != NULL) + *outstr++ = ch; ++outlen; p += l; todo -= l; @@ -928,29 +940,42 @@ utf8_to_ucs2(char_u *instr, int inlen, short_u *outstr, int *unconvlenp) } /* - * Convert an UCS-2 string to UTF-8. - * The input is "instr[inlen]" with "inlen" in number of ucs-2 words. + * Convert an UTF-16 string to UTF-8. + * The input is "instr[inlen]" with "inlen" in number of UTF-16 words. * When "outstr" is NULL only return the required number of bytes. * Otherwise "outstr" must be a buffer of sufficient size. * Return the number of bytes produced. */ int -ucs2_to_utf8(short_u *instr, int inlen, char_u *outstr) +utf16_to_utf8(short_u *instr, int inlen, char_u *outstr) { int outlen = 0; int todo = inlen; short_u *p = instr; int l; + int ch, ch2; while (todo > 0) { + ch = *p; + if (ch >= 0xD800 && ch <= 0xDBFF && todo > 1) + { + /* surrogate pairs handling */ + ch2 = p[1]; + if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) + { + ch = ((ch - 0xD800) << 10) + (ch2 & 0x3FF) + 0x10000; + ++p; + --todo; + } + } if (outstr != NULL) { - l = utf_char2bytes(*p, outstr); + l = utf_char2bytes(ch, outstr); outstr += l; } else - l = utf_char2len(*p); + l = utf_char2len(ch); ++p; outlen += l; --todo; @@ -1079,14 +1104,14 @@ crnl_to_nl(const char_u *str, int *size) */ /* - * Convert "str" from 'encoding' to UCS-2. + * Convert "str" from 'encoding' to UTF-16. * Input in "str" with length "*lenp". When "lenp" is NULL, use strlen(). * Output is returned as an allocated string. "*lenp" is set to the length of * the result. A trailing NUL is always added. * Returns NULL when out of memory. */ short_u * -enc_to_ucs2(char_u *str, int *lenp) +enc_to_utf16(char_u *str, int *lenp) { vimconv_T conv; WCHAR *ret; @@ -1102,7 +1127,7 @@ enc_to_ucs2(char_u *str, int *lenp) if (enc_codepage > 0) { - /* We can do any CP### -> UCS-2 in one pass, and we can do it + /* We can do any CP### -> UTF-16 in one pass, and we can do it * without iconv() (convert_* may need iconv). */ MultiByteToWideChar_alloc(enc_codepage, 0, str, *lenp, &ret, &length); } @@ -1123,11 +1148,11 @@ enc_to_ucs2(char_u *str, int *lenp) } convert_setup(&conv, NULL, NULL); - length = utf8_to_ucs2(str, *lenp, NULL, NULL); + length = utf8_to_utf16(str, *lenp, NULL, NULL); ret = (WCHAR *)alloc((unsigned)((length + 1) * sizeof(WCHAR))); if (ret != NULL) { - utf8_to_ucs2(str, *lenp, (short_u *)ret, NULL); + utf8_to_utf16(str, *lenp, (short_u *)ret, NULL); ret[length] = 0; } @@ -1139,7 +1164,7 @@ enc_to_ucs2(char_u *str, int *lenp) } /* - * Convert an UCS-2 string to 'encoding'. + * Convert an UTF-16 string to 'encoding'. * Input in "str" with length (counted in wide characters) "*lenp". When * "lenp" is NULL, use wcslen(). * Output is returned as an allocated string. If "*lenp" is not NULL it is @@ -1147,7 +1172,7 @@ enc_to_ucs2(char_u *str, int *lenp) * Returns NULL when out of memory. */ char_u * -ucs2_to_enc(short_u *str, int *lenp) +utf16_to_enc(short_u *str, int *lenp) { vimconv_T conv; char_u *utf8_str = NULL, *enc_str = NULL; @@ -1161,7 +1186,7 @@ ucs2_to_enc(short_u *str, int *lenp) if (enc_codepage > 0) { - /* We can do any UCS-2 -> CP### in one pass. */ + /* We can do any UTF-16 -> CP### in one pass. */ int length; WideCharToMultiByte_alloc(enc_codepage, 0, str, *lenp, @@ -1171,10 +1196,10 @@ ucs2_to_enc(short_u *str, int *lenp) } /* Avoid allocating zero bytes, it generates an error message. */ - utf8_str = alloc(ucs2_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL)); + utf8_str = alloc(utf16_to_utf8(str, *lenp == 0 ? 1 : *lenp, NULL)); if (utf8_str != NULL) { - *lenp = ucs2_to_utf8(str, *lenp, utf8_str); + *lenp = utf16_to_utf8(str, *lenp, utf8_str); /* We might be called before we have p_enc set up. */ conv.vc_type = CONV_NONE; @@ -1308,7 +1333,7 @@ clip_mch_request_selection(VimClipboard *cbd) if (hMemWstr[str_size] == NUL) break; } - to_free = str = ucs2_to_enc((short_u *)hMemWstr, &str_size); + to_free = str = utf16_to_enc((short_u *)hMemWstr, &str_size); GlobalUnlock(hMemW); } } @@ -1340,7 +1365,7 @@ clip_mch_request_selection(VimClipboard *cbd) # if defined(FEAT_MBYTE) && defined(WIN3264) /* The text is in the active codepage. Convert to 'encoding', - * going through UCS-2. */ + * going through UTF-16. */ acp_to_enc(str, str_size, &to_free, &maxlen); if (to_free != NULL) { @@ -1404,7 +1429,7 @@ acp_to_enc(str, str_size, out, outlen) if (widestr != NULL) { ++*outlen; /* Include the 0 after the string */ - *out = ucs2_to_enc((short_u *)widestr, outlen); + *out = utf16_to_enc((short_u *)widestr, outlen); vim_free(widestr); } } @@ -1466,9 +1491,9 @@ clip_mch_set_selection(VimClipboard *cbd) WCHAR *out; int len = metadata.txtlen; - /* Convert the text to UCS-2. This is put on the clipboard as + /* Convert the text to UTF-16. This is put on the clipboard as * CF_UNICODETEXT. */ - out = (WCHAR *)enc_to_ucs2(str, &len); + out = (WCHAR *)enc_to_utf16(str, &len); if (out != NULL) { WCHAR *lpszMemW; @@ -1488,7 +1513,7 @@ clip_mch_set_selection(VimClipboard *cbd) WideCharToMultiByte(GetACP(), 0, out, len, str, metadata.txtlen, 0, 0); - /* Allocate memory for the UCS-2 text, add one NUL word to + /* Allocate memory for the UTF-16 text, add one NUL word to * terminate the string. */ hMemW = (LPSTR)GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (len + 1) * sizeof(WCHAR)); diff --git a/src/os_win32.c b/src/os_win32.c index 4844299210..3d0ba7ddfd 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -1587,7 +1587,7 @@ executable_exists(char *name) #ifdef FEAT_MBYTE if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - WCHAR *p = enc_to_ucs2(name, NULL); + WCHAR *p = enc_to_utf16(name, NULL); WCHAR fnamew[_MAX_PATH]; WCHAR *dumw; long n; @@ -2440,7 +2440,7 @@ mch_dirname( if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0) { - char_u *p = ucs2_to_enc(wbuf, NULL); + char_u *p = utf16_to_enc(wbuf, NULL); if (p != NULL) { @@ -2466,7 +2466,7 @@ mch_getperm(char_u *name) #ifdef FEAT_MBYTE if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - WCHAR *p = enc_to_ucs2(name, NULL); + WCHAR *p = enc_to_utf16(name, NULL); long n; if (p != NULL) @@ -2495,7 +2495,7 @@ mch_setperm( #ifdef FEAT_MBYTE if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - WCHAR *p = enc_to_ucs2(name, NULL); + WCHAR *p = enc_to_utf16(name, NULL); long n; if (p != NULL) @@ -2522,7 +2522,7 @@ mch_hide(char_u *name) WCHAR *p = NULL; if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) - p = enc_to_ucs2(name, NULL); + p = enc_to_utf16(name, NULL); #endif #ifdef FEAT_MBYTE @@ -2590,7 +2590,7 @@ mch_is_linked(char_u *fname) WCHAR *wn = NULL; if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) - wn = enc_to_ucs2(fname, NULL); + wn = enc_to_utf16(fname, NULL); if (wn != NULL) { hFile = CreateFileW(wn, /* file name */ @@ -4239,7 +4239,7 @@ mch_remove(char_u *name) if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - wn = enc_to_ucs2(name, NULL); + wn = enc_to_utf16(name, NULL); if (wn != NULL) { SetFileAttributesW(wn, FILE_ATTRIBUTE_NORMAL); @@ -4382,8 +4382,8 @@ mch_rename( if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - wold = enc_to_ucs2((char_u *)pszOldFile, NULL); - wnew = enc_to_ucs2((char_u *)pszNewFile, NULL); + wold = enc_to_utf16((char_u *)pszOldFile, NULL); + wnew = enc_to_utf16((char_u *)pszNewFile, NULL); if (wold != NULL && wnew != NULL) retval = mch_wrename(wold, wnew); vim_free(wold); @@ -4492,7 +4492,7 @@ mch_access(char *n, int p) WCHAR *wn = NULL; if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) - wn = enc_to_ucs2(n, NULL); + wn = enc_to_utf16(n, NULL); #endif if (mch_isdir(n)) @@ -4618,7 +4618,7 @@ getout: #if defined(FEAT_MBYTE) || defined(PROTO) /* - * Version of open() that may use ucs2 file name. + * Version of open() that may use UTF-16 file name. */ int mch_open(char *name, int flags, int mode) @@ -4630,7 +4630,7 @@ mch_open(char *name, int flags, int mode) if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - wn = enc_to_ucs2(name, NULL); + wn = enc_to_utf16(name, NULL); if (wn != NULL) { f = _wopen(wn, flags, mode); @@ -4648,7 +4648,7 @@ mch_open(char *name, int flags, int mode) } /* - * Version of fopen() that may use ucs2 file name. + * Version of fopen() that may use UTF-16 file name. */ FILE * mch_fopen(char *name, char *mode) @@ -4675,8 +4675,8 @@ mch_fopen(char *name, char *mode) else if (newMode == 'b') _set_fmode(_O_BINARY); # endif - wn = enc_to_ucs2(name, NULL); - wm = enc_to_ucs2(mode, NULL); + wn = enc_to_utf16(name, NULL); + wm = enc_to_utf16(mode, NULL); if (wn != NULL && wm != NULL) f = _wfopen(wn, wm); vim_free(wn); @@ -4776,8 +4776,8 @@ copy_infostreams(char_u *from, char_u *to) int len; /* Convert the file names to wide characters. */ - fromw = enc_to_ucs2(from, NULL); - tow = enc_to_ucs2(to, NULL); + fromw = enc_to_utf16(from, NULL); + tow = enc_to_utf16(to, NULL); if (fromw != NULL && tow != NULL) { /* Open the file for reading. */ @@ -5122,7 +5122,7 @@ fix_arg_enc(void) for (i = 0; i < used_file_count; ++i) { idx = used_file_indexes[i]; - str = ucs2_to_enc(ArglistW[idx], NULL); + str = utf16_to_enc(ArglistW[idx], NULL); if (str != NULL) { #ifdef FEAT_DIFF diff --git a/src/proto/os_mswin.pro b/src/proto/os_mswin.pro index 752a27ba8d..2bf927d019 100644 --- a/src/proto/os_mswin.pro +++ b/src/proto/os_mswin.pro @@ -22,14 +22,14 @@ int mch_chdir __ARGS((char *path)); int can_end_termcap_mode __ARGS((int give_msg)); int mch_screenmode __ARGS((char_u *arg)); int mch_libcall __ARGS((char_u *libname, char_u *funcname, char_u *argstring, int argint, char_u **string_result, int *number_result)); -int utf8_to_ucs2 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp)); -int ucs2_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr)); +int utf8_to_utf16 __ARGS((char_u *instr, int inlen, short_u *outstr, int *unconvlenp)); +int utf16_to_utf8 __ARGS((short_u *instr, int inlen, char_u *outstr)); void MultiByteToWideChar_alloc __ARGS((UINT cp, DWORD flags, LPCSTR in, int inlen, LPWSTR *out, int *outlen)); void WideCharToMultiByte_alloc __ARGS((UINT cp, DWORD flags, LPCWSTR in, int inlen, LPSTR *out, int *outlen, LPCSTR def, LPBOOL useddef)); int clip_mch_own_selection __ARGS((VimClipboard *cbd)); void clip_mch_lose_selection __ARGS((VimClipboard *cbd)); -short_u *enc_to_ucs2 __ARGS((char_u *str, int *lenp)); -char_u *ucs2_to_enc __ARGS((short_u *str, int *lenp)); +short_u *enc_to_utf16 __ARGS((char_u *str, int *lenp)); +char_u *utf16_to_enc __ARGS((short_u *str, int *lenp)); void clip_mch_request_selection __ARGS((VimClipboard *cbd)); void acp_to_enc __ARGS((char_u *str, int str_size, char_u **out, int *outlen)); void clip_mch_set_selection __ARGS((VimClipboard *cbd)); diff --git a/src/version.c b/src/version.c index ee0240ef35..242041fc19 100644 --- a/src/version.c +++ b/src/version.c @@ -676,6 +676,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 49, /**/ 48, /**/