diff --git a/log/include/logglobals.h b/log/include/logglobals.h index eac087ba2ec5f4523c998829b33eabf323966d9a..eb838f163d9e30af1625fc08e1e333aa06f9590d 100644 --- a/log/include/logglobals.h +++ b/log/include/logglobals.h @@ -7,9 +7,6 @@ #include "logstructs.h" extern char *GetChipmunkPath(); -extern char *my_strdup(); -#undef strdup -#define strdup my_strdup #define newci_findprocedure2 findprocedure extern int findprocedure (char *name, void (**start)()); diff --git a/log/src/label.c b/log/src/label.c index c508a457e7ca2bbfb0648df51cbe411b8d62737e..03aa53e92883ccce03b8db8b15e5b26e89b507b7 100644 --- a/log/src/label.c +++ b/log/src/label.c @@ -1,4 +1,5 @@ +#include <string.h> #include <p2c/p2c.h> #include <p2c/newkbd.h> #include "settings.h" @@ -392,4 +393,3 @@ void displabel(log_lrec **l) unlinklabel(*l); Free(*l); } - diff --git a/log/src/log.c b/log/src/log.c index 7fd6d373d2fd7e211d69870db0f05c4f4e95d883..2a98def303a73770f1a17011df0d43613ad40284 100644 --- a/log/src/log.c +++ b/log/src/log.c @@ -34,6 +34,7 @@ #include <unistd.h> #include <time.h> +#include <string.h> #define LOAD_SEARCH /* Use the search path in load command. */ @@ -79,7 +80,6 @@ #include "utils.h" char *GetChipmunkPath(); -char *my_strdup(); int findprocedure (char *name, void (**start)()); enum cursors; diff --git a/log/src/loged.c b/log/src/loged.c index c741326fd1bc93c1caee93282b932a26eff0993f..9a8da4319bd160b19269ff5184689b31e55cffdb 100644 --- a/log/src/loged.c +++ b/log/src/loged.c @@ -46,6 +46,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ */ #include <unistd.h> +#include <string.h> #include <p2c/p2c.h> @@ -66,9 +67,6 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <p2c/regex.h> -char *my_strdup(char *); -#undef strdup -#define strdup my_strdup #define newci_findprocedure2 findprocedure extern int findprocedure (char *name, void (**start)()); extern short getshortsw(char *); @@ -916,7 +914,7 @@ krec *k; P_ibetween((long)gridymin, (long)WITH1->UU.U99.y3, (long)gridymax) && P_ibetween((long)gridxmin, (long)WITH1->UU.U99.x4, (long)gridxmax) && P_ibetween((long)gridymin, (long)WITH1->UU.U99.y4, (long)gridymax))) -/* p2c: loged.text, line 805: +/* p2c: loged.text, line 805: * Note: Line breaker spent 2.0 seconds, 5000 tries on line 826 [251] */ setscale(gridscale + 1L); break; @@ -2268,7 +2266,7 @@ char *s_, *gname_; FORLIM = k->sizelbl / 4; for (i = 1; i <= FORLIM; i++) { readint(&V); - memmove((void *)(k->lbl + V.j - 1), + memmove((void *)(k->lbl + V.j - 1), (const void *)GETFBUF(V.f, filerec).c4[V.p], 4); V.j += 4; V.p++; @@ -2689,7 +2687,7 @@ long num; /* drpin() functions as both grpin() and erpin(), using the 'visible' arg. */ -/* it can place the pin number north or south in addition to east or west. */ +/* it can place the pin number north or south in addition to east or west. */ static void drpin(x, y, n, visible) short x,y,n; int visible; @@ -3612,13 +3610,13 @@ struct LOC_drawcmd *LINK; for (i = 0; i < FORLIM; i++) { WITH = &kind.vector[i]; if (P_ibetween((long)gridxmin, (long)WITH->x1, (long)gridxmax) && - P_ibetween((long)gridymin, (long)WITH->y1, (long)gridymax) && + P_ibetween((long)gridymin, (long)WITH->y1, (long)gridymax) && ((WITH->kind != 'b' && WITH->kind != 'c' && WITH->kind != 'r' && WITH->kind != 'E' && WITH->kind != 'e' && WITH->kind != 'F' && - WITH->kind != 'C' && WITH->kind != 'v') || - (P_ibetween((long) gridxmin, (long)WITH->UU.U99.x2, (long)gridxmax) - && P_ibetween((long)gridymin, (long)WITH->UU.U99.y2, (long)gridymax) - && ((WITH->kind != 'c' && WITH->kind != 'F') || + WITH->kind != 'C' && WITH->kind != 'v') || + (P_ibetween((long) gridxmin, (long)WITH->UU.U99.x2, (long)gridxmax) + && P_ibetween((long)gridymin, (long)WITH->UU.U99.y2, (long)gridymax) + && ((WITH->kind != 'c' && WITH->kind != 'F') || (P_ibetween((long)gridxmin, (long)WITH->UU.U99.x3, (long)gridxmax) && P_ibetween((long)gridymin, (long)WITH->UU.U99.y3, @@ -4181,7 +4179,7 @@ static void drawcmd() case 251: /* X ConfigureNotify (resize) event */ autoscale(1L); - break; + break; case ' ': case '5': @@ -4207,14 +4205,14 @@ static void drawcmd() case '<': if (gridscale < 4) { autoscale(gridscale + 1L); - needrefr = true; + needrefr = true; } break; case '>': if (gridscale > 1) { autoscale(gridscale - 1L); - needrefr = true; + needrefr = true; } break; @@ -4228,12 +4226,12 @@ static void drawcmd() case 'X': /*destroy (obsolete) pin-number annotations*/ kind.numpnums = 0; - needrefr = true; + needrefr = true; break; case 'L': show_preview = show_preview ? false : true; - needrefr = true; + needrefr = true; break; case '\003': @@ -5449,7 +5447,7 @@ static void dumpcmd() P_imax2((long)WITH->x1, (long)WITH->UU.U99.x2) - WITH->UU.U98.num, P_imax2((long)(-WITH->y1), (long)(-WITH->UU.U99.y2)) - WITH->UU.U98.num, WITH->UU.U98.num); -/* p2c: loged.text, line 5381: +/* p2c: loged.text, line 5381: * Note: Line breaker spent 2.0 seconds, 5000 tries on line 5498 [251] */ fprintf(V.f, "%ld %ld %d 90 180 arc %ld %ld %d 180 270 arc CP SP\n", P_imin2((long)WITH->x1, (long)WITH->UU.U99.x2) + WITH->UU.U98.num, diff --git a/log/src/logntk.c b/log/src/logntk.c index eb30c6ef0ececa9c0629c153d244ac6bcdfc7600..8b7b9097645a4adda5f14b743d85c0b55b6415f4 100644 --- a/log/src/logntk.c +++ b/log/src/logntk.c @@ -34,15 +34,11 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Modified 12/16/86 to fix mossim problems */ /* Modified 7/27/88 to support digital hierarchy */ - +#include <string.h> #include <p2c/p2c.h> #include <p2c/strings.h> #include "logntk.h" -extern char *my_strdup(char *s); -#undef strdup -#define strdup my_strdup - #define main_name "-Main-" @@ -1184,12 +1180,12 @@ struct LOC_dologntk *LINK; tolower(t->kind), i, (char *)g->pin[0]->temp, (char *)g->pin[2]->temp, (char *)g->pin[1]->temp); handled = true; - } - else + } + else { fprintf(LINK->outf, "%c %ld %s %s %s %s ;\n", tolower(t->kind), i, (char *)g->pin[0]->temp, - (char *)g->pin[2]->temp,(char *)g->pin[1]->temp, + (char *)g->pin[2]->temp,(char *)g->pin[1]->temp, (char *)g->pin[3]->temp ); handled = true; } @@ -1449,7 +1445,7 @@ struct LOC_Log_logntk_proc *LINK; log_nrec *probenode, *rednode; log_brec *curbox; long i, xpos, ypos, FORLIM; - + (*LINK->act->hook.clearfunc)(); defndir = mydefndirectory((int)LINK->act->curpage, LINK); curdef = NULL; diff --git a/log/src/logsimed.c b/log/src/logsimed.c index a0828da08166500666887a26f32d37bee3e893d4..a62c8500d40c36a29a46aea8c0ecd3c5f8ee4225 100644 --- a/log/src/logsimed.c +++ b/log/src/logsimed.c @@ -37,7 +37,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* $debug$ {*/ - +#include <string.h> #include <p2c/p2c.h> #include <p2c/strings.h> #include "logsimed.h" @@ -72,7 +72,7 @@ char *tmp; if (strlen(LINK->buf) + strlen(s) + 1 > LINK->bufsiz) { tmp = strdup(LINK->buf); Free(LINK->buf); - LINK->bufsiz = strlen(tmp) + strlen(s) + 1 + GROW_SIZE; + LINK->bufsiz = strlen(tmp) + strlen(s) + 1 + GROW_SIZE; LINK->buf = (char*)Malloc(LINK->bufsiz); strcpy(LINK->buf, tmp); Free(tmp); @@ -1493,7 +1493,7 @@ struct LOC_edit_16 *LINK; /* p2c: logsimed.text, line 1282: * Warning: Type mismatch in VAR parameter term [295] */ - newci_inputstring(s, im_keep, "\015\n\037\003\004", + newci_inputstring(s, im_keep, "\015\n\037\003\004", (char *)&LINK->ch, false, &pos); } @@ -1618,7 +1618,7 @@ char *name_; * Note: character >= 128 encountered [281] */ } else { nc_getXY(&sx, &sy); - nc_insLine((int)sy, 1); + nc_insLine((int)sy, 1); } if (sbuf == NULL) { sbuf = (char*)Malloc(1024); @@ -1733,7 +1733,7 @@ char *name_; } else { STR2 = strdup(recallbuf); Free(recallbuf); - recallbuf = (char*)Malloc(strlen(STR2) + strlen(sbuf) + 1 ); + recallbuf = (char*)Malloc(strlen(STR2) + strlen(sbuf) + 1 ); strcpy(recallbuf,STR2); strcat(recallbuf, sbuf); Free(STR2); diff --git a/log/src/logsimh.c b/log/src/logsimh.c index 133a20d99ece05fdbfee3da3137acbb7ac556e14..dc9c28272e4fcddaa6b391028541ec683e36cc22 100644 --- a/log/src/logsimh.c +++ b/log/src/logsimh.c @@ -34,18 +34,13 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ The following module is subject to change at any time. */ - +#include <string.h> #include <p2c/p2c.h> #include <p2c/strings.h> #include <p2c/math.h> #include "logsimh.h" -char *my_strdup(); -#undef strdup -#define strdup my_strdup - - /* caged_date="R lastmoddate = '$X by $U';" */ #define lastmoddate "Apr 21, 1989 5:23 pm by dave" @@ -3990,7 +3985,7 @@ struct LOC_compilepage *LINK; else fprintf(f, "None"); putc('\n', f); - fprintf(f, "%sExternal pins: %d\n", pref, LINK->numports); + fprintf(f, "%sExternal pins: %d\n", pref, LINK->numports); } diff --git a/log/src/logspc.c b/log/src/logspc.c index 801da7701fd7ad06095a2afbda5ef98a1ad795e2..70fe5baa82ceaedc485993779ba2b4d6928f2802 100644 --- a/log/src/logspc.c +++ b/log/src/logspc.c @@ -131,17 +131,13 @@ char pre_file[256] = "", post_file[256] = ""; /* for #include-esque stuff */ /* End Of Spice Globals */ - +#include <string.h> #include <p2c/p2c.h> #include <p2c/strings.h> #include "logspc.h" extern double AnaVdd; -char *my_strdup(); -#undef strdup -#define strdup my_strdup - #define main_name "-Main-" typedef enum { @@ -1571,7 +1567,7 @@ struct LOC_dologspc *LINK; lambda*g->attr[10].UU.r, lambda*g->attr[9].UU.r); break; case 'n': /* 3-pin NFET with implicit 4th pin and geometry */ - fprintf (LINK->outf, "M%ld %s %s %s %s NMOS1 ", m_ctr, + fprintf (LINK->outf, "M%ld %s %s %s %s NMOS1 ", m_ctr, (char *)g->pin[1]->temp, /* n-source */ (char *)g->pin[0]->temp, /* gate */ (char *)g->pin[2]->temp, /* n-drain */ @@ -1581,7 +1577,7 @@ struct LOC_dologspc *LINK; default_L, g->attr[N_Ratio - 1].UU.r * default_L); break; case 'i': /* 3-pin NFET7T */ - fprintf (LINK->outf, "M%ld %s %s %s %s NMOS1 ", m_ctr, + fprintf (LINK->outf, "M%ld %s %s %s %s NMOS1 ", m_ctr, (char *)g->pin[1]->temp, /* n-source */ (char *)g->pin[0]->temp, /* gate */ (char *)g->pin[2]->temp, /* n-drain */ @@ -2034,7 +2030,7 @@ struct LOC_Log_logspc_proc *LINK; strcat(STR1, "/"); strcat(STR1, pre_file); incfp = fopen (STR1, "r"); - if (incfp) { + if (incfp) { /* fprintf(V.outf, "* LOGSPC pre-include from file %s\n", STR1); */ diff --git a/log/src/logstuff.c b/log/src/logstuff.c index 3f7a1453f32c77e706fbbad60643ed8d0a24f5dd..54ffeeecc2261d18e8fe107f9c30ccdf5c0f4c04 100644 --- a/log/src/logstuff.c +++ b/log/src/logstuff.c @@ -210,16 +210,6 @@ void nc_scrollXY(int x, int y) } - -char *my_strdup(char *s) -{ - char *buf = Malloc(strlen(s) + 1); - strcpy(buf, s); - return buf; -} - - - extern struct ext_proc ext_proc_table[]; int findprocedure(char *name, void (**proc)()) @@ -239,7 +229,6 @@ int findprocedure(char *name, void (**proc)()) } - void newci_inputmap() { } @@ -253,5 +242,3 @@ int x, dx; { printf("nc_insLine not implemented\n"); } - - diff --git a/psys/include/p2c/strings.h b/psys/include/p2c/strings.h index 6e7d2b6aab8ff351ab302a935bd812aef79dddb9..966eee4444e20b54aa5d23988da4d9f4147cd8a7 100644 --- a/psys/include/p2c/strings.h +++ b/psys/include/p2c/strings.h @@ -53,4 +53,3 @@ extern void strchange (char** sp, char *); extern char *strcpy_overlap(char *dst, char *src) DEPRECATED; #endif - diff --git a/psys/src/misc.c b/psys/src/misc.c index 70d779546d9454647818aadc9c001c4d8008d508..ef6d94f655fafc378a28b75f3a3737bcd687198d 100644 --- a/psys/src/misc.c +++ b/psys/src/misc.c @@ -1,10 +1,11 @@ #define MISC_G #include <stdio.h> +#include <string.h> #include <p2c/p2c.h> #include <p2c/misc.h> -#ifndef LACK_GETPWNAM +#ifndef LACK_GETPWNAM #include <pwd.h> #endif @@ -13,13 +14,13 @@ void misc_getioerrmsg(char *s, long i) sprintf(s, "misc_getioerrmsg Error number %ld", i); } -#if defined __FreeBSD__|| defined __bsdi__ +#if defined __FreeBSD__ || defined __bsdi__ char *cuserid(char *s) { char *sp; static char sbuf[L_cuserid + 1]; - + if ((sp = getenv("USER")) == NULL) { if (s != NULL) s[0] = '\0'; @@ -31,7 +32,7 @@ char *cuserid(char *s) #endif -#ifndef LACK_GETPWNAM +#ifndef LACK_GETPWNAM /* tilde-expansion for platforms with passwd mechanisms. * this replaces a leading ~/ with the user's home directory, @@ -55,7 +56,7 @@ struct passwd *pw; Free(name); } else { pw = getpwuid( geteuid() ); - } + } if (pw != NULL) { ret = (char *) Malloc(strlen(pw->pw_dir) + strlen(s) - len); strcpy(ret,pw->pw_dir); @@ -65,7 +66,7 @@ struct passwd *pw; } if (ret == NULL) ret = strdup(s); - return ret; + return ret; } #else @@ -91,4 +92,3 @@ char *ret = NULL; } #endif - diff --git a/psys/src/newcrt.c b/psys/src/newcrt.c index a045975f761e2af9476624c7b72167c1436be2bd..babfdab35a5d9bb22cdfcb57a4fc2b4edc467fd5 100644 --- a/psys/src/newcrt.c +++ b/psys/src/newcrt.c @@ -2,6 +2,7 @@ #define HIRES #include <stdio.h> +#include <string.h> #include <stdarg.h> #include <signal.h> @@ -43,7 +44,7 @@ #endif static long WindowEventMask = ExposureMask | KeyPressMask | - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask; static unsigned long WinAttrMask = CWBackPixel | CWBorderPixel | CWEventMask | CWCursor; @@ -134,7 +135,7 @@ static void WindowInitialize() screennum = DefaultScreen(m_display); root = DefaultRootWindow(m_display); - + if (BlackAndWhite) { WinAttr.background_pixel = BlackPixel(m_display, DefaultScreen(m_display)); WinAttr.border_pixel = WhitePixel(m_display, DefaultScreen(m_display)); @@ -148,7 +149,7 @@ static void WindowInitialize() #endif WinAttr.event_mask = WindowEventMask; WinAttr.cursor = XCreateFontCursor(m_display, XC_tcross); - XRecolorCursor(m_display, WinAttr.cursor, &m_colors[0][15], + XRecolorCursor(m_display, WinAttr.cursor, &m_colors[0][15], &m_colors[0][m_black]); WinSizeHints.max_width = XDisplayWidth(m_display, screennum); WinSizeHints.max_height = XDisplayHeight(m_display, screennum); @@ -157,11 +158,11 @@ static void WindowInitialize() nc_usrfont = strdup(DefaultFont); /* This next section allows entries in .Xdefaults to set initial - size and position of the newcrt window. + size and position of the newcrt window. Jim Clark 7/13/92 */ usrgeo = XGetDefault(m_display, "newcrt", "geometry"); - + if (usrgeo == NULL) WinSizeHints.flags |= PPosition; else @@ -177,10 +178,10 @@ static void WindowInitialize() nc_window = XCreateWindow(m_display, root, jc_winX, jc_winY, jc_winW, jc_winH, WinBorder, - CopyFromParent, InputOutput, + CopyFromParent, InputOutput, DefaultVisual(m_display, screennum), WinAttrMask, &WinAttr); - + /* End of revised section. */ XStoreName(m_display, nc_window, "newcrt"); @@ -283,21 +284,21 @@ void nc_putChar(x, y, c) int x, y; uchar c; { - if (! nc_initialized) + if (! nc_initialized) nc_initialize(); CheckRefresh(); if (x >= 0 && x < nc_curWindow->width && y >= 0 && y < nc_curWindow->height) { NC_SCREEN(y*TextW+x).i = nc_highlight + c; - XDrawImageString(m_display, nc_window, nc_gc, - nc_curWindow->gleft+x*nc_fontwidth, - nc_curWindow->top+y*nc_fontheight + ascent, + XDrawImageString(m_display, nc_window, nc_gc, + nc_curWindow->gleft+x*nc_fontwidth, + nc_curWindow->top+y*nc_fontheight + ascent, (char *)&c, 1); if (nc_highlight & nc_under) { XDrawLine(m_display, nc_window, nc_gc, - nc_curWindow->gleft+x*nc_fontwidth, - nc_curWindow->top+y*nc_fontheight + ascent + 1, - nc_curWindow->gleft+(x+1)*nc_fontwidth-1, + nc_curWindow->gleft+x*nc_fontwidth, + nc_curWindow->top+y*nc_fontheight + ascent + 1, + nc_curWindow->gleft+(x+1)*nc_fontwidth-1, nc_curWindow->top+y*nc_fontheight + ascent + 1); } } @@ -330,7 +331,7 @@ char *cp; fprintf(stderr, "') called\n"); return; } - if (! nc_initialized) + if (! nc_initialized) nc_initialize(); CheckRefresh(); if (x < 0) { @@ -345,15 +346,15 @@ char *cp; int i; for (i = 0; i < len; i++) NC_SCREEN(y*TextW+x+i).i = nc_highlight + cp[i]; - XDrawImageString(m_display, nc_window, nc_gc, - nc_curWindow->gleft+x*nc_fontwidth, - nc_curWindow->top+y*nc_fontheight + ascent, + XDrawImageString(m_display, nc_window, nc_gc, + nc_curWindow->gleft+x*nc_fontwidth, + nc_curWindow->top+y*nc_fontheight + ascent, cp, len); if (nc_highlight & nc_under) { - XDrawLine(m_display, nc_window, nc_gc, - nc_curWindow->gleft+x*nc_fontwidth, - nc_curWindow->top+y*nc_fontheight + ascent + 1, - nc_curWindow->gleft+x*nc_fontwidth + len*nc_fontwidth - 1, + XDrawLine(m_display, nc_window, nc_gc, + nc_curWindow->gleft+x*nc_fontwidth, + nc_curWindow->top+y*nc_fontheight + ascent + 1, + nc_curWindow->gleft+x*nc_fontwidth + len*nc_fontwidth - 1, nc_curWindow->top+y*nc_fontheight + ascent + 1); } } @@ -385,10 +386,10 @@ int x1, y1, x2, y2; i * nc_fontwidth, j * nc_fontheight + ascent, linebuf, len); if (nc_highlight & nc_under) { - XDrawLine(m_display, nc_window, nc_gc, + XDrawLine(m_display, nc_window, nc_gc, i*nc_fontwidth, - j*nc_fontheight + ascent + 1, - i*nc_fontwidth + len*nc_fontwidth - 1, + j*nc_fontheight + ascent + 1, + i*nc_fontwidth + len*nc_fontwidth - 1, j*nc_fontheight + ascent + 1); } } @@ -433,7 +434,7 @@ void nc_refreshScreen() #endif } } - + void CheckRefresh() { XEvent event; @@ -518,10 +519,10 @@ char *str; nc_curWindow->gtop+nc_fontheight*y + ascent, str++, 1); if (nc_highlight & nc_under) { - XDrawLine(m_display, nc_window, nc_gc, - nc_curWindow->gleft+x*nc_fontwidth, - nc_curWindow->top+y*nc_fontheight + ascent + 1, - nc_curWindow->gleft+x*nc_fontwidth + nc_fontwidth - 1, + XDrawLine(m_display, nc_window, nc_gc, + nc_curWindow->gleft+x*nc_fontwidth, + nc_curWindow->top+y*nc_fontheight + ascent + 1, + nc_curWindow->gleft+x*nc_fontwidth + nc_fontwidth - 1, nc_curWindow->top+y*nc_fontheight + ascent + 1); } x++; @@ -610,7 +611,7 @@ char *str_; YPOS--; break; } - else if (*str >= 128) + else if (*str >= 128) switch (*str) { case 128: /* Normal */ nc_setHighlight(nc_highlight & colormask); @@ -673,10 +674,10 @@ char *str_; nc_curWindow->gtop+nc_fontheight*YPOS + ascent, (char *)str, len); if (nc_highlight & nc_under) { - XDrawLine(m_display, nc_window, nc_gc, - nc_curWindow->gleft+XPOS*nc_fontwidth, - nc_curWindow->top+YPOS*nc_fontheight + ascent + 1, - nc_curWindow->gleft+XPOS*nc_fontwidth + len*nc_fontwidth-1, + XDrawLine(m_display, nc_window, nc_gc, + nc_curWindow->gleft+XPOS*nc_fontwidth, + nc_curWindow->top+YPOS*nc_fontheight + ascent + 1, + nc_curWindow->gleft+XPOS*nc_fontwidth + len*nc_fontwidth-1, nc_curWindow->top+YPOS*nc_fontheight + ascent + 1); } str += len - 1; @@ -760,7 +761,7 @@ int x, y, dx, dy; return; } if (nc_initialized) { -/* fprintf(stdout, "nc_clearXY(%d, %d, %d, %d)\n", x, y, dx, dy); +/* fprintf(stdout, "nc_clearXY(%d, %d, %d, %d)\n", x, y, dx, dy); getchar(); */ if ((dx > 0) && (dy > 0)) { XClearArea(m_display, nc_window, nc_curWindow->gleft+nc_fontwidth*x, @@ -811,7 +812,7 @@ static void fix_string(str, buf) unsigned char *str, *buf; { unsigned char *cp1, *cp2; - + cp2 = buf; for (cp1 = str; *cp1; cp1++) { switch (*cp1) { @@ -890,7 +891,7 @@ void nc_fprintf(FILE * outfile, char * fmt, ...) if ((*p2 = *p1) == '\n') *(++p2) = '\015'; *p2 = '\0'; - + nc_writeStr(XPOS, YPOS, printbuffer2); } else { fix_string((unsigned char *) fmt, (unsigned char *) fmt2); @@ -915,7 +916,7 @@ void nc_puts(char * s) nc_writeStr(XPOS, YPOS, "\n\015"); /* fprintf(stderr, "nc_puts() exits, cursor at (%d,%d)\n", XPOS, YPOS); */ } - + void nc_fputs(char * s, FILE *outfile) { @@ -935,7 +936,7 @@ void nc_fputs(char * s, FILE *outfile) fputs(str2, outfile); #define fputs nc_fputs } -} +} void nc_putchar(uchar c) @@ -1081,4 +1082,3 @@ int nc_alphashared() { return false; } - diff --git a/psys/src/numex.c b/psys/src/numex.c index aa8fd493dd727430dd5745a2290815827e72f259..cdda9984bb418e1b9f84aab854f1ef1e9e00b47f 100644 --- a/psys/src/numex.c +++ b/psys/src/numex.c @@ -1,5 +1,5 @@ #include <p2c/p2c.h> - +#include <string.h> #define NUMEX_G #include <p2c/numex.h> @@ -98,20 +98,20 @@ static int readreal(char *s, long *i, double *r, ne_desc *desc) while (s[*i - 1] == ' ') (*i)++; j = *i; - + if (s[*i - 1] == '-' || s[*i - 1] == '+') (*i)++; - + while (isdigit(s[*i - 1])) (*i)++; - + if (s[*i - 1] == '.' && isdigit(s[*i])) { do { (*i)++; } while (isdigit(s[*i - 1])); } - + if ((s[*i - 1] == 'E' || s[*i - 1] == 'e') && ((isdigit(s[*i]) || (s[*i] == '-' || s[*i] == '+')) && isdigit(s[*i + 1]))) { (*i)++; @@ -120,10 +120,10 @@ static int readreal(char *s, long *i, double *r, ne_desc *desc) while (isdigit(s[*i - 1])) (*i)++; } - + if (*i <= j) return false; - + buf[*i - j] = '\0'; memmove((void*)buf, (void*)(&s[j - 1]), *i - j); *r = strtod(buf, &STR1); @@ -137,22 +137,22 @@ static int readreal(char *s, long *i, double *r, ne_desc *desc) sprintf(buf + strlen(buf), "%c", s[*i - 1]); (*i)++; } - + strupper(buf, buf); if (strends(buf, strupper(STR2, desc->units))) { buf[strlen(buf) - strlen(desc->units)] = '\0'; } - + if (*buf == '\0') return Result; ch = buf[0]; - + switch (ch) { case 'F': *r *= 1e-15; return Result; - + case 'P': *r *= 1e-12; return Result; @@ -172,7 +172,7 @@ static int readreal(char *s, long *i, double *r, ne_desc *desc) case 'G': *r *= 1e9; return Result; - + case 'T': *r *= 1e12; return Result; @@ -590,11 +590,11 @@ static int istrue(ne_nexrec *nex, struct LOC_opt *LINK) case ne_rc: Result = (nex->UU.r != 0); break; - + case ne_sc: Result = (*nex->UU.s != '\0'); break; - + default: Result = false; break; @@ -608,23 +608,23 @@ static int isfalse(ne_nexrec *nex, struct LOC_opt *LINK) switch ((ne_opkind)nex->op) { - + case ne_error: Result = ((ne_errorkind)nex->UU.err == ne_badval); break; - + case ne_ic: Result = (nex->UU.i == 0); break; - + case ne_rc: Result = (nex->UU.r == 0); break; - + case ne_sc: Result = (*nex->UU.s == '\0'); break; - + default: Result = false; break; @@ -644,10 +644,10 @@ static int foldfunction(struct LOC_opt *LINK) return false; Result = true; FORLIM = WITH->nargs; - + for (i1 = 0; i1 < FORLIM; i1++) { - if (WITH->UU.U99.pvals[i1]->op >= 32 || + if (WITH->UU.U99.pvals[i1]->op >= 32 || ((1L << WITH->UU.U99.pvals[i1]->op) & ((1L << ((long)ne_ic)) | (1L << ((long)ne_rc)) | (1L << ((long)ne_sc)))) == 0) Result = false; } @@ -683,7 +683,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) for (i1 = 0; i1 < FORLIM; i1++) WITH->UU.U99.pvals[i1] = opt(&WITH->UU.U99.pvals[i1], LINK); } - + /* optimize(pvals[i1], desc, which, mode); */ switch ((ne_opkind)WITH->op) { @@ -794,12 +794,12 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if ((ne_opkind)WITH->UU.U10.p2->op == ne_ic && WITH->UU.U10.p2->UU.i == 0) error(ne_divzero, &V); break; - + case ne_ineg: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic) collapseint(-WITH->UU.U10.p1->UU.i, &V); break; - + case ne_radd: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc &&(ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapsereal(WITH->UU.U10.p1->UU.r + WITH->UU.U10.p2->UU.r, &V); @@ -808,14 +808,14 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if ((ne_opkind)WITH->UU.U10.p2->op == ne_rc && WITH->UU.U10.p2->UU.r == 0) collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_rsub: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapsereal(WITH->UU.U10.p1->UU.r - WITH->UU.U10.p2->UU.r, &V); else if ((ne_opkind)WITH->UU.U10.p2->op == ne_rc && WITH->UU.U10.p2->UU.r == 0) collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_rmul: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapsereal(WITH->UU.U10.p1->UU.r * WITH->UU.U10.p2->UU.r, &V); @@ -829,7 +829,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) WITH->UU.U10.p2->UU.r == 0) collapsehalf(WITH->UU.U10.p2, WITH->UU.U10.p1, &V); break; - + case ne_rdiv: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapsereal(WITH->UU.U10.p1->UU.r / WITH->UU.U10.p2->UU.r, &V); @@ -845,12 +845,12 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapsereal(ma_ytox(WITH->UU.U10.p1->UU.r, WITH->UU.U10.p2->UU.r), &V); break; - + case ne_rneg: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapsereal(-WITH->UU.U10.p1->UU.r, &V); break; - + case ne_sadd: if ((ne_opkind)WITH->UU.U10.p1->op == ne_sc && (ne_opkind)WITH->UU.U10.p2->op == ne_sc) { @@ -869,124 +869,124 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if ((ne_opkind)WITH->UU.U10.p2->op == ne_sc && *WITH->UU.U10.p2->UU.s == '\0') collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_itor: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic) collapsereal((double)WITH->UU.U10.p1->UU.i, &V); break; - + case ne_imod: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) { collapseint(WITH->UU.U10.p1->UU.i % WITH->UU.U10.p2->UU.i, &V); } break; - + case ne_rbool: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapseint((long)(WITH->UU.U10.p1->UU.r != 0), &V); break; - + case ne_sbool: if ((ne_opkind)WITH->UU.U10.p1->op == ne_sc) collapseint((long)(*WITH->UU.U10.p1->UU.s != '\0'), &V); break; - + case ne_ieq: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint((long)(WITH->UU.U10.p1->UU.i == WITH->UU.U10.p2->UU.i), &V); break; - + case ne_ine: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint((long)(WITH->UU.U10.p1->UU.i != WITH->UU.U10.p2->UU.i), &V); break; - + case ne_ilt: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint((long)(WITH->UU.U10.p1->UU.i < WITH->UU.U10.p2->UU.i), &V); break; - + case ne_ile: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint((long)(WITH->UU.U10.p1->UU.i <= WITH->UU.U10.p2->UU.i), &V); break; - + case ne_igt: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint((long)(WITH->UU.U10.p1->UU.i > WITH->UU.U10.p2->UU.i), &V); break; - + case ne_ige: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint((long)(WITH->UU.U10.p1->UU.i >= WITH->UU.U10.p2->UU.i), &V); break; - + case ne_req: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapseint((long)(WITH->UU.U10.p1->UU.r == WITH->UU.U10.p2->UU.r), &V); break; - + case ne_rne: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapseint((long)(WITH->UU.U10.p1->UU.r != WITH->UU.U10.p2->UU.r), &V); break; - + case ne_rlt: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapseint((long)(WITH->UU.U10.p1->UU.r < WITH->UU.U10.p2->UU.r), &V); break; - + case ne_rle: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapseint((long)(WITH->UU.U10.p1->UU.r <= WITH->UU.U10.p2->UU.r), &V); break; - + case ne_rgt: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapseint((long)(WITH->UU.U10.p1->UU.r > WITH->UU.U10.p2->UU.r), &V); break; - + case ne_rge: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc && (ne_opkind)WITH->UU.U10.p2->op == ne_rc) collapseint((long)(WITH->UU.U10.p1->UU.r >= WITH->UU.U10.p2->UU.r), &V); break; - + case ne_seq: if ((ne_opkind)WITH->UU.U10.p1->op == ne_sc && (ne_opkind)WITH->UU.U10.p2->op == ne_sc) collapseint((long)(strcmp(WITH->UU.U10.p1->UU.s, WITH->UU.U10.p2->UU.s) == 0), &V); break; - + case ne_sne: if ((ne_opkind)WITH->UU.U10.p1->op == ne_sc && (ne_opkind)WITH->UU.U10.p2->op == ne_sc) collapseint((long)(strcmp(WITH->UU.U10.p1->UU.s, WITH->UU.U10.p2->UU.s) != 0), &V); break; - + case ne_slt: if ((ne_opkind)WITH->UU.U10.p1->op == ne_sc && (ne_opkind)WITH->UU.U10.p2->op == ne_sc) collapseint((long)(strcmp(WITH->UU.U10.p1->UU.s, WITH->UU.U10.p2->UU.s) < 0), &V); break; - + case ne_sle: if ((ne_opkind)WITH->UU.U10.p1->op == ne_sc && (ne_opkind)WITH->UU.U10.p2->op == ne_sc) collapseint((long)(strcmp(WITH->UU.U10.p1->UU.s, WITH->UU.U10.p2->UU.s) <= 0), &V); break; - + case ne_sgt: if ((ne_opkind)WITH->UU.U10.p1->op == ne_sc && (ne_opkind)WITH->UU.U10.p2->op == ne_sc) collapseint((long)(strcmp(WITH->UU.U10.p1->UU.s, WITH->UU.U10.p2->UU.s) > 0), &V); break; - + case ne_sge: if ((ne_opkind)WITH->UU.U10.p1->op == ne_sc && (ne_opkind)WITH->UU.U10.p2->op == ne_sc) collapseint((long)(strcmp(WITH->UU.U10.p1->UU.s, WITH->UU.U10.p2->UU.s) >= 0), &V); break; - + case ne_not: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic) collapseint(~WITH->UU.U10.p1->UU.i, &V); break; - + case ne_and: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint(WITH->UU.U10.p1->UU.i & WITH->UU.U10.p2->UU.i, &V); @@ -999,7 +999,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if ((ne_opkind)WITH->UU.U10.p2->op == ne_ic && WITH->UU.U10.p2->UU.i == 0) collapsehalf(WITH->UU.U10.p2, WITH->UU.U10.p1, &V); break; - + case ne_or: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint(WITH->UU.U10.p1->UU.i | WITH->UU.U10.p2->UU.i, &V); @@ -1012,7 +1012,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if ((ne_opkind)WITH->UU.U10.p2->op == ne_ic && WITH->UU.U10.p2->UU.i == -1) collapsehalf(WITH->UU.U10.p2, WITH->UU.U10.p1, &V); break; - + case ne_xor: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint(WITH->UU.U10.p1->UU.i ^ WITH->UU.U10.p2->UU.i, &V); @@ -1021,7 +1021,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if ((ne_opkind)WITH->UU.U10.p2->op == ne_ic && WITH->UU.U10.p2->UU.i == 0) collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_lsh: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint(WITH->UU.U10.p1->UU.i << WITH->UU.U10.p2->UU.i, &V); @@ -1029,7 +1029,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) ((ne_opkind)WITH->UU.U10.p2->op == ne_ic && WITH->UU.U10.p2->UU.i == 0)) collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_rsh: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic && (ne_opkind)WITH->UU.U10.p2->op == ne_ic) collapseint(WITH->UU.U10.p1->UU.i >> WITH->UU.U10.p2->UU.i, &V); @@ -1037,7 +1037,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) ((ne_opkind)WITH->UU.U10.p2->op == ne_ic && WITH->UU.U10.p2->UU.i == 0)) collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_lnot: optimize(&WITH->UU.U10.p1, LINK->desc, LINK->which, LINK->mode); if (istrue(WITH->UU.U10.p1, &V)) @@ -1045,7 +1045,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if (isfalse(WITH->UU.U10.p1, &V)) collapseint(1L, &V); break; - + case ne_iand: optimize(&WITH->UU.U10.p1, LINK->desc, LINK->which, LINK->mode); if (istrue(WITH->UU.U10.p1, &V)) @@ -1053,7 +1053,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if (isfalse(WITH->UU.U10.p1, &V)) collapseint(0L, &V); break; - + case ne_ior: optimize(&WITH->UU.U10.p1, LINK->desc, LINK->which, LINK->mode); if (isfalse(WITH->UU.U10.p1, &V)) @@ -1061,7 +1061,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if (istrue(WITH->UU.U10.p1, &V)) collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_rand: optimize(&WITH->UU.U10.p1, LINK->desc, LINK->which, LINK->mode); if (istrue(WITH->UU.U10.p1, &V)) @@ -1069,7 +1069,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if (isfalse(WITH->UU.U10.p1, &V)) collapsereal(0.0, &V); break; - + case ne_ror: optimize(&WITH->UU.U10.p1, LINK->desc, LINK->which, LINK->mode); if (isfalse(WITH->UU.U10.p1, &V)) @@ -1077,7 +1077,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if (istrue(WITH->UU.U10.p1, &V)) collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_rxor: optimize(&WITH->UU.U10.p1, LINK->desc, LINK->which, LINK->mode); if ((ne_opkind)WITH->UU.U10.p1->op == ne_error && (ne_errorkind)WITH->UU.U10.p1->UU.err == ne_badval) @@ -1085,7 +1085,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if (istrue(WITH->UU.U10.p1, &V)) collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_sand: optimize(&WITH->UU.U10.p1, LINK->desc, LINK->which, LINK->mode); if (istrue(WITH->UU.U10.p1, &V)) @@ -1093,7 +1093,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if (isfalse(WITH->UU.U10.p1, &V)) collapsestr("", &V); break; - + case ne_sor: optimize(&WITH->UU.U10.p1, LINK->desc, LINK->which, LINK->mode); if (isfalse(WITH->UU.U10.p1, &V)) @@ -1101,7 +1101,7 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if (istrue(WITH->UU.U10.p1, &V)) collapsehalf(WITH->UU.U10.p1, WITH->UU.U10.p2, &V); break; - + case ne_icond: case ne_rcond: case ne_scond: @@ -1111,62 +1111,62 @@ static ne_nexrec *opt(ne_nexrec **nex_, struct LOC_optimize *LINK) else if (istrue(WITH->UU.U10.p1, &V)) collapsecond(WITH->UU.U10.p1, opt(&WITH->UU.U10.p2, LINK), WITH->UU.U10.p3, &V); break; - + case ne_round: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapseint((long)floor(WITH->UU.U10.p1->UU.r + 0.5), &V); break; - + case ne_trunc: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapseint((long)WITH->UU.U10.p1->UU.r, &V); break; - + case ne_ln: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapsereal(log(WITH->UU.U10.p1->UU.r), &V); break; - + case ne_exp: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapsereal(exp(WITH->UU.U10.p1->UU.r), &V); break; - + case ne_iabs: if ((ne_opkind)WITH->UU.U10.p1->op == ne_ic) collapseint(labs(WITH->UU.U10.p1->UU.i), &V); break; - + case ne_rabs: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapsereal(fabs(WITH->UU.U10.p1->UU.r), &V); break; - + case ne_sqrt: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapsereal(sqrt(WITH->UU.U10.p1->UU.r), &V); break; - + case ne_sin: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapsereal(sin(WITH->UU.U10.p1->UU.r), &V); break; - + case ne_cos: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapsereal(cos(WITH->UU.U10.p1->UU.r), &V); break; - + case ne_tan: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapsereal(tan(WITH->UU.U10.p1->UU.r), &V); break; - + case ne_arctan: if ((ne_opkind)WITH->UU.U10.p1->op == ne_rc) collapsereal(atan(WITH->UU.U10.p1->UU.r), &V); break; - + default: break; } @@ -1194,11 +1194,11 @@ static void optimize(ne_nexrec **nex, ne_desc *desc_, na_strlist_t *which_, long case -5: V.err = ne_divzero; break; - + case -7: V.err = ne_underflow; break; - + default: V.err = ne_overflow; break; @@ -1219,7 +1219,7 @@ void ne_constant(ne_nexrec **nex, ne_desc *desc, char *which_) char which[256]; na_strlist_t *l1, *l2; char buf[256]; - + strcpy(which, which_); if (!desc->casesens) strupper(which, which); @@ -1239,7 +1239,7 @@ void ne_notconstant(ne_nexrec **nex, ne_desc *desc, char *which_) char which[256]; na_strlist_t *l1, *l2; char buf[256]; - + strcpy(which, which_); if (!desc->casesens) strupper(which, which); @@ -1267,7 +1267,7 @@ void ne_notconstantlist(ne_nexrec **nex, ne_desc *desc, na_strlist_t *which) static ne_nexrec *make2(ne_opkind op, ne_nexrec *nex, ne_nexrec *nex2) { ne_nexrec *n; - + newnexrec(&n, (long)((nex != NULL) + (nex2 != NULL)), op); n->UU.U10.p1 = nex; n->UU.U10.p2 = nex2; @@ -1277,7 +1277,7 @@ static ne_nexrec *make2(ne_opkind op, ne_nexrec *nex, ne_nexrec *nex2) static ne_nexrec *make3(ne_opkind op, ne_nexrec *nex, ne_nexrec *nex2, ne_nexrec *nex3) { ne_nexrec *n; - + newnexrec(&n, 3L, op); n->UU.U10.p1 = nex; n->UU.U10.p2 = nex2; @@ -1289,12 +1289,12 @@ ne_nexrec *ne_typecast(ne_nexrec *nex, ne_datatype typ) { switch (typ) { - + case ne_notype: ne_dispose(&nex); nex = ne_makeerror(ne_badtypes); break; - + case ne_integer: if (realp(nex)) { @@ -1306,7 +1306,7 @@ ne_nexrec *ne_typecast(ne_nexrec *nex, ne_datatype typ) nex = ne_makeerror(ne_badtypes); } break; - + case ne_real: if (integerp(nex)) { @@ -1318,7 +1318,7 @@ ne_nexrec *ne_typecast(ne_nexrec *nex, ne_datatype typ) nex = ne_makeerror(ne_badtypes); } break; - + case ne_string: if (!stringp(nex)) { @@ -1326,7 +1326,7 @@ ne_nexrec *ne_typecast(ne_nexrec *nex, ne_datatype typ) nex = ne_makeerror(ne_badtypes); } break; - + case ne_boolean: if (realp(nex)) nex = make2(ne_rbool, nex, NULL); @@ -1381,7 +1381,7 @@ static ne_nexrec *parexp(struct LOC_expr *LINK) { ne_nexrec *nex; char ch, ch2; - + nex = NULL; ch = skipspc(LINK->LINK); if (ch != '(' && ch != '[') { @@ -1416,7 +1416,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) long FORLIM; int allocdone; /* flag for deallocation */ void* tryalloc; - + nex = NULL; allocdone = 0; ch = skipspc(LINK->LINK); @@ -1449,64 +1449,64 @@ static ne_nexrec *factor(struct LOC_expr *LINK) } switch (kind) { - + case ne_kind_intconst: nex = make2(ne_ic, NULL, NULL); nex->UU.i = (long)value; break; - + case ne_kind_intvalue: nex = make2(ne_ip, NULL, NULL); nex->UU.U10.ip = (long*)(&l1->value); nex->UU.U10.ips = l1; break; - + case ne_kind_intptr: nex = make2(ne_ip, NULL, NULL); nex->UU.U10.ip = (long *)value; nex->UU.U10.ips = l1; break; - + case ne_kind_realconst: nex = make2(ne_rc, NULL, NULL); rp = (double *)value; nex->UU.r = *rp; break; - + case ne_kind_srealconst: nex = make2(ne_rc, NULL, NULL); nex->UU.r = na_srtor(value); break; - + case ne_kind_realptr: nex = make2(ne_rp, NULL, NULL); nex->UU.U11.rp = (double *)value; nex->UU.U11.rps = l1; break; - + case ne_kind_realxptr: nex = make2(ne_rxp, NULL, NULL); nex->UU.U11.rp = (double *)value; nex->UU.U11.rps = l1; break; - + case ne_kind_strconst: nex = make2(ne_sc, NULL, NULL); nex->UU.s = (char *)strdup((char *)value); break; - + case ne_kind_strvalue: nex = make2(ne_sp, NULL, NULL); nex->UU.U12.sp = (char **)(&l1->value); nex->UU.U12.sps = l1; break; - + case ne_kind_strptr: nex = make2(ne_sp, NULL, NULL); nex->UU.U12.sp = (char **)value; nex->UU.U12.sps = l1; break; - + case ne_kind_intfunc: case ne_kind_realfunc: case ne_kind_strfunc: @@ -1561,15 +1561,15 @@ static ne_nexrec *factor(struct LOC_expr *LINK) { switch (kind) { - + case ne_kind_intfunc: newnexrec(&nex, i, ne_if); break; - + case ne_kind_realfunc: newnexrec(&nex, i, ne_rf); break; - + case ne_kind_strfunc: newnexrec(&nex, i, ne_sf); break; @@ -1581,29 +1581,29 @@ static ne_nexrec *factor(struct LOC_expr *LINK) nex->UU.U15.fps = l1; } break; - + case ne_kind_intarg: nex = make2(ne_iarg, NULL, NULL); nex->UU.i = (long)value; break; - + case ne_kind_realarg: nex = make2(ne_rarg, NULL, NULL); nex->UU.i = (long)value; break; - + case ne_kind_strarg: nex = make2(ne_sarg, NULL, NULL); nex->UU.i = (long)value; break; - + case ne_kind_nex: if (value == NULL) error_(ne_undef, &nex, NULL, LINK->LINK); else ne_copy((ne_nexrec *)value, &nex); break; - + default: if (LINK->LINK->desc->builtin) { @@ -1616,7 +1616,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) { switch (builtins[i - 1].kind) { - + case 'A': nex = parexp(LINK); if (realp(nex)) @@ -1624,14 +1624,14 @@ static ne_nexrec *factor(struct LOC_expr *LINK) else if (!integerp(nex)) error_(ne_badtypes, &nex, NULL, LINK->LINK); break; - + case 'B': nex = ne_typecast(parexp(LINK), ne_real); if ((ne_opkind)nex->op == ne_error) error_((ne_errorkind)nex->UU.err, &nex, NULL, LINK->LINK); nex = make2(builtins[i - 1].op, nex, NULL); break; - + case 'C': nex = parexp(LINK); if (integerp(nex)) @@ -1641,7 +1641,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) else error_(ne_badtypes, &nex, NULL, LINK->LINK); break; - + case 'P': nex = make2(ne_rc, NULL, NULL); nex->UU.r = 3.1415926536; @@ -1651,7 +1651,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) error_(ne_undef, &nex, NULL, LINK->LINK); break; } - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } @@ -1660,7 +1660,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) { LINK->LINK->p++; nex = expr((long)neg_prec, LINK->LINK); - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } @@ -1671,7 +1671,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) nex = expr((long)neg_prec, LINK->LINK); if (realp(nex)) { nex = make2(ne_rneg, nex, NULL); - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } @@ -1679,7 +1679,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) nex = make2(ne_ineg, nex, NULL); else error_(ne_badtypes, &nex, NULL, LINK->LINK); - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } @@ -1689,7 +1689,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) LINK->LINK->p++; nex = ne_typecast(expr((long)lnot_prec, LINK->LINK), ne_boolean); nex = make2(ne_lnot, nex, NULL); - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } @@ -1704,7 +1704,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) nex = make2(ne_not, nex, NULL); else error_(ne_badtypes, &nex, NULL, LINK->LINK); - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } @@ -1746,7 +1746,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) do { LINK->LINK->p++; - if (LINK->LINK->ex[LINK->LINK->p - 1] == ch) + if (LINK->LINK->ex[LINK->LINK->p - 1] == ch) { if (LINK->LINK->ex[LINK->LINK->p] == ch) { @@ -1778,27 +1778,27 @@ static ne_nexrec *factor(struct LOC_expr *LINK) } while (!done); nex = make2(ne_sc, nex, NULL); nex->UU.s = (char *)strdup(name); - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } - + if (ch == '[' || ch == '(') { nex = parexp(LINK); - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } - + if (!(ch == '.' || isdigit(ch))) { error_(ne_syntax, &nex, NULL, LINK->LINK); - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } - + i = 0; p0 = LINK->LINK->p; while (isdigit(LINK->LINK->ex[LINK->LINK->p - 1]) && (i < 214748364L || @@ -1809,16 +1809,16 @@ static ne_nexrec *factor(struct LOC_expr *LINK) LINK->LINK->p++; } TEMP = skipspc(LINK->LINK); - + if (!(TEMP == '.' || isalnum(TEMP))) { nex = make2(ne_ic, NULL, NULL); nex->UU.i = i; - if (allocdone) + if (allocdone) na_free((void*)&args); return nex; } - + LINK->LINK->p = p0; if (readreal(LINK->LINK->ex, &LINK->LINK->p, &r, LINK->LINK->desc)) { @@ -1829,7 +1829,7 @@ static ne_nexrec *factor(struct LOC_expr *LINK) { error_(ne_syntax, &nex, NULL, LINK->LINK); } - + if (allocdone) { na_free((void*)&args); @@ -1843,7 +1843,7 @@ static ne_nexrec *expr(long prec, struct LOC_ne_intcompile *LINK) ne_nexrec *nex, *nex2, *nex3; char ch; long opn, dp; - + V.LINK = LINK; nex = factor(&V); do @@ -1905,11 +1905,11 @@ static ne_nexrec *expr(long prec, struct LOC_ne_intcompile *LINK) ch = '\b'; /*log. X-checking or*/ dp = 2; } - + opn = numopersyms; while (opn >= 1 && opers[opn - 1].name != ch) opn--; - + if (opn >= 1 && opers[opn - 1].lprec > prec) { if (ch == '?') @@ -1987,7 +1987,7 @@ void ne_intcompile(char *ex_, long *endp, ne_nexrec **nex, ne_desc *desc_) { struct LOC_ne_intcompile V; long startp; - + V.ex = ex_; V.desc = desc_; *nex = NULL; @@ -2011,7 +2011,7 @@ void ne_compile(char *ex_, ne_nexrec **nex, ne_desc *desc) char ex[256]; long len, endp; char STR1[256]; - + strcpy(ex, ex_); if (strlen(ex) == 255) { @@ -2050,7 +2050,7 @@ static void uncompile (ne_nexrec *nex, int prec, struct LOC_ne_uncompile *LINK); static void append(char *s, struct LOC_ne_uncompile *LINK) { long i; - + i = strlen(LINK->ex) + strlen(s) - 255; if (i < 1) { strcat(LINK->ex, s); @@ -2074,7 +2074,7 @@ static void appenderrname(ne_nexrec *nex, struct LOC_ne_uncompile *LINK) char buf[256]; long i; char STR1[256]; - + strcpy(buf, ne_errorkind_NAMES[nex->UU.err]); i = strlen(buf) + 1; buf[i - 1] = '\0'; @@ -2094,7 +2094,7 @@ static void args(struct LOC_uncompile *LINK) long i1; ne_nexrec *WITH; long FORLIM; - + WITH = LINK->nex; if (WITH->nargs == 0) return; @@ -2122,20 +2122,20 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) ne_nexrec *WITH; char STR1[256]; long FORLIM; - + V.LINK = LINK; V.nex = nex_; WITH = V.nex; LINK->lastop = (ne_opkind)WITH->op; switch ((ne_opkind)WITH->op) { - + case ne_error: append("error(", LINK); appenderrname(V.nex, LINK); appendc(')', LINK); break; - + case ne_ic: if (LINK->desc->scaled) { @@ -2147,7 +2147,7 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) append(STR1, LINK); } break; - + case ne_rc: if (LINK->desc->scaled) { @@ -2158,7 +2158,7 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) append(STR1, LINK); } break; - + case ne_sc: if (*WITH->UU.s == '\0') append("''", LINK); @@ -2189,7 +2189,7 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) appendc('\'', LINK); } break; - + case ne_ip: case ne_rp: case ne_sp: @@ -2199,7 +2199,7 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) else append("(var)", LINK); break; - + case ne_if: case ne_rf: case ne_sf: @@ -2209,28 +2209,28 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) append("(func)", LINK); args(&V); break; - + case ne_itor: case ne_rbool: case ne_sbool: uncompile(WITH->UU.U10.p1, prec, LINK); break; - + case ne_iarg: sprintf(STR1, "i_arg(%ld)", WITH->UU.i); append(STR1, LINK); break; - + case ne_rarg: sprintf(STR1, "r_arg(%ld)", WITH->UU.i); append(STR1, LINK); break; - + case ne_sarg: sprintf(STR1, "s_arg(%ld)", WITH->UU.i); append(STR1, LINK); break; - + case ne_ineg: case ne_rneg: if (neg_prec < prec) @@ -2240,7 +2240,7 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) if (neg_prec < prec) appendc(')', LINK); break; - + case ne_not: if (not_prec < prec) appendc('(', LINK); @@ -2249,7 +2249,7 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) if (not_prec < prec) appendc(')', LINK); break; - + case ne_lnot: if (lnot_prec < prec) appendc('(', LINK); @@ -2258,48 +2258,48 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) if (lnot_prec < prec) appendc(')', LINK); break; - + case ne_round: func("round", &V); break; - + case ne_trunc: func("trunc", &V); break; - + case ne_ln: func("ln", &V); break; - + case ne_exp: func("exp", &V); break; - + case ne_iabs: case ne_rabs: func("abs", &V); break; - + case ne_sqrt: func("sqrt", &V); break; - + case ne_sin: func("sin", &V); break; - + case ne_cos: func("cos", &V); break; - + case ne_tan: func("tan", &V); break; - + case ne_arctan: func("arctan", &V); break; - + default: j = numopersyms; while (j >= 1 && (ne_opkind)opers[j - 1].iop != (ne_opkind)WITH->op && @@ -2315,56 +2315,56 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) LINK->ch = opers[j - 1].name; nex2 = WITH->UU.U10.p2; switch (LINK->ch) - { + { case '\001': if (LINK->desc->doubleeq) append("!=", LINK); else append("<>", LINK); break; - + case '\002': append("<=", LINK); break; - + case '\003': append(">=", LINK); break; - + case '\004': append("&&", LINK); break; - + case '\005': append("||", LINK); break; - + case '\006': append("<<", LINK); break; - + case '\007': append(">>", LINK); break; - + case '\b': append("!!", LINK); break; - + case '?': appendc(LINK->ch, LINK); uncompile(WITH->UU.U10.p2, 0, LINK); appendc(':', LINK); nex2 = WITH->UU.U10.p3; break; - + default: if (LINK->ch == '=' && LINK->desc->doubleeq) appendc(LINK->ch, LINK); appendc(LINK->ch, LINK); break; } - + if (opers[j - 1].lprec == opers[j - 1].rprec) uncompile(nex2, opers[j - 1].lprec + 1, LINK); else @@ -2378,7 +2378,7 @@ static void uncompile(ne_nexrec *nex_, int prec, struct LOC_ne_uncompile *LINK) void ne_uncompile(ne_nexrec *nex, char *ex_, ne_desc *desc_) { struct LOC_ne_uncompile V; - + V.ex = ex_; V.desc = desc_; V.desc->error = (unsigned)ne_noerror; @@ -2412,22 +2412,22 @@ static void evalargs(ne_nexrec *nex) else { switch (nex->UU.U15.fp->UU.U99.ptypes[P_imin2(i + 1, (long)nex->UU.U15.fp->nargs) - 1]) { - + case ne_integer: case ne_boolean: ne_argarray[i].U1.i1 = ne_ieval(nex->UU.U99.pvals[i]); break; - + case ne_real: ne_argarray[i].r = ne_reval(nex->UU.U99.pvals[i]); break; - + case ne_string: ne_seval(buf, nex->UU.U99.pvals[i]); na_outeralloc((void* *)(&ne_argarray[i].U16.sp1), strlen(buf) + 1L, (long)framesize); strcpy(ne_argarray[i].U16.sp1, buf); break; - + default: break; } @@ -2440,7 +2440,7 @@ static void evalargs(ne_nexrec *nex) int ne_condeval(ne_nexrec *nex) { int Result = -1; - + TRY(try2); Result = (ne_ieval(nex) != 0); RECOVER(try2); @@ -2458,18 +2458,18 @@ long ne_ieval(ne_nexrec *nex) na_quadword *saveargarr; ne_nexrec *WITH; char STR1[256], STR2[256]; - + WITH = nex; switch ((ne_opkind)nex->op) - { + { case ne_ic: Result = WITH->UU.i; break; - + case ne_ip: Result = *WITH->UU.U10.ip; break; - + case ne_if: if (WITH->UU.U15.fp->subnex) { @@ -2478,15 +2478,15 @@ long ne_ieval(ne_nexrec *nex) evalargs(nex); switch ((int)types[(*WITH->UU.U15.fp->UU.nexp)->op]) { - + case ne_integer: Result = ne_ieval(*WITH->UU.U15.fp->UU.nexp); break; - + case ne_real: /*in case of $range off$*/ Result = (long)floor(ne_reval(*WITH->UU.U15.fp->UU.nexp) + 0.5); break; - + default: P_escapecode = -9; goto _Ltry3; @@ -2508,38 +2508,38 @@ long ne_ieval(ne_nexrec *nex) Result = i1; } break; - + case ne_iarg: if (ne_argarray == NULL) Result = 0; else Result = ne_argarray[WITH->UU.i - 1].U1.i1; break; - + case ne_iadd: Result = ne_ieval(WITH->UU.U10.p1) + ne_ieval(WITH->UU.U10.p2); break; - + case ne_isub: Result = ne_ieval(WITH->UU.U10.p1) - ne_ieval(WITH->UU.U10.p2); break; - + case ne_imul: Result = ne_ieval(WITH->UU.U10.p1) * ne_ieval(WITH->UU.U10.p2); break; - + case ne_idiv: Result = ne_ieval(WITH->UU.U10.p1) / ne_ieval(WITH->UU.U10.p2); break; - + case ne_ineg: Result = -ne_ieval(WITH->UU.U10.p1); break; - + case ne_imod: Result = ne_ieval(WITH->UU.U10.p1) % ne_ieval(WITH->UU.U10.p2); break; - + case ne_rbool: TRY(try4); Result = (ne_reval(WITH->UU.U10.p1) != 0); @@ -2549,7 +2549,7 @@ long ne_ieval(ne_nexrec *nex) Result = 0; ENDTRY(try4); break; - + case ne_sbool: TRY(try5); Result = (*ne_seval(STR1, WITH->UU.U10.p1) != '\0'); @@ -2559,114 +2559,114 @@ long ne_ieval(ne_nexrec *nex) Result = 0; ENDTRY(try5); break; - + case ne_ieq: Result = (ne_ieval(WITH->UU.U10.p1) == ne_ieval(WITH->UU.U10.p2)); break; - + case ne_ine: Result = (ne_ieval(WITH->UU.U10.p1) != ne_ieval(WITH->UU.U10.p2)); break; - + case ne_ilt: Result = (ne_ieval(WITH->UU.U10.p1) < ne_ieval(WITH->UU.U10.p2)); break; - + case ne_ile: Result = (ne_ieval(WITH->UU.U10.p1) <= ne_ieval(WITH->UU.U10.p2)); break; - + case ne_igt: Result = (ne_ieval(WITH->UU.U10.p1) > ne_ieval(WITH->UU.U10.p2)); break; - + case ne_ige: Result = (ne_ieval(WITH->UU.U10.p1) >= ne_ieval(WITH->UU.U10.p2)); break; - + case ne_req: Result = (ne_reval(WITH->UU.U10.p1) == ne_reval(WITH->UU.U10.p2)); break; - + case ne_rne: Result = (ne_reval(WITH->UU.U10.p1) != ne_reval(WITH->UU.U10.p2)); break; - + case ne_rlt: Result = (ne_reval(WITH->UU.U10.p1) < ne_reval(WITH->UU.U10.p2)); break; - + case ne_rle: Result = (ne_reval(WITH->UU.U10.p1) <= ne_reval(WITH->UU.U10.p2)); break; - + case ne_rgt: Result = (ne_reval(WITH->UU.U10.p1) > ne_reval(WITH->UU.U10.p2)); break; - + case ne_rge: Result = (ne_reval(WITH->UU.U10.p1) >= ne_reval(WITH->UU.U10.p2)); break; - + case ne_seq: Result = (strcmp(ne_seval(STR1, WITH->UU.U10.p1), ne_seval(STR2, WITH->UU.U10.p2)) == 0); break; - + case ne_sne: Result = (strcmp(ne_seval(STR1, WITH->UU.U10.p1), ne_seval(STR2, WITH->UU.U10.p2)) != 0); break; - + case ne_slt: Result = (strcmp(ne_seval(STR1, WITH->UU.U10.p1), ne_seval(STR2, WITH->UU.U10.p2)) < 0); break; - + case ne_sle: Result = (strcmp(ne_seval(STR1, WITH->UU.U10.p1), ne_seval(STR2, WITH->UU.U10.p2)) <= 0); break; - + case ne_sgt: Result = (strcmp(ne_seval(STR1, WITH->UU.U10.p1), ne_seval(STR2, WITH->UU.U10.p2)) > 0); break; - + case ne_sge: Result = (strcmp(ne_seval(STR1, WITH->UU.U10.p1), ne_seval(STR2, WITH->UU.U10.p2)) >= 0); break; - + case ne_not: Result = ~ne_ieval(WITH->UU.U10.p1); break; - + case ne_and: Result = ne_ieval(WITH->UU.U10.p1) & ne_ieval(WITH->UU.U10.p2); break; - + case ne_or: Result = ne_ieval(WITH->UU.U10.p1) | ne_ieval(WITH->UU.U10.p2); break; - + case ne_xor: Result = ne_ieval(WITH->UU.U10.p1) ^ ne_ieval(WITH->UU.U10.p2); break; - + case ne_lsh: Result = ne_ieval(WITH->UU.U10.p1) << ne_ieval(WITH->UU.U10.p2); break; - + case ne_rsh: Result = ne_ieval(WITH->UU.U10.p1) >> ne_ieval(WITH->UU.U10.p2); break; - + case ne_lnot: Result = !ne_condeval(WITH->UU.U10.p1); break; - + case ne_iand: if (ne_condeval(WITH->UU.U10.p1)) Result = ne_ieval(WITH->UU.U10.p2); else Result = 0; break; - + case ne_ior: TRY(try6); i1 = ne_ieval(WITH->UU.U10.p1); @@ -2680,26 +2680,26 @@ long ne_ieval(ne_nexrec *nex) else Result = i1; break; - + case ne_icond: if (ne_condeval(WITH->UU.U10.p1)) Result = ne_ieval(WITH->UU.U10.p2); else Result = ne_ieval(WITH->UU.U10.p3); break; - + case ne_round: Result = (long)floor(ne_reval(WITH->UU.U10.p1) + 0.5); break; - + case ne_trunc: Result = (long)ne_reval(WITH->UU.U10.p1); break; - + case ne_iabs: Result = labs(ne_ieval(WITH->UU.U10.p1)); break; - + default: _Escape(-9); break; @@ -2713,25 +2713,25 @@ double ne_reval(ne_nexrec *nex) double Result, r1; na_quadword *saveargarr; ne_nexrec *WITH; - + WITH = nex; switch ((ne_opkind)nex->op) { - + case ne_rc: Result = WITH->UU.r; break; - + case ne_rp: Result = *WITH->UU.U11.rp; break; - + case ne_rxp: if (*WITH->UU.U11.rp == ne_badvalue) _Escape(ne_badescape); Result = *WITH->UU.U11.rp; break; - + case ne_rf: if (WITH->UU.U15.fp->subnex) { @@ -2740,15 +2740,15 @@ double ne_reval(ne_nexrec *nex) evalargs(nex); switch ((int)types[(*WITH->UU.U15.fp->UU.nexp)->op]) { - + case ne_integer: Result = ne_ieval(*WITH->UU.U15.fp->UU.nexp); break; - + case ne_real: /*in case of $range off$*/ Result = ne_reval(*WITH->UU.U15.fp->UU.nexp); break; - + default: P_escapecode = -9; goto _Ltry7; @@ -2769,74 +2769,74 @@ double ne_reval(ne_nexrec *nex) Result = r1; } break; - + case ne_rarg: if (ne_argarray == NULL) Result = 0.0; else Result = ne_argarray[WITH->UU.i - 1].r; break; - + case ne_radd: Result = ne_reval(WITH->UU.U10.p1) + ne_reval(WITH->UU.U10.p2); break; - + case ne_rsub: Result = ne_reval(WITH->UU.U10.p1) - ne_reval(WITH->UU.U10.p2); break; - + case ne_rmul: Result = ne_reval(WITH->UU.U10.p1) * ne_reval(WITH->UU.U10.p2); break; - + case ne_rdiv: Result = ne_reval(WITH->UU.U10.p1) / ne_reval(WITH->UU.U10.p2); break; - + case ne_rneg: Result = -ne_reval(WITH->UU.U10.p1); break; - + case ne_rpow: Result = ma_ytox(ne_reval(WITH->UU.U10.p1), ne_reval(WITH->UU.U10.p2)); break; - + case ne_itor: Result = ne_ieval(WITH->UU.U10.p1); break; - + case ne_ln: Result = log(ne_reval(WITH->UU.U10.p1)); break; - + case ne_exp: Result = exp(ne_reval(WITH->UU.U10.p1)); break; - + case ne_rabs: Result = fabs(ne_reval(WITH->UU.U10.p1)); break; - + case ne_sqrt: Result = sqrt(ne_reval(WITH->UU.U10.p1)); break; - + case ne_sin: Result = sin(ne_reval(WITH->UU.U10.p1)); break; - + case ne_cos: Result = cos(ne_reval(WITH->UU.U10.p1)); break; - + case ne_tan: Result = tan(ne_reval(WITH->UU.U10.p1)); break; - + case ne_arctan: Result = atan(ne_reval(WITH->UU.U10.p1)); break; - + case ne_rand: TRY(try8); r1 = ne_reval(WITH->UU.U10.p1); @@ -2850,7 +2850,7 @@ double ne_reval(ne_nexrec *nex) else Result = 0.0; break; - + case ne_ror: TRY(try9); r1 = ne_reval(WITH->UU.U10.p1); @@ -2864,7 +2864,7 @@ double ne_reval(ne_nexrec *nex) else Result = r1; break; - + case ne_rxor: TRY(try10); Result = ne_reval(WITH->UU.U10.p1); @@ -2874,14 +2874,14 @@ double ne_reval(ne_nexrec *nex) Result = ne_reval(WITH->UU.U10.p2); ENDTRY(try10); break; - + case ne_rcond: if (ne_condeval(WITH->UU.U10.p1)) Result = ne_reval(WITH->UU.U10.p2); else Result = ne_reval(WITH->UU.U10.p3); break; - + default: Result = 0; _Escape(-9); @@ -2897,19 +2897,19 @@ char *ne_seval(char *Result, ne_nexrec *nex) na_quadword *saveargarr; ne_nexrec *WITH; char STR1[256], STR2[256]; - + WITH = nex; switch ((ne_opkind)nex->op) { - + case ne_sc: strcpy(Result, WITH->UU.s); break; - + case ne_sp: strcpy(Result, *WITH->UU.U12.sp); break; - + case ne_sf: if (WITH->UU.U15.fp->subnex) { @@ -2932,19 +2932,19 @@ char *ne_seval(char *Result, ne_nexrec *nex) strcpy(Result, s1); } break; - + case ne_sarg: if (ne_argarray == NULL) strcpy(Result, ""); else strcpy(Result, ne_argarray[WITH->UU.i - 1].U16.sp1); break; - + case ne_sadd: sprintf(Result, "%s%s", ne_seval(STR1, WITH->UU.U10.p1), ne_seval(STR2, WITH->UU.U10.p2)); break; - + case ne_sand: TRY(try12); ne_seval(s1, WITH->UU.U10.p1); @@ -2958,7 +2958,7 @@ char *ne_seval(char *Result, ne_nexrec *nex) else strcpy(Result, ""); break; - + case ne_sor: TRY(try13); ne_seval(s1, WITH->UU.U10.p1); @@ -2972,14 +2972,14 @@ char *ne_seval(char *Result, ne_nexrec *nex) else strcpy(Result, s1); break; - + case ne_scond: if (ne_condeval(WITH->UU.U10.p1)) ne_seval(Result, WITH->UU.U10.p2); else ne_seval(Result, WITH->UU.U10.p3); break; - + default: _Escape(-9); break; @@ -3005,47 +3005,47 @@ void ne_evaluate(ne_nexrec *nex, ne_nexrec *res) case ne_notype: *res = *nex; break; - + case ne_integer: res->op = (unsigned)ne_ic; res->UU.i = ne_ieval(nex); break; - + case ne_real: res->op = (unsigned)ne_rc; res->UU.r = ne_reval(nex); break; - + case ne_string: res->op = (unsigned)ne_sc; res->UU.s = (char *)strdup(ne_seval(STR1, nex)); break; } RECOVER(try14); - + if (P_escapecode == -20) _Escape(P_escapecode); res->op = (unsigned)ne_error; - + switch (P_escapecode) { - + case -3: res->UU.err = (unsigned)ne_undef; break; - + case -5: res->UU.err = (unsigned)ne_divzero; break; - + case -7: res->UU.err = (unsigned)ne_underflow; break; - + case ne_badescape: res->UU.err = (unsigned)ne_badval; break; - + default: res->UU.err = (unsigned)ne_overflow; break; @@ -3060,19 +3060,19 @@ static void faileval(ne_nexrec *nex, ne_desc *desc, long esc) _Escape((int)esc); desc->error = (unsigned)((ne_errorkind)nex->UU.err); switch ((ne_errorkind)nex->UU.err) { - + case ne_underflow: _Escape(-7); break; - + case ne_divzero: _Escape(-5); break; - + case ne_strlong: _Escape(-8); break; - + default: _Escape((int)esc); break; @@ -3116,7 +3116,7 @@ long ne_ievalexpr(char *ex, ne_desc *desc) long Result; ne_nexrec *nex; long esc; - + ne_compile(ex, &nex, desc); TRY(try15); Result = ne_ievaluate(nex, desc); @@ -3134,7 +3134,7 @@ double ne_revalexpr(char *ex, ne_desc *desc) double Result; ne_nexrec *nex; long esc; - + ne_compile(ex, &nex, desc); TRY(try16); Result = ne_revaluate(nex, desc); @@ -3151,7 +3151,7 @@ char *ne_sevalexpr(char *Result, char *ex, ne_desc *desc) { ne_nexrec *nex; long esc; - + ne_compile(ex, &nex, desc); TRY(try17); ne_sevaluate(Result, nex, desc); @@ -3161,7 +3161,7 @@ char *ne_sevalexpr(char *Result, char *ex, ne_desc *desc) ne_dispose(&nex); _Escape((int)esc); ENDTRY(try17); - + return Result; } @@ -3181,7 +3181,7 @@ void ne_makesrealconst(na_strlist_t *sym, double r) void ne_makerealconst(na_strlist_t *sym, double r) { double *rp; - + sym->kind = ne_kind_realconst; rp = (double *)Malloc(sizeof(double)); *rp = r; @@ -3228,7 +3228,7 @@ void ne_makestrptrvar(na_strlist_t *sym, char **sp) static void setupfunc(na_strlist_t *sym, ne_functionrec **fp, long nargs, ne_datatype *args) { long i; - + *fp = (ne_functionrec *)Malloc(sizeof(ne_functionrec) + nargs * 2); (*fp)->nargs = nargs; for (i = 0; i < nargs; i++) @@ -3242,7 +3242,7 @@ static void setupfunc(na_strlist_t *sym, ne_functionrec **fp, long nargs, ne_dat void ne_makeintmfunc(na_strlist_t *sym, long nargs, ne_datatype *args, _PROCEDURE pr) { ne_functionrec *fp; - + sym->kind = ne_kind_intfunc; setupfunc(sym, &fp, nargs, args); fp->subnex = false; @@ -3252,7 +3252,7 @@ void ne_makeintmfunc(na_strlist_t *sym, long nargs, ne_datatype *args, _PROCEDUR void ne_makerealmfunc(na_strlist_t *sym, long nargs, ne_datatype *args, _PROCEDURE pr) { ne_functionrec *fp; - + sym->kind = ne_kind_realfunc; setupfunc(sym, &fp, nargs, args); fp->subnex = false; @@ -3262,7 +3262,7 @@ void ne_makerealmfunc(na_strlist_t *sym, long nargs, ne_datatype *args, _PROCEDU void ne_makestrmfunc(na_strlist_t *sym, long nargs, ne_datatype *args, _PROCEDURE pr) { ne_functionrec *fp; - + sym->kind = ne_kind_strfunc; setupfunc(sym, &fp, nargs, args); fp->subnex = false; @@ -3273,7 +3273,7 @@ void ne_makestrmfunc(na_strlist_t *sym, long nargs, ne_datatype *args, _PROCEDUR void ne_makeintfunc(na_strlist_t *sym, ne_datatype t1, ne_datatype t2, ne_datatype t3, _PROCEDURE pr) { ne_datatype args[3]; - + args[0] = t1; args[1] = t2; args[2] = t3; @@ -3283,7 +3283,7 @@ void ne_makeintfunc(na_strlist_t *sym, ne_datatype t1, ne_datatype t2, ne_dataty void ne_makerealfunc(na_strlist_t *sym, ne_datatype t1, ne_datatype t2, ne_datatype t3, _PROCEDURE pr) { ne_datatype args[3]; - + args[0] = t1; args[1] = t2; args[2] = t3; @@ -3293,7 +3293,7 @@ void ne_makerealfunc(na_strlist_t *sym, ne_datatype t1, ne_datatype t2, ne_datat void ne_makestrfunc(na_strlist_t *sym, ne_datatype t1, ne_datatype t2, ne_datatype t3, _PROCEDURE pr) { ne_datatype args[3]; - + args[0] = t1; args[1] = t2; args[2] = t3; @@ -3303,7 +3303,7 @@ void ne_makestrfunc(na_strlist_t *sym, ne_datatype t1, ne_datatype t2, ne_dataty void ne_makeintsfunc(na_strlist_t *sym, long nargs, ne_datatype *args, ne_nexrec **nex) { ne_functionrec *fp; - + sym->kind = ne_kind_intfunc; setupfunc(sym, &fp, nargs, args); fp->subnex = true; @@ -3313,7 +3313,7 @@ void ne_makeintsfunc(na_strlist_t *sym, long nargs, ne_datatype *args, ne_nexrec void ne_makerealsfunc(na_strlist_t *sym, long nargs, ne_datatype *args, ne_nexrec **nex) { ne_functionrec *fp; - + sym->kind = ne_kind_realfunc; setupfunc(sym, &fp, nargs, args); fp->subnex = true; @@ -3323,7 +3323,7 @@ void ne_makerealsfunc(na_strlist_t *sym, long nargs, ne_datatype *args, ne_nexre void ne_makestrsfunc(na_strlist_t *sym, long nargs, ne_datatype *args, ne_nexrec **nex) { ne_functionrec *fp; - + sym->kind = ne_kind_strfunc; setupfunc(sym, &fp, nargs, args); fp->subnex = true; @@ -3351,7 +3351,7 @@ void ne_makestrarg(na_strlist_t *sym, long i) void ne_setminargs(na_strlist_t *sym, long minargs) { ne_functionrec *fp; - + fp = (ne_functionrec *)sym->value; fp->minargs = P_imin2((long)fp->nargs, minargs); } @@ -3359,7 +3359,7 @@ void ne_setminargs(na_strlist_t *sym, long minargs) void ne_setmaxargs(na_strlist_t *sym, long maxargs) { ne_functionrec *fp; - + fp = (ne_functionrec *)sym->value; fp->maxargs = P_imin2(P_imax2((long)fp->nargs, maxargs), (long)ne_maxargs); } @@ -3367,7 +3367,7 @@ void ne_setmaxargs(na_strlist_t *sym, long maxargs) void ne_makestaticfunc(na_strlist_t *sym) { ne_functionrec *fp; - + fp = (ne_functionrec *)sym->value; fp->static_ = true; } @@ -3376,15 +3376,15 @@ void ne_disposesym(na_strlist_t *sym) { double *rp; ne_functionrec *fp; - + switch (sym->kind) { - + case ne_kind_realconst: rp = (double *)sym->value; Free(rp); break; - + case ne_kind_intfunc: case ne_kind_realfunc: case ne_kind_strfunc: @@ -3399,7 +3399,7 @@ void ne_disposesym(na_strlist_t *sym) void ne_disposesymtab(na_strlist_t **symtab) { na_strlist_t *l1; - + l1 = *symtab; while (l1 != NULL) { diff --git a/psys/src/strings.c b/psys/src/strings.c index 39ab87da7ae59a5f1c3e96d0203cb15187489b95..82fdbea2113fadb94856b7c9d6dc1564718f598b 100644 --- a/psys/src/strings.c +++ b/psys/src/strings.c @@ -549,4 +549,3 @@ char *strcpy_overlap(char *dst, char *src) } while (1); return dst; } -