]> granicus.if.org Git - vim/commitdiff
updated for version 7.1-126 v7.1.126
authorBram Moolenaar <Bram@vim.org>
Sun, 30 Sep 2007 12:02:55 +0000 (12:02 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 30 Sep 2007 12:02:55 +0000 (12:02 +0000)
src/buffer.c
src/ex_docmd.c
src/fileio.c
src/gui_gtk.c
src/gui_w48.c
src/proto/ex_docmd.pro
src/proto/fileio.pro
src/quickfix.c
src/version.c

index c29fb236ef0b34d286edfcca785f30081f57c30e..9f4c3deb4919a8b039fc237a372e2689f2fb0ad3 100644 (file)
@@ -4261,12 +4261,12 @@ alist_name(aep)
 do_arg_all(count, forceit, keep_tabs)
     int        count;
     int        forceit;                /* hide buffers in current windows */
-    int keep_tabs;             /* keep curren tabs, for ":tab drop file" */
+    int keep_tabs;             /* keep current tabs, for ":tab drop file" */
 {
     int                i;
     win_T      *wp, *wpnext;
     char_u     *opened;        /* array of flags for which args are open */
-    int                opened_len;     /* lenght of opened[] */
+    int                opened_len;     /* length of opened[] */
     int                use_firstwin = FALSE;   /* use first window for arglist */
     int                split_ret = OK;
     int                p_ea_save;
@@ -4946,10 +4946,7 @@ read_viminfo_bufferlist(virp, writing)
        /* Expand "~/" in the file name at "line + 1" to a full path.
         * Then try shortening it by comparing with the current directory */
        expand_env(xline, NameBuff, MAXPATHL);
-       mch_dirname(IObuff, IOSIZE);
-       sfname = shorten_fname(NameBuff, IObuff);
-       if (sfname == NULL)
-           sfname = NameBuff;
+       sfname = shorten_fname1(NameBuff);
 
        buf = buflist_new(NameBuff, sfname, (linenr_T)0, BLN_LISTED);
        if (buf != NULL)        /* just in case... */
index 3b874e79c2673a9bee60f72d05063ba589f561a1..72b939bdb67d6c6e60a6fad3acfdee7b2ea128ab 100644 (file)
@@ -276,7 +276,6 @@ static void ex_popup __ARGS((exarg_T *eap));
 static void    ex_swapname __ARGS((exarg_T *eap));
 static void    ex_syncbind __ARGS((exarg_T *eap));
 static void    ex_read __ARGS((exarg_T *eap));
-static void    ex_cd __ARGS((exarg_T *eap));
 static void    ex_pwd __ARGS((exarg_T *eap));
 static void    ex_equal __ARGS((exarg_T *eap));
 static void    ex_sleep __ARGS((exarg_T *eap));
@@ -7778,7 +7777,7 @@ free_cd_dir()
 /*
  * ":cd", ":lcd", ":chdir" and ":lchdir".
  */
-    static void
+    void
 ex_cd(eap)
     exarg_T    *eap;
 {
index 84416df083986feeabe8cf70d05d22e28eb9b60e..39b4226355d5311ab44458edba17b39190addf62 100644 (file)
@@ -114,7 +114,7 @@ struct bw_info
 {
     int                bw_fd;          /* file descriptor */
     char_u     *bw_buf;        /* buffer with data to be written */
-    int                bw_len; /* lenght of data */
+    int                bw_len;         /* length of data */
 #ifdef HAS_BW_FLAGS
     int                bw_flags;       /* FIO_ flags */
 #endif
@@ -5553,6 +5553,27 @@ make_bom(buf, name)
 }
 #endif
 
+/*
+ * Try to find a shortname by comparing the fullname with the current
+ * directory.
+ * Returns "full_path" or pointer into "full_path" if shortened.
+ */
+    char_u *
+shorten_fname1(full_path)
+    char_u     *full_path;
+{
+    char_u     dirname[MAXPATHL];
+    char_u     *p = full_path;
+
+    if (mch_dirname(dirname, MAXPATHL) == OK)
+    {
+       p = shorten_fname(full_path, dirname);
+       if (p == NULL || *p == NUL)
+           p = full_path;
+    }
+    return p;
+}
+
 /*
  * Try to find a shortname by comparing the fullname with the current
  * directory.
index cfba5c7647760ae3c57acbcfb68417674ed84296..740d4a044e04b41315cc883a3b1a6c1b78211fcf 100644 (file)
@@ -1272,7 +1272,6 @@ gui_mch_browse(int saving,
     GtkWidget          *fc;
 #endif
     char_u             dirbuf[MAXPATHL];
-    char_u             *p;
 
 # ifdef HAVE_GTK2
     title = CONVERT_TO_UTF8(title);
@@ -1363,11 +1362,7 @@ gui_mch_browse(int saving,
        return NULL;
 
     /* shorten the file name if possible */
-    mch_dirname(dirbuf, MAXPATHL);
-    p = shorten_fname(gui.browse_fname, dirbuf);
-    if (p == NULL)
-       p = gui.browse_fname;
-    return vim_strsave(p);
+    return vim_strsave(shorten_fname1(gui.browse_fname));
 }
 
 #if defined(HAVE_GTK2) || defined(PROTO)
@@ -1427,11 +1422,7 @@ gui_mch_browsedir(
        return NULL;
 
     /* shorten the file name if possible */
-    mch_dirname(dirbuf, MAXPATHL);
-    p = shorten_fname(dirname, dirbuf);
-    if (p == NULL || *p == NUL)
-       p = dirname;
-    p = vim_strsave(p);
+    p = vim_strsave(shorten_fname1(dirname));
     g_free(dirname);
     return p;
 
index f0739263faff62c34772651d463f3fb0e4645ebc..cfbbbc00b4c025bffe317c130fd863a91601cc5e 100644 (file)
@@ -3301,11 +3301,7 @@ gui_mch_browseW(
     SetFocus(s_hwnd);
 
     /* Shorten the file name if possible */
-    mch_dirname(IObuff, IOSIZE);
-    p = shorten_fname((char_u *)fileBuf, IObuff);
-    if (p == NULL)
-       p = (char_u *)fileBuf;
-    return vim_strsave(p);
+    return vim_strsave(shorten_fname1((char_u *)fileBuf));
 }
 # endif /* FEAT_MBYTE */
 
@@ -3450,11 +3446,7 @@ gui_mch_browse(
     SetFocus(s_hwnd);
 
     /* Shorten the file name if possible */
-    mch_dirname(IObuff, IOSIZE);
-    p = shorten_fname((char_u *)fileBuf, IObuff);
-    if (p == NULL)
-       p = (char_u *)fileBuf;
-    return vim_strsave(p);
+    return vim_strsave(shorten_fname1((char_u *)fileBuf));
 }
 #endif /* FEAT_BROWSE */
 
index 899c68e490b48e2d651d085524aa1dd21a69e6df..22a0f103ceec4286bcbd7234e95d3eab31787d67 100644 (file)
@@ -39,6 +39,7 @@ void ex_splitview __ARGS((exarg_T *eap));
 void tabpage_new __ARGS((void));
 void do_exedit __ARGS((exarg_T *eap, win_T *old_curwin));
 void free_cd_dir __ARGS((void));
+void ex_cd __ARGS((exarg_T *eap));
 void do_sleep __ARGS((long msec));
 int vim_mkdir_emsg __ARGS((char_u *name, int prot));
 FILE *open_exfile __ARGS((char_u *fname, int forceit, char *mode));
index fd7a04f62b47f68c307540cde8efafddd124fbc7..e5a1b284aec5c7659839075d4bf731f00cfd397e 100644 (file)
@@ -6,6 +6,7 @@ int check_file_readonly __ARGS((char_u *fname, int perm));
 int buf_write __ARGS((buf_T *buf, char_u *fname, char_u *sfname, linenr_T start, linenr_T end, exarg_T *eap, int append, int forceit, int reset_changed, int filtering));
 void msg_add_fname __ARGS((buf_T *buf, char_u *fname));
 void msg_add_lines __ARGS((int insert_space, long lnum, long nchars));
+char_u *shorten_fname1 __ARGS((char_u *full_path));
 char_u *shorten_fname __ARGS((char_u *full_path, char_u *dir_name));
 void shorten_fnames __ARGS((int force));
 void shorten_filenames __ARGS((char_u **fnames, int count));
index c3cee13a1aecf32ae8ee95b5c9325d2fa68b5468..32c6cd08d4e7dce529844928c07efbdc6235d205 100644 (file)
@@ -2972,6 +2972,7 @@ ex_vimgrep(eap)
     regmmatch_T        regmatch;
     int                fcount;
     char_u     **fnames;
+    char_u     *fname;
     char_u     *s;
     char_u     *p;
     int                fi;
@@ -2995,6 +2996,9 @@ ex_vimgrep(eap)
     int                flags = 0;
     colnr_T    col;
     long       tomatch;
+    char_u     dirname_start[MAXPATHL];
+    char_u     dirname_now[MAXPATHL];
+    char_u     *target_dir = NULL;
 
     switch (eap->cmdidx)
     {
@@ -3069,17 +3073,23 @@ ex_vimgrep(eap)
        goto theend;
     }
 
+    /* Remember the current directory, because a BufRead autocommand that does
+     * ":lcd %:p:h" changes the meaning of short path names. */
+    mch_dirname(dirname_start, MAXPATHL);
+
     seconds = (time_t)0;
     for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi)
     {
+       fname = shorten_fname1(fnames[fi]);
        if (time(NULL) > seconds)
        {
-           /* Display the file name every second or so. */
+           /* Display the file name every second or so, show the user we are
+            * working on it. */
            seconds = time(NULL);
            msg_start();
-           p = msg_strtrunc(fnames[fi], TRUE);
+           p = msg_strtrunc(fname, TRUE);
            if (p == NULL)
-               msg_outtrans(fnames[fi]);
+               msg_outtrans(fname);
            else
            {
                msg_outtrans(p);
@@ -3111,7 +3121,19 @@ ex_vimgrep(eap)
 
            /* Load file into a buffer, so that 'fileencoding' is detected,
             * autocommands applied, etc. */
-           buf = load_dummy_buffer(fnames[fi]);
+           buf = load_dummy_buffer(fname);
+
+           /* When autocommands changed directory: go back.  We assume it was
+            * ":lcd %:p:h". */
+           mch_dirname(dirname_now, MAXPATHL);
+           if (STRCMP(dirname_start, dirname_now) != 0)
+           {
+               exarg_T ea;
+
+               ea.arg = dirname_start;
+               ea.cmdidx = CMD_lcd;
+               ex_cd(&ea);
+           }
 
            p_mls = save_mls;
 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
@@ -3125,7 +3147,7 @@ ex_vimgrep(eap)
        if (buf == NULL)
        {
            if (!got_int)
-               smsg((char_u *)_("Cannot open file \"%s\""), fnames[fi]);
+               smsg((char_u *)_("Cannot open file \"%s\""), fname);
        }
        else
        {
@@ -3139,9 +3161,10 @@ ex_vimgrep(eap)
                while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
                                                                     col) > 0)
                {
+                   ;
                    if (qf_add_entry(qi, &prevp,
                                NULL,       /* dir */
-                               fnames[fi],
+                               fname,
                                0,
                                ml_get_buf(buf,
                                     regmatch.startpos[0].lnum + lnum, FALSE),
@@ -3209,6 +3232,13 @@ ex_vimgrep(eap)
 
                if (buf != NULL)
                {
+                   /* If the buffer is still loaded we need to use the
+                    * directory we jumped to below. */
+                   if (buf == first_match_buf
+                           && target_dir == NULL
+                           && STRCMP(dirname_start, dirname_now) != 0)
+                       target_dir = vim_strsave(dirname_now);
+
                    /* The buffer is still loaded, the Filetype autocommands
                     * need to be done now, in that buffer.  And the modelines
                     * need to be done (again).  But not the window-local
@@ -3252,6 +3282,16 @@ ex_vimgrep(eap)
                /* If we jumped to another buffer redrawing will already be
                 * taken care of. */
                redraw_for_dummy = FALSE;
+
+           /* Jump to the directory used after loading the buffer. */
+           if (curbuf == first_match_buf && target_dir != NULL)
+           {
+               exarg_T ea;
+
+               ea.arg = target_dir;
+               ea.cmdidx = CMD_lcd;
+               ex_cd(&ea);
+           }
        }
     }
     else
@@ -3269,6 +3309,7 @@ ex_vimgrep(eap)
     }
 
 theend:
+    vim_free(target_dir);
     vim_free(regmatch.regprog);
 }
 
index eef1e8869afdd12e90cb586d686bcfad40ac61b5..6714a9205ad14a726d069796c312e2eb61433e1e 100644 (file)
@@ -666,6 +666,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    126,
 /**/
     125,
 /**/