- Allow comments to be placed at the end of configuration line.

Sponsored by:   Porta Software Ltd
Approved by:    re
MFC after:      2 weeks
This commit is contained in:
Maxim Sobolev 2002-12-11 01:19:56 +00:00
parent 5e7972fe32
commit f2562be03e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=107737
3 changed files with 21 additions and 5 deletions

View File

@ -3,6 +3,6 @@
PROG= newsyslog
MAN= newsyslog.8
WARNS?= 2
WARNS?= 4
.include <bsd.prog.mk>

View File

@ -79,7 +79,11 @@ that should be handled by
.Nm .
Each line has five mandatory fields and four optional fields, with
whitespace separating each field. Blank lines or lines beginning with
``#'' are ignored. The fields of the configuration file are as
``#'' are ignored. If ``#'' is placed in the middle of the line,
``#'' character and the rest of the line after it is ignored.
To prevent special meaning, the ``#'' may be escaped with ``\\'',
in this case preceding ``\\'' is removed and ``#'' treated as ordinary
character. The fields of the configuration file are as
follows:
.Pp
.Bl -tag -width indent
@ -297,7 +301,7 @@ to archive all filenames matching this pattern using the same
options.
See
.Xr glob 3
for details on matching rules.
for details on syntax and matching rules.
.It Ar path_to_pid_file
This optional field specifies
the file name to read to find the daemon process id. If this

View File

@ -290,7 +290,7 @@ parse_file(char **files)
{
FILE *f;
char line[BUFSIZ], *parse, *q;
char *errline, *group;
char *cp, *errline, *group;
char **p;
struct conf_entry *first, *working;
struct passwd *pass;
@ -306,9 +306,21 @@ parse_file(char **files)
if (!f)
err(1, "%s", conf);
while (fgets(line, BUFSIZ, f)) {
if ((line[0] == '\n') || (line[0] == '#'))
if ((line[0] == '\n') || (line[0] == '#') ||
(strlen(line) == 0))
continue;
errline = strdup(line);
for (cp = line + 1; *cp != '\0'; cp++) {
if (*cp != '#')
continue;
if (*(cp - 1) == '\\') {
strcpy(cp - 1, cp);
cp--;
continue;
}
*cp = '\0';
break;
}
q = parse = missing_field(sob(line), errline);
parse = son(line);