Mercurial > vim
comparison src/buffer.c @ 42:c75153d791d0
updated for version 7.0026
author | vimboss |
---|---|
date | Wed, 29 Dec 2004 20:58:21 +0000 |
parents | f529edb9bab3 |
children | 03f7c369396c |
comparison
equal
deleted
inserted
replaced
41:f529edb9bab3 | 42:c75153d791d0 |
---|---|
1639 buf->b_ino = st.st_ino; | 1639 buf->b_ino = st.st_ino; |
1640 } | 1640 } |
1641 #endif | 1641 #endif |
1642 buf->b_u_synced = TRUE; | 1642 buf->b_u_synced = TRUE; |
1643 buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED; | 1643 buf->b_flags = BF_CHECK_RO | BF_NEVERLOADED; |
1644 if (flags & BLN_DUMMY) | |
1645 buf->b_flags |= BF_DUMMY; | |
1644 buf_clear_file(buf); | 1646 buf_clear_file(buf); |
1645 clrallmarks(buf); /* clear marks */ | 1647 clrallmarks(buf); /* clear marks */ |
1646 fmarks_check_names(buf); /* check file marks for this file */ | 1648 fmarks_check_names(buf); /* check file marks for this file */ |
1647 buf->b_p_bl = (flags & BLN_LISTED) ? TRUE : FALSE; /* init 'buflisted' */ | 1649 buf->b_p_bl = (flags & BLN_LISTED) ? TRUE : FALSE; /* init 'buflisted' */ |
1648 #ifdef FEAT_AUTOCMD | 1650 #ifdef FEAT_AUTOCMD |
1872 #endif | 1874 #endif |
1873 curwin->w_set_curswant = TRUE; | 1875 curwin->w_set_curswant = TRUE; |
1874 } | 1876 } |
1875 } | 1877 } |
1876 | 1878 |
1879 #if defined(FEAT_QUICKFIX) || defined(FEAT_EVAL) || defined(PROTO) | |
1880 /* | |
1881 * Find file in buffer list by name (it has to be for the current window). | |
1882 * Returns NULL if not found. | |
1883 */ | |
1884 buf_T * | |
1885 buflist_findname_exp(fname) | |
1886 char_u *fname; | |
1887 { | |
1888 char_u *ffname; | |
1889 buf_T *buf = NULL; | |
1890 | |
1891 /* First make the name into a full path name */ | |
1892 ffname = FullName_save(fname, | |
1893 #ifdef UNIX | |
1894 TRUE /* force expansion, get rid of symbolic links */ | |
1895 #else | |
1896 FALSE | |
1897 #endif | |
1898 ); | |
1899 if (ffname != NULL) | |
1900 { | |
1901 buf = buflist_findname(ffname); | |
1902 vim_free(ffname); | |
1903 } | |
1904 return buf; | |
1905 } | |
1906 #endif | |
1907 | |
1877 /* | 1908 /* |
1878 * Find file in buffer list by name (it has to be for the current window). | 1909 * Find file in buffer list by name (it has to be for the current window). |
1879 * "ffname" must have a full path. | 1910 * "ffname" must have a full path. |
1911 * Skips dummy buffers. | |
1912 * Returns NULL if not found. | |
1880 */ | 1913 */ |
1881 buf_T * | 1914 buf_T * |
1882 buflist_findname(ffname) | 1915 buflist_findname(ffname) |
1883 char_u *ffname; | 1916 char_u *ffname; |
1884 { | 1917 { |
1891 } | 1924 } |
1892 | 1925 |
1893 /* | 1926 /* |
1894 * Same as buflist_findname(), but pass the stat structure to avoid getting it | 1927 * Same as buflist_findname(), but pass the stat structure to avoid getting it |
1895 * twice for the same file. | 1928 * twice for the same file. |
1929 * Returns NULL if not found. | |
1896 */ | 1930 */ |
1897 static buf_T * | 1931 static buf_T * |
1898 buflist_findname_stat(ffname, stp) | 1932 buflist_findname_stat(ffname, stp) |
1899 char_u *ffname; | 1933 char_u *ffname; |
1900 struct stat *stp; | 1934 struct stat *stp; |
1901 { | 1935 { |
1902 #endif | 1936 #endif |
1903 buf_T *buf; | 1937 buf_T *buf; |
1904 | 1938 |
1905 for (buf = firstbuf; buf != NULL; buf = buf->b_next) | 1939 for (buf = firstbuf; buf != NULL; buf = buf->b_next) |
1906 if (!otherfile_buf(buf, ffname | 1940 if ((buf->b_flags & BF_DUMMY) == 0 && !otherfile_buf(buf, ffname |
1907 #ifdef UNIX | 1941 #ifdef UNIX |
1908 , stp | 1942 , stp |
1909 #endif | 1943 #endif |
1910 )) | 1944 )) |
1911 return buf; | 1945 return buf; |
2455 */ | 2489 */ |
2456 int | 2490 int |
2457 setfname(buf, ffname, sfname, message) | 2491 setfname(buf, ffname, sfname, message) |
2458 buf_T *buf; | 2492 buf_T *buf; |
2459 char_u *ffname, *sfname; | 2493 char_u *ffname, *sfname; |
2460 int message; | 2494 int message; /* give message when buffer already exists */ |
2461 { | 2495 { |
2462 buf_T *obuf; | 2496 buf_T *obuf = NULL; |
2463 #ifdef UNIX | 2497 #ifdef UNIX |
2464 struct stat st; | 2498 struct stat st; |
2465 #endif | 2499 #endif |
2466 | 2500 |
2467 if (ffname == NULL || *ffname == NUL) | 2501 if (ffname == NULL || *ffname == NUL) |
2487 * - if the buffer is not loaded, delete it from the list | 2521 * - if the buffer is not loaded, delete it from the list |
2488 */ | 2522 */ |
2489 #ifdef UNIX | 2523 #ifdef UNIX |
2490 if (mch_stat((char *)ffname, &st) < 0) | 2524 if (mch_stat((char *)ffname, &st) < 0) |
2491 st.st_dev = (dev_T)-1; | 2525 st.st_dev = (dev_T)-1; |
2492 obuf = buflist_findname_stat(ffname, &st); | 2526 #endif |
2527 if (!(buf->b_flags & BF_DUMMY)) | |
2528 #ifdef UNIX | |
2529 obuf = buflist_findname_stat(ffname, &st); | |
2493 #else | 2530 #else |
2494 obuf = buflist_findname(ffname); | 2531 obuf = buflist_findname(ffname); |
2495 #endif | 2532 #endif |
2496 if (obuf != NULL && obuf != buf) | 2533 if (obuf != NULL && obuf != buf) |
2497 { | 2534 { |
2498 if (obuf->b_ml.ml_mfp != NULL) /* it's loaded, fail */ | 2535 if (obuf->b_ml.ml_mfp != NULL) /* it's loaded, fail */ |
2499 { | 2536 { |