r2648 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Jun 5 11:16:29 CEST 2008


Author: phk
Date: 2008-06-05 11:16:29 +0200 (Thu, 05 Jun 2008)
New Revision: 2648

Modified:
   trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Add a new-line before, and reword some of the default cautions a little
bit.

Automatically calculate the margin, based on the width of the parameter
names we have.


Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-06-05 09:12:51 UTC (rev 2647)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-06-05 09:16:29 UTC (rev 2648)
@@ -56,6 +56,7 @@
 #define MAGIC_INIT_STRING	"\001"
 
 struct parspec;
+static int margin;
 
 typedef void tweak_t(struct cli *, const struct parspec *, const char *arg);
 
@@ -422,19 +423,20 @@
  */
 
 #define DELAYED_EFFECT_TEXT \
-	"NB: This parameter will take some time to take effect."
+	"\nNB: This parameter may take quite some time to take (full) effect."
 
 #define MUST_RESTART_TEXT \
-	"NB: This parameter will not take any effect until the " \
+	"\nNB: This parameter will not take any effect until the " \
 	"child process has been restarted."
 
 #define MUST_RELOAD_TEXT \
-	"NB: This parameter will not take any effect until the " \
+	"\nNB: This parameter will not take any effect until the " \
 	"VCL programs have been reloaded."
 
 #define EXPERIMENTAL_TEXT \
-	"NB: We don't know yet if it is a good idea to change " \
-	"this parameter.  Caution advised."
+	"\nNB: We do not know yet if it is a good idea to change " \
+	"this parameter, or if the default value is even sensible.  " \
+	"Caution is advised, and feedback is most welcome."
 
 /*
  * Remember to update varnishd.1 whenever you add / remove a parameter or
@@ -672,7 +674,6 @@
 /*--------------------------------------------------------------------*/
 
 #define WIDTH 76
-#define MARGIN 20
 
 static void
 mcf_wrap(struct cli *cli, const char *text)
@@ -684,13 +685,13 @@
 		q = strchr(p, '\n');
 		if (q == NULL)
 			q = strchr(p, '\0');
-		if (q > p + WIDTH - MARGIN) {
-			q = p + WIDTH - MARGIN;
+		if (q > p + WIDTH - margin) {
+			q = p + WIDTH - margin;
 			while (q > p && *q != ' ')
 				q--;
 			AN(q);
 		}
-		cli_out(cli, "%*s %.*s\n", MARGIN, "", (int)(q - p), p);
+		cli_out(cli, "%*s %.*s\n", margin, "", (int)(q - p), p);
 		p = q;
 		if (*p == ' ' || *p == '\n')
 			p++;
@@ -711,7 +712,7 @@
 	for (pp = parspec; pp->name != NULL; pp++) {
 		if (av[2] != NULL && !lfmt && strcmp(pp->name, av[2]))
 			continue;
-		cli_out(cli, "%-*s ", MARGIN, pp->name);
+		cli_out(cli, "%-*s ", margin, pp->name);
 		if (pp->func == NULL) {
 			cli_out(cli, "Not implemented.\n");
 			if (av[2] != NULL && !lfmt)
@@ -726,7 +727,7 @@
 			cli_out(cli, "\n");
 		if (av[2] != NULL) {
 			cli_out(cli, "%-*s Default is %s\n",
-			    MARGIN, "", pp->def);
+			    margin, "", pp->def);
 			mcf_wrap(cli, pp->descr);
 			if (pp->flags & DELAYED_EFFECT)
 				mcf_wrap(cli, DELAYED_EFFECT_TEXT);
@@ -803,6 +804,8 @@
 
 	for (pp = parspec; pp->name != NULL; pp++) {
 		cli_out(cli, "Set Default for %s = %s\n", pp->name, pp->def);
+		if (strlen(pp->name) + 1 > margin)
+			margin = strlen(pp->name) + 1;
 		pp->func(cli, pp, pp->def);
 		if (cli->result != CLIS_OK)
 			return;




More information about the varnish-commit mailing list