Exemple #1
0
/*parameter for initializing the virtual frequency*/
static int __init uml_freq_setup(char *line, int *add) {
	reltime.frequency = atold(line);
	return 0;
}
Exemple #2
0
int
rd_F (unit *ftnunit, ufloat *p, long w, long d, ftnlen len)
{
   char            s[MAX_INPUT_SIZE], *sp, *c, *exppos=NULL;
   int             ch, nfrac, exp, dot, se;
   int		   extrachars=0;
   int		   i, ich;
   char		   cc;

   dot = 1;			/* no dot */
   if (w == 0) {
      if (len < 8) {
	 w = 15;
	 d = 7;
      } else if (len == 8) {
	 w = 25;
	 d = 16;
      }
      else {
	 w = 40;
	 d = 32;
      }
   }
   if ((int) w >= MAX_INPUT_SIZE) {
      ch = GETS (sp = s, MAX_INPUT_SIZE-1, ','); 
      for (i = MAX_INPUT_SIZE-1; i < w; i++) {
	  ich = GETS (&cc, 1, ',');
	  if (!ch) break;
	  if (!isspace(cc))
	     return (errno = 186);
      }
   } else
      ch = GETS (sp = s, (int) w, ',');
   if (ch < 0)
      return (ch);
   sp[ch] = '\0';
   while (*sp == ' ')
      sp++;
   if (*sp == '-') {
      sp++;
   } else {
      if (*sp == '+')
	 sp++;
   }
loop1:
   while (*sp >= '0' && *sp <= '9') {
      sp++;
   }
   if (*sp == ' ') {
      if (ftnunit->f77cblank) { *sp++='0'; }
      else {c=sp; while (*c) { *c=*(c+1); c++; } }
      goto loop1;
   }
   nfrac = 0;
   if (*sp == '.') {
      {c=sp; while (*c) { *c=*(c+1); c++; } }
      dot = 0;
loop2:
      while (*sp >= '0' && *sp <= '9') {
	 nfrac--;
	 sp++;
      }
      if (*sp == ' ') {
      if (ftnunit->f77cblank) { *sp++='0'; nfrac--; }
      else {c=sp; while (*c) { *c=*(c+1); c++; } }
	 goto loop2;
      }
   }
   if (*sp == 'd' || *sp == 'e' || *sp == 'D' || *sp == 'E'
       || *sp == 'q' || *sp == 'Q') {
      {
      exppos=sp;
      *sp++='e';
      }
   } else if (*sp != '+' && *sp != '-')
      {
      nfrac -= ftnunit->f77scale;
      exppos=sp;
      }
   while (*sp == ' ') {c=sp; while (*c) { *c=*(c+1); c++; } }
   if (*sp == '-') {
      if (exppos==NULL) exppos=sp;
      sp++;
      se = 1;
   } else {
      if (exppos==NULL) exppos=sp;
      se = 0;
      if (*sp == '+')
	 sp++;
   }
   exp = 0;
loop3:
   while (*sp >= '0' && *sp <= '9') {
      exp = exp * 10 + (*sp - '0');
      sp++;
   }
   if (*sp == ' ') {
      if (ftnunit->f77cblank)
	 exp *= 10;
      sp++;
      goto loop3;
   }
   /* here we figure out if there is any unexpected characters */
   if (*sp) extrachars=1;
   if (se)
      exp = nfrac - exp;
   else
      exp += nfrac;
   if (dot)
      exp -= d;
   *exppos++='e';
   /* re-write exponent */
   if (exp < 0)
	{
	*exppos++='-';
	exp = - exp;
	}
   if (exp > 999) exp=999;	/* currently cant handle exponents that large */
   if (exp > 99)
	{
	*exppos++ = (char) ((exp/100) + '0');
	exp = exp % 100;
	if (exp < 10)
	    *exppos++ = '0';
	}
   if (exp > 9)
	{
	*exppos++ = (char) ((exp/10) + '0');
	exp = exp % 10;
	}
   *exppos++ = (char) (exp + '0');
   *exppos = '\0';
   /* now convert */
   if (len < sizeof (double))
      p->pf = atof(s);
   else if (len == sizeof (double))
      p->pd =  atof(s);
   else
      p->pld =  atold(s);
   if (extrachars)
      return (errno = 115);
   else
      return (0);
}