Subject: A patch for the -version option

From: Olivier Chapuis <[email-masked]>
Date: Tue, 21 Sep 1999 09:12:48 +0200

Hello,

Attached to this message a patch against the current cvs tree.
If you apply it and try fvwm2 -version then fvwm2 supplies
information on the compile-time options (readline, rplay, 
stroke, xpm, imlib, gnome). This is useful to build and install
portable .fvwm2rc file.

Modified file: 
	: ChangeLog
fvwm    : fvwm.c, fvwm2.1

Olivier

Index: ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v
retrieving revision 1.628
diff -u -b -B -u -r1.628 ChangeLog
--- ChangeLog	1999/09/21 03:49:25	1.628
+++ ChangeLog	1999/09/21 07:13:42
@@ -1,3 +1,9 @@
+1999-09-21 Olivier Chapuis <[email-masked]>
+
+	* fvwm/fvwm.c: fvwm2 -version supplies informations on the 
+	compile-time options: readline, rplay, stroke, xpm, imlib, gnome.
+	* fvwm/fvwm2.1:
+
 1999-09-20  Bob Woodside  <[email-masked]>
 
 	* fvwm/events.c (HandleButtonPress): Dropped the raise on window
Index: fvwm/fvwm.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.c,v
retrieving revision 1.159
diff -u -b -B -u -r1.159 fvwm.c
--- fvwm/fvwm.c	1999/09/09 01:01:08	1.159
+++ fvwm/fvwm.c	1999/09/21 07:13:47
@@ -316,8 +316,19 @@
     }
     else if (strncasecmp(argv[i], "-version", 8) == 0)
     {
-      fvwm_msg(INFO,"main", "Fvwm Version %s compiled on %s at %s\n",
+      fvwm_msg(INFO,"main", "Fvwm Version %s compiled on %s at %s",
               VERSION,__DATE__,__TIME__);
+      if ( HAVE_READLINE || HAVE_RPLAY ||  HAVE_STROKE || XPM || IMLIB ||
+	   GNOME ) 
+      {
+	fvwm_msg(INFO,"main", "With support for: %s%s%s%s%s%s",
+		 (HAVE_READLINE) ? "ReadLine " : "",
+		 (HAVE_RPLAY) ? "RPlay " : "",
+		 (HAVE_STROKE) ? "Stroke " : "",
+		 (XPM) ? "XPM " : "",
+		 (IMLIB) ? "IMLIB " : "",
+		 (GNOME) ? "Gnome" : "");
+      }
       exit(0);
     }
     else
Index: fvwm/fvwm2.1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm2.1,v
retrieving revision 1.197
diff -u -b -B -u -r1.197 fvwm2.1
--- fvwm/fvwm2.1	1999/09/20 17:16:03	1.197
+++ fvwm/fvwm2.1	1999/09/21 07:14:12
@@ -113,7 +113,9 @@
 option. Normally, fvwm will attempt to start up on all screens
 of a multi-screen display.
 .IP "\fB-version\fP"
-Print the version of fvwm to stderr.
+Print the version of fvwm to stderr. Also print configuration informations:
+says if fvwm has been compiled with readline, rplay, stroke, xpm, imlib or 
+gnome support.
 .IP "\fB-visual\fP \fIvisual class\fP"

---

From: Dominik Vogt <[email-masked]>
Date: Tue, 21 Sep 1999 13:34:14 +0200

> +      if ( HAVE_READLINE || HAVE_RPLAY ||  HAVE_STROKE || XPM || IMLIB ||
                                                                    ^^^^^

That doesn't work. I don't have IMLIB and thus the IMLIB macro is undefined.
You have to wrap the output with '#ifdef IMLIB'. I guess it's the same with
the other compile time options.

Bye

Dominik ^_^

-- 
Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/14-4596, fax: 07031/14-3883, [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Olivier Chapuis <[email-masked]>
Date: Tue, 21 Sep 1999 14:32:16 +0200

> the other compile time options.

Aaahrg ... Shame on me !!!
I try it by putting XPM to 0 in config.h (every thing is defined
on my machine) but I see now that this really stupid (I didn't wanted
to see 6 #ifdef FOO neither introduce a new string variable).
Anyway, do you think that it is a good idea ? If yes I can try to do
something that work and which is elegant (I imagine that everybody 
here can do it in one second !).
Olivier
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Dan Espen <[email-masked]>
Date: Tue, 21 Sep 1999 09:20:12 -0400

> here can do it in one second !).

I think its a good idea.

Its simple enough, but why should we take away your fun?

--
Dan Espen
444 Hoes Lane  Room RRC 1C-214           E-mail: [email-masked]
Piscataway, NJ 08854                     Phone: (732) 699-5570
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Olivier Chapuis <[email-masked]>
Date: Tue, 21 Sep 1999 15:52:28 +0200

> Its simple enough, but why should we take away your fun?

Ok I will send a patch Friday (I am now far from my devel machine).
But perhaps a better idea is that "make install" install config.h as
say fvwmconfig.h in goodprefix/include ?

Olivier

---

From: Olivier Chapuis <[email-masked]>
Date: Fri, 24 Sep 1999 08:14:28 +0200

> the other compile time options.

Hello,
I have attached a version which works.
Olivier

Index: ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v
retrieving revision 1.634
diff -u -b -B -u -r1.634 ChangeLog
--- ChangeLog	1999/09/24 00:42:31	1.634
+++ ChangeLog	1999/09/24 06:13:42
@@ -1,3 +1,8 @@
+1999-09-24  Olivier Chapuis <[email-masked]>
+
+	* fvwm/fvwm.c: -vesrion option print compile-time informations.
+	* fvwm/fvwm2.1:
+
 1999-09-23  Dominik Vogt  <[email-masked]>
 
 	* fvwm/menus.c (paint_item):
Index: fvwm/fvwm.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.c,v
retrieving revision 1.159
diff -u -b -B -u -r1.159 fvwm.c
--- fvwm/fvwm.c	1999/09/09 01:01:08	1.159
+++ fvwm/fvwm.c	1999/09/24 06:13:47
@@ -316,8 +316,31 @@
     }
     else if (strncasecmp(argv[i], "-version", 8) == 0)
     {
-      fvwm_msg(INFO,"main", "Fvwm Version %s compiled on %s at %s\n",
+      char *configinfo = strdup("");
+      fvwm_msg(INFO,"main", "Fvwm Version %s compiled on %s at %s",
               VERSION,__DATE__,__TIME__);
+#ifdef HAVE_READLINE
+      configinfo = strcat(configinfo ," ReadLine");
+#endif
+#ifdef HAVE_RPLAY
+      configinfo = strcat(configinfo ," RPlay");
+#endif
+#ifdef HAVE_STROKE
+      configinfo = strcat(configinfo ," Stroke");
+#endif
+#ifdef XPM
+      configinfo = strcat(configinfo, " XPM");
+#endif
+#ifdef IMLIB
+      configinfo = strcat(configinfo, " IMLIB");
+#endif
+#ifdef GNOME
+      configinfo = strcat(configinfo, " Gnome");
+#endif
+      if (strlen(configinfo))  
+	fvwm_msg(INFO,"main", "with support for:%s\n", configinfo);
+      else 
+	fprintf(stderr, "\n");
       exit(0);
     }
     else
Index: fvwm/fvwm2.1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm2.1,v
retrieving revision 1.197
diff -u -b -B -u -r1.197 fvwm2.1
--- fvwm/fvwm2.1	1999/09/20 17:16:03	1.197
+++ fvwm/fvwm2.1	1999/09/24 06:14:14
@@ -113,7 +113,9 @@
 option. Normally, fvwm will attempt to start up on all screens
 of a multi-screen display.
 .IP "\fB-version\fP"
-Print the version of fvwm to stderr.
+Print the version of fvwm to stderr. Also print configuration informations:
+says if fvwm has been compiled with readline, rplay, stroke, xpm, imlib or 
+gnome support.
 .IP "\fB-visual\fP \fIvisual class\fP"
 Causes fvwm to use \fIvisual class\fP for the window borders and menus.
 \fIvisual class\fP can be StaticGray, GrayScale, StaticColor, PseudoColor,
Index: utils/fvwm-menu-directory.1

---

From: Mikhael Goikhman <[email-masked]>
Date: Fri, 24 Sep 1999 08:55:37 +0200

> I have attached a version which works.

Ok, here is a manual patch on the above patch (you get the idea):

-      char *configinfo = strdup("");
+      char configinfo[50] = "";

Regards,
Mikhael.

---

From: Mark Rainford <[email-masked]>
Date: Fri, 24 Sep 1999 12:52:46 +0100

Oliver et al,

I have an idea which relates to your patch for printing fvwm's compiled
options.

I would like to print fvwm's version into the error log: at our site we
keep more than one fvwm version available - allowing users time to
migrate their configs. We used the -version cmdline option, until it was
changed to also terminate the WM !

My thinking is to introduce a percent (%) trip character to the Echo
command which would recognize a keyword so that, for example

	Echo rock %version hard place

would print the fvwm version string between a rock and a hard place.
Other keywords could be introduced as the need arises, e.g.,
%configoptions for your extra line. The string could be either kept in a
static variable, or for some future keyword, returned by a function
call, thereby allowing a user defined function to print dynamic
information.

The -version cmdline option would be unaffected.

This may be overkill - since I can also get what I want by a locally
removing the call to exit(). Any thoughts ?

Fri, 24 Sep 1999 08:14:28 +0200 Olivier Chapuis wrote:
> .....
> ......

-- 

Regards,  Mark.

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 24 Sep 1999 14:08:48 +0200

> call, thereby allowing a user defined function to print dynamic

This is already possible. Fvwm replaces certain '$x' strings by
some predefined strings, e.g. '$r' is replaced by the window's
resource name. A '$v' could easily be added (function expand() in
file fvwm/functions.c). This works everywhere, not only in Echo
commands.

Bye

Dominik ^_^

---

From: Mark Rainford <[email-masked]>
Date: Fri, 24 Sep 1999 15:43:00 +0100

Hi Dominik

> file fvwm/functions.c). This works everywhere, not only in Echo

That'll do nicely, thankyou.

I started adding "$v" to fvwm/functions.c(expand), but then received
your "CVS domivogt: * Applied version info patch." email ... however,
"cvs diff" only shows my edits. How come your patch doesn't show up ?

In case it is any use, the stuff I did is attached.
-- 

Regards,  Mark.

Index: functions.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/functions.c,v
retrieving revision 1.91
diff -u -b -B -r1.91 functions.c
--- functions.c	1999/09/24 12:27:03	1.91
+++ functions.c	1999/09/24 14:34:52
@@ -64,6 +64,7 @@
 
 extern XEvent Event;
 extern FvwmWindow *Tmp_win;
+extern char const * const Fvwm_VersionInfo;
 
 /* forward declarations */
 static void ComplexFunction(F_CMD_ARGS);
@@ -410,6 +411,10 @@
 	    case 'x':
 	      sprintf(&out[j], "%d", Scr.Vx);
 	      j += strlen(&out[j]);
+	      i++;
+	      break;
+	    case 'v':
+	      sprintf(&out[j], "%s", Fvwm_VersionInfo);
 	      i++;
 	      break;
 	    case 'y':
Index: fvwm.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.c,v
retrieving revision 1.160
diff -u -b -B -r1.160 fvwm.c
--- fvwm.c	1999/09/24 12:27:03	1.160
+++ fvwm.c	1999/09/24 14:35:03
@@ -153,6 +153,8 @@
 int fd_width, x_fd;
 char *display_name = NULL;
 char *user_home_dir;
+char const *Fvwm_VersionInfo;
+char const *Fvwm_ConfigInfo;
 
 typedef enum { FVWM_RUNNING=0, FVWM_DONE, FVWM_RESTART } FVWM_STATE;
 
@@ -186,6 +188,8 @@
 
   DBUG("main","Entered, about to parse args");
 
+  setVersionInfo();
+
 #ifdef I18N_MB
   if (setlocale(LC_CTYPE, "") == NULL)
     fvwm_msg(ERR, "main", "Can't set locale. Check your $LC_CTYPE or $LANG.\n");
@@ -316,32 +320,8 @@
     }
     else if (strncasecmp(argv[i], "-version", 8) == 0)
     {
-      char configinfo[128] = "";
-
-      fvwm_msg(INFO,"main", "Fvwm Version %s compiled on %s at %s",
-              VERSION,__DATE__,__TIME__);
-#ifdef HAVE_READLINE
-      strcat(configinfo ," ReadLine");
-#endif
-#ifdef HAVE_RPLAY
-      strcat(configinfo ," RPlay");
-#endif
-#ifdef HAVE_STROKE
-      strcat(configinfo ," Stroke");
-#endif
-#ifdef XPM
-      strcat(configinfo, " XPM");
-#endif
-#ifdef IMLIB
-      strcat(configinfo, " IMLIB");
-#endif
-#ifdef GNOME
-      strcat(configinfo, " Gnome");
-#endif
-      if (strlen(configinfo))
-	fvwm_msg(INFO,"main", "with support for:%s\n", configinfo);
-      else
-	fprintf(stderr, "\n");
+      fvwm_msg(INFO,"main",Fvwm_VersionInfo);
+      if (Fvwm_ConfigInfo != NULL) fvwm_msg(INFO,"main",Fvwm_ConfigInfo);
       exit(0);
     }
     else
@@ -2120,4 +2100,41 @@
 const char *getInitFunctionName(int n)
 {
   return initFunctionNames[n >= 0 && n < 3? n: 3];
+}
+
+
+void setVersionInfo(void)
+{
+  char buf[1024];
+  int emptylen;
+
+  /* Set version information string */
+  sprintf(buf,"Fvwm Version %s compiled on %s at %s",
+          VERSION,__DATE__,__TIME__);
+  Fvwm_VersionInfo = strdup(buf);
+
+  /* Set configuration info string (may end up empty) */
+  strcpy(buf,"with support for: ");
+  emptylen = strlen(buf);
+
+#ifdef HAVE_READLINE
+  strcat(buf ," ReadLine");
+#endif
+#ifdef HAVE_RPLAY
+  strcat(buf ," RPlay");
+#endif
+#ifdef HAVE_STROKE
+  strcat(buf ," Stroke");
+#endif
+#ifdef XPM
+  strcat(buf, " XPM");
+#endif
+#ifdef IMLIB
+  strcat(buf, " IMLIB");
+#endif
+#ifdef GNOME
+  strcat(buf, " Gnome");
+#endif
+
+  Fvwm_ConfigInfo = (strlen(buf) == emptylen) ? '\0' : strdup(buf);
 }
Index: fvwm2.1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm2.1,v
retrieving revision 1.198
diff -u -b -B -r1.198 fvwm2.1
--- fvwm2.1	1999/09/24 12:27:04	1.198
+++ fvwm2.1	1999/09/24 14:35:32
@@ -3753,7 +3753,7 @@
 an action to be performed on the button-press, if the function is
 invoked with prior knowledge of which window to act on.
 
-The special symbols $d, $w, $c, $r, $n, $x, $y and $0 through $9 are available
+The special symbols $d, $w, $c, $r, $n, $v, $x, $y and $0 through $9 are available
 in the ComplexFunctions or Macros, or whatever you want to call them.
 Within a macro, $w is expanded to the window-id (expressed in
 hex, i.e. 0x10023c) of the window for which the macro was called, $x and $y
@@ -3761,6 +3761,7 @@
 and $d is expanded to the current desk number.
 $c, $r, $n are expanded to the window resource class, resource name
 and window name respectively.
+$v expands to the first line printed by the -version command line option.
 $0 through $9 are the arguments to the macro, so if you call
 .EX
 Key F10 R A Function MailFunction \\
Index: stack.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/stack.c,v
retrieving revision 1.25
diff -u -b -B -r1.25 stack.c

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 24 Sep 1999 17:01:16 +0200

> "cvs diff" only shows my edits. How come your patch doesn't show up ?

The changes from this patch are in fvwm.c, not in functions.c.

> In case it is any use, the stuff I did is attached.

You can see the previous changes in the patch you posted. It's
the part with all the #ifdef's.

Bye

Dominik ^_^

---

From: Mark Rainford <[email-masked]>
Date: Fri, 24 Sep 1999 16:12:40 +0100

> the part with all the #ifdef's.

Okay, I understand now: I got all confused because I only saw the
"Applied patch" email after I'd done "cvs update" :-(

-- 

Regards,  Mark.