Ignore specific message patch

Wookey wookey@aleph1.co.uk
Mon, 27 Mar 2000 23:10:45 +0100 (BST)


This message is in MIME format. If you are reading this text, then your mail
package doesn't fully support MIME - there may be a newer release available
from your supplier.

Created using the !Marcel mail package from ANT Ltd <sales@ant.co.uk>

--3543563-971770350-954198645=:2031478333
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII

Here's a rather naff patch I just hacked up to solve a problem. It may be
of use to others so I'm posting it.

The way we structure our data (combined with the way another group
structures its related data) means that we get a lot of 'fixed point
already fixed at same co-ordinates' warnings. 

Also I remember immoh saying he got a lot of warnings that he'd like to
be able to just turn off. 

So, I've added a 
*IGNOREMSG nn
command which will mean that the message number given (you need to look
them up in the messages.txt file) will just be ignored.

This only works for errors generated at the time the file is being
parsed, as the info goes in the begin/end structure. So messages that
only come out at the end like 'station not attached to fixed point' can't
(apparently) be turned off this way.

The crummy implementation means you can only select one message - if
anyone can be bothered, then making a short array, a list or a bitmap to
hold the 'ignore these' numbers would be better.

It's also just occurred to ne that you probably shouldn't be allowed to
do this for fatal errors...

The fact that it doesn't always do the trick got me thinking that what I
really want to do is to be able to specify some fixed points as 'not
necessarily used'. The most common being GPS locations.

The obvious thing is the add a 'type' the the *FIX command
*FIX GPS nnnn nnn nnn    (GPS implies NOWARN as well as some SDs, perhaps)
*FIX NORMAL nnn nnn nnn
*FIX NOWARN nnn nnnn nnn

but this changes the format of the command, which is bad. I'm not sure if
we can easily allow both syntaxes - probably, in which case that would
seem sensible. But maybe we should have a *GPS command, although that
seems like gratuitious extra commands - *FIX already does what we want,
it's just a matter of the details.

Another approach to the problem would be a more general attribute
mechanism which would have 'Don't warn about non-use' as one of the
possibilities. I think I posted a list of attribute possibilities to this
list a couple of months back, but didn't get much response. Maybe I'm
just imagingin it?

Anyway, suggestions as to what others want might suggest a sensible way
to go. I can just hack something up for my own purposes, but unless it's
too hard I might as well try and do it properly in a generically useful
manner.

Perhaps setting a general 'warning level' might be a good idea. Which
warnings do people find a problem (apart from the two mentionned above)?

Wookey
-- 
Aleph One Ltd, Bottisham, CAMBRIDGE, CB5 9BA, UK  Tel (00 44) 1223 811679
work: http://www.aleph1.co.uk/     play: http://www.chaos.org.uk/~wookey/

--3543563-971770350-954198645=:2031478333
Content-Type: TEXT/Plain; NAME=commpatch
Content-Transfer-Encoding: QUOTED-PRINTABLE

diff -u survex-0.93.orig/src/cavern.h survex-0.93/src/cavern.h
--- survex-0.93.orig/src/cavern.h=09Mon Mar 13 00:04:08 2000
+++ survex-0.93/src/cavern.h=09Mon Mar 27 20:30:14 2000
@@ -209,9 +209,10 @@
    real Var[Q_MAC];
    real z[Q_MAC];
    real sc[Q_MAC];
    real units[Q_MAC];  =20
    datum *ordering;
    int begin_lineno; /* 0 means no block started in this file */
+   int ignoremesg; /* warning/error to be ignored, should be a list, or bi=
tmap?*/
    struct Settings *next;
 } settings;
=20
diff -u survex-0.93.orig/src/commands.c survex-0.93/src/commands.c
--- survex-0.93.orig/src/commands.c=09Mon Mar 13 00:04:08 2000
+++ survex-0.93/src/commands.c=09Mon Mar 27 21:35:18 2000
@@ -140,6 +140,13 @@
    }
 }
=20
+static void
+default_ignoremesg(settings *s)
+{
+      s->ignoremesg =3D 0;
+}
+
+
 extern void
 default_all(settings *s)
 {
@@ -152,13 +159,14 @@
    default_grade(s);
    default_units(s);
    default_calib(s);
+   default_ignoremesg(s);
 }
=20
=20
    skipblanks();
@@ -232,11 +240,11 @@
 }
=20
 typedef enum {CMD_NULL =3D -1, CMD_BEGIN, CMD_CALIBRATE, CMD_CASE, CMD_DAT=
A,
-   CMD_DEFAULT, CMD_END, CMD_EQUATE, CMD_FIX, CMD_INCLUDE, CMD_INFER,
+   CMD_DEFAULT, CMD_END, CMD_EQUATE, CMD_FIX, CMD_IGNOREMESG, CMD_INCLUDE,=
 CMD_INFER,
    CMD_LRUD, CMD_MEASURE, CMD_PREFIX, CMD_SD, CMD_SET, CMD_SOLVE, CMD_TITL=
E,
    CMD_TRUNCATE, CMD_UNITS
 } cmds;
-=20
+
 static sztok cmd_tab[] =3D {
      {"BEGIN",     CMD_BEGIN},
      {"CALIBRATE", CMD_CALIBRATE},
@@ -246,6 +254,7 @@
      {"END",       CMD_END},
      {"EQUATE",    CMD_EQUATE},
      {"FIX",       CMD_FIX},
+     {"IGNOREMSG", CMD_IGNOREMESG},
      {"INCLUDE",   CMD_INCLUDE},
      {"INFER",     CMD_INFER},
      {"LRUD",      CMD_LRUD},
=20


@@ -1013,18 +1022,28 @@
 =09 } else {
 =09    ch =3D 'F';
 =09    read_numeric(fFalse);
-=09    NOT_YET;=09      =20
+=09    NOT_YET;
 =09 }
       } else {
 =09 ch =3D 'O';
 =09 read_numeric(fFalse);
-=09 NOT_YET;=09      =20
-      }     =20
+=09 NOT_YET;
+      }
    }
    /* for backward compatibility, "*truncate 0" means "*truncate off" */
    pcs->Truncate =3D (truncate_at < 1) ? INT_MAX : truncate_at;
 }
=20
+/* set message number to be ignored - 0 means don't ignore any */
+/* this is kind of primitive and should allow more than one skippable mess=
sage */
+static void
+set_ignoremesg(void)
+{
+  int mesgnum;
+    mesgnum =3D (int) read_numeric(fFalse);
+    pcs->ignoremesg =3D mesgnum;
+}
+
 extern void
 handle_command(void)
 {
@@ -1054,8 +1073,9 @@
     case CMD_SET: set_chars(); break;
     case CMD_TITLE: set_title(); break;
     case CMD_TRUNCATE: set_truncate(); break;
+    case CMD_IGNOREMESG: set_ignoremesg(); break;
     default:
       compile_error(/*Unknown command in data file - line ignored*/12);
       showandskipline(NULL, strlen(buffer));
-   } =20
+   }
 }
diff -u survex-0.93.orig/src/datain.c survex-0.93/src/datain.c
--- survex-0.93.orig/src/datain.c=09Mon Mar 13 00:04:08 2000
+++ survex-0.93/src/datain.c=09Mon Mar 27 20:38:21 2000
@@ -77,20 +77,26 @@
 compile_error(int en, ...)
 {
    va_list ap;
-   va_start(ap, en);
-   error_list_parent_files();
-   v_report(1, file.filename, file.line, en, ap);
-   va_end(ap);
+   if(pcs->ignoremesg !=3D en)
+   {
+     va_start(ap, en);
+     error_list_parent_files();
+     v_report(1, file.filename, file.line, en, ap);
+     va_end(ap);
+   }
 }
=20
 void
 compile_warning(int en, ...)
 {
    va_list ap;
-   va_start(ap, en);
-   error_list_parent_files();
-   v_report(0, file.filename, file.line, en, ap);
-   va_end(ap);
+   if(pcs->ignoremesg !=3D en)
+   {
+     va_start(ap, en);
+     error_list_parent_files();
+     v_report(0, file.filename, file.line, en, ap);
+     va_end(ap);
+   }
 }
=20
 /* This function makes a note where to put output files */



--3543563-971770350-954198645=:2031478333--