Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gps af malfeature

5 views
Skip to first unread message

k...@rna.uucp

unread,
Jul 15, 1986, 6:40:12 PM7/15/86
to
Questionable feature for af.
Of interest to gps users on various Unix flavors.

Backgrounder:
The af (arithmetic filter) manual page advises that af command line numeric
parameters cannot contain ``E notation.'' (They mean Scientific notation,
e.g. 1.23e04). That is a severe limitation, because we have several
scripts that make their own af command line parameters using af. Guess
what, af gladly outputs E notation, but such a result can't be used as
a parameter. Here's how af might produce a number containing E notation.

$ af '1000000+100000'
1.1e+06
$

script done on Tue Jul 15 18:28:21 1986

Repeat by:
Try the following af command:

$ af '1e01+2e02'

af assumes that the funny name ``e01'' refers to the stdin, and then
complains that the file ``e02'' can't be opened.

Anyway, we had working scripts that broke when the numbers got too small
and so it seemed a fix was in order, even though this is a FEATURE
according to the manual page. The fix is very simple (although recompiling
af may not be). The only file that needs to be changed is `aeparse.c'
in the /wherever_gps_src_is_stored/graf/stat.d directory.

*** aeparse.c.orig Tue Jul 15 17:29:33 1986
--- aeparse.c Tue Jul 15 17:35:57 1986
***************
*** 1,5
static char SCCSID[]="@(#)aeparse.c 1.2";
/* <: t-5 d :> */

#include "s.h"
#include "stdio.h"

--- 1,6 -----
static char SCCSID[]="@(#)aeparse.c 1.2";
/* <: t-5 d :> */
+ /* kc 7/86 command line exponential notation allowed */

#include "s.h"
#include "stdio.h"
***************
*** 172,177
case IDENT: while( ISID(**p) || **p=='/' ) *buf++ = *(*p)++;
break;
case CONST: while( ISNUM(**p) ) *buf++ = *(*p)++;
break;
default: if(!silent) ERRPR1(? %c,*(*p)++); break;
}

--- 173,184 -----
case IDENT: while( ISID(**p) || **p=='/' ) *buf++ = *(*p)++;
break;
case CONST: while( ISNUM(**p) ) *buf++ = *(*p)++;
+ /* following four lines added by kc 7/86 to allow
+ exponents on the command line */
+ if( (**p == 'e') || (**p == 'E') ) /* exponent */
+ *buf++ = *(*p)++;
+ while( ISNUM(**p) )
+ *buf++ = *(*p)++;
break;
default: if(!silent) ERRPR1(? %c,*(*p)++); break;
}


Kaare Christian
cmcl2!rna!kc

k...@rna.uucp

unread,
Jul 16, 1986, 1:36:07 PM7/16/86
to
In my previous posting about the af command line parameter problem
my solution neglected the possibility of negative exponents. Sorry.
What follows is the correct (I hope) code to improve af so that it
allows scientific notation in its command line parameters. This fix
supersedes the previous.

*** aeparse.c.orig Tue Jul 15 17:29:33 1986

--- aeparse.c Tue Jul 15 21:55:58 1986


***************
*** 1,5
static char SCCSID[]="@(#)aeparse.c 1.2";
/* <: t-5 d :> */

#include "s.h"
#include "stdio.h"

--- 1,6 -----
static char SCCSID[]="@(#)aeparse.c 1.2";
/* <: t-5 d :> */
+ /* kc 7/86 command line exponential notation allowed */

#include "s.h"
#include "stdio.h"
***************
*** 172,177
case IDENT: while( ISID(**p) || **p=='/' ) *buf++ = *(*p)++;
break;
case CONST: while( ISNUM(**p) ) *buf++ = *(*p)++;
break;
default: if(!silent) ERRPR1(? %c,*(*p)++); break;
}

--- 173,186 -----


case IDENT: while( ISID(**p) || **p=='/' ) *buf++ = *(*p)++;
break;
case CONST: while( ISNUM(**p) ) *buf++ = *(*p)++;
+ /* following four lines added by kc 7/86 to allow
+ exponents on the command line */
+ if( (**p == 'e') || (**p == 'E') ) /* exponent */
+ *buf++ = *(*p)++;

+ if( **p == '-' ) /* sign */


+ *buf++ = *(*p)++;
+ while( ISNUM(**p) )
+ *buf++ = *(*p)++;
break;
default: if(!silent) ERRPR1(? %c,*(*p)++); break;
}

Once again, sorry for the inconvenience of two messages when one should
have been enough.

Kaare Christian
cmcl2!rna!kc

0 new messages