View | Details | Raw Unified | Return to bug 14751
Collapse All | Expand All

(-)a/vixie-cron/usr.sbin/cron/crontab.c (-14 / +31 lines)
Lines 56-62 static void list_cmd(void), Link Here
56
			check_error(const char *),
56
			check_error(const char *),
57
			parse_args(int c, char *v[]),
57
			parse_args(int c, char *v[]),
58
			die(int);
58
			die(int);
59
static	int		replace_cmd(void);
59
static	int		replace_cmd(void),
60
				ignore_comments(FILE *);
61
60
62
61
static void
63
static void
62
usage(const char *msg) {
64
usage(const char *msg) {
Lines 247-252 list_cmd(void) { Link Here
247
	/* file is open. copy to stdout, close.
249
	/* file is open. copy to stdout, close.
248
	 */
250
	 */
249
	Set_LineNum(1)
251
	Set_LineNum(1)
252
253
	/* ignore the top few comments since we probably put them there.
254
	 */
255
	ch = ignore_comments(f);
256
250
	while (EOF != (ch = get_char(f)))
257
	while (EOF != (ch = get_char(f)))
251
		putchar(ch);
258
		putchar(ch);
252
	fclose(f);
259
	fclose(f);
Lines 281-287 static void Link Here
281
edit_cmd(void) {
288
edit_cmd(void) {
282
	char n[MAX_FNAME], q[MAX_TEMPSTR], *editor;
289
	char n[MAX_FNAME], q[MAX_TEMPSTR], *editor;
283
	FILE *f;
290
	FILE *f;
284
	int ch, t, x;
291
	int ch, t;
285
	struct stat statbuf, xstatbuf;
292
	struct stat statbuf, xstatbuf;
286
	struct timespec mtimespec;
293
	struct timespec mtimespec;
287
	struct timeval tv[2];
294
	struct timeval tv[2];
Lines 337-354 edit_cmd(void) { Link Here
337
344
338
	/* ignore the top few comments since we probably put them there.
345
	/* ignore the top few comments since we probably put them there.
339
	 */
346
	 */
340
	x = 0;
347
	ch = ignore_comments(f);
341
	while (EOF != (ch = get_char(f))) {
342
		if ('#' != ch) {
343
			putc(ch, NewCrontab);
344
			break;
345
		}
346
		while (EOF != (ch = get_char(f)))
347
			if (ch == '\n')
348
				break;
349
		if (++x >= NHEADER_LINES)
350
			break;
351
	}
352
348
353
	/* copy the rest of the crontab (if any) to the temp file.
349
	/* copy the rest of the crontab (if any) to the temp file.
354
	 */
350
	 */
Lines 651-653 die(int x) { Link Here
651
		(void) unlink(TempFilename);
647
		(void) unlink(TempFilename);
652
	_exit(ERROR_EXIT);
648
	_exit(ERROR_EXIT);
653
}
649
}
650
651
static int
652
ignore_comments(FILE *f) {
653
	int ch, x;
654
655
	x = 0;
656
	while (EOF != (ch = get_char(f))) {
657
		if ('#' != ch) {
658
			putc(ch, NewCrontab);
659
			break;
660
		}
661
		while (EOF != (ch = get_char(f)))
662
			if (ch == '\n')
663
				break;
664
		if (++x >= NHEADER_LINES)
665
			break;
666
	}
667
668
	return ch;
669
}
670

Return to bug 14751