]> git.pld-linux.org Git - packages/vim.git/blob - 6.2.481
- new
[packages/vim.git] / 6.2.481
1 To: vim-dev@vim.org
2 Subject: Patch 6.2.481
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 6.2.481
11 Problem:    When writing a file it is not possible to specify that hard and/or
12             symlinks are to be broken instead of preserved.
13 Solution:   Add the "breaksymlink" and "breakhardlink" values to 'backupcopy'.
14             (Simon Ekstrand)
15 Files:      runtime/doc/options.txt, src/fileio.c, src/option.c, src/option.h
16
17
18 *** ../vim-6.2.480/runtime/doc/options.txt      Mon Apr  5 19:51:11 2004
19 --- runtime/doc/options.txt     Sun Apr 18 17:03:19 2004
20 ***************
21 *** 1,4 ****
22 ! *options.txt* For Vim version 6.2.  Last change: 2004 Apr 05
23   
24   
25                   VIM REFERENCE MANUAL    by Bram Moolenaar
26 --- 1,4 ----
27 ! *options.txt* For Vim version 6.2.  Last change: 2004 Apr 18
28   
29   
30                   VIM REFERENCE MANUAL    by Bram Moolenaar
31 ***************
32 *** 834,844 ****
33                         global
34                         {not in Vi}
35         When writing a file and a backup is made, this option tells how it's
36 !       done:
37         "yes"   make a copy of the file and overwrite the original one
38         "no"    rename the file and write a new one
39         "auto"  one of the previous, what works best
40   
41         Making a copy and overwriting the original file:
42         - Takes extra time to copy the file.
43         + When the file has special attributes, is a (hard/symbolic) link or
44 --- 836,852 ----
45                         global
46                         {not in Vi}
47         When writing a file and a backup is made, this option tells how it's
48 !       done.  This is a comma separated list of words.
49 !       
50 !       The main values are:
51         "yes"   make a copy of the file and overwrite the original one
52         "no"    rename the file and write a new one
53         "auto"  one of the previous, what works best
54   
55 +       Extra values that can be combined with the ones above are:
56 +       "breaksymlink"  always break symlinks when writing
57 +       "breakhardlink" always break hardlinks when writing
58
59         Making a copy and overwriting the original file:
60         - Takes extra time to copy the file.
61         + When the file has special attributes, is a (hard/symbolic) link or
62 ***************
63 *** 856,861 ****
64 --- 864,878 ----
65         is possible without side effects (the attributes can be passed on and
66         and the file is not a link) that is used.  When problems are expected,
67         a copy will be made.
68
69 +       The "breaksymlink" and "breakhardlink" values can be used in
70 +       combination with any of "yes", "no" and "auto".  When included, they
71 +       force Vim to always break either symbolic or hard links by doing
72 +       exactly what the "no" option does, renaming the original file to
73 +       become the backup and writing a new file in its place.  This can be
74 +       useful for example in source trees where all the files are symbolic or
75 +       hard links and any changes should stay in the local source tree, not
76 +       be propagated back to the original source.
77                                                         *crontab*
78         One situation where "no" and "auto" will cause problems: A program
79         that opens a file, invokes Vim to edit that file, and then tests if
80 *** ../vim-6.2.480/src/fileio.c Fri Apr 16 19:59:33 2004
81 --- src/fileio.c        Mon Apr 19 09:52:52 2004
82 ***************
83 *** 2876,2887 ****
84        */
85       if (!(append && *p_pm == NUL) && !filtering && perm >= 0 && dobackup)
86       {
87 !       if (*p_bkc == 'y' || append)    /* "yes" */
88             backup_copy = TRUE;
89   #if defined(UNIX) || defined(WIN32)
90 !       else if (*p_bkc == 'a')         /* "auto" */
91         {
92 -           struct stat st;
93             int         i;
94   
95   # ifdef UNIX
96 --- 2876,2890 ----
97        */
98       if (!(append && *p_pm == NUL) && !filtering && perm >= 0 && dobackup)
99       {
100 ! #if defined(UNIX) || defined(WIN32)
101 !       struct stat st;
102 ! #endif
103
104 !       if ((bkc_flags & BKC_YES) || append)    /* "yes" */
105             backup_copy = TRUE;
106   #if defined(UNIX) || defined(WIN32)
107 !       else if ((bkc_flags & BKC_AUTO))        /* "auto" */
108         {
109             int         i;
110   
111   # ifdef UNIX
112 ***************
113 *** 2932,2937 ****
114 --- 2935,2965 ----
115                 }
116             }
117         }
118
119 + # ifdef UNIX
120 +       /*
121 +        * Break symlinks and/or hardlinks if we've been asked to.
122 +        */
123 +       if ((bkc_flags & BKC_BREAKSYMLINK) || (bkc_flags & BKC_BREAKHARDLINK))
124 +       {
125 +           int lstat_res;
126
127 +           lstat_res = mch_lstat((char *)fname, &st);
128
129 +           /* Symlinks. */
130 +           if ((bkc_flags & BKC_BREAKSYMLINK)
131 +                   && lstat_res == 0
132 +                   && st.st_ino != st_old.st_ino)
133 +               backup_copy = FALSE;
134
135 +           /* Hardlinks. */
136 +           if ((bkc_flags & BKC_BREAKHARDLINK)
137 +                   && st_old.st_nlink > 1
138 +                   && (lstat_res != 0 || st.st_ino == st_old.st_ino))
139 +               backup_copy = FALSE;
140 +       }
141 + #endif
142
143   #endif
144   
145         /* make sure we have a valid backup extension to use */
146 *** ../vim-6.2.480/src/option.c Wed Apr 14 11:08:53 2004
147 --- src/option.c        Sun Apr 18 17:20:24 2004
148 ***************
149 *** 402,408 ****
150       {"backup",            "bk",   P_BOOL|P_VI_DEF|P_VIM,
151                             (char_u *)&p_bk, PV_NONE,
152                             {(char_u *)FALSE, (char_u *)0L}},
153 !     {"backupcopy",  "bkc",  P_STRING|P_VIM,
154                             (char_u *)&p_bkc, PV_NONE,
155   #ifdef UNIX
156                             {(char_u *)"yes", (char_u *)"auto"}
157 --- 402,408 ----
158       {"backup",            "bk",   P_BOOL|P_VI_DEF|P_VIM,
159                             (char_u *)&p_bk, PV_NONE,
160                             {(char_u *)FALSE, (char_u *)0L}},
161 !     {"backupcopy",  "bkc",  P_STRING|P_VIM|P_COMMA|P_NODUP,
162                             (char_u *)&p_bkc, PV_NONE,
163   #ifdef UNIX
164                             {(char_u *)"yes", (char_u *)"auto"}
165 ***************
166 *** 2391,2397 ****
167   static char *(p_ambw_values[]) = {"single", "double", NULL};
168   #endif
169   static char *(p_bg_values[]) = {"light", "dark", NULL};
170 - static char *(p_bkc_values[]) = {"yes", "auto", "no", NULL};
171   static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
172   static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
173   #ifdef FEAT_WAK
174 --- 2403,2408 ----
175 ***************
176 *** 4295,4300 ****
177 --- 4306,4312 ----
178       (void)init_chartab();
179   
180       (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
181 +     (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
182   #ifdef FEAT_SESSION
183       (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
184       (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
185 ***************
186 *** 4624,4631 ****
187       /* 'backupcopy' */
188       else if (varp == &p_bkc)
189       {
190 !       if (check_opt_strings(p_bkc, p_bkc_values, FALSE) != OK)
191             errmsg = e_invarg;
192       }
193   
194       /* 'backupext' and 'patchmode' */
195 --- 4636,4651 ----
196       /* 'backupcopy' */
197       else if (varp == &p_bkc)
198       {
199 !       if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
200             errmsg = e_invarg;
201 +       if (((bkc_flags & BKC_AUTO) != 0)
202 +               + ((bkc_flags & BKC_YES) != 0)
203 +               + ((bkc_flags & BKC_NO) != 0) != 1)
204 +       {
205 +           /* Must have exactly one of "auto", "yes"  and "no". */
206 +           (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
207 +           errmsg = e_invarg;
208 +       }
209       }
210   
211       /* 'backupext' and 'patchmode' */
212 *** ../vim-6.2.480/src/option.h Fri Apr  2 21:06:43 2004
213 --- src/option.h        Sun Apr 18 17:18:35 2004
214 ***************
215 *** 301,306 ****
216 --- 301,315 ----
217   EXTERN char_u *p_bg;          /* 'background' */
218   EXTERN int    p_bk;           /* 'backup' */
219   EXTERN char_u *p_bkc;         /* 'backupcopy' */
220 + EXTERN unsigned       bkc_flags;
221 + #ifdef IN_OPTION_C
222 + static char *(p_bkc_values[]) = {"yes", "auto", "no", "breaksymlink", "breakhardlink", NULL};
223 + #endif
224 + # define BKC_YES              0x001
225 + # define BKC_AUTO             0x002
226 + # define BKC_NO                       0x004
227 + # define BKC_BREAKSYMLINK     0x008
228 + # define BKC_BREAKHARDLINK    0x010
229   EXTERN char_u *p_bdir;        /* 'backupdir' */
230   EXTERN char_u *p_bex;         /* 'backupext' */
231   #ifdef FEAT_WILDIGN
232 *** ../vim-6.2.480/src/version.c        Sat Apr 17 21:14:10 2004
233 --- src/version.c       Mon Apr 19 16:51:55 2004
234 ***************
235 *** 639,640 ****
236 --- 639,642 ----
237   {   /* Add new patch number below this line */
238 + /**/
239 +     481,
240   /**/
241
242 -- 
243 A disclaimer for the disclaimer:
244 "and before I get a huge amount of complaints , I have no control over the
245 disclaimer at the end of this mail :-)" (Timothy Aldrich)
246
247  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
248 ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
249 \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
250  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
This page took 0.494379 seconds and 3 git commands to generate.