• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisãoc19f6b8d0393dd28a2673da19e8acef59d371f65 (tree)
Hora2008-05-30 04:47:13
Autorvimboss
Commitervimboss

Mensagem de Log

updated for version 7.1-304

Mudança Sumário

Diff

diff -r fe3ec5ea62f7 -r c19f6b8d0393 src/eval.c
--- a/src/eval.c Thu May 29 13:36:10 2008 +0000
+++ b/src/eval.c Thu May 29 19:47:13 2008 +0000
@@ -21068,8 +21068,12 @@
2106821068 static int shortpath_for_partial __ARGS((char_u **fnamep, char_u **bufp, int *fnamelen));
2106921069
2107021070 /*
21071- * Get the short pathname of a file.
21072- * Returns 1 on success. *fnamelen is 0 for nonexistent path.
21071+ * Get the short path (8.3) for the filename in "fnamep".
21072+ * Only works for a valid file name.
21073+ * When the path gets longer "fnamep" is changed and the allocated buffer
21074+ * is put in "bufp".
21075+ * *fnamelen is the length of "fnamep" and set to 0 for a nonexistent path.
21076+ * Returns OK on success, FAIL on failure.
2107321077 */
2107421078 static int
2107521079 get_short_pathname(fnamep, bufp, fnamelen)
@@ -21077,36 +21081,44 @@
2107721081 char_u **bufp;
2107821082 int *fnamelen;
2107921083 {
21080- int l,len;
21084+ int l, len;
2108121085 char_u *newbuf;
2108221086
2108321087 len = *fnamelen;
21084-
2108521088 l = GetShortPathName(*fnamep, *fnamep, len);
2108621089 if (l > len - 1)
2108721090 {
2108821091 /* If that doesn't work (not enough space), then save the string
21089- * and try again with a new buffer big enough
21090- */
21092+ * and try again with a new buffer big enough. */
2109121093 newbuf = vim_strnsave(*fnamep, l);
2109221094 if (newbuf == NULL)
21093- return 0;
21095+ return FAIL;
2109421096
2109521097 vim_free(*bufp);
2109621098 *fnamep = *bufp = newbuf;
2109721099
21098- l = GetShortPathName(*fnamep,*fnamep,l+1);
21099-
21100- /* Really should always succeed, as the buffer is big enough */
21100+ /* Really should always succeed, as the buffer is big enough. */
21101+ l = GetShortPathName(*fnamep, *fnamep, l+1);
2110121102 }
2110221103
2110321104 *fnamelen = l;
21104- return 1;
21105-}
21106-
21107-/*
21108- * Create a short path name. Returns the length of the buffer it needs.
21109- * Doesn't copy over the end of the buffer passed in.
21105+ return OK;
21106+}
21107+
21108+/*
21109+ * Get the short path (8.3) for the filename in "fname". The converted
21110+ * path is returned in "bufp".
21111+ *
21112+ * Some of the directories specified in "fname" may not exist. This function
21113+ * will shorten the existing directories at the beginning of the path and then
21114+ * append the remaining non-existing path.
21115+ *
21116+ * fname - Pointer to the filename to shorten. On return, contains the
21117+ * pointer to the shortened pathname
21118+ * bufp - Pointer to an allocated buffer for the filename.
21119+ * fnamelen - Length of the filename pointed to by fname
21120+ *
21121+ * Returns OK on success (or nothing done) and FAIL on failure (out of memory).
2111021122 */
2111121123 static int
2111221124 shortpath_for_invalid_fname(fname, bufp, fnamelen)
@@ -21114,85 +21126,106 @@
2111421126 char_u **bufp;
2111521127 int *fnamelen;
2111621128 {
21117- char_u *s, *p, *pbuf2, *pbuf3;
21129+ char_u *short_fname, *save_fname, *pbuf_unused;
21130+ char_u *endp, *save_endp;
2111821131 char_u ch;
21119- int len, len2, plen, slen;
21132+ int old_len, len;
21133+ int new_len, sfx_len;
21134+ int retval = OK;
2112021135
2112121136 /* Make a copy */
21122- len2 = *fnamelen;
21123- pbuf2 = vim_strnsave(*fname, len2);
21124- pbuf3 = NULL;
21125-
21126- s = pbuf2 + len2 - 1; /* Find the end */
21127- slen = 1;
21128- plen = len2;
21129-
21130- if (after_pathsep(pbuf2, s + 1))
21131- {
21132- --s;
21133- ++slen;
21134- --plen;
21135- }
21136-
21137- do
21138- {
21139- /* Go back one path-separator */
21140- while (s > pbuf2 && !after_pathsep(pbuf2, s + 1))
21141- {
21142- --s;
21143- ++slen;
21144- --plen;
21145- }
21146- if (s <= pbuf2)
21147- break;
21148-
21149- /* Remember the character that is about to be splatted */
21150- ch = *s;
21151- *s = 0; /* get_short_pathname requires a null-terminated string */
21152-
21153- /* Try it in situ */
21154- p = pbuf2;
21155- if (!get_short_pathname(&p, &pbuf3, &plen))
21156- {
21157- vim_free(pbuf2);
21158- return -1;
21159- }
21160- *s = ch; /* Preserve the string */
21161- } while (plen == 0);
21162-
21163- if (plen > 0)
21164- {
21165- /* Remember the length of the new string. */
21166- *fnamelen = len = plen + slen;
21137+ old_len = *fnamelen;
21138+ save_fname = vim_strnsave(*fname, old_len);
21139+ pbuf_unused = NULL;
21140+ short_fname = NULL;
21141+
21142+ endp = save_fname + old_len - 1; /* Find the end of the copy */
21143+ save_endp = endp;
21144+
21145+ /*
21146+ * Try shortening the supplied path till it succeeds by removing one
21147+ * directory at a time from the tail of the path.
21148+ */
21149+ len = 0;
21150+ for (;;)
21151+ {
21152+ /* go back one path-separator */
21153+ while (endp > save_fname && !after_pathsep(save_fname, endp + 1))
21154+ --endp;
21155+ if (endp <= save_fname)
21156+ break; /* processed the complete path */
21157+
21158+ /*
21159+ * Replace the path separator with a NUL and try to shorten the
21160+ * resulting path.
21161+ */
21162+ ch = *endp;
21163+ *endp = 0;
21164+ short_fname = save_fname;
21165+ len = STRLEN(short_fname) + 1;
21166+ if (get_short_pathname(&short_fname, &pbuf_unused, &len) == FAIL)
21167+ {
21168+ retval = FAIL;
21169+ goto theend;
21170+ }
21171+ *endp = ch; /* preserve the string */
21172+
21173+ if (len > 0)
21174+ break; /* successfully shortened the path */
21175+
21176+ /* failed to shorten the path. Skip the path separator */
21177+ --endp;
21178+ }
21179+
21180+ if (len > 0)
21181+ {
21182+ /*
21183+ * Succeeded in shortening the path. Now concatenate the shortened
21184+ * path with the remaining path at the tail.
21185+ */
21186+
21187+ /* Compute the length of the new path. */
21188+ sfx_len = (int)(save_endp - endp) + 1;
21189+ new_len = len + sfx_len;
21190+
21191+ *fnamelen = new_len;
2116721192 vim_free(*bufp);
21168- if (len > len2)
21169- {
21170- /* If there's not enough space in the currently allocated string,
21171- * then copy it to a buffer big enough.
21172- */
21173- *fname= *bufp = vim_strnsave(p, len);
21193+ if (new_len > old_len)
21194+ {
21195+ /* There is not enough space in the currently allocated string,
21196+ * copy it to a buffer big enough. */
21197+ *fname = *bufp = vim_strnsave(short_fname, new_len);
2117421198 if (*fname == NULL)
21175- return -1;
21176- }
21177- else
21178- {
21179- /* Transfer pbuf2 to being the main buffer (it's big enough) */
21180- *fname = *bufp = pbuf2;
21181- if (p != pbuf2)
21182- strncpy(*fname, p, plen);
21183- pbuf2 = NULL;
21184- }
21185- /* Concat the next bit */
21186- strncpy(*fname + plen, s, slen);
21187- (*fname)[len] = '\0';
21188- }
21189- vim_free(pbuf3);
21190- vim_free(pbuf2);
21191- return 0;
21199+ {
21200+ retval = FAIL;
21201+ goto theend;
21202+ }
21203+ }
21204+ else
21205+ {
21206+ /* Transfer short_fname to the main buffer (it's big enough),
21207+ * unless get_short_pathname() did its work in-place. */
21208+ *fname = *bufp = save_fname;
21209+ if (short_fname != save_fname)
21210+ vim_strncpy(save_fname, short_fname, len);
21211+ save_fname = NULL;
21212+ }
21213+
21214+ /* concat the not-shortened part of the path */
21215+ vim_strncpy(*fname + len, endp, sfx_len);
21216+ (*fname)[new_len] = NUL;
21217+ }
21218+
21219+theend:
21220+ vim_free(pbuf_unused);
21221+ vim_free(save_fname);
21222+
21223+ return retval;
2119221224 }
2119321225
2119421226 /*
2119521227 * Get a pathname for a partial path.
21228+ * Returns OK for success, FAIL for failure.
2119621229 */
2119721230 static int
2119821231 shortpath_for_partial(fnamep, bufp, fnamelen)
@@ -21222,8 +21255,8 @@
2122221255
2122321256 len = tflen = (int)STRLEN(tfname);
2122421257
21225- if (!get_short_pathname(&tfname, &pbuf, &len))
21226- return -1;
21258+ if (get_short_pathname(&tfname, &pbuf, &len) == FAIL)
21259+ return FAIL;
2122721260
2122821261 if (len == 0)
2122921262 {
@@ -21232,8 +21265,8 @@
2123221265 * there's not a lot of point in guessing what it might be.
2123321266 */
2123421267 len = tflen;
21235- if (shortpath_for_invalid_fname(&tfname, &pbuf, &len) == -1)
21236- return -1;
21268+ if (shortpath_for_invalid_fname(&tfname, &pbuf, &len) == FAIL)
21269+ return FAIL;
2123721270 }
2123821271
2123921272 /* Count the paths backward to find the beginning of the desired string. */
@@ -21257,7 +21290,7 @@
2125721290 if (p >= tfname)
2125821291 *p = '~';
2125921292 else
21260- return -1;
21293+ return FAIL;
2126121294 }
2126221295 else
2126321296 ++p;
@@ -21268,7 +21301,7 @@
2126821301 *bufp = pbuf;
2126921302 *fnamep = p;
2127021303
21271- return 0;
21304+ return OK;
2127221305 }
2127321306 #endif /* WIN3264 */
2127421307
@@ -21276,7 +21309,7 @@
2127621309 * Adjust a filename, according to a string of modifiers.
2127721310 * *fnamep must be NUL terminated when called. When returning, the length is
2127821311 * determined by *fnamelen.
21279- * Returns valid flags.
21312+ * Returns VALID_ flags or -1 for failure.
2128021313 * When there is an error, *fnamep is set to NULL.
2128121314 */
2128221315 int
@@ -21488,7 +21521,7 @@
2148821521 */
2148921522 if (!has_fullname && !vim_isAbsName(*fnamep))
2149021523 {
21491- if (shortpath_for_partial(fnamep, bufp, fnamelen) == -1)
21524+ if (shortpath_for_partial(fnamep, bufp, fnamelen) == FAIL)
2149221525 return -1;
2149321526 }
2149421527 else
@@ -21498,7 +21531,7 @@
2149821531 /* Simple case, already have the full-name
2149921532 * Nearly always shorter, so try first time. */
2150021533 l = *fnamelen;
21501- if (!get_short_pathname(fnamep, bufp, &l))
21534+ if (get_short_pathname(fnamep, bufp, &l) == FAIL)
2150221535 return -1;
2150321536
2150421537 if (l == 0)
@@ -21506,7 +21539,7 @@
2150621539 /* Couldn't find the filename.. search the paths.
2150721540 */
2150821541 l = *fnamelen;
21509- if (shortpath_for_invalid_fname(fnamep, bufp, &l ) == -1)
21542+ if (shortpath_for_invalid_fname(fnamep, bufp, &l) == FAIL)
2151021543 return -1;
2151121544 }
2151221545 *fnamelen = l;
diff -r fe3ec5ea62f7 -r c19f6b8d0393 src/version.c
--- a/src/version.c Thu May 29 13:36:10 2008 +0000
+++ b/src/version.c Thu May 29 19:47:13 2008 +0000
@@ -667,6 +667,8 @@
667667 static int included_patches[] =
668668 { /* Add new patch number below this line */
669669 /**/
670+ 304,
671+/**/
670672 303,
671673 /**/
672674 302,
Show on old repository browser