gps af malfeature

kc at rna.UUCP kc at rna.UUCP
Wed Jul 16 08:40:12 AEST 1986


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



More information about the Net.bugs mailing list