|
Lines 43-49
Link Here
|
| 43 |
# include <locale.h> |
43 |
# include <locale.h> |
| 44 |
#endif |
44 |
#endif |
| 45 |
|
45 |
|
| 46 |
|
46 |
#include <string.h> |
| 47 |
#define NHEADER_LINES 3 |
47 |
#define NHEADER_LINES 3 |
| 48 |
|
48 |
|
| 49 |
|
49 |
|
|
Lines 269-282
Link Here
|
| 269 |
fprintf(stderr, "\"%s\":%d: %s\n", Filename, LineNumber-1, msg); |
269 |
fprintf(stderr, "\"%s\":%d: %s\n", Filename, LineNumber-1, msg); |
| 270 |
} |
270 |
} |
| 271 |
|
271 |
|
|
|
272 |
/* dwr 2000-11-04 compare entire statbuf instead of mtime's |
| 273 |
* (avoids some nasty #ifdef POSIX). |
| 274 |
*/ |
| 272 |
|
275 |
|
| 273 |
static void |
276 |
static void |
| 274 |
edit_cmd() { |
277 |
edit_cmd() { |
| 275 |
char n[MAX_FNAME], q[MAX_TEMPSTR], *editor; |
278 |
char n[MAX_FNAME], q[MAX_TEMPSTR], *editor; |
| 276 |
FILE *f; |
279 |
FILE *f; |
| 277 |
int ch, t, x; |
280 |
int ch, t, x; |
| 278 |
struct stat statbuf; |
281 |
struct stat statbuf, statprev; |
| 279 |
time_t mtime; |
|
|
| 280 |
WAIT_T waiter; |
282 |
WAIT_T waiter; |
| 281 |
PID_T pid, xpid; |
283 |
PID_T pid, xpid; |
| 282 |
mode_t um; |
284 |
mode_t um; |
|
Lines 340-351
Link Here
|
| 340 |
if (fclose(NewCrontab)) |
342 |
if (fclose(NewCrontab)) |
| 341 |
err(ERROR_EXIT, "%s", Filename); |
343 |
err(ERROR_EXIT, "%s", Filename); |
| 342 |
again: |
344 |
again: |
| 343 |
if (stat(Filename, &statbuf) < 0) { |
345 |
if (stat(Filename, &statprev) < 0) { |
| 344 |
warn("stat"); |
346 |
warn("stat"); |
| 345 |
fatal: unlink(Filename); |
347 |
fatal: unlink(Filename); |
| 346 |
exit(ERROR_EXIT); |
348 |
exit(ERROR_EXIT); |
| 347 |
} |
349 |
} |
| 348 |
mtime = statbuf.st_mtime; |
|
|
| 349 |
|
350 |
|
| 350 |
if ((!(editor = getenv("VISUAL"))) |
351 |
if ((!(editor = getenv("VISUAL"))) |
| 351 |
&& (!(editor = getenv("EDITOR"))) |
352 |
&& (!(editor = getenv("EDITOR"))) |
|
Lines 409-415
Link Here
|
| 409 |
warn("stat"); |
410 |
warn("stat"); |
| 410 |
goto fatal; |
411 |
goto fatal; |
| 411 |
} |
412 |
} |
| 412 |
if (mtime == statbuf.st_mtime) { |
413 |
if (0 == (memcmp(&statprev, &statbuf, sizeof(statprev))) ){ |
| 413 |
warnx("no changes made to crontab"); |
414 |
warnx("no changes made to crontab"); |
| 414 |
goto remove; |
415 |
goto remove; |
| 415 |
} |
416 |
} |