This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch, master, updated. glibc-2.13-247-g652ffab


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  652ffab11358f8961770792cbbecbaec42c69479 (commit)
      from  16985fd0c79ccffc105d77c9076ab0a4bb0e5714 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=652ffab11358f8961770792cbbecbaec42c69479

commit 652ffab11358f8961770792cbbecbaec42c69479
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sun May 29 22:07:49 2011 -0400

    Make resolv.conf parsing more compact

diff --git a/ChangeLog b/ChangeLog
index a003ac9..f650fba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2011-05-29  Ulrich Drepper  <drepper@gmail.com>
 
+	* resolv/res_init.c (res_setoptions): Make the code more compact.
+
 	[BZ #11558]
 	* resolv/res_init.c (res_setoptions): Recognize use-vc option and
 	set RES_USEVC.
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 2908c10..64934b0 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -521,39 +521,42 @@ res_setoptions(res_state statp, const char *options, const char *source) {
 			}
 			printf(";;\tdebug\n");
 #endif
-		} else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) {
-			statp->options |= RES_USE_INET6;
-		} else if (!strncmp(cp, "ip6-bytestring",
-				    sizeof("ip6-bytestring") - 1)) {
-			statp->options |= RES_USEBSTRING;
-		} else if (!strncmp(cp, "no-ip6-dotint",
-				    sizeof("no-ip6-dotint") - 1)) {
-			statp->options |= RES_NOIP6DOTINT;
-		} else if (!strncmp(cp, "ip6-dotint",
-				    sizeof("ip6-dotint") - 1)) {
-			statp->options &= ~RES_NOIP6DOTINT;
-		} else if (!strncmp(cp, "rotate", sizeof("rotate") - 1)) {
-			statp->options |= RES_ROTATE;
-		} else if (!strncmp(cp, "no-check-names",
-				    sizeof("no-check-names") - 1)) {
-			statp->options |= RES_NOCHECKNAME;
-		} else if (!strncmp(cp, "edns0", sizeof("edns0") - 1)) {
-			statp->options |= RES_USE_EDNS0;
-		} else if (!strncmp(cp, "single-request-reopen",
-				    sizeof("single-request-reopen") - 1)) {
-			statp->options |= RES_SNGLKUPREOP;
-		} else if (!strncmp(cp, "single-request",
-				    sizeof("single-request") - 1)) {
-			statp->options |= RES_SNGLKUP;
-		} else if (!strncmp(cp, "no_tld_query",
-				    sizeof("no_tld_query") - 1) ||
-			   !strncmp(cp, "no-tld-query",
-				    sizeof("no-tld-query") - 1)) {
-			statp->options |= RES_NOTLDQUERY;
-		} else if (!strncmp(cp, "use-vc", sizeof("use-vc") - 1)) {
-			statp->options |= RES_USEVC;
 		} else {
-			/* XXX - print a warning here? */
+		  static const struct
+		  {
+		    char str[22];
+		    uint8_t len;
+		    uint8_t clear;
+		    unsigned long int flag;
+		  } options[] = {
+#define STRnLEN(str) str, sizeof (str) - 1
+		    { STRnLEN ("inet6"), 0, RES_USE_INET6 },
+		    { STRnLEN ("ip6-bytestring"), 0, RES_USEBSTRING },
+		    { STRnLEN ("no-ip6-dotint"), 0, RES_NOIP6DOTINT },
+		    { STRnLEN ("ip6-dotint"), 1, ~RES_NOIP6DOTINT },
+		    { STRnLEN ("rotate"), 0, RES_ROTATE },
+		    { STRnLEN ("no-check-names"), 0, RES_NOCHECKNAME },
+		    { STRnLEN ("edns0"), 0, RES_USE_EDNS0 },
+		    { STRnLEN ("single-request-reopen"), 0, RES_SNGLKUPREOP },
+		    { STRnLEN ("single-request"), 0, RES_SNGLKUP },
+		    { STRnLEN ("no_tld_query"), 0, RES_NOTLDQUERY },
+		    { STRnLEN ("no-tld-query"), 0, RES_NOTLDQUERY },
+		    { STRnLEN ("use-vc"), 0, RES_USEVC }
+		  };
+#define noptions (sizeof (options) / sizeof (options[0]))
+		  int i;
+		  for (i = 0; i < noptions; ++i)
+		    if (strncmp (cp, options[i].str, options[i].len) == 0)
+		      {
+			if (options[i].clear)
+			  statp->options &= options[i].flag;
+			else
+			  statp->options |= options[i].flag;
+			break;
+		      }
+		  if (i == noptions) {
+		    /* XXX - print a warning here? */
+		  }
 		}
 		/* skip to next run of spaces */
 		while (*cp && *cp != ' ' && *cp != '\t')

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog         |    2 +
 resolv/res_init.c |   67 +++++++++++++++++++++++++++-------------------------
 2 files changed, 37 insertions(+), 32 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]