Exemple #1
0
/*
 * readDoubleFromString - s - pointer to parsing source - d - ptr to double
 * handles negatives (high or low minus, depending on mode) and "Inf".
 * Result: 1 on success, 0 on failure - number loaded in d, and s advanced
 */
Z I readDoubleFromString(C **s,F *d)
{
  C *r=*s;
  I i='\242'==*r||(1!=APL)&&'-'==*r,j;
  r+=i;
  j=strncmp(r,"Inf",3)||isal(r[3]);
  if(j&&!isdi(r['.'==*r]))R 0;
  if(!j)*s=r+3,*d=Inf;
#ifdef linux
/* Linux's strtod differs from other implementations in that it also */
/* converts hexadecimal values.  This causes problems for A+ code line */
/* y,@0x or y,@0x22 where it removes both the 0 and the x */
  else
    {
      if( r[0]=='0'&&(r[1]=='x'||r[1]=='X'))
	{
	  *d=0.0;
	  *s=r+1;
	}
      else 
	for(*d=strtod(r,s);**s=='0';++*s);
    }
#else
  else 
    for(*d=strtod(r,s);**s=='0';++*s);
Exemple #2
0
int
pchar(register tchar i)
{
	register int j;
	static int hx = 0;	/* records if have seen HX */
	static int xon = 0;	/* records if have seen XON */
	static int drawfcn = 0;	/* records if have seen DRAWFCN */

	if (hx) {
		hx = 0;
		j = absmot(i);
		if (isnmot(i)) {
			if (j > dip->blss)
				dip->blss = j;
		} else {
			if (j > dip->alss)
				dip->alss = j;
			ralss = dip->alss;
		}
		return 1;
	}
	if (ismot(i)) {
		pchar1(i); 
		return 1;
	}
	switch (j = cbits(i)) {
	case 0:
	case IMP:
	case RIGHT:
	case LEFT:
		if (xflag) {
			i = j = FILLER;	/* avoid kerning in output routine */
			goto dfl;
		}
		return 1;
	case HX:
		hx = 1;
		if (xflag) {
			i = j = FILLER;	/* avoid kerning in output routine */
			goto dfl;
		}
		return 1;
	case XON:
		xon = 1;
		goto dfl;
	case XOFF:
		xon = 0;
		goto dfl;
	case DRAWFCN:
		drawfcn = !drawfcn;
		goto dfl;
	case PRESC:
		if (dip == &d[0])
			j = eschar;	/* fall through */
	default:
	dfl:
#ifndef NROFF
		if (html) {
			if (!xflag || !isdi(i)) {
				setcbits(i, j >= NCHARS ? j :
				    tflg ? trnttab[j] : trtab[j]);
				if (xon == 0 && drawfcn == 0 && i < NCHARS)
					setcbits(i, ftrans(fbits(i),
					    cbits(i)));
			}
		} else
#endif
		if (!xflag || !isdi(i)) {
			setcbits(i, tflg ? trnttab[j] : trtab[j]);
			if (xon == 0 && drawfcn == 0)
				setcbits(i, ftrans(fbits(i), cbits(i)));
		}
	}
#ifdef	NROFF
	if (xon && xflag)
		return 1;
#endif	/* NROFF */
	pchar1(i);
	return 1;
}
Exemple #3
0
I isan(I c){R isal(c)||isdi(c);}