Mercurial > vim
comparison src/buffer.c @ 9387:f094d4085014 v7.4.1975
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 1 17:17:39 2016 +0200
patch 7.4.1975
Problem: On MS-Windows large files (> 2Gbyte) cause problems.
Solution: Use "off_T" instead of "off_t". Use "stat_T" instead of "struct
stat". Use 64 bit system functions if available. (Ken Takata)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 01 Jul 2016 17:30:07 +0200 |
parents | ea504064c996 |
children | 1003973c99df |
comparison
equal
deleted
inserted
replaced
9386:80deab13679b | 9387:f094d4085014 |
---|---|
33 static char_u *fname_match(regmatch_T *rmp, char_u *name, int ignore_case); | 33 static char_u *fname_match(regmatch_T *rmp, char_u *name, int ignore_case); |
34 #endif | 34 #endif |
35 static void buflist_setfpos(buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options); | 35 static void buflist_setfpos(buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options); |
36 static wininfo_T *find_wininfo(buf_T *buf, int skip_diff_buffer); | 36 static wininfo_T *find_wininfo(buf_T *buf, int skip_diff_buffer); |
37 #ifdef UNIX | 37 #ifdef UNIX |
38 static buf_T *buflist_findname_stat(char_u *ffname, struct stat *st); | 38 static buf_T *buflist_findname_stat(char_u *ffname, stat_T *st); |
39 static int otherfile_buf(buf_T *buf, char_u *ffname, struct stat *stp); | 39 static int otherfile_buf(buf_T *buf, char_u *ffname, stat_T *stp); |
40 static int buf_same_ino(buf_T *buf, struct stat *stp); | 40 static int buf_same_ino(buf_T *buf, stat_T *stp); |
41 #else | 41 #else |
42 static int otherfile_buf(buf_T *buf, char_u *ffname); | 42 static int otherfile_buf(buf_T *buf, char_u *ffname); |
43 #endif | 43 #endif |
44 #ifdef FEAT_TITLE | 44 #ifdef FEAT_TITLE |
45 static int ti_change(char_u *str, char_u **last); | 45 static int ti_change(char_u *str, char_u **last); |
1661 linenr_T lnum, /* preferred cursor line */ | 1661 linenr_T lnum, /* preferred cursor line */ |
1662 int flags) /* BLN_ defines */ | 1662 int flags) /* BLN_ defines */ |
1663 { | 1663 { |
1664 buf_T *buf; | 1664 buf_T *buf; |
1665 #ifdef UNIX | 1665 #ifdef UNIX |
1666 struct stat st; | 1666 stat_T st; |
1667 #endif | 1667 #endif |
1668 | 1668 |
1669 fname_expand(curbuf, &ffname, &sfname); /* will allocate ffname */ | 1669 fname_expand(curbuf, &ffname, &sfname); /* will allocate ffname */ |
1670 | 1670 |
1671 /* | 1671 /* |
2181 */ | 2181 */ |
2182 buf_T * | 2182 buf_T * |
2183 buflist_findname(char_u *ffname) | 2183 buflist_findname(char_u *ffname) |
2184 { | 2184 { |
2185 #ifdef UNIX | 2185 #ifdef UNIX |
2186 struct stat st; | 2186 stat_T st; |
2187 | 2187 |
2188 if (mch_stat((char *)ffname, &st) < 0) | 2188 if (mch_stat((char *)ffname, &st) < 0) |
2189 st.st_dev = (dev_T)-1; | 2189 st.st_dev = (dev_T)-1; |
2190 return buflist_findname_stat(ffname, &st); | 2190 return buflist_findname_stat(ffname, &st); |
2191 } | 2191 } |
2196 * Returns NULL if not found. | 2196 * Returns NULL if not found. |
2197 */ | 2197 */ |
2198 static buf_T * | 2198 static buf_T * |
2199 buflist_findname_stat( | 2199 buflist_findname_stat( |
2200 char_u *ffname, | 2200 char_u *ffname, |
2201 struct stat *stp) | 2201 stat_T *stp) |
2202 { | 2202 { |
2203 #endif | 2203 #endif |
2204 buf_T *buf; | 2204 buf_T *buf; |
2205 | 2205 |
2206 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 2206 for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
2845 char_u *sfname, | 2845 char_u *sfname, |
2846 int message) /* give message when buffer already exists */ | 2846 int message) /* give message when buffer already exists */ |
2847 { | 2847 { |
2848 buf_T *obuf = NULL; | 2848 buf_T *obuf = NULL; |
2849 #ifdef UNIX | 2849 #ifdef UNIX |
2850 struct stat st; | 2850 stat_T st; |
2851 #endif | 2851 #endif |
2852 | 2852 |
2853 if (ffname == NULL || *ffname == NUL) | 2853 if (ffname == NULL || *ffname == NUL) |
2854 { | 2854 { |
2855 /* Removing the name. */ | 2855 /* Removing the name. */ |
3082 static int | 3082 static int |
3083 otherfile_buf( | 3083 otherfile_buf( |
3084 buf_T *buf, | 3084 buf_T *buf, |
3085 char_u *ffname | 3085 char_u *ffname |
3086 #ifdef UNIX | 3086 #ifdef UNIX |
3087 , struct stat *stp | 3087 , stat_T *stp |
3088 #endif | 3088 #endif |
3089 ) | 3089 ) |
3090 { | 3090 { |
3091 /* no name is different */ | 3091 /* no name is different */ |
3092 if (ffname == NULL || *ffname == NUL || buf->b_ffname == NULL) | 3092 if (ffname == NULL || *ffname == NUL || buf->b_ffname == NULL) |
3093 return TRUE; | 3093 return TRUE; |
3094 if (fnamecmp(ffname, buf->b_ffname) == 0) | 3094 if (fnamecmp(ffname, buf->b_ffname) == 0) |
3095 return FALSE; | 3095 return FALSE; |
3096 #ifdef UNIX | 3096 #ifdef UNIX |
3097 { | 3097 { |
3098 struct stat st; | 3098 stat_T st; |
3099 | 3099 |
3100 /* If no struct stat given, get it now */ | 3100 /* If no stat_T given, get it now */ |
3101 if (stp == NULL) | 3101 if (stp == NULL) |
3102 { | 3102 { |
3103 if (!buf->b_dev_valid || mch_stat((char *)ffname, &st) < 0) | 3103 if (!buf->b_dev_valid || mch_stat((char *)ffname, &st) < 0) |
3104 st.st_dev = (dev_T)-1; | 3104 st.st_dev = (dev_T)-1; |
3105 stp = &st; | 3105 stp = &st; |
3130 * Must always be called when b_fname is changed!. | 3130 * Must always be called when b_fname is changed!. |
3131 */ | 3131 */ |
3132 void | 3132 void |
3133 buf_setino(buf_T *buf) | 3133 buf_setino(buf_T *buf) |
3134 { | 3134 { |
3135 struct stat st; | 3135 stat_T st; |
3136 | 3136 |
3137 if (buf->b_fname != NULL && mch_stat((char *)buf->b_fname, &st) >= 0) | 3137 if (buf->b_fname != NULL && mch_stat((char *)buf->b_fname, &st) >= 0) |
3138 { | 3138 { |
3139 buf->b_dev_valid = TRUE; | 3139 buf->b_dev_valid = TRUE; |
3140 buf->b_dev = st.st_dev; | 3140 buf->b_dev = st.st_dev; |
3148 * Return TRUE if dev/ino in buffer "buf" matches with "stp". | 3148 * Return TRUE if dev/ino in buffer "buf" matches with "stp". |
3149 */ | 3149 */ |
3150 static int | 3150 static int |
3151 buf_same_ino( | 3151 buf_same_ino( |
3152 buf_T *buf, | 3152 buf_T *buf, |
3153 struct stat *stp) | 3153 stat_T *stp) |
3154 { | 3154 { |
3155 return (buf->b_dev_valid | 3155 return (buf->b_dev_valid |
3156 && stp->st_dev == buf->b_dev | 3156 && stp->st_dev == buf->b_dev |
3157 && stp->st_ino == buf->b_ino); | 3157 && stp->st_ino == buf->b_ino); |
3158 } | 3158 } |