To: vim-dev@vim.org Subject: Patch 6.1.217 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.217 Problem: When sourcing the same Vim script using a different name (symbolic link or MS-Windows 8.3 name) it is listed twice with ":scriptnames". (Tony Mechelynck) Solution: Turn the script name into a full path before using it. On Unix compare inode/device numbers. Files: src/ex_cmds2.c *** ../vim61.216/src/ex_cmds2.c Sun Oct 6 18:30:28 2002 --- src/ex_cmds2.c Sat Oct 12 17:22:00 2002 *************** *** 1822,1830 **** static char_u *get_one_sourceline __ARGS((struct source_cookie *sp)); #ifdef FEAT_EVAL ! /* Growarray to store the names of sourced scripts. */ ! static garray_T script_names = {0, 0, sizeof(char_u *), 4, NULL}; ! #define SCRIPT_NAME(id) (((char_u **)script_names.ga_data)[(id) - 1]) #endif /* --- 1822,1842 ---- static char_u *get_one_sourceline __ARGS((struct source_cookie *sp)); #ifdef FEAT_EVAL ! /* Growarray to store the names of sourced scripts. ! * For Unix also store the dev/ino, so that we don't have to stat() each ! * script when going through the list. */ ! struct scriptstuff ! { ! char_u *name; ! # ifdef UNIX ! int dev; ! ino_t ino; ! # endif ! }; ! static garray_T script_names = {0, 0, sizeof(struct scriptstuff), 4, NULL}; ! #define SCRIPT_NAME(id) (((struct scriptstuff *)script_names.ga_data)[(id) - 1].name) ! #define SCRIPT_DEV(id) (((struct scriptstuff *)script_names.ga_data)[(id) - 1].dev) ! #define SCRIPT_INO(id) (((struct scriptstuff *)script_names.ga_data)[(id) - 1].ino) #endif /* *************** *** 1851,1856 **** --- 1863,1871 ---- static scid_T last_current_SID = 0; void *save_funccalp; int save_debug_break_level = debug_break_level; + # ifdef UNIX + struct stat st; + # endif #endif #ifdef STARTUPTIME struct timeval tv_rel; *************** *** 1858,1869 **** #endif #ifdef RISCOS ! fname_exp = mch_munge_fname(fname); #else ! fname_exp = expand_env_save(fname); #endif if (fname_exp == NULL) ! goto theend; #ifdef MACOS_CLASSIC slash_n_colon_adjust(fname_exp); #endif --- 1873,1888 ---- #endif #ifdef RISCOS ! p = mch_munge_fname(fname); #else ! p = expand_env_save(fname); #endif + if (p == NULL) + return retval; + fname_exp = fix_fname(p); + vim_free(p); if (fname_exp == NULL) ! return retval; #ifdef MACOS_CLASSIC slash_n_colon_adjust(fname_exp); #endif *************** *** 1977,1985 **** * If it's new, generate a new SID. */ save_current_SID = current_SID; for (current_SID = script_names.ga_len; current_SID > 0; --current_SID) if (SCRIPT_NAME(current_SID) != NULL ! && fnamecmp(SCRIPT_NAME(current_SID), fname_exp) == 0) break; if (current_SID == 0) { --- 1996,2016 ---- * If it's new, generate a new SID. */ save_current_SID = current_SID; + # ifdef UNIX + if (mch_stat((char *)fname_exp, &st) < 0) + st.st_dev = -1; + # endif for (current_SID = script_names.ga_len; current_SID > 0; --current_SID) if (SCRIPT_NAME(current_SID) != NULL ! && ( ! # ifdef UNIX ! /* compare dev/ino when possible, it catches symbolic ! * links */ ! (st.st_dev != -1 && SCRIPT_DEV(current_SID) != -1) ! ? (SCRIPT_DEV(current_SID) == st.st_dev ! && SCRIPT_INO(current_SID) == st.st_ino) : ! # endif ! fnamecmp(SCRIPT_NAME(current_SID), fname_exp) == 0)) break; if (current_SID == 0) { *************** *** 1994,1999 **** --- 2025,2035 ---- --script_names.ga_room; } SCRIPT_NAME(current_SID) = fname_exp; + # ifdef UNIX + SCRIPT_DEV(current_SID) = st.st_dev; + if (st.st_dev != -1) + SCRIPT_INO(current_SID) = st.st_ino; + # endif fname_exp = NULL; } /* Allocate the local script variables to use for this script. */ *** ../vim61.216/src/version.c Sat Oct 12 15:48:03 2002 --- src/version.c Sat Oct 12 17:23:58 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 217, /**/ -- hundred-and-one symptoms of being an internet addict: 204. You're being audited because you mailed your tax return to the IRC. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///