/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley Software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <locale.h>
#include <signal.h>
struct unit
{
double factor;
};
struct table
{
double factor;
char *name;
struct prefix
{
double factor;
char *pname;
} prefix[] =
{
1e-21, "zepto",
1e-24, "yocto",
1e-18, "atto",
1e-15, "femto",
1e-12, "pico",
1e-9, "nano",
1e-6, "micro",
1e-3, "milli",
1e-2, "centi",
1e-1, "deci",
1e1, "deka",
1e1, "deca",
1e2, "hecta",
1e2, "hecto",
1e3, "kilo",
1e6, "mega",
1e6, "meg",
1e9, "giga",
1e12, "tera",
1e15, "peta",
1e18, "exa",
1e21, "zetta",
1e24, "yotta",
1<<10, "kibi",
1L<<20, "mebi",
1L<<30, "gibi",
1LL<<40,"tebi",
0.0, 0
};
int fperrc;
int peekc;
int dumpflg;
double getflt(void);
int get(void);
void init(void);
int pu(int u, int i, int f);
int
{
int i;
char *file;
double f;
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
argc--;
argv++;
dumpflg++;
}
if(argc > 1)
exit(1);
}
init();
loop:
fperrc = 0;
goto loop;
if(fperrc)
goto fp;
goto loop1;
for(i=0; i<NDIM; i++)
goto conform;
if(fperrc || f == 0.0)
goto fp;
printf("\t* %e\n", f);
goto loop;
if(fperrc)
goto fp;
goto loop;
fp:
goto loop;
}
void
{
struct unit *p;
int f, i;
p = up;
f = 0;
for(i=0; i<NDIM; i++)
if(f&1) {
putchar('/');
f = 0;
for(i=0; i<NDIM; i++)
}
putchar('\n');
}
int
pu(int u, int i, int f)
{
if(u > 0) {
if(f&2)
putchar('-');
if(unames[i])
if(u > 1)
putchar(u+'0');
return(2);
}
if(u < 0)
return(1);
return(0);
}
int
{
struct unit *p;
int c;
char *cp;
p = up;
for(c=0; c<NDIM; c++)
p->dim[c] = 0;
if(p->factor == 0.)
p->factor = 1.0;
err = 0;
den = 0;
loop:
switch(c=get()) {
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '-':
case '/':
case ' ':
case '\t':
case '\n':
*cp++ = 0;
}
if(c == '/')
den++;
if(c == '\n')
return(err);
goto loop;
}
*cp++ = c;
goto loop;
}
int
{
struct unit *p;
struct table *q;
int i;
double e;
p = up;
e = 1.0;
loop:
if(q->name) {
l1:
if(den) {
for(i=0; i<NDIM; i++)
} else {
for(i=0; i<NDIM; i++)
}
if(c >= '2' && c <= '9') {
c--;
goto l1;
}
return(0);
}
if(*cp1++ == 0) {
cp1--;
break;
}
if(*cp1 == 0) {
goto loop;
}
}
*cp1 = 0;
goto loop;
}
return(1);
}
int
{
if(*c2++ == 0)
return(1);
return(0);
}
void
init(void)
{
char *cp;
int c, i, f, t;
char *np;
for(i=0; i<NDIM; i++) {
*cp++ = '*';
*cp++ = i+'a';
*cp++ = '*';
*cp++ = 0;
}
l0:
c = get();
if(c == 0) {
if(dumpflg) {
continue;
} }
return;
}
if(c == '/') {
while(c != '\n' && c != 0)
c = get();
goto l0;
}
if(c == '\n')
goto l0;
while(c != ' ' && c != '\t') {
*cp++ = c;
c = get();
if (c==0)
goto l0;
if(c == '\n') {
*cp++ = 0;
goto redef;
for(c=0; c<NDIM; c++)
i++;
goto l0;
}
}
*cp++ = 0;
goto redef;
f = 0;
i++;
goto l0;
for(c=0; c<NDIM; c++) {
if(t>1 || (f>0 && t!=0))
goto l0;
if(f==0 && t==1) {
if(unames[c])
goto l0;
f = c+1;
}
}
if(f>0)
goto l0;
goto l0;
}
double
getflt(void)
{
int c, i, dp;
double d, e;
int f;
d = 0.;
dp = 0;
do
c = get();
while(c == ' ' || c == '\t');
l1:
if(c >= '0' && c <= '9') {
d = d*10. + c-'0';
if(dp)
dp++;
c = get();
goto l1;
}
if(c == '.') {
dp++;
c = get();
goto l1;
}
if(dp)
dp--;
if(c == '+' || c == '-') {
f = 0;
if(c == '-')
f++;
i = 0;
c = get();
while(c >= '0' && c <= '9') {
i = i*10 + c-'0';
c = get();
}
if(f)
i = -i;
dp -= i;
}
e = 1.;
i = dp;
if(i < 0)
i = -i;
while(i--)
e *= 10.;
if(dp < 0)
d *= e; else
d /= e;
if(c == '|')
return(d/getflt());
peekc = c;
return(d);
}
int
get(void)
{
int c;
if(c=peekc) {
peekc = 0;
return(c);
}
if (c == EOF) {
printf("\n");
exit(0);
}
return(0);
}
return(c);
}
struct table *
{
char *np;
unsigned int h;
h = 0;
while(*np)
if( ((int)h)<0) h= -(int)h;
h %= NTAB;
l0:
return(tp);
return(tp);
tp++;
goto l0;
}
void
{
fperrc++;
}