ports/71099: Update port sysutils/anacron: now compiles with gcc 3.4

dz at 426.ch dz at 426.ch
Sun Aug 29 11:30:20 UTC 2004


>Number:         71099
>Category:       ports
>Synopsis:       Update port sysutils/anacron: now compiles with gcc 3.4
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 29 11:30:17 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Derik van Zuetphen
>Release:        FreeBSD 5.2.1-RELEASE-p9 i386
>Organization:
>Environment:
System: FreeBSD trevize.a.426.ch 5.2.1-RELEASE-p9 FreeBSD 5.2.1-RELEASE-p9 #10: Mon Aug 2 14:04:17 CEST 2004 root at trevize.a.426.ch:/usr/obj/usr/src/sys/TREVIZE i386

gcc version 3.4.2 20040806 (prerelease) [FreeBSD]

>Description:
>How-To-Repeat:
>Fix:

--- anacron.shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	anacron
#	anacron/files
#	anacron/files/patch-aa
#	anacron/Makefile
#	anacron/pkg-descr
#	anacron/pkg-plist
#	anacron/distinfo
#	anacron/pkg-message
#
echo c - anacron
mkdir -p anacron > /dev/null 2>&1
echo c - anacron/files
mkdir -p anacron/files > /dev/null 2>&1
echo x - anacron/files/patch-aa
sed 's/^X//' >anacron/files/patch-aa << 'END-of-anacron/files/patch-aa'
Xdiff -uN ../anacron-2.3/Makefile ./Makefile
X--- ../anacron-2.3/Makefile	Fri Jun 23 00:26:11 2000
X+++ ./Makefile	Thu Aug 26 11:52:13 2004
X@@ -19,16 +19,16 @@
X #   `COPYING' that comes with the Anacron source distribution.
X 
X 
X-PREFIX = 
X-BINDIR = $(PREFIX)/usr/sbin
X-MANDIR = $(PREFIX)/usr/man
X+PREFIX ?= /usr/local
X+BINDIR = $(PREFIX)/sbin
X+MANDIR = $(PREFIX)/man
X CFLAGS = -Wall -pedantic -O2
X #CFLAGS = -Wall -O2 -g -DDEBUG
X 
X # If you change these, please update the man-pages too
X # Only absolute paths here, please
X SPOOLDIR = /var/spool/anacron
X-ANACRONTAB = /etc/anacrontab
X+ANACRONTAB = $(PREFIX)/etc/anacrontab
X 
X RELEASE = 2.3
X package_name = anacron-$(RELEASE)
X@@ -64,7 +64,7 @@
X 
X .PHONY: installdirs
X installdirs:
X-	$(INSTALL_DIR) $(BINDIR) $(PREFIX)$(SPOOLDIR) \
X+	$(INSTALL_DIR) $(BINDIR) $(SPOOLDIR) \
X 		$(MANDIR)/man5 $(MANDIR)/man8
X 
X .PHONY: install
X@@ -72,6 +72,7 @@
X 	$(INSTALL_PROGRAM) anacron $(BINDIR)/anacron
X 	$(INSTALL_DATA) anacrontab.5 $(MANDIR)/man5/anacrontab.5
X 	$(INSTALL_DATA) anacron.8 $(MANDIR)/man8/anacron.8
X+	$(INSTALL_DATA) anacrontab.sample $(PREFIX)/etc/anacrontab.sample
X 
X .PHONY: clean
X clean:
Xdiff -uN ../anacron-2.3/Makefile.orig ./Makefile.orig
X--- ../anacron-2.3/Makefile.orig	Thu Jan  1 01:00:00 1970
X+++ ./Makefile.orig	Fri Jun 23 00:26:11 2000
X@@ -0,0 +1,95 @@
X+#   Anacron - run commands periodically
X+#   Copyright (C) 1998  Itai Tzur <itzur at actcom.co.il>
X+#
X+#   This program is free software; you can redistribute it and/or modify
X+#   it under the terms of the GNU General Public License as published by
X+#   the Free Software Foundation; either version 2 of the License, or
X+#   (at your option) any later version.
X+#
X+#   This program is distributed in the hope that it will be useful,
X+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
X+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X+#   GNU General Public License for more details.
X+#
X+#   You should have received a copy of the GNU General Public License
X+#   along with this program; if not, write to the Free Software
X+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
X+#
X+#   The GNU General Public License can also be found in the file
X+#   `COPYING' that comes with the Anacron source distribution.
X+
X+
X+PREFIX = 
X+BINDIR = $(PREFIX)/usr/sbin
X+MANDIR = $(PREFIX)/usr/man
X+CFLAGS = -Wall -pedantic -O2
X+#CFLAGS = -Wall -O2 -g -DDEBUG
X+
X+# If you change these, please update the man-pages too
X+# Only absolute paths here, please
X+SPOOLDIR = /var/spool/anacron
X+ANACRONTAB = /etc/anacrontab
X+
X+RELEASE = 2.3
X+package_name = anacron-$(RELEASE)
X+distfiles = ChangeLog COPYING README TODO anacron.8 anacrontab.5 Makefile *.h *.c
X+
X+SHELL = /bin/sh
X+INSTALL = install
X+INSTALL_PROGRAM = $(INSTALL)
X+INSTALL_DATA = $(INSTALL)
X+INSTALL_DIR = $(INSTALL) -d
X+GZIP = gzip -9 -f
X+ALL_CPPFLAGS = -DSPOOLDIR=\"$(SPOOLDIR)\" -DRELEASE=\"$(RELEASE)\" \
X+	-DANACRONTAB=\"$(ANACRONTAB)\" $(CPPFLAGS)
X+
X+csources := $(wildcard *.c)
X+objects = $(csources:.c=.o)
X+
X+.PHONY: all
X+all: anacron
X+
X+# This makefile generates header file dependencies auto-magically
X+%.d: %.c
X+	$(SHELL) -ec "$(CC) -MM $(ALL_CPPFLAGS) $< \
X+	| sed '1s/^\(.*\)\.o[ :]*/\1.d &/1' > $@"
X+
X+include $(csources:.c=.d)
X+
X+anacron: $(objects)
X+	$(CC) $(LDFLAGS) $^ $(LOADLIBES) -o $@
X+
X+%.o : %.c
X+	$(CC) -c $(ALL_CPPFLAGS) $(CFLAGS) $< -o $@
X+
X+.PHONY: installdirs
X+installdirs:
X+	$(INSTALL_DIR) $(BINDIR) $(PREFIX)$(SPOOLDIR) \
X+		$(MANDIR)/man5 $(MANDIR)/man8
X+
X+.PHONY: install
X+install: installdirs
X+	$(INSTALL_PROGRAM) anacron $(BINDIR)/anacron
X+	$(INSTALL_DATA) anacrontab.5 $(MANDIR)/man5/anacrontab.5
X+	$(INSTALL_DATA) anacron.8 $(MANDIR)/man8/anacron.8
X+
X+.PHONY: clean
X+clean:
X+	rm -f *.o *.d anacron
X+
X+distclean: clean
X+	rm -f *~
X+
X+.PHONY: dist
X+dist: $(package_name).tar.gz
X+
X+$(package_name).tar.gz: $(distfiles)
X+	mkdir $(package_name)
X+	ln $(distfiles) $(package_name)
X+	chmod 0644 $(package_name)/*
X+	chmod 0755 $(package_name)
X+	tar cf $(package_name).tar $(package_name)
X+	$(GZIP) $(package_name).tar
X+	rm -r $(package_name)
X+
X+release: distclean $(package_name).tar.gz
Xdiff -uN ../anacron-2.3/anacron.8 ./anacron.8
X--- ../anacron-2.3/anacron.8	Fri Jun 23 00:42:05 2000
X+++ ./anacron.8	Thu Aug 26 11:52:13 2004
X@@ -18,7 +18,7 @@
X usually controlled by \fBcron\fR.
X .PP
X When executed, Anacron reads a list of jobs from a configuration file, normally
X-.I /etc/anacrontab
X+.I /usr/local/etc/anacrontab
X (see \fBanacrontab(5)\fR).  This file
X contains the list of jobs that Anacron controls.  Each
X job entry specifies a period in days, 
X@@ -84,7 +84,7 @@
X .TP
X .B -n
X Run jobs now.  Ignore the delay specifications in the
X-.I /etc/anacrontab
X+.I /usr/local/etc/anacrontab
X file.  This options implies \fB-s\fR.
X .TP
X .B -d
X@@ -117,7 +117,7 @@
X for more information.
X .SH FILES
X .TP
X-.I /etc/anacrontab
X+.I /usr/local/etc/anacrontab
X Contains specifications of jobs.  See \fBanacrontab(5)\fR for a complete
X description.
X .TP
Xdiff -uN ../anacron-2.3/anacron.8.orig ./anacron.8.orig
X--- ../anacron-2.3/anacron.8.orig	Thu Jan  1 01:00:00 1970
X+++ ./anacron.8.orig	Fri Jun 23 00:42:05 2000
X@@ -0,0 +1,147 @@
X+.TH ANACRON 8 2000-06-22 "Sean 'Shaleh' Perry" "Anacron Users' Manual"
X+.SH NAME
X+anacron \- runs commands periodically
X+.SH SYNOPSIS
X+.B anacron \fR[\fB-s\fR] [\fB-f\fR] [\fB-n\fR] [\fB-d\fR] [\fB-q\fR]
X+[\fB-t anacrontab\fR] [\fIjob\fR] ...
X+.br
X+.B anacron -u [\fB-t anacrontab\fR] \fR[\fIjob\fR] ...
X+.br
X+.B anacron \fR[\fB-V\fR|\fB-h\fR]
X+.SH DESCRIPTION
X+Anacron
X+can be used to execute commands periodically, with a
X+frequency specified in days.  Unlike \fBcron(8)\fR,
X+it does not assume that the machine is running continuously.  Hence,
X+it can be used on machines that aren't running 24 hours a day,
X+to control daily, weekly, and monthly jobs that are
X+usually controlled by \fBcron\fR.
X+.PP
X+When executed, Anacron reads a list of jobs from a configuration file, normally
X+.I /etc/anacrontab
X+(see \fBanacrontab(5)\fR).  This file
X+contains the list of jobs that Anacron controls.  Each
X+job entry specifies a period in days, 
X+a delay in minutes, a unique
X+job identifier, and a shell command.
X+.PP
X+For each job, Anacron checks whether
X+this job has been executed in the last n days, where n is the period specified
X+for that job.  If not, Anacron runs the job's shell command, after waiting
X+for the number of minutes specified as the delay parameter.
X+.PP
X+After the command exits, Anacron records the date in a special
X+timestamp file for that job, so it can know when to execute it again.  Only
X+the date is used for the time
X+calculations.  The hour is not used.
X+.PP
X+When there are no more jobs to be run, Anacron exits.
X+.PP
X+Anacron only considers jobs whose identifier, as
X+specified in the \fIanacrontab\fR matches any of
X+the
X+.I job
X+command-line arguments.  The
X+.I job
X+arguments can be shell wildcard patterns (be sure to protect them from
X+your shell with adequate quoting).  Specifying no
X+.I job
X+arguments, is equivalent to specifying "*"  (That is, all jobs will be
X+considered).
X+.PP
X+Unless the \fB-d\fR option is given (see below), Anacron forks to the
X+background when it starts, and the parent process exits
X+immediately.
X+.PP
X+Unless the \fB-s\fR or \fB-n\fR options are given, Anacron starts jobs
X+immediately when their delay is over.  The execution of different jobs is
X+completely independent.
X+.PP
X+If a job generates any output on its standard output or standard error,
X+the output is mailed to the user running Anacron (usually root).
X+.PP
X+Informative messages about what Anacron is doing are sent to \fBsyslogd(8)\fR
X+under facility \fBcron\fR, priority \fBnotice\fR.  Error messages are sent at
X+priority \fBerror\fR.
X+.PP
X+"Active" jobs (i.e. jobs that Anacron already decided
X+to run and now wait for their delay to pass, and jobs that are currently
X+being executed by
X+Anacron), are "locked", so that other copies of Anacron won't run them
X+at the same time.
X+.SH OPTIONS
X+.TP
X+.B -f
X+Force execution of the jobs, ignoring the timestamps.
X+.TP
X+.B -u
X+Only update the timestamps of the jobs, to the current date, but
X+don't run anything.
X+.TP
X+.B -s
X+Serialize execution of jobs.  Anacron will not start a new job before the
X+previous one finished.
X+.TP
X+.B -n
X+Run jobs now.  Ignore the delay specifications in the
X+.I /etc/anacrontab
X+file.  This options implies \fB-s\fR.
X+.TP
X+.B -d
X+Don't fork to the background.  In this mode, Anacron will output informational
X+messages to standard error, as well as to syslog.  The output of jobs
X+is mailed as usual.
X+.TP
X+.B -q
X+Suppress messages to standard error.  Only applicable with \fB-d\fR.
X+.TP
X+.B -t anacrontab
X+Use specified anacrontab, rather than the default
X+.TP
X+.B -V
X+Print version information, and exit.
X+.TP
X+.B -h
X+Print short usage message, and exit.
X+.SH SIGNALS
X+After receiving a \fBSIGUSR1\fR signal, Anacron waits for running
X+jobs, if any, to finish and then exits.  This can be used to stop
X+Anacron cleanly.
X+.SH NOTES
X+Make sure that the time-zone is set correctly before Anacron is
X+started.  (The time-zone affects the date).  This is usually accomplished
X+by setting the TZ environment variable, or by installing a
X+.I /usr/lib/zoneinfo/localtime
X+file.  See
X+.B tzset(3)
X+for more information.
X+.SH FILES
X+.TP
X+.I /etc/anacrontab
X+Contains specifications of jobs.  See \fBanacrontab(5)\fR for a complete
X+description.
X+.TP
X+.I /var/spool/anacron
X+This directory is used by Anacron for storing timestamp files.
X+.SH "SEE ALSO"
X+.B anacrontab(5), cron(8), tzset(3)
X+.PP
X+The Anacron
X+.I README
X+file.
X+.SH BUGS
X+Anacron never removes timestamp files.  Remove unused files manually.
X+.PP
X+Anacron
X+uses up to two file descriptors for each active job.  It may run out of
X+descriptors if there are more than about 125 active jobs (on normal kernels).
X+.PP
X+Mail comments, suggestions and bug reports to Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)>.
X+.SH AUTHOR
X+Anacron was originally conceived and implemented by Christian Schwarz
X+<schwarz at monet.m.isar.de>.
X+.PP
X+The current implementation is a complete rewrite by Itai Tzur
X+<itzur at actcom.co.il>.
X+.PP
X+The code base is currently maintained by Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)>.
Xdiff -uN ../anacron-2.3/anacrontab.5 ./anacrontab.5
X--- ../anacron-2.3/anacrontab.5	Wed Jun 21 01:12:18 2000
X+++ ./anacrontab.5	Thu Aug 26 11:52:13 2004
X@@ -1,9 +1,9 @@
X .TH ANACRONTAB 5 1998-02-02 "Itai Tzur" "Anacron Users' Manual"
X .SH NAME
X-/etc/anacrontab \- configuration file for anacron
X+/usr/local/etc/anacrontab \- configuration file for anacron
X .SH DESCRIPTION
X The file
X-.I /etc/anacrontab
X+.I /usr/local/etc/anacrontab
X describes the jobs controlled by \fBanacron(8)\fR.  Its lines can be of
X three kinds:  job-description lines, environment
X assignments, or empty lines.
Xdiff -uN ../anacron-2.3/anacrontab.5.orig ./anacrontab.5.orig
X--- ../anacron-2.3/anacrontab.5.orig	Thu Jan  1 01:00:00 1970
X+++ ./anacrontab.5.orig	Wed Jun 21 01:12:18 2000
X@@ -0,0 +1,48 @@
X+.TH ANACRONTAB 5 1998-02-02 "Itai Tzur" "Anacron Users' Manual"
X+.SH NAME
X+/etc/anacrontab \- configuration file for anacron
X+.SH DESCRIPTION
X+The file
X+.I /etc/anacrontab
X+describes the jobs controlled by \fBanacron(8)\fR.  Its lines can be of
X+three kinds:  job-description lines, environment
X+assignments, or empty lines.
X+.PP
X+Job-description lines are of the form:
X+.PP
X+   period  delay  job-identifier  command
X+.PP
X+The
X+.I period
X+is specified in days, the
X+.I delay
X+in minutes.  The
X+.I job-identifier
X+can contain any non-blank character, except slashes.  It is used to identify
X+the job in Anacron messages,
X+and as the name for the job's timestamp file.  The
X+.I command
X+can be any shell command.
X+.PP
X+Environment assignment lines are of the form:
X+.PP
X+   VAR = VALUE
X+.PP
X+Spaces around
X+.I VAR
X+are removed.  No spaces around
X+.I VALUE
X+are allowed (unless you want them to be part of the value).  The assignment
X+takes effect from the next line to the end of the file, or to the next
X+assignment of the same variable.
X+.PP
X+Empty lines are either blank lines, line containing white-space only, or
X+lines with white-space followed by a '#' followed by an arbitrary comment.
X+.SH "SEE ALSO"
X+.B anacron(8)
X+.PP
X+The Anacron
X+.I README
X+file.
X+.SH AUTHOR
X+Itai Tzur <itzur at actcom.co.il>
Xdiff -uN ../anacron-2.3/anacrontab.sample ./anacrontab.sample
X--- ../anacron-2.3/anacrontab.sample	Thu Jan  1 01:00:00 1970
X+++ ./anacrontab.sample	Thu Aug 26 11:52:13 2004
X@@ -0,0 +1,12 @@
X+
X+PATH=/bin:/sbin:/usr/bin:/usr/sbin
X+
X+# days		make sure the command is executed at least every 'days' days
X+# delay		delay in minutes, before a command starts
X+# id		unique id of a command
X+
X+# days	delay	id		command
X+1	5	daily		periodic daily
X+7	15	weekly		periodic weekly
X+30	60	monthly		periodic monthly
X+
Xdiff -uN ../anacron-2.3/gregor.c ./gregor.c
X--- ../anacron-2.3/gregor.c	Fri Jun 23 00:50:40 2000
X+++ ./gregor.c	Thu Aug 26 12:00:36 2004
X@@ -65,7 +65,7 @@
X {
X     int dn;
X     int i;
X-    const int isleap; /* save three calls to leap() */
X+    int isleap; /* save three calls to leap() */
X 
X     /* Some validity checks */
X 
Xdiff -uN ../anacron-2.3/matchrx.c ./matchrx.c
X--- ../anacron-2.3/matchrx.c	Wed Jun 21 01:12:18 2000
X+++ ./matchrx.c	Thu Aug 26 11:52:13 2004
X@@ -23,6 +23,7 @@
X 
X 
X #include <stdio.h>
X+#include <unistd.h>
X #include <regex.h>
X #include <stdarg.h>
X #include <stdlib.h>
Xdiff -uN ../anacron-2.3/matchrx.c.orig ./matchrx.c.orig
X--- ../anacron-2.3/matchrx.c.orig	Thu Jan  1 01:00:00 1970
X+++ ./matchrx.c.orig	Wed Jun 21 01:12:18 2000
X@@ -0,0 +1,74 @@
X+/*
X+    Anacron - run commands periodically
X+    Copyright (C) 1998  Itai Tzur <itzur at actcom.co.il>
X+    Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh at debian.org>
X+ 
X+    This program is free software; you can redistribute it and/or modify
X+    it under the terms of the GNU General Public License as published by
X+    the Free Software Foundation; either version 2 of the License, or
X+    (at your option) any later version.
X+ 
X+    This program is distributed in the hope that it will be useful,
X+    but WITHOUT ANY WARRANTY; without even the implied warranty of
X+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X+    GNU General Public License for more details.
X+ 
X+    You should have received a copy of the GNU General Public License
X+    along with this program; if not, write to the Free Software
X+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
X+ 
X+    The GNU General Public License can also be found in the file
X+    `COPYING' that comes with the Anacron source distribution.
X+*/
X+
X+
X+#include <stdio.h>
X+#include <regex.h>
X+#include <stdarg.h>
X+#include <stdlib.h>
X+#include "matchrx.h"
X+
X+int
X+match_rx(const char *rx, char *string, int n_sub,  /* char **substrings */...)
X+/* Return 1 if the regular expression "*rx" matches the string "*string",
X+ * 0 if not, -1 on error.
X+ * "Extended" regular expressions are used.
X+ * Additionally, there should be "n_sub" "substrings" arguments.  These,
X+ * if not NULL, and if the match succeeds are set to point to the 
X+ * corresponding substrings of the regexp.
X+ * The original string is changed, and the substrings must not overlap,
X+ * or even be directly adjacent.
X+ * This is not the most efficient, or elegant way of doing this.
X+ */
X+{
X+	int r, n;
X+	regex_t crx;
X+	va_list va;
X+	char **substring;
X+	regmatch_t *sub_offsets;
X+	sub_offsets = malloc(sizeof(regmatch_t) * (n_sub + 1));
X+	memset(sub_offsets, 0, sizeof(regmatch_t) * (n_sub + 1));
X+
X+	if (regcomp(&crx, rx, REG_EXTENDED)) return - 1;
X+	r = regexec(&crx, string, n_sub + 1, sub_offsets, 0);
X+	if (r != 0 && r != REG_NOMATCH) return - 1;
X+	regfree(&crx);
X+	if (r == REG_NOMATCH) return 0;
X+
X+	va_start(va, n_sub);
X+	n = 1;
X+	while (n <= n_sub)
X+	{
X+		substring = va_arg(va, char**);
X+		if (substring != NULL)
X+		{
X+			if (sub_offsets[n].rm_so == -1) return - 1;
X+			*substring = string + sub_offsets[n].rm_so;
X+			*(string + sub_offsets[n].rm_eo) = 0;
X+		}
X+		n++;
X+	}
X+	va_end(va);
X+	free(sub_offsets);
X+	return 1;
X+}
Xdiff -uN ../anacron-2.3/readtab.c ./readtab.c
X--- ../anacron-2.3/readtab.c	Fri Jun 23 00:13:12 2000
X+++ ./readtab.c	Thu Aug 26 11:52:13 2004
X@@ -19,6 +19,11 @@
X  
X     The GNU General Public License can also be found in the file
X     `COPYING' that comes with the Anacron source distribution.
X+
X+    Changes:
X+
X+    May 2003 (Derik van Zuetphen)
X+	replaced obstack with malloc/realloc calls
X */
X 
X 
X@@ -29,7 +34,6 @@
X #include <errno.h>
X #include <stdio.h>
X #include <stdlib.h>
X-#include <obstack.h>
X #include <limits.h>
X #include <fnmatch.h>
X #include <unistd.h>
X@@ -37,8 +41,6 @@
X #include "global.h"
X #include "matchrx.h"
X 
X-static struct obstack input_o;   /* holds input line */
X-static struct obstack tab_o;    /* holds processed data read from anacrontab */
X static FILE *tab;
X job_rec **job_array;
X int njobs;                       /* number of jobs to run */
X@@ -47,9 +49,7 @@
X static job_rec *last_job_rec;    /* last job stored in memory, at the moment */
X static env_rec *last_env_rec;    /* last environment assignment stored */
X 
X-/* some definitions for the obstack macros */
X-#define obstack_chunk_alloc xmalloc
X-#define obstack_chunk_free free
X+#define MAXTABLINE	1000
X 
X static void *
X xmalloc (size_t size)
X@@ -63,6 +63,18 @@
X     return ptr;
X }
X 
X+static void *
X+xrealloc (void *mem, size_t size)
X+/* Just like standard realloc(), only never returns NULL. */
X+{
X+    void * ptr;
X+
X+    ptr = realloc(mem,size);
X+    if (ptr == NULL)
X+	die("Memory exhausted");
X+    return ptr;
X+}
X+
X static int
X conv2int(const char *s)
X /* Return the int or -1 on over/under-flow
X@@ -78,19 +90,20 @@
X }
X 
X static char *
X-read_tab_line ()
X+read_tab_line (char *line)
X /* Read one line and return a pointer to it.
X Return NULL if no more lines.
X  */
X {
X     int c;
X+    int i = 0;
X 
X     if (feof(tab)) return NULL;
X-    while ((c = getc(tab)) != EOF && c != '\n')
X-	obstack_1grow(&input_o, c);
X+    while (i < MAXTABLINE-1 && (c = getc(tab)) != EOF && c != '\n')
X+	line[i++] = c;
X     if (ferror(tab)) die_e("Error reading %s", anacrontab);
X-    obstack_1grow(&input_o, '\0');
X-    return obstack_finish(&input_o);
X+    line[i] = 0;
X+    return line;
X }
X 
X static int
X@@ -119,8 +132,8 @@
X 
X     var_len = strlen(env_var);
X     val_len = strlen(value);
X-    er = obstack_alloc(&tab_o, sizeof(env_rec));
X-    er->assign = obstack_alloc(&tab_o, var_len + 1 + val_len + 1);
X+    er = (env_rec*)xmalloc(sizeof(env_rec));
X+    er->assign = (char*)xmalloc(var_len + 1 + val_len + 1);
X     strcpy(er->assign, env_var);
X     er->assign[var_len] = '=';
X     strcpy(er->assign + var_len + 1, value);
X@@ -151,14 +164,14 @@
X 		 anacrontab, line_num);
X 	return;
X     }
X-    jr = obstack_alloc(&tab_o, sizeof(job_rec));
X+    jr = (job_rec*)xmalloc(sizeof(job_rec));
X     jr->period = period;
X     jr->delay = delay;
X     jr->tab_line = line_num;
X-    jr->ident = obstack_alloc(&tab_o, ident_len + 1);
X+    jr->ident = (char*)xmalloc(ident_len + 1);
X     strcpy(jr->ident, ident);
X     jr->arg_num = job_arg_num(ident);
X-    jr->command = obstack_alloc(&tab_o, command_len + 1);
X+    jr->command = (char*)xmalloc(command_len + 1);
X     strcpy(jr->command, command);
X     jr->job_pid = jr->mailer_pid = 0;
X     if (last_job_rec != NULL) last_job_rec->next = jr;
X@@ -222,7 +235,7 @@
X read_tab()
X /* Read the anacrontab file into memory */
X {
X-    char *tab_line;
X+    char tab_line[MAXTABLINE];
X 
X     first_job_rec = last_job_rec = NULL;
X     first_env_rec = last_env_rec = NULL;
X@@ -231,14 +244,10 @@
X     /* Open the anacrontab file */
X     tab = fopen(anacrontab, "r");
X     if (tab == NULL) die_e("Error opening %s", anacrontab);
X-    /* Initialize the obstacks */
X-    obstack_init(&input_o);
X-    obstack_init(&tab_o);
X-    while ((tab_line = read_tab_line()) != NULL)
X+    while ((read_tab_line(tab_line)) != NULL)
X     {
X 	line_num++;
X 	parse_tab_line(tab_line);
X-	obstack_free(&input_o, tab_line);
X     }
X     if (fclose(tab)) die_e("Error closing %s", anacrontab);
X }
X@@ -269,16 +278,17 @@
X 
X     j = first_job_rec;
X     njobs = 0;
X+    job_array = NULL;
X     while (j != NULL)
X     {
X 	if (j->arg_num != -1 && (update_only || consider_job(j)))
X 	{
X+	    job_array = (job_rec**)xrealloc(job_array, (njobs+1)*sizeof(j));
X+	    job_array[njobs] = j;
X 	    njobs++;
X-	    obstack_grow(&tab_o, &j, sizeof(j));
X 	}
X 	j = j->next;
X     }
X-    job_array = obstack_finish(&tab_o);
X 
X     /* sort the jobs */
X     qsort(job_array, njobs, sizeof(*job_array),
Xdiff -uN ../anacron-2.3/readtab.c.orig ./readtab.c.orig
X--- ../anacron-2.3/readtab.c.orig	Thu Jan  1 01:00:00 1970
X+++ ./readtab.c.orig	Fri Jun 23 00:13:12 2000
X@@ -0,0 +1,286 @@
X+/*
X+    Anacron - run commands periodically
X+    Copyright (C) 1998  Itai Tzur <itzur at actcom.co.il>
X+    Copyright (C) 1999  Sean 'Shaleh' Perry <shaleh at debian.org>
X+ 
X+    This program is free software; you can redistribute it and/or modify
X+    it under the terms of the GNU General Public License as published by
X+    the Free Software Foundation; either version 2 of the License, or
X+    (at your option) any later version.
X+ 
X+    This program is distributed in the hope that it will be useful,
X+    but WITHOUT ANY WARRANTY; without even the implied warranty of
X+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X+    GNU General Public License for more details.
X+ 
X+    You should have received a copy of the GNU General Public License
X+    along with this program; if not, write to the Free Software
X+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
X+ 
X+    The GNU General Public License can also be found in the file
X+    `COPYING' that comes with the Anacron source distribution.
X+*/
X+
X+
X+/*  /etc/anacrontab parsing, and job sorting
X+ */
X+
X+#include <string.h>
X+#include <errno.h>
X+#include <stdio.h>
X+#include <stdlib.h>
X+#include <obstack.h>
X+#include <limits.h>
X+#include <fnmatch.h>
X+#include <unistd.h>
X+#include <signal.h>
X+#include "global.h"
X+#include "matchrx.h"
X+
X+static struct obstack input_o;   /* holds input line */
X+static struct obstack tab_o;    /* holds processed data read from anacrontab */
X+static FILE *tab;
X+job_rec **job_array;
X+int njobs;                       /* number of jobs to run */
X+static int jobs_read;            /* number of jobs read */
X+static int line_num;             /* current line in anacrontab */
X+static job_rec *last_job_rec;    /* last job stored in memory, at the moment */
X+static env_rec *last_env_rec;    /* last environment assignment stored */
X+
X+/* some definitions for the obstack macros */
X+#define obstack_chunk_alloc xmalloc
X+#define obstack_chunk_free free
X+
X+static void *
X+xmalloc (size_t size)
X+/* Just like standard malloc(), only never returns NULL. */
X+{
X+    void * ptr;
X+
X+    ptr = malloc(size);
X+    if (ptr == NULL)
X+	die("Memory exhausted");
X+    return ptr;
X+}
X+
X+static int
X+conv2int(const char *s)
X+/* Return the int or -1 on over/under-flow
X+ */
X+{
X+    long l;
X+
X+    errno = 0;
X+    l = strtol(s, NULL, 10);
X+    /* we use negative as error, so I am really returning unsigned int */
X+    if (errno == ERANGE || l < 0 || l > INT_MAX) return - 1;
X+    return l;
X+}
X+
X+static char *
X+read_tab_line ()
X+/* Read one line and return a pointer to it.
X+Return NULL if no more lines.
X+ */
X+{
X+    int c;
X+
X+    if (feof(tab)) return NULL;
X+    while ((c = getc(tab)) != EOF && c != '\n')
X+	obstack_1grow(&input_o, c);
X+    if (ferror(tab)) die_e("Error reading %s", anacrontab);
X+    obstack_1grow(&input_o, '\0');
X+    return obstack_finish(&input_o);
X+}
X+
X+static int
X+job_arg_num(const char *ident)
X+/* Return the command-line-argument number refering to this job-identifier.
X+ * If it isn't specified, return -1.
X+ */
X+{
X+    int i, r;
X+
X+    for (i = 0; i < nargs; i++)
X+    {
X+	r = fnmatch(args[i], ident, 0);
X+	if (r == 0) return i;
X+	if (r != FNM_NOMATCH) die("fnmatch() error");
X+    }
X+    return - 1;
X+}
X+
X+static void
X+register_env(const char *env_var, const char *value)
X+/* Store the environment assignment "env_var"="value" */
X+{
X+    env_rec *er;
X+    int var_len, val_len;
X+
X+    var_len = strlen(env_var);
X+    val_len = strlen(value);
X+    er = obstack_alloc(&tab_o, sizeof(env_rec));
X+    er->assign = obstack_alloc(&tab_o, var_len + 1 + val_len + 1);
X+    strcpy(er->assign, env_var);
X+    er->assign[var_len] = '=';
X+    strcpy(er->assign + var_len + 1, value);
X+    er->assign[var_len + 1 + val_len] = 0;
X+    if (last_env_rec != NULL) last_env_rec->next = er;
X+    else first_env_rec = er;
X+    last_env_rec = er;
X+    Debug(("on line %d: %s", line_num, er->assign));
X+}
X+
X+static void
X+register_job(const char *periods, const char *delays,
X+	     const char *ident, char *command)
X+/* Store a job definition */
X+{
X+    int period, delay;
X+    job_rec *jr;
X+    int ident_len, command_len;
X+
X+    ident_len = strlen(ident);
X+    command_len = strlen(command);
X+    jobs_read++;
X+    period = conv2int(periods);
X+    delay = conv2int(delays);
X+    if (period < 0 || delay < 0)
X+    {
X+	complain("%s: number out of range on line %d, skipping",
X+		 anacrontab, line_num);
X+	return;
X+    }
X+    jr = obstack_alloc(&tab_o, sizeof(job_rec));
X+    jr->period = period;
X+    jr->delay = delay;
X+    jr->tab_line = line_num;
X+    jr->ident = obstack_alloc(&tab_o, ident_len + 1);
X+    strcpy(jr->ident, ident);
X+    jr->arg_num = job_arg_num(ident);
X+    jr->command = obstack_alloc(&tab_o, command_len + 1);
X+    strcpy(jr->command, command);
X+    jr->job_pid = jr->mailer_pid = 0;
X+    if (last_job_rec != NULL) last_job_rec->next = jr;
X+    else first_job_rec = jr;
X+    last_job_rec = jr;
X+    jr->prev_env_rec = last_env_rec;
X+    jr->next = NULL;
X+    Debug(("Read job - period=%d, delay=%d, ident=%s, command=%s",
X+	   jr->period, jr->delay, jr->ident, jr->command));
X+}
X+
X+static void
X+parse_tab_line(char *line)
X+{
X+    int r;
X+    char *env_var;
X+    char *value;
X+    char *periods;
X+    char *delays;
X+    char *ident;
X+    char *command;
X+
X+    /* an empty line? */
X+    r = match_rx("^[ \t]*($|#)", line, 0);
X+    if (r == -1) goto reg_err;
X+    if (r)
X+    {
X+	Debug(("line %d empty", line_num));
X+	return;
X+    }
X+
X+    /* an environment assignment? */
X+    r = match_rx("^[ \t]*([^ \t=]+)[ \t]*=(.*)$", line, 2,
X+		 &env_var, &value);
X+    if (r == -1) goto reg_err;
X+    if (r)
X+    {
X+	register_env(env_var, value);
X+	return;
X+    }
X+
X+    /* a job? */
X+    r = match_rx("^[ \t]*([[:digit:]]+)[ \t]+([[:digit:]]+)[ \t]+"
X+		 "([^ \t/]+)[ \t]+([^ \t].*)$",
X+		 line, 4, &periods, &delays, &ident, &command);
X+    if (r == -1) goto reg_err;
X+    if (r)
X+    {
X+	register_job(periods, delays, ident, command);
X+	return;
X+    }
X+    complain("Invalid syntax in %s on line %d - skipping this line",
X+	     anacrontab, line_num);
X+    return;
X+
X+ reg_err:
X+    die("Regex error reading %s", anacrontab);
X+}
X+
X+void
X+read_tab()
X+/* Read the anacrontab file into memory */
X+{
X+    char *tab_line;
X+
X+    first_job_rec = last_job_rec = NULL;
X+    first_env_rec = last_env_rec = NULL;
X+    jobs_read = 0;
X+    line_num = 0;
X+    /* Open the anacrontab file */
X+    tab = fopen(anacrontab, "r");
X+    if (tab == NULL) die_e("Error opening %s", anacrontab);
X+    /* Initialize the obstacks */
X+    obstack_init(&input_o);
X+    obstack_init(&tab_o);
X+    while ((tab_line = read_tab_line()) != NULL)
X+    {
X+	line_num++;
X+	parse_tab_line(tab_line);
X+	obstack_free(&input_o, tab_line);
X+    }
X+    if (fclose(tab)) die_e("Error closing %s", anacrontab);
X+}
X+
X+static int
X+execution_order(const job_rec **job1, const job_rec **job2)
X+/* Comparison function for sorting the jobs.
X+ */
X+{
X+    int d;
X+
X+    d = (*job1)->arg_num - (*job2)->arg_num;
X+    if (d != 0 && now) return d;
X+    d = (*job1)->delay - (*job2)->delay;
X+    if (d != 0) return d;
X+    d = (*job1)->tab_line - (*job2)->tab_line;
X+    return d;
X+}
X+
X+void
X+arrange_jobs()
X+/* Make an array of pointers to jobs that are going to be executed,
X+ * and arrange them in the order of execution.
X+ * Also lock these jobs.
X+ */
X+{
X+    job_rec *j;
X+
X+    j = first_job_rec;
X+    njobs = 0;
X+    while (j != NULL)
X+    {
X+	if (j->arg_num != -1 && (update_only || consider_job(j)))
X+	{
X+	    njobs++;
X+	    obstack_grow(&tab_o, &j, sizeof(j));
X+	}
X+	j = j->next;
X+    }
X+    job_array = obstack_finish(&tab_o);
X+
X+    /* sort the jobs */
X+    qsort(job_array, njobs, sizeof(*job_array),
X+	  (int (*)(const void *, const void *))execution_order);
X+}
END-of-anacron/files/patch-aa
echo x - anacron/Makefile
sed 's/^X//' >anacron/Makefile << 'END-of-anacron/Makefile'
X# New ports collection makefile for:   anacron
X# Date created:        15 Jul 2003
X# Whom:                Derik van Zuetphen <dz at 426.ch>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	anacron
XPORTVERSION=	2.3
XPORTREVISION=	2
XCATEGORIES=	sysutils
XMASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
XMASTER_SITE_SUBDIR=	anacron
X
XMAINTAINER=	dz at 426.ch
XCOMMENT=	Schedules periodic jobs on systems that are not permanently up
X
XMAN8=		anacron.8
XMAN5=		anacrontab.5
XUSE_GMAKE=	yes
X
Xpost-install:
X	${CAT} pkg-message
X	${STRIP_CMD} ${PREFIX}/sbin/anacron
X
X.include <bsd.port.mk>
END-of-anacron/Makefile
echo x - anacron/pkg-descr
sed 's/^X//' >anacron/pkg-descr << 'END-of-anacron/pkg-descr'
XAnacron is a periodic command scheduler.  It executes commands at
Xintervals specified in days.  Unlike cron, it does not assume that the
Xsystem is running continuously.  It can therefore be used to control
Xthe execution of daily, weekly and monthly jobs (or anything with a
Xperiod of n days), on systems that don't run 24 hours a day.
X
XAnacron is not an attempt to make cron redundant.
X
XRequirements
X - A functioning syslog daemon.
X - A functioning /usr/lib/sendmail command.  (all MTAs should have that).
X
XWWW: http://sourceforge.net/projects/anacron
END-of-anacron/pkg-descr
echo x - anacron/pkg-plist
sed 's/^X//' >anacron/pkg-plist << 'END-of-anacron/pkg-plist'
Xsbin/anacron
Xetc/anacrontab.sample
END-of-anacron/pkg-plist
echo x - anacron/distinfo
sed 's/^X//' >anacron/distinfo << 'END-of-anacron/distinfo'
XMD5 (anacron-2.3.tar.gz) = 865cc1dfe1ed75c470d3e6de13763f03
XSIZE (anacron-2.3.tar.gz) = 24140
END-of-anacron/distinfo
echo x - anacron/pkg-message
sed 's/^X//' >anacron/pkg-message << 'END-of-anacron/pkg-message'
X
XConfiguration hints:
X- Copy ${PREFIX}/etc/anacrontab.sample to ${PREFIX}/etc/anacrontab
X- Activate the 'periodic' commands in anacrontab
X- Deactivate the 'periodic' commands in /etc/crontab
X- Add 'anacron' to /etc/rc.local
X- Read anacron(8) and anacrontab(5)
X
END-of-anacron/pkg-message
exit
--- anacron.shar ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list