int write_undo_file = FALSE;
context_sha256_T sha_ctx;
#endif
+ unsigned int bkc = get_bkc_value(buf);
if (fname == NULL || *fname == NUL) /* safety check */
return FAIL;
struct stat st;
#endif
- if ((bkc_flags & BKC_YES) || append) /* "yes" */
+ if ((bkc & BKC_YES) || append) /* "yes" */
backup_copy = TRUE;
#if defined(UNIX) || defined(WIN32)
- else if ((bkc_flags & BKC_AUTO)) /* "auto" */
+ else if ((bkc & BKC_AUTO)) /* "auto" */
{
int i;
/*
* Break symlinks and/or hardlinks if we've been asked to.
*/
- if ((bkc_flags & BKC_BREAKSYMLINK) || (bkc_flags & BKC_BREAKHARDLINK))
+ if ((bkc & BKC_BREAKSYMLINK) || (bkc & BKC_BREAKHARDLINK))
{
# ifdef UNIX
int lstat_res;
lstat_res = mch_lstat((char *)fname, &st);
/* Symlinks. */
- if ((bkc_flags & BKC_BREAKSYMLINK)
+ if ((bkc & BKC_BREAKSYMLINK)
&& lstat_res == 0
&& st.st_ino != st_old.st_ino)
backup_copy = FALSE;
/* Hardlinks. */
- if ((bkc_flags & BKC_BREAKHARDLINK)
+ if ((bkc & BKC_BREAKHARDLINK)
&& st_old.st_nlink > 1
&& (lstat_res != 0 || st.st_ino == st_old.st_ino))
backup_copy = FALSE;
# else
# if defined(WIN32)
/* Symlinks. */
- if ((bkc_flags & BKC_BREAKSYMLINK) && mch_is_symbolic_link(fname))
+ if ((bkc & BKC_BREAKSYMLINK) && mch_is_symbolic_link(fname))
backup_copy = FALSE;
/* Hardlinks. */
- if ((bkc_flags & BKC_BREAKHARDLINK) && mch_is_hard_link(fname))
+ if ((bkc & BKC_BREAKHARDLINK) && mch_is_hard_link(fname))
backup_copy = FALSE;
# endif
# endif
*/
#define PV_AI OPT_BUF(BV_AI)
#define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
+#define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC))
#ifdef FEAT_QUICKFIX
# define PV_BH OPT_BUF(BV_BH)
# define PV_BT OPT_BUF(BV_BT)
(char_u *)&p_bk, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP,
- (char_u *)&p_bkc, PV_NONE,
+ (char_u *)&p_bkc, PV_BKC,
#ifdef UNIX
{(char_u *)"yes", (char_u *)"auto"}
#else
#ifdef FEAT_LISP
check_string_option(&buf->b_p_lw);
#endif
+ check_string_option(&buf->b_p_bkc);
}
/*
}
/* 'backupcopy' */
- else if (varp == &p_bkc)
+ else if (gvarp == &p_bkc)
{
- if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
+ char_u *bkc = p_bkc;
+ unsigned int *flags = &bkc_flags;
+
+ if (opt_flags & OPT_LOCAL)
+ {
+ bkc = curbuf->b_p_bkc;
+ flags = &curbuf->b_bkc_flags;
+ }
+
+ if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
errmsg = e_invarg;
- if (((bkc_flags & BKC_AUTO) != 0)
- + ((bkc_flags & BKC_YES) != 0)
- + ((bkc_flags & BKC_NO) != 0) != 1)
+ if ((((int)*flags & BKC_AUTO) != 0)
+ + (((int)*flags & BKC_YES) != 0)
+ + (((int)*flags & BKC_NO) != 0) != 1)
{
/* Must have exactly one of "auto", "yes" and "no". */
- (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
+ (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
errmsg = e_invarg;
}
}
}
/*
- * Iterate over options. First argument is a pointer to a pointer to a structure
- * inside options[] array, second is option type like in the above function.
+ * Iterate over options. First argument is a pointer to a pointer to a
+ * structure inside options[] array, second is option type like in the above
+ * function.
*
- * If first argument points to NULL it is assumed that iteration just started
+ * If first argument points to NULL it is assumed that iteration just started
* and caller needs the very first value.
- * If first argument points to the end marker function returns NULL and sets
+ * If first argument points to the end marker function returns NULL and sets
* first argument to NULL.
*
* Returns full option name for current option on each call.
case PV_AR:
buf->b_p_ar = -1;
break;
+ case PV_BKC:
+ clear_string_option(&buf->b_p_bkc);
+ buf->b_bkc_flags = 0;
+ break;
case PV_TAGS:
clear_string_option(&buf->b_p_tags);
break;
#ifdef FEAT_LISP
case PV_LW: return (char_u *)&(curbuf->b_p_lw);
#endif
+ case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
}
return NULL; /* "cannot happen" */
}
? (char_u *)&(curbuf->b_p_ar) : p->var;
case PV_TAGS: return *curbuf->b_p_tags != NUL
? (char_u *)&(curbuf->b_p_tags) : p->var;
+ case PV_BKC: return *curbuf->b_p_bkc != NUL
+ ? (char_u *)&(curbuf->b_p_bkc) : p->var;
#ifdef FEAT_FIND_ID
case PV_DEF: return *curbuf->b_p_def != NUL
? (char_u *)&(curbuf->b_p_def) : p->var;
* are not copied, start using the global value */
buf->b_p_ar = -1;
buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
+ buf->b_p_bkc = empty_option;
+ buf->b_bkc_flags = 0;
#ifdef FEAT_QUICKFIX
buf->b_p_gp = empty_option;
buf->b_p_mp = empty_option;
return OK;
}
#endif
+
+/*
+ * Get the local or global value of 'backupcopy'.
+ */
+ unsigned int
+get_bkc_value(buf)
+ buf_T *buf;
+{
+ return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
+}