Mercurial > hg > octave-kai > gnulib-hg
annotate lib/savewd.c @ 13616:acc972b5da60
fcntl-h, etc.: prefer O_SEARCH to O_RDONLY when applicable
POSIX 2008 specifies a new 'open' flag O_SEARCH, which can be used
when one needs search access to a directory but not read access.
On systems where it is available, it works in some cases where
O_RDONLY does not, namely on directories that are searchable but
not readable, and which need only to be searchable. If O_SEARCH
is not available, fall back to the traditional method of using
O_RDONLY.
* lib/fcntl.in.h (O_SEARCH): #define to O_RDONLY if not defined.
* lib/chdir-long.c (cdb_advance_fd): Use O_SEARCH, not O_RDONLY,
when opening a directory that needs only to be searchable.
* lib/chdir-safer.c (chdir_no_follow): Likewise.
* lib/fts.c (diropen, fts_open, fd_ring_check): Likewise.
* lib/openat-proc.c (openat_proc_name): Likewise.
* lib/openat.c (openat_needs_fchdir): Likewise.
* lib/save-cwd.c (save_cwd): Likewise.
* lib/savewd.c (savewd_save, savewd_chdir): Likewise.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 01 Sep 2010 13:45:53 -0700 |
parents | c2cbabec01dd |
children | 97fc9a21a8fb |
rev | line source |
---|---|
7315 | 1 /* Save and restore the working directory, possibly using a child process. |
2 | |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12518
diff
changeset
|
3 Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc. |
7315 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9216
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
7315 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9216
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9216
diff
changeset
|
8 (at your option) any later version. |
7315 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9216
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
7315 | 17 |
18 /* Written by Paul Eggert. */ | |
19 | |
20 #include <config.h> | |
21 | |
22 #include "savewd.h" | |
23 | |
24 #include <assert.h> | |
25 #include <errno.h> | |
26 #include <fcntl.h> | |
7375 | 27 #include <signal.h> |
7315 | 28 #include <stdbool.h> |
8196
5166dec344af
exit.h is replaced with stdlib.h.
Bruno Haible <bruno@clisp.org>
parents:
7408
diff
changeset
|
29 #include <stdlib.h> |
7315 | 30 #include <sys/types.h> |
31 #include <sys/wait.h> | |
32 #include <unistd.h> | |
33 | |
34 #include "dirname.h" | |
35 #include "fcntl-safer.h" | |
36 | |
37 /* Save the working directory into *WD, if it hasn't been saved | |
38 already. Return true if a child has been forked to do the real | |
39 work. */ | |
40 static bool | |
41 savewd_save (struct savewd *wd) | |
42 { | |
43 switch (wd->state) | |
44 { | |
45 case INITIAL_STATE: | |
46 /* Save the working directory, or prepare to fall back if possible. */ | |
47 { | |
13616
acc972b5da60
fcntl-h, etc.: prefer O_SEARCH to O_RDONLY when applicable
Paul Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
48 int fd = open_safer (".", O_SEARCH); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
49 if (0 <= fd) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
50 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
51 wd->state = FD_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
52 wd->val.fd = fd; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
53 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
54 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
55 if (errno != EACCES && errno != ESTALE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
56 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
57 wd->state = ERROR_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
58 wd->val.errnum = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
59 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
60 } |
7315 | 61 } |
62 wd->state = FORKING_STATE; | |
63 wd->val.child = -1; | |
64 /* Fall through. */ | |
65 case FORKING_STATE: | |
66 if (wd->val.child < 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
67 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
68 /* "Save" the initial working directory by forking a new |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
69 subprocess that will attempt all the work from the chdir |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
70 until until the next savewd_restore. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
71 wd->val.child = fork (); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
72 if (wd->val.child != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
73 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
74 if (0 < wd->val.child) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
75 return true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
76 wd->state = ERROR_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
77 wd->val.errnum = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
78 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
79 } |
7315 | 80 break; |
81 | |
82 case FD_STATE: | |
83 case FD_POST_CHDIR_STATE: | |
84 case ERROR_STATE: | |
85 case FINAL_STATE: | |
86 break; | |
87 | |
88 default: | |
89 assert (false); | |
90 } | |
91 | |
92 return false; | |
93 } | |
94 | |
95 int | |
96 savewd_chdir (struct savewd *wd, char const *dir, int options, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
97 int open_result[2]) |
7315 | 98 { |
99 int fd = -1; | |
100 int result = 0; | |
101 | |
102 /* Open the directory if requested, or if avoiding a race condition | |
103 is requested and possible. */ | |
7408 | 104 if (open_result |
105 || (options & (HAVE_WORKING_O_NOFOLLOW ? SAVEWD_CHDIR_NOFOLLOW : 0))) | |
7315 | 106 { |
107 fd = open (dir, | |
13616
acc972b5da60
fcntl-h, etc.: prefer O_SEARCH to O_RDONLY when applicable
Paul Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
108 (O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
109 | (options & SAVEWD_CHDIR_NOFOLLOW ? O_NOFOLLOW : 0))); |
7315 | 110 |
111 if (open_result) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
112 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
113 open_result[0] = fd; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
114 open_result[1] = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
115 } |
7315 | 116 |
117 if (fd < 0 && (errno != EACCES || (options & SAVEWD_CHDIR_READABLE))) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
118 result = -1; |
7315 | 119 } |
120 | |
121 if (result == 0 && ! (0 <= fd && options & SAVEWD_CHDIR_SKIP_READABLE)) | |
122 { | |
123 if (savewd_save (wd)) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
124 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
125 open_result = NULL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
126 result = -2; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
127 } |
7315 | 128 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
129 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
130 result = (fd < 0 ? chdir (dir) : fchdir (fd)); |
7315 | 131 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
132 if (result == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
133 switch (wd->state) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
134 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
135 case FD_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
136 wd->state = FD_POST_CHDIR_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
137 break; |
7315 | 138 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
139 case ERROR_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
140 case FD_POST_CHDIR_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
141 case FINAL_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
142 break; |
7315 | 143 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
144 case FORKING_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
145 assert (wd->val.child == 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
146 break; |
7315 | 147 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
148 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
149 assert (false); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
150 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
151 } |
7315 | 152 } |
153 | |
154 if (0 <= fd && ! open_result) | |
155 { | |
156 int e = errno; | |
157 close (fd); | |
158 errno = e; | |
159 } | |
160 | |
161 return result; | |
162 } | |
163 | |
164 int | |
165 savewd_restore (struct savewd *wd, int status) | |
166 { | |
167 switch (wd->state) | |
168 { | |
169 case INITIAL_STATE: | |
170 case FD_STATE: | |
171 /* The working directory is the desired directory, so there's no | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
172 work to do. */ |
7315 | 173 break; |
174 | |
175 case FD_POST_CHDIR_STATE: | |
176 /* Restore the working directory using fchdir. */ | |
177 if (fchdir (wd->val.fd) == 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
178 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
179 wd->state = FD_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
180 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
181 } |
7315 | 182 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
183 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
184 int chdir_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
185 close (wd->val.fd); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
186 wd->state = ERROR_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
187 wd->val.errnum = chdir_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
188 } |
7315 | 189 /* Fall through. */ |
190 case ERROR_STATE: | |
191 /* Report an error if asked to restore the working directory. */ | |
192 errno = wd->val.errnum; | |
193 return -1; | |
194 | |
195 case FORKING_STATE: | |
196 /* "Restore" the working directory by waiting for the subprocess | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
197 to finish. */ |
7315 | 198 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
199 pid_t child = wd->val.child; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
200 if (child == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
201 _exit (status); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
202 if (0 < child) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
203 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
204 int child_status; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
205 while (waitpid (child, &child_status, 0) < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
206 assert (errno == EINTR); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
207 wd->val.child = -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
208 if (! WIFEXITED (child_status)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
209 raise (WTERMSIG (child_status)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
210 return WEXITSTATUS (child_status); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
211 } |
7315 | 212 } |
213 break; | |
214 | |
215 default: | |
216 assert (false); | |
217 } | |
218 | |
219 return 0; | |
220 } | |
221 | |
222 void | |
223 savewd_finish (struct savewd *wd) | |
224 { | |
225 switch (wd->state) | |
226 { | |
227 case INITIAL_STATE: | |
228 case ERROR_STATE: | |
229 break; | |
230 | |
231 case FD_STATE: | |
232 case FD_POST_CHDIR_STATE: | |
233 close (wd->val.fd); | |
234 break; | |
235 | |
236 case FORKING_STATE: | |
237 assert (wd->val.child < 0); | |
238 break; | |
239 | |
240 default: | |
241 assert (false); | |
242 } | |
243 | |
244 wd->state = FINAL_STATE; | |
245 } | |
246 | |
247 /* Return true if the actual work is currently being done by a | |
248 subprocess. | |
249 | |
250 A true return means that the caller and the subprocess should | |
251 resynchronize later with savewd_restore, using only their own | |
252 memory to decide when to resynchronize; they should not consult the | |
253 file system to decide, because that might lead to race conditions. | |
254 This is why savewd_chdir is broken out into another function; | |
255 savewd_chdir's callers _can_ inspect the file system to decide | |
256 whether to call savewd_chdir. */ | |
257 static inline bool | |
258 savewd_delegating (struct savewd const *wd) | |
259 { | |
260 return wd->state == FORKING_STATE && 0 < wd->val.child; | |
261 } | |
262 | |
263 int | |
264 savewd_process_files (int n_files, char **file, | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
265 int (*act) (char *, struct savewd *, void *), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
266 void *options) |
7315 | 267 { |
268 int i = 0; | |
269 int last_relative; | |
270 int exit_status = EXIT_SUCCESS; | |
271 struct savewd wd; | |
272 savewd_init (&wd); | |
273 | |
274 for (last_relative = n_files - 1; 0 <= last_relative; last_relative--) | |
275 if (! IS_ABSOLUTE_FILE_NAME (file[last_relative])) | |
276 break; | |
277 | |
278 for (; i < last_relative; i++) | |
279 { | |
280 if (! savewd_delegating (&wd)) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
281 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
282 int s = act (file[i], &wd, options); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
283 if (exit_status < s) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
284 exit_status = s; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
285 } |
7315 | 286 |
287 if (! IS_ABSOLUTE_FILE_NAME (file[i + 1])) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
288 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
289 int r = savewd_restore (&wd, exit_status); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
290 if (exit_status < r) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
291 exit_status = r; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
292 } |
7315 | 293 } |
294 | |
295 savewd_finish (&wd); | |
296 | |
297 for (; i < n_files; i++) | |
298 { | |
299 int s = act (file[i], &wd, options); | |
300 if (exit_status < s) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
301 exit_status = s; |
7315 | 302 } |
303 | |
304 return exit_status; | |
305 } |