Subject: FVWM: patch to make debugging fvwmrc easier: add line number to error

From: "jeff (j.d.) sparkes" <[email-masked]>
Date: Wed, 25 Oct 1995 09:49:00 -0400

-----BEGIN PGP SIGNED MESSAGE-----

When I switched over to fvwm-2, I found this really helped me with debugging
my .fvwmrc since it told on which line it found the problem.  It also adds
the filename in case you use M4 or cpp.

This is against patchlevel 33, but should apply easily to newer ones.

===================================================================
RCS file: fvwm.c,v
retrieving revision 1.1
diff -c -r1.1 fvwm.c
*** fvwm.c	1995/08/10 14:44:05	1.1
- --- fvwm.c	1995/08/10 14:44:59
***************
*** 1032,1040 ****
  
  void fvwm_err(char *message, char *arg1, char *arg2, char *arg3)
  {
    char line[255];
    char temp[1000];
!   strcpy(line,"fvwm: ");
    sprintf(temp,message,arg1,arg2,arg3);
    strncat(line,temp,248);
    line[248+6] = 0;
- --- 1032,1043 ----
  
  void fvwm_err(char *message, char *arg1, char *arg2, char *arg3)
  {
+   extern char *fvwm_file;
+   extern int LineNumber;
+     
    char line[255];
    char temp[1000];
!   sprintf(line,"fvwm: at %s:%d: ", fvwm_file, LineNumber);
    sprintf(temp,message,arg1,arg2,arg3);
    strncat(line,temp,248);
    line[248+6] = 0;
===================================================================
RCS file: read.c,v
retrieving revision 1.1
diff -c -r1.1 read.c
*** read.c	1995/08/10 14:41:08	1.1
- --- read.c	1995/08/10 14:44:21
***************
*** 21,26 ****
- --- 21,28 ----
  #include "module.h"
  
  char *fvwm_file = NULL;
+ int   LineNumber = 0;
+ 
  #include <fcntl.h>
  void AddToModList(char *tline);
  
***************
*** 105,113 ****
- --- 107,117 ----
      free(fvwm_file);
    fvwm_file = filename;
  
+   LineNumber = 0;
    tline = fgets(line,(sizeof line)-1,fd);
    while(tline != (char *)0)
      {
+       LineNumber++;
        while(isspace(*tline))tline++;
        if((strlen(&tline[0])>1)&&(tline[0]!='#')&&(tline[0]!='*'))
  	ExecuteFunction(tline,tmp_win,eventp,context,*Module);

--
Jeff Sparkes
[email-masked]    Bell-Northern Research, Ottawa, Ontario, Canada
--
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].