Mercurial > hg > octave-lojdl > gnulib-hg
annotate lib/savewd.c @ 17325:9d7698fd5b5f
openpty: fix bug where HAVE_OPENPTY is mistakenly 1
Problem reported by Mats Erik Andersson in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-02/msg00051.html>.
* m4/pty.m4 (gl_FUNC_OPENPTY): Define HAVE_OPENPTY when the
openpty function exists, not merely when we intend to replace it.
This corrects the 2013-01-31 patch, which mistakenly defined
HAVE_OPENPTY even on hosts that lacked it.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 08 Feb 2013 08:03:23 -0800 |
parents | e542fd46ad6f |
children |
rev | line source |
---|---|
7315 | 1 /* Save and restore the working directory, possibly using a child process. |
2 | |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
17181
diff
changeset
|
3 Copyright (C) 2006-2007, 2009-2013 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 | |
17181
a80e4b259d9b
chdir-long, cycle-check, savewd: better 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
22 #define SAVEWD_INLINE _GL_EXTERN_INLINE |
a80e4b259d9b
chdir-long, cycle-check, savewd: better 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
23 |
7315 | 24 #include "savewd.h" |
25 | |
26 #include <assert.h> | |
27 #include <errno.h> | |
28 #include <fcntl.h> | |
7375 | 29 #include <signal.h> |
7315 | 30 #include <stdbool.h> |
8196
5166dec344af
exit.h is replaced with stdlib.h.
Bruno Haible <bruno@clisp.org>
parents:
7408
diff
changeset
|
31 #include <stdlib.h> |
7315 | 32 #include <sys/types.h> |
33 #include <sys/wait.h> | |
34 #include <unistd.h> | |
35 | |
14393
9f47f8c334f2
dirname: move m4/dos.m4 functionality into lib/dosname.h
Paul Eggert <eggert@cs.ucla.edu>
parents:
14079
diff
changeset
|
36 #include "dosname.h" |
7315 | 37 #include "fcntl-safer.h" |
38 | |
39 /* Save the working directory into *WD, if it hasn't been saved | |
40 already. Return true if a child has been forked to do the real | |
41 work. */ | |
42 static bool | |
43 savewd_save (struct savewd *wd) | |
44 { | |
45 switch (wd->state) | |
46 { | |
47 case INITIAL_STATE: | |
48 /* Save the working directory, or prepare to fall back if possible. */ | |
49 { | |
13616
acc972b5da60
fcntl-h, etc.: prefer O_SEARCH to O_RDONLY when applicable
Paul Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
50 int fd = open_safer (".", O_SEARCH); |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
51 if (0 <= fd) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
52 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
53 wd->state = FD_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
54 wd->val.fd = fd; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
55 break; |
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 if (errno != EACCES && errno != ESTALE) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
58 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
59 wd->state = ERROR_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
60 wd->val.errnum = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
61 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
62 } |
7315 | 63 } |
64 wd->state = FORKING_STATE; | |
65 wd->val.child = -1; | |
66 /* Fall through. */ | |
67 case FORKING_STATE: | |
68 if (wd->val.child < 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
69 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
70 /* "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
|
71 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
|
72 until until the next savewd_restore. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
73 wd->val.child = fork (); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
74 if (wd->val.child != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
75 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
76 if (0 < wd->val.child) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
77 return true; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
78 wd->state = ERROR_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
79 wd->val.errnum = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
80 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
81 } |
7315 | 82 break; |
83 | |
84 case FD_STATE: | |
85 case FD_POST_CHDIR_STATE: | |
86 case ERROR_STATE: | |
87 case FINAL_STATE: | |
88 break; | |
89 | |
90 default: | |
91 assert (false); | |
92 } | |
93 | |
94 return false; | |
95 } | |
96 | |
97 int | |
98 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
|
99 int open_result[2]) |
7315 | 100 { |
101 int fd = -1; | |
102 int result = 0; | |
103 | |
104 /* Open the directory if requested, or if avoiding a race condition | |
105 is requested and possible. */ | |
7408 | 106 if (open_result |
107 || (options & (HAVE_WORKING_O_NOFOLLOW ? SAVEWD_CHDIR_NOFOLLOW : 0))) | |
7315 | 108 { |
109 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
|
110 (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
|
111 | (options & SAVEWD_CHDIR_NOFOLLOW ? O_NOFOLLOW : 0))); |
7315 | 112 |
113 if (open_result) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
114 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
115 open_result[0] = fd; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
116 open_result[1] = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
117 } |
7315 | 118 |
119 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
|
120 result = -1; |
7315 | 121 } |
122 | |
123 if (result == 0 && ! (0 <= fd && options & SAVEWD_CHDIR_SKIP_READABLE)) | |
124 { | |
125 if (savewd_save (wd)) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
126 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
127 open_result = NULL; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
128 result = -2; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
129 } |
7315 | 130 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
131 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
132 result = (fd < 0 ? chdir (dir) : fchdir (fd)); |
7315 | 133 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
134 if (result == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
135 switch (wd->state) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
136 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
137 case FD_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
138 wd->state = FD_POST_CHDIR_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
139 break; |
7315 | 140 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
141 case ERROR_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
142 case FD_POST_CHDIR_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
143 case FINAL_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
144 break; |
7315 | 145 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
146 case FORKING_STATE: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
147 assert (wd->val.child == 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
148 break; |
7315 | 149 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
150 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
151 assert (false); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
152 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
153 } |
7315 | 154 } |
155 | |
156 if (0 <= fd && ! open_result) | |
157 { | |
158 int e = errno; | |
159 close (fd); | |
160 errno = e; | |
161 } | |
162 | |
163 return result; | |
164 } | |
165 | |
166 int | |
167 savewd_restore (struct savewd *wd, int status) | |
168 { | |
169 switch (wd->state) | |
170 { | |
171 case INITIAL_STATE: | |
172 case FD_STATE: | |
173 /* 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
|
174 work to do. */ |
7315 | 175 break; |
176 | |
177 case FD_POST_CHDIR_STATE: | |
178 /* Restore the working directory using fchdir. */ | |
179 if (fchdir (wd->val.fd) == 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
180 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
181 wd->state = FD_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
182 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
183 } |
7315 | 184 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
185 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
186 int chdir_errno = errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
187 close (wd->val.fd); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
188 wd->state = ERROR_STATE; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
189 wd->val.errnum = chdir_errno; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
190 } |
7315 | 191 /* Fall through. */ |
192 case ERROR_STATE: | |
193 /* Report an error if asked to restore the working directory. */ | |
194 errno = wd->val.errnum; | |
195 return -1; | |
196 | |
197 case FORKING_STATE: | |
198 /* "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
|
199 to finish. */ |
7315 | 200 { |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
201 pid_t child = wd->val.child; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
202 if (child == 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
203 _exit (status); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
204 if (0 < child) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
205 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
206 int child_status; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
207 while (waitpid (child, &child_status, 0) < 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
208 assert (errno == EINTR); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
209 wd->val.child = -1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
210 if (! WIFEXITED (child_status)) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
211 raise (WTERMSIG (child_status)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
212 return WEXITSTATUS (child_status); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
213 } |
7315 | 214 } |
215 break; | |
216 | |
217 default: | |
218 assert (false); | |
219 } | |
220 | |
221 return 0; | |
222 } | |
223 | |
224 void | |
225 savewd_finish (struct savewd *wd) | |
226 { | |
227 switch (wd->state) | |
228 { | |
229 case INITIAL_STATE: | |
230 case ERROR_STATE: | |
231 break; | |
232 | |
233 case FD_STATE: | |
234 case FD_POST_CHDIR_STATE: | |
235 close (wd->val.fd); | |
236 break; | |
237 | |
238 case FORKING_STATE: | |
239 assert (wd->val.child < 0); | |
240 break; | |
241 | |
242 default: | |
243 assert (false); | |
244 } | |
245 | |
246 wd->state = FINAL_STATE; | |
247 } | |
248 | |
249 /* Return true if the actual work is currently being done by a | |
250 subprocess. | |
251 | |
252 A true return means that the caller and the subprocess should | |
253 resynchronize later with savewd_restore, using only their own | |
254 memory to decide when to resynchronize; they should not consult the | |
255 file system to decide, because that might lead to race conditions. | |
256 This is why savewd_chdir is broken out into another function; | |
257 savewd_chdir's callers _can_ inspect the file system to decide | |
258 whether to call savewd_chdir. */ | |
17181
a80e4b259d9b
chdir-long, cycle-check, savewd: better 'inline'
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
259 static bool |
7315 | 260 savewd_delegating (struct savewd const *wd) |
261 { | |
262 return wd->state == FORKING_STATE && 0 < wd->val.child; | |
263 } | |
264 | |
265 int | |
266 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
|
267 int (*act) (char *, struct savewd *, void *), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
268 void *options) |
7315 | 269 { |
270 int i = 0; | |
271 int last_relative; | |
272 int exit_status = EXIT_SUCCESS; | |
273 struct savewd wd; | |
274 savewd_init (&wd); | |
275 | |
276 for (last_relative = n_files - 1; 0 <= last_relative; last_relative--) | |
277 if (! IS_ABSOLUTE_FILE_NAME (file[last_relative])) | |
278 break; | |
279 | |
280 for (; i < last_relative; i++) | |
281 { | |
282 if (! savewd_delegating (&wd)) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
283 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
284 int s = act (file[i], &wd, options); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
285 if (exit_status < s) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
286 exit_status = s; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
287 } |
7315 | 288 |
289 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
|
290 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
291 int r = savewd_restore (&wd, exit_status); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
292 if (exit_status < r) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
293 exit_status = r; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
294 } |
7315 | 295 } |
296 | |
297 savewd_finish (&wd); | |
298 | |
299 for (; i < n_files; i++) | |
300 { | |
301 int s = act (file[i], &wd, options); | |
302 if (exit_status < s) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11941
diff
changeset
|
303 exit_status = s; |
7315 | 304 } |
305 | |
306 return exit_status; | |
307 } |