To: vim-dev@vim.org Subject: Patch 6.1.129 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.129 Problem: On Solaris editing "file/" and then "file" results in using the same buffer. (Jim Battle) Solution: Before using stat(), check that there is no illegal trailing slash. Files: src/auto/configure, src/config.h.in, src/configure.in, src/macros.h src/misc2.c, src/proto/misc2.pro *** ../vim61.128/src/auto/configure Sun Jun 23 14:29:26 2002 --- src/auto/configure Sun Jun 30 16:29:09 2002 *************** *** 5953,5964 **** fi rm -f conftest* echo $ac_n "checking for iconv_open()""... $ac_c" 1>&6 ! echo "configure:5913: checking for iconv_open()" >&5 save_LIBS="$LIBS" LIBS="$LIBS -liconv" cat > conftest.$ac_ext <&6 + echo "configure:5958: checking whether stat() ignores a trailing slash" >&5 + if test "$cross_compiling" = yes; then + { echo "configure: error: failed to compile test program" 1>&2; exit 1; } + else + cat > conftest.$ac_ext < + #include + main() {struct stat st; exit(stat("configure/", &st) != 0); } + EOF + if { (eval echo configure:5969: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null + then + echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF + #define STAT_IGNORES_SLASH 1 + EOF + + else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo "$ac_t""no" 1>&6 + fi + rm -fr conftest* + fi + + echo $ac_n "checking for iconv_open()""... $ac_c" 1>&6 ! echo "configure:5986: checking for iconv_open()" >&5 save_LIBS="$LIBS" LIBS="$LIBS -liconv" cat > conftest.$ac_ext < + #include + main() {struct stat st; exit(stat("configure/", &st) != 0); }], + AC_MSG_RESULT(yes); AC_DEFINE(STAT_IGNORES_SLASH), + AC_MSG_RESULT(no), AC_MSG_ERROR(failed to compile test program)) + dnl Link with iconv for charset translation, if not found without library. dnl check for iconv() requires including iconv.h dnl Add "-liconv" when possible; Solaris has iconv but use GNU iconv when it *** ../vim61.128/src/macros.h Tue Jan 1 20:52:19 2002 --- src/macros.h Sat Jul 13 14:48:26 2002 *************** *** 145,151 **** # ifdef MSWIN /* has it's own mch_stat() function */ # define mch_stat(n, p) vim_stat((n), (p)) # else ! # define mch_stat(n, p) stat((n), (p)) # endif #endif --- 145,157 ---- # ifdef MSWIN /* has it's own mch_stat() function */ # define mch_stat(n, p) vim_stat((n), (p)) # else ! # ifdef STAT_IGNORES_SLASH ! /* On Solaris stat() accepts "file/" as if it was "file". Return -1 if ! * the name ends in "/" and it's not a directory. */ ! # define mch_stat(n, p) (illegal_slash(n) ? -1 : stat((n), (p))) ! # else ! # define mch_stat(n, p) stat((n), (p)) ! # endif # endif #endif *** ../vim61.128/src/misc2.c Thu May 16 22:15:58 2002 --- src/misc2.c Sat Jul 13 14:55:56 2002 *************** *** 2648,2653 **** --- 2648,2673 ---- } #endif + #if defined(STAT_IGNORES_SLASH) || defined(PROTO) + /* + * Check if "name" ends in a slash and is not a directory. + * Used for systems where stat() ignores a trailing slash on a file name. + * The Vim code assumes a trailing slash is only ignored for a directory. + */ + int + illegal_slash(name) + char *name; + { + if (name[0] == NUL) + return FALSE; /* no file name is not illegal */ + if (name[strlen(name) - 1] != '/') + return FALSE; /* no trailing slash */ + if (mch_isdir(name)) + return FALSE; /* trailing slash for a directory */ + return TRUE; + } + #endif + #if defined(CURSOR_SHAPE) || defined(PROTO) /* *** ../vim61.128/src/proto/misc2.pro Fri Mar 22 21:41:16 2002 --- src/proto/misc2.pro Sat Jul 13 14:56:05 2002 *************** *** 66,71 **** --- 66,72 ---- int call_shell __ARGS((char_u *cmd, int opt)); int get_real_state __ARGS((void)); int vim_chdirfile __ARGS((char_u *fname)); + int illegal_slash __ARGS((char *name)); char_u *parse_shape_opt __ARGS((int what)); int get_shape_idx __ARGS((int mouse)); void update_mouseshape __ARGS((int shape_idx)); *** ../vim61.128/src/version.c Sun Jul 14 16:37:14 2002 --- src/version.c Sun Jul 21 20:25:29 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 129, /**/ -- hundred-and-one symptoms of being an internet addict: 11. You find yourself typing "com" after every period when using a word processor.com /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///