Subject: [Fwd: A patch for the -version option]

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

Whoops .. and here is a second version: without the compilation warnings
!

> 
> Hi Dominik
> 
> > 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.
> 
> 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:49:40
@@ -64,6 +64,7 @@
 
 extern XEvent Event;
 extern FvwmWindow *Tmp_win;
+extern char *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:49:51
@@ -110,6 +110,7 @@
 static void InitVariables(void);
 static void usage(void);
 static int MappedNotOverride(Window w);
+static void setVersionInfo(void);
 
 XContext FvwmContext;		/* context for fvwm windows */
 XContext MenuContext;		/* context for fvwm menus */
@@ -153,6 +154,8 @@
 int fd_width, x_fd;
 char *display_name = NULL;
 char *user_home_dir;
+char *Fvwm_VersionInfo;
+char *Fvwm_ConfigInfo;
 
 typedef enum { FVWM_RUNNING=0, FVWM_DONE, FVWM_RESTART } FVWM_STATE;
 
@@ -186,6 +189,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 +321,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 +2101,41 @@
 const char *getInitFunctionName(int n)
 {
   return initFunctionNames[n >= 0 && n < 3? n: 3];
+}
+
+
+static 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:50:20
@@ -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