Config file parser changes:
- Trailing spaces and empty lines are ignored. - A `#' sign will mark the remaining of the line as a comment. Reviewed by: Ari Suutari <ari@suutari.iki.fi>
This commit is contained in:
parent
55b9d469e8
commit
2e7e7c71ef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=51063
@ -270,7 +270,11 @@ in the configuration file. For example, the line
|
|||||||
|
|
||||||
is synonomous with
|
is synonomous with
|
||||||
.Fl log .
|
.Fl log .
|
||||||
Empty lines and lines beginning with '#' are ignored.
|
.Pp
|
||||||
|
Trailing spaces and empty lines are ignored.
|
||||||
|
A
|
||||||
|
.Ql \&#
|
||||||
|
sign will mark the remaining of the line as a comment.
|
||||||
|
|
||||||
.It Fl reverse
|
.It Fl reverse
|
||||||
Reverse operation of natd. This can be useful in some
|
Reverse operation of natd. This can be useful in some
|
||||||
|
@ -1246,7 +1246,7 @@ void ReadConfigFile (const char* fileName)
|
|||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
char* ptr;
|
char *ptr, *p;
|
||||||
char* option;
|
char* option;
|
||||||
|
|
||||||
file = fopen (fileName, "r");
|
file = fopen (fileName, "r");
|
||||||
@ -1263,18 +1263,20 @@ void ReadConfigFile (const char* fileName)
|
|||||||
errx (1, "config line too long: %s", buf);
|
errx (1, "config line too long: %s", buf);
|
||||||
|
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
if (buf[0] == '#')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ptr = buf;
|
|
||||||
/*
|
/*
|
||||||
* Skip white space at beginning of line.
|
* Check for comments, strip off trailing spaces.
|
||||||
*/
|
*/
|
||||||
while (*ptr && isspace (*ptr))
|
if ((ptr = strchr(buf, '#')))
|
||||||
++ptr;
|
*ptr = '\0';
|
||||||
|
for (ptr = buf; isspace(*ptr); ++ptr)
|
||||||
|
continue;
|
||||||
if (*ptr == '\0')
|
if (*ptr == '\0')
|
||||||
continue;
|
continue;
|
||||||
|
for (p = strchr(buf, '\0'); isspace(*--p);)
|
||||||
|
continue;
|
||||||
|
*++p = '\0';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extract option name.
|
* Extract option name.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user