ALT Linux repos
S: | 4.1.20060426-alt10.3 |
5.0: | 4.1.20060426-alt6 |
4.1: | 4.1.20060426-alt4 |
4.0: | 4.1.20060426-alt4 |
3.0: | 4.1.20040916-alt2 |
Group :: System/Servers
RPM: vixie-cron
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: vixie-cron-4.1.20060426-alt-crontab-list.patch
Download
Download
--- vixie-cron-4.1.20060426/usr.sbin/cron/crontab.c
+++ vixie-cron-4.1.20060426/usr.sbin/cron/crontab.c
@@ -55,7 +55,8 @@ static void list_cmd(void),
edit_cmd(void),
check_error(const char *),
parse_args(int c, char *v[]),
- die(int);
+ die(int),
+ copy_crontab(FILE *f, FILE *t);
static int replace_cmd(void);
static void
@@ -247,8 +248,7 @@ list_cmd(void) {
/* file is open. copy to stdout, close.
*/
Set_LineNum(1)
- while (EOF != (ch = get_char(f)))
- putchar(ch);
+ copy_crontab(f, stdout);
fclose(f);
}
@@ -334,27 +334,7 @@ edit_cmd(void) {
}
Set_LineNum(1)
-
- /* ignore the top few comments since we probably put them there.
- */
- x = 0;
- while (EOF != (ch = get_char(f))) {
- if ('#' != ch) {
- putc(ch, NewCrontab);
- break;
- }
- while (EOF != (ch = get_char(f)))
- if (ch == '\n')
- break;
- if (++x >= NHEADER_LINES)
- break;
- }
-
- /* copy the rest of the crontab (if any) to the temp file.
- */
- if (EOF != ch)
- while (EOF != (ch = get_char(f)))
- putc(ch, NewCrontab);
+ copy_crontab(f, NewCrontab);
fclose(f);
if (fflush(NewCrontab) < OK) {
perror(Filename);
@@ -651,3 +631,29 @@ die(int x) {
(void) unlink(TempFilename);
_exit(ERROR_EXIT);
}
+
+static void
+copy_crontab(FILE *f, FILE *t)
+{
+ int ch, x = 0;
+
+ /* skip the top few comments since we probably put them there.
+ */
+ while (EOF != (ch = get_char(f))) {
+ if ('#' != ch) {
+ putc(ch, t);
+ break;
+ }
+ while (EOF != (ch = get_char(f)))
+ if (ch == '\n')
+ break;
+ if ((EOF == ch) || (++x >= NHEADER_LINES))
+ break;
+ }
+
+ /* copy the rest of the crontab (if any).
+ */
+ if (EOF != ch)
+ while (EOF != (ch = get_char(f)))
+ putc(ch, t);
+}