[PATCH] nslookup: skip line comments on parsing /etc/resolv.conf

Leesoo Ahn yisooan at fedoraproject.org
Wed Apr 22 15:36:03 UTC 2020


Line comments with '#' mark at the beginning are compared to
on every 'if' statement although those lines could be notified
as comments at the early stage.
It better skips them, hence we save a few cycles while parsing.

These tests are passed,
     # comment type 1
#      comment type 2
# comment type 3
#comment type 4

Signed-off-by: Leesoo Ahn <yisooan at fedoraproject.org>
---
 networking/nslookup.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/networking/nslookup.c b/networking/nslookup.c
index c43e60558..c94391f01 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -707,6 +707,11 @@ static void parse_resolvconf(void)
 			p = strtok(line, " \t\n");
 			if (!p)
 				continue;
+
+			/* line comment? */
+			if (*p == '#')
+				continue; /* yes */
+
 			dbg("resolv_key:'%s'\n", p);
 			arg = strtok(NULL, "\n");
 			dbg("resolv_arg:'%s'\n", arg);
-- 
2.24.1



More information about the busybox mailing list