Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/usr.sbin/cron Pull up revision 1.19 (requested by huber...



details:   https://anonhg.NetBSD.org/src/rev/4c319f5d9604
branches:  netbsd-1-6
changeset: 530661:4c319f5d9604
user:      tron <tron%NetBSD.org@localhost>
date:      Sun Sep 07 07:33:36 2003 +0000

description:
Pull up revision 1.19 (requested by hubertf in ticket #1450):
In "crontab -l", suppress the header lines, just as "crontab -e" does.
OK'd by Christos Zoulas and Paul Vixie.
Fixes PR 21705.

diffstat:

 usr.sbin/cron/crontab.c |  58 ++++++++++++++++++++++++++++++------------------
 1 files changed, 36 insertions(+), 22 deletions(-)

diffs (114 lines):

diff -r afc142c5544e -r 4c319f5d9604 usr.sbin/cron/crontab.c
--- a/usr.sbin/cron/crontab.c   Fri Sep 05 21:49:10 2003 +0000
+++ b/usr.sbin/cron/crontab.c   Sun Sep 07 07:33:36 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crontab.c,v 1.15 1999/05/29 18:43:40 christos Exp $    */
+/*     $NetBSD: crontab.c,v 1.15.10.1 2003/09/07 07:33:36 tron Exp $   */
 
 /* Copyright 1988,1990,1993,1994 by Paul Vixie
  * All rights reserved
@@ -22,7 +22,7 @@
 #if 0
 static char rcsid[] = "Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp";
 #else
-__RCSID("$NetBSD: crontab.c,v 1.15 1999/05/29 18:43:40 christos Exp $");
+__RCSID("$NetBSD: crontab.c,v 1.15.10.1 2003/09/07 07:33:36 tron Exp $");
 #endif
 #endif
 
@@ -77,6 +77,7 @@
                        poke_daemon __P((void)),
                        check_error __P((const char *)),
                        parse_args __P((int c, char *v[])),
+                       skip_header __P((int *, FILE *)),
                        usage __P((char *));
 static int             replace_cmd __P((void));
 
@@ -259,6 +260,34 @@
                      User, Filename, Options[(int)Option]))
 }
 
+static void
+skip_header(pch, f)
+       int     *pch;
+       FILE    *f;
+{
+       int ch;
+       int x;
+       
+       /* ignore the top few comments since we probably put them there.
+        */
+       for (x = 0;  x < NHEADER_LINES;  x++) {
+               ch = get_char(f);
+               if (EOF == ch)
+                       break;
+               if ('#' != ch) {
+                       putc(ch, NewCrontab);
+                       break;
+               }
+               while (EOF != (ch = get_char(f)))
+                       if (ch == '\n')
+                               break;
+               if (EOF == ch)
+                       break;
+       }
+
+       *pch = ch;
+}
+
 
 static void
 list_cmd() {
@@ -279,6 +308,7 @@
        /* file is open. copy to stdout, close.
         */
        Set_LineNum(1)
+       skip_header(&ch, f);
        while (EOF != (ch = get_char(f)))
                putchar(ch);
        fclose(f);
@@ -316,7 +346,7 @@
        char            n[MAX_FNAME], q[MAX_TEMPSTR];
        const char      *editor;
        FILE            *f;
-       int             ch, t, x;
+       int             ch, t;
        struct stat     statbuf;
        time_t          mtime;
        long            mtimensec;
@@ -357,24 +387,8 @@
        }
 
        Set_LineNum(1)
-
-       /* ignore the top few comments since we probably put them there.
-        */
-       for (x = 0;  x < NHEADER_LINES;  x++) {
-               ch = get_char(f);
-               if (EOF == ch)
-                       break;
-               if ('#' != ch) {
-                       putc(ch, NewCrontab);
-                       break;
-               }
-               while (EOF != (ch = get_char(f)))
-                       if (ch == '\n')
-                               break;
-               if (EOF == ch)
-                       break;
-       }
-
+        skip_header(&ch, f);
+         
        /* copy the rest of the crontab (if any) to the temp file.
         */
        if (EOF != ch)
@@ -571,7 +585,7 @@
        fprintf(tmp, "# DO NOT EDIT THIS FILE - edit the master and reinstall.\n");
        fprintf(tmp, "# (%s installed on %-24.24s)\n", Filename, ctime(&now));
        fprintf(tmp, "# (Cron version -- %s)\n",
-           "$NetBSD: crontab.c,v 1.15 1999/05/29 18:43:40 christos Exp $");
+           "$NetBSD: crontab.c,v 1.15.10.1 2003/09/07 07:33:36 tron Exp $");
 
        /* copy the crontab to the tmp
         */



Home | Main Index | Thread Index | Old Index