To: vim_dev@googlegroups.com Subject: Patch 8.2.1743 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1743 Problem: Cannot build without the eval feature. Solution: Move shorten_dir outside of #ifdef. Files: src/filepath.c *** ../vim-8.2.1742/src/filepath.c 2020-09-25 22:42:43.852669232 +0200 --- src/filepath.c 2020-09-25 23:47:04.952183405 +0200 *************** *** 710,715 **** --- 710,778 ---- return valid; } + /* + * Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname" + * "trim_len" specifies how many characters to keep for each directory. + * Must be 1 or more. + * It's done in-place. + */ + static void + shorten_dir_len(char_u *str, int trim_len) + { + char_u *tail, *s, *d; + int skip = FALSE; + int dirchunk_len = 0; + + tail = gettail(str); + d = str; + for (s = str; ; ++s) + { + if (s >= tail) // copy the whole tail + { + *d++ = *s; + if (*s == NUL) + break; + } + else if (vim_ispathsep(*s)) // copy '/' and next char + { + *d++ = *s; + skip = FALSE; + dirchunk_len = 0; + } + else if (!skip) + { + *d++ = *s; // copy next char + if (*s != '~' && *s != '.') // and leading "~" and "." + { + ++dirchunk_len; // only count word chars for the size + + // keep copying chars until we have our preferred length (or + // until the above if/else branches move us along) + if (dirchunk_len >= trim_len) + skip = TRUE; + } + + if (has_mbyte) + { + int l = mb_ptr2len(s); + + while (--l > 0) + *d++ = *++s; + } + } + } + } + + /* + * Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname" + * It's done in-place. + */ + void + shorten_dir(char_u *str) + { + shorten_dir_len(str, 1); + } + #if defined(FEAT_EVAL) || defined(PROTO) /* *************** *** 1352,1420 **** } /* - * Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname" - * "trim_len" specifies how many characters to keep for each directory. - * Must be 1 or more. - * It's done in-place. - */ - static void - shorten_dir_len(char_u *str, int trim_len) - { - char_u *tail, *s, *d; - int skip = FALSE; - int dirchunk_len = 0; - - tail = gettail(str); - d = str; - for (s = str; ; ++s) - { - if (s >= tail) // copy the whole tail - { - *d++ = *s; - if (*s == NUL) - break; - } - else if (vim_ispathsep(*s)) // copy '/' and next char - { - *d++ = *s; - skip = FALSE; - dirchunk_len = 0; - } - else if (!skip) - { - *d++ = *s; // copy next char - if (*s != '~' && *s != '.') // and leading "~" and "." - { - ++dirchunk_len; // only count word chars for the size - - // keep copying chars until we have our preferred length (or - // until the above if/else branches move us along) - if (dirchunk_len >= trim_len) - skip = TRUE; - } - - if (has_mbyte) - { - int l = mb_ptr2len(s); - - while (--l > 0) - *d++ = *++s; - } - } - } - } - - /* - * Shorten the path of a file from "~/foo/../.bar/fname" to "~/f/../.b/fname" - * It's done in-place. - */ - void - shorten_dir(char_u *str) - { - shorten_dir_len(str, 1); - } - - /* * "pathshorten()" function */ void --- 1415,1420 ---- *** ../vim-8.2.1742/src/version.c 2020-09-25 23:12:47.835917573 +0200 --- src/version.c 2020-09-25 23:47:55.528074272 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1743, /**/ -- An alien life briefly visits earth. Just before departing it leaves a message in the dust on the back of a white van. The world is shocked and wants to know what it means. After months of studies the worlds best linguistic scientists are able to decipher the message: "Wash me!". /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///