static double epow( EPNODE *ep ) { EPNODE *ep1 = ep->v.kid; double d; int lasterrno; lasterrno = errno; errno = 0; d = pow(evalue(ep1), evalue(ep1->sibling)); #ifdef isnan if (errno == 0) { if (isnan(d)) errno = EDOM; else if (isinf(d)) errno = ERANGE; } #endif if (errno == EDOM || errno == ERANGE) { wputs("Illegal power\n"); return(0.0); } errno = lasterrno; return(d); }
CON(int, puts(const char* str)) { wchar_t wbuf[PRINTF_BUFSIZE]; wsprintf(wbuf, L"%s", str); wputs(wbuf); return 0; }
void getstatement(void) /* get next statement */ { EPNODE *ep; char *qname; VARDEF *vdef; if (nextc == ';') { /* empty statement */ scan(); return; } if (esupport&E_OUTCHAN && nextc == '$') { /* channel assignment */ ep = getchan(); addchan(ep); } else { /* ordinary definition */ ep = getdefn(); qname = qualname(dname(ep), 0); if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL) { if (vdef->def != NULL && epcmp(ep, vdef->def)) { wputs(qname); if (vdef->def->type == ':') wputs(": redefined constant expression\n"); else wputs(": redefined\n"); } else if (ep->v.kid->type == FUNC && vdef->lib != NULL) { wputs(qname); wputs(": definition hides library function\n"); } } if (ep->type == ':') dremove(qname); else dclear(qname); dpush(qname, ep); } if (nextc != EOF) { if (nextc != ';') syntax("';' expected"); scan(); } }
static void checkfile(void) /* ready a file */ { register int i; /* process header */ gotview = 0; if (echoheader) { fputs(input[nfiles].name, stdout); fputs(":\n", stdout); } getheader(input[nfiles].fp, headline, NULL); if (wrongformat < 0) { eputs(input[nfiles].name); eputs(": not a Radiance picture\n"); quit(1); } if (wrongformat > 0) { wputs(input[nfiles].name); wputs(": warning -- incompatible picture format\n"); } if (!gotview || setview(&input[nfiles].vw) != NULL) input[nfiles].vw.type = 0; if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) { eputs(input[nfiles].name); eputs(": bad picture size\n"); quit(1); } if (xmax == 0 && ymax == 0) { xmax = scanlen(&input[nfiles].rs); ymax = numscans(&input[nfiles].rs); } else if (scanlen(&input[nfiles].rs) != xmax || numscans(&input[nfiles].rs) != ymax) { eputs(input[nfiles].name); eputs(": resolution mismatch\n"); quit(1); } /* allocate scanlines */ for (i = 0; i < WINSIZ; i++) input[nfiles].scan[i] = (COLOR *)emalloc(xmax*sizeof(COLOR)); }
/* ---------- PAINT Message ---------- */ static void PaintMsg(WINDOW wnd) { if (Selecting) return; if (wnd == inFocus) SendMessage(GetParent(wnd), ADDSTATUS, 0, 0); SetStandardColor(wnd); wputs(wnd, GetText(wnd), 0, 0); if (ActiveMenuBar->ActiveSelection != -1 && (wnd == inFocus || mwnd != NULL)) { char *sel, *cp; int offset, offset1; sel = DFmalloc(200); offset=menu[ActiveMenuBar->ActiveSelection].x1; offset1=menu[ActiveMenuBar->ActiveSelection].x2; GetText(wnd)[offset1] = '\0'; SetReverseColor(wnd); memset(sel, '\0', 200); strcpy(sel, GetText(wnd)+offset); cp = strchr(sel, CHANGECOLOR); if (cp != NULL) *(cp + 2) = background | 0x80; wputs(wnd, sel, offset-ActiveMenuBar->ActiveSelection*4, 0); GetText(wnd)[offset1] = ' '; if (mwnd == NULL && wnd == inFocus) { char *st = ActiveMenu [ActiveMenuBar->ActiveSelection].StatusText; if (st != NULL) SendMessage(GetParent(wnd), ADDSTATUS, (PARAM)st, 0); } free(sel); } }
void quit( /* exit gracefully */ int code ) { if (ourdisplay != NULL) dev_close(); /* if (rtpd.pid > 0) { */ if (rtpd.running) { if (close_process(&rtpd) > 0) wputs("bad exit status from rtrace\n"); /* rtpd.pid = 0; */ } exit(code); }
static double edivi( EPNODE *ep ) { EPNODE *ep1 = ep->v.kid; double d; d = evalue(ep1->sibling); if (d == 0.0) { wputs("Division by zero\n"); errno = ERANGE; return(0.0); } return(evalue(ep1) / d); }