Skip to content

Commit 27fc8ca

Browse files
committed
patch 8.1.2152: problems navigating tags file on MacOS Catalina
Problem: Problems navigating tags file on MacOS Catalina. Solution: Use fseek instead of lseek. (John Lamb, fixes #5061)
1 parent 3c8cd4a commit 27fc8ca

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

src/tag.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,23 +2198,23 @@ find_tags(
21982198
#endif
21992199

22002200
#ifdef FEAT_TAG_BINS
2201-
/*
2202-
* When starting a binary search, get the size of the file and
2203-
* compute the first offset.
2204-
*/
2201+
// When starting a binary search, get the size of the file and
2202+
// compute the first offset.
22052203
if (state == TS_BINARY)
22062204
{
2207-
/* Get the tag file size (don't use mch_fstat(), it's not
2208-
* portable). */
2209-
if ((filesize = vim_lseek(fileno(fp),
2210-
(off_T)0L, SEEK_END)) <= 0)
2205+
if (vim_fseek(fp, 0L, SEEK_END) != 0)
2206+
// can't seek, don't use binary search
22112207
state = TS_LINEAR;
22122208
else
22132209
{
2214-
vim_lseek(fileno(fp), (off_T)0L, SEEK_SET);
2215-
2216-
/* Calculate the first read offset in the file. Start
2217-
* the search in the middle of the file. */
2210+
// Get the tag file size (don't use mch_fstat(), it's
2211+
// not portable). Don't use lseek(), it doesn't work
2212+
// properly on MacOS Catalina.
2213+
filesize = vim_ftell(fp);
2214+
vim_fseek(fp, 0L, SEEK_SET);
2215+
2216+
// Calculate the first read offset in the file. Start
2217+
// the search in the middle of the file.
22182218
search_info.low_offset = 0;
22192219
search_info.low_char = 0;
22202220
search_info.high_offset = filesize;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ static char *(features[]) =
753753

754754
static int included_patches[] =
755755
{ /* Add new patch number below this line */
756+
/**/
757+
2152,
756758
/**/
757759
2151,
758760
/**/

0 commit comments

Comments
 (0)