diff options
author | James McCoy <jamessan@jamessan.com> | 2017-06-07 14:05:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 14:05:46 +0000 |
commit | d3d0c9a7b11cad3f277f732dee6c782d1d911b48 (patch) | |
tree | 9440bfffd38ff3cdf98127c95764db1f84adadb7 /src/nvim/tag.c | |
parent | cb0abce5be1dd6212425589b61826332834dc977 (diff) | |
parent | ca1ba1085a2be1f8963b48c9ccf3936359959924 (diff) | |
download | rneovim-d3d0c9a7b11cad3f277f732dee6c782d1d911b48.tar.gz rneovim-d3d0c9a7b11cad3f277f732dee6c782d1d911b48.tar.bz2 rneovim-d3d0c9a7b11cad3f277f732dee6c782d1d911b48.zip |
Merge pull request #5621 from jamessan/vim-7.4.1975
vim-patch:7.4.1975,7.4.1976,7.4.1977,7.4.1978,7.4.1979,7.4.1986,7.4.2029,7.4.2224,8.0.0219,8.0.0614
Diffstat (limited to 'src/nvim/tag.c')
-rw-r--r-- | src/nvim/tag.c | 86 |
1 files changed, 33 insertions, 53 deletions
diff --git a/src/nvim/tag.c b/src/nvim/tag.c index 88b45add54..be9d621c7d 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -106,15 +106,6 @@ static char_u *topmsg = (char_u *)N_("E556: at top of tag stack"); static char_u *tagmatchname = NULL; /* name of last used tag */ /* - * We use ftello() here, if available. It returns off_t instead of long, - * which helps if long is 32 bit and off_t is 64 bit. - * We assume that when fseeko() is available then ftello() is too. - */ -#ifdef HAVE_FSEEKO -# define ftell ftello -#endif - -/* * Tag for preview window is remembered separately, to avoid messing up the * normal tagstack. */ @@ -1088,22 +1079,21 @@ find_tags ( char_u *p; char_u *s; int i; - int tag_file_sorted = NUL; /* !_TAG_FILE_SORTED value */ - struct tag_search_info /* Binary search file offsets */ - { - off_t low_offset; /* offset for first char of first line that - could match */ - off_t high_offset; /* offset of char after last line that could - match */ - off_t curr_offset; /* Current file offset in search range */ - off_t curr_offset_used; /* curr_offset used when skipping back */ - off_t match_offset; /* Where the binary search found a tag */ - int low_char; /* first char at low_offset */ - int high_char; /* first char at high_offset */ + int tag_file_sorted = NUL; // !_TAG_FILE_SORTED value + struct tag_search_info { // Binary search file offsets + off_T low_offset; // offset for first char of first line that + // could match + off_T high_offset; // offset of char after last line that could + // match + off_T curr_offset; // Current file offset in search range + off_T curr_offset_used; // curr_offset used when skipping back + off_T match_offset; // Where the binary search found a tag + int low_char; // first char at low_offset + int high_char; // first char at high_offset } search_info; - off_t filesize; + off_T filesize; int tagcmp; - off_t offset; + off_T offset; int round; enum { TS_START, /* at start of file */ @@ -1378,36 +1368,28 @@ find_tags ( if (state == TS_BINARY || state == TS_SKIP_BACK) { /* Adjust the search file offset to the correct position */ search_info.curr_offset_used = search_info.curr_offset; -#ifdef HAVE_FSEEKO - fseeko(fp, search_info.curr_offset, SEEK_SET); -#else - fseek(fp, (long)search_info.curr_offset, SEEK_SET); -#endif + vim_fseek(fp, search_info.curr_offset, SEEK_SET); eof = vim_fgets(lbuf, LSIZE, fp); if (!eof && search_info.curr_offset != 0) { /* The explicit cast is to work around a bug in gcc 3.4.2 * (repeated below). */ - search_info.curr_offset = ftell(fp); + search_info.curr_offset = vim_ftell(fp); if (search_info.curr_offset == search_info.high_offset) { - /* oops, gone a bit too far; try from low offset */ -#ifdef HAVE_FSEEKO - fseeko(fp, search_info.low_offset, SEEK_SET); -#else - fseek(fp, (long)search_info.low_offset, SEEK_SET); -#endif + // oops, gone a bit too far; try from low offset + vim_fseek(fp, search_info.low_offset, SEEK_SET); search_info.curr_offset = search_info.low_offset; } eof = vim_fgets(lbuf, LSIZE, fp); } /* skip empty and blank lines */ while (!eof && vim_isblankline(lbuf)) { - search_info.curr_offset = ftell(fp); + search_info.curr_offset = vim_ftell(fp); eof = vim_fgets(lbuf, LSIZE, fp); } if (eof) { /* Hit end of file. Skip backwards. */ state = TS_SKIP_BACK; - search_info.match_offset = ftell(fp); + search_info.match_offset = vim_ftell(fp); search_info.curr_offset = search_info.curr_offset_used; continue; } @@ -1523,10 +1505,10 @@ line_read_in: */ if (state == TS_BINARY) { // Get the tag file size. - if ((filesize = lseek(fileno(fp), (off_t)0L, SEEK_END)) <= 0) { + if ((filesize = vim_lseek(fileno(fp), (off_T)0L, SEEK_END)) <= 0) { state = TS_LINEAR; } else { - lseek(fileno(fp), (off_t)0L, SEEK_SET); + vim_lseek(fileno(fp), (off_T)0L, SEEK_SET); /* Calculate the first read offset in the file. Start * the search in the middle of the file. */ @@ -1564,11 +1546,7 @@ parse_line: /* Avoid getting stuck. */ linear = TRUE; state = TS_LINEAR; -# ifdef HAVE_FSEEKO - fseeko(fp, search_info.low_offset, SEEK_SET); -# else - fseek(fp, (long)search_info.low_offset, SEEK_SET); -# endif + vim_fseek(fp, search_info.low_offset, SEEK_SET); } continue; } @@ -1647,7 +1625,7 @@ parse_line: continue; } if (tagcmp < 0) { - search_info.curr_offset = ftell(fp); + search_info.curr_offset = vim_ftell(fp); if (search_info.curr_offset < search_info.high_offset) { search_info.low_offset = search_info.curr_offset; if (sortic) @@ -1683,10 +1661,11 @@ parse_line: } else if (state == TS_STEP_FORWARD) { assert(cmplen >= 0); if (mb_strnicmp(tagp.tagname, orgpat.head, (size_t)cmplen) != 0) { - if ((off_t)ftell(fp) > search_info.match_offset) - break; /* past last match */ - else - continue; /* before first match */ + if ((off_T)vim_ftell(fp) > search_info.match_offset) { + break; // past last match + } else { + continue; // before first match + } } } else /* skip this match if it can't match */ @@ -1907,10 +1886,11 @@ parse_line: if (line_error) { EMSG2(_("E431: Format error in tags file \"%s\""), tag_fname); - if (!use_cscope) - EMSGN(_("Before byte %" PRId64), ftell(fp)); - stop_searching = TRUE; - line_error = FALSE; + if (!use_cscope) { + EMSGN(_("Before byte %" PRId64), vim_ftell(fp)); + } + stop_searching = true; + line_error = false; } if (!use_cscope) |