To: vim-dev@vim.org Subject: patch 5.4.35 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.4.35 Problem: There is no function to get the current file size. Solution: Allow using line2byte() with the number of lines in the file plus one. This returns the offset of the line past the end of the file, which is the file size plus one. Files: src/eval.c, runtime/doc/eval.txt *** ../vim-5.4.34/src/eval.c Tue Aug 10 16:10:35 1999 --- src/eval.c Wed Aug 18 12:47:08 1999 *************** *** 3358,3364 **** linenr_t lnum = 0; lnum = get_var_number(&argvars[0]); ! if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count) retvar->var_val.var_number = -1; else retvar->var_val.var_number = ml_find_line_or_offset(curbuf, lnum, NULL); --- 3360,3366 ---- linenr_t lnum = 0; lnum = get_var_number(&argvars[0]); ! if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1) retvar->var_val.var_number = -1; else retvar->var_val.var_number = ml_find_line_or_offset(curbuf, lnum, NULL); *** ../vim-5.4.34/runtime/doc/eval.txt Wed Jul 21 22:43:32 1999 --- runtime/doc/eval.txt Wed Aug 18 13:01:02 1999 *************** *** 597,602 **** --- 608,615 ---- for the current buffer. The first character has byte count one. Also see |line2byte()|, |go| and |:goto|. + {not available when compiled without the |+byte_offset| + feature} *char2nr()* char2nr({expr}) *************** *** 1001,1007 **** Return the byte count from the start of the buffer for line {lnum}. This includes the end-of-line character, depending on the 'fileformat' option for the current buffer. The first ! line returns 1; Also see |byte2line()|, |go| and |:goto|. *localtime()* --- 1023,1035 ---- Return the byte count from the start of the buffer for line {lnum}. This includes the end-of-line character, depending on the 'fileformat' option for the current buffer. The first ! line returns 1. ! This can also be used to get the byte count for the line just ! below the last line: ! > line2byte(line("$") + 1) ! This is the file size plus one. ! When {lnum} is invalid, or the |+byte_offset| feature has been ! disabled at compile time, -1 is returned. Also see |byte2line()|, |go| and |:goto|. *localtime()* *** ../vim-5.4.34/src/version.h Wed Aug 18 12:53:26 1999 --- src/version.h Wed Aug 18 12:53:02 1999 *************** *** 19,26 **** #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 34 ! #define VIM_VERSION_PATCHLEVEL_STR "34" /* * VIM_VERSION_NODOT is used for the runtime directory name. --- 19,26 ---- #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 35 ! #define VIM_VERSION_PATCHLEVEL_STR "35" /* * VIM_VERSION_NODOT is used for the runtime directory name. *************** *** 30,35 **** */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.34" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.34 (1999 Aug 18)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.34 (1999 Aug 18, compiled " --- 30,35 ---- */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.35" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.35 (1999 Aug 18)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.35 (1999 Aug 18, compiled " -- hundred-and-one symptoms of being an internet addict: 129. You cancel your newspaper subscription. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /