comparison src/change.c @ 18679:fd95d4dbeb37 v8.1.2331

patch 8.1.2331: the option.c file is still very big Commit: https://github.com/vim/vim/commit/7bae0b1bc84a95d565ffab38cf7f82ad21c656b6 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 21 22:14:18 2019 +0100 patch 8.1.2331: the option.c file is still very big Problem: The option.c file is still very big. Solution: Move a few functions to where they fit better. (Yegappan Lakshmanan, closes #4895)
author Bram Moolenaar <Bram@vim.org>
date Thu, 21 Nov 2019 22:15:03 +0100
parents bbea1f108187
children c469e1930456
comparison
equal deleted inserted replaced
18678:cb4a4b71df4a 18679:fd95d4dbeb37
863 else if (always_inc_changedtick) 863 else if (always_inc_changedtick)
864 ++CHANGEDTICK(buf); 864 ++CHANGEDTICK(buf);
865 #ifdef FEAT_NETBEANS_INTG 865 #ifdef FEAT_NETBEANS_INTG
866 netbeans_unmodified(buf); 866 netbeans_unmodified(buf);
867 #endif 867 #endif
868 }
869
870 /*
871 * Save the current values of 'fileformat' and 'fileencoding', so that we know
872 * the file must be considered changed when the value is different.
873 */
874 void
875 save_file_ff(buf_T *buf)
876 {
877 buf->b_start_ffc = *buf->b_p_ff;
878 buf->b_start_eol = buf->b_p_eol;
879 buf->b_start_bomb = buf->b_p_bomb;
880
881 /* Only use free/alloc when necessary, they take time. */
882 if (buf->b_start_fenc == NULL
883 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
884 {
885 vim_free(buf->b_start_fenc);
886 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
887 }
888 }
889
890 /*
891 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
892 * from when editing started (save_file_ff() called).
893 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
894 * changed and 'binary' is not set.
895 * Also when 'endofline' was changed and 'fixeol' is not set.
896 * When "ignore_empty" is true don't consider a new, empty buffer to be
897 * changed.
898 */
899 int
900 file_ff_differs(buf_T *buf, int ignore_empty)
901 {
902 /* In a buffer that was never loaded the options are not valid. */
903 if (buf->b_flags & BF_NEVERLOADED)
904 return FALSE;
905 if (ignore_empty
906 && (buf->b_flags & BF_NEW)
907 && buf->b_ml.ml_line_count == 1
908 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
909 return FALSE;
910 if (buf->b_start_ffc != *buf->b_p_ff)
911 return TRUE;
912 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
913 return TRUE;
914 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
915 return TRUE;
916 if (buf->b_start_fenc == NULL)
917 return (*buf->b_p_fenc != NUL);
918 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
868 } 919 }
869 920
870 /* 921 /*
871 * Insert string "p" at the cursor position. Stops at a NUL byte. 922 * Insert string "p" at the cursor position. Stops at a NUL byte.
872 * Handles Replace mode and multi-byte characters. 923 * Handles Replace mode and multi-byte characters.