From d6cfb4b626bcce25727cac2ec239c69d30a3773e Mon Sep 17 00:00:00 2001 From: pnenzi Date: Fri, 26 May 2000 08:35:05 +0000 Subject: [PATCH] Corrected errors I made during last commit. Paolo Arno, sorry for the notdef. --- src/circuit/ptfuncs.c | 127 ++++++++++++++++++++++-------------- src/frontend/plotting/x11.c | 88 +------------------------ 2 files changed, 80 insertions(+), 135 deletions(-) diff --git a/src/circuit/ptfuncs.c b/src/circuit/ptfuncs.c index 53e0d3185..cb2fe926c 100644 --- a/src/circuit/ptfuncs.c +++ b/src/circuit/ptfuncs.c @@ -21,38 +21,44 @@ Author: 1987 Wayne A. Christopher, U. C. Berkeley CAD Group #ifndef HAVE_ATANH extern double asinh(), acosh(), atanh(); -#endif +#endif double PTfudge_factor; #define MODULUS(NUM,LIMIT) ((NUM) - ((int) ((NUM) / (LIMIT))) * (LIMIT)) -double PTabs(double arg) +double +PTabs(double arg) { return arg >= 0.0 ? arg : -arg; } -double PTsgn(double arg) +double +PTsgn(double arg) { return arg > 0.0 ? 1.0 : arg < 0.0 ? -1.0 : 0.0; } -double PTplus(double arg1, double arg2) +double +PTplus(double arg1, double arg2) { return (arg1 + arg2); } -double PTminus(double arg1, double arg2) +double +PTminus(double arg1, double arg2) { return (arg1 - arg2); } -double PTtimes(double arg1, double arg2) +double +PTtimes(double arg1, double arg2) { return (arg1 * arg2); } -double PTdivide(double arg1, double arg2) +double +PTdivide(double arg1, double arg2) { if (arg2 >= 0.0) arg2 += PTfudge_factor; @@ -60,12 +66,13 @@ double PTdivide(double arg1, double arg2) arg2 -= PTfudge_factor; if (arg2 == 0.0) - return (HUGE); + return (HUGE); return (arg1 / arg2); } -double PTpower(double arg1, double arg2) +double +PTpower(double arg1, double arg2) { if (arg1 < 0.0) { if (fabs(arg2 - ((int) arg2)) / (arg2 + 0.001) < 0.000001) { @@ -77,42 +84,48 @@ double PTpower(double arg1, double arg2) return (pow(arg1, arg2)); } -double PTacos(double arg) +double +PTacos(double arg) { return (acos(arg)); } -double PTacosh(double arg) +double +PTacosh(double arg) { #ifdef HAVE_ACOSH return (acosh(arg)); #else if (arg < 1.0) arg = 1.0; - return (log(arg + sqrt(arg * arg - 1.0))); -#endif + return (log(arg + sqrt(arg*arg-1.0))); +#endif } -double PTasin(double arg) +double +PTasin(double arg) { return (asin(arg)); } -double PTasinh(double arg) +double +PTasinh(double arg) { #ifdef HAVE_ASINH return (asinh(arg)); #else return log(arg + sqrt(arg * arg + 1.0)); -#endif +#endif } -double PTatan(double arg) +double +PTatan(double arg) { return (atan(arg)); } -double PTatanh(double arg) +double +PTatanh(double arg) { #ifdef HAVE_ATANH return (atanh(arg)); @@ -122,20 +135,36 @@ double PTatanh(double arg) else if (arg > 1.0) arg = 1.0 - PTfudge_factor - 1e-10; return (log((1.0 + arg) / (1.0 - arg)) / 2.0); -#endif +#endif } -double PTustep(double arg) +double +PTustep(double arg) { if (arg < 0.0) return 0.0; else if (arg > 0.0) return 1.0; else - return 0.5; /* Ick! */ + return 0.5; /* Ick! */ } -double PTuramp(double arg) +/* MW. PTcif is like "C" if - 0 for (arg<=0), 1 elsewhere */ + +double +PTustep2(double arg) +{ + if (arg <= 0.0) + return 0.0; + else if (arg <= 1.0) + return arg; + else //if (arg > 1.0) + return 1.0; +} + + +double +PTuramp(double arg) { if (arg < 0.0) return 0.0; @@ -143,75 +172,75 @@ double PTuramp(double arg) return arg; } -double PTcos(double arg) +double +PTcos(double arg) { return (cos(MODULUS(arg, 2 * M_PI))); } -double PTcosh(double arg) +double +PTcosh(double arg) { return (cosh(arg)); } -double PTexp(double arg) +double +PTexp(double arg) { return (exp(arg)); } -double PTln(double arg) +double +PTln(double arg) { if (arg < 0.0) -#ifdef EXPERIMENTAL_CODE - return (HUGE); -#else - arg = -arg; -#endif + return (HUGE); return (log(arg)); } -double PTlog(double arg) +double +PTlog(double arg) { if (arg <= 0.0) -#ifdef EXPERIMENTAL_CODE - return (HUGE); -#else - arg = -arg; -#endif + return (HUGE); return (log10(arg)); } -double PTsin(double arg) +double +PTsin(double arg) { return (sin(MODULUS(arg, 2 * M_PI))); } -double PTsinh(double arg) +double +PTsinh(double arg) { return (sinh(arg)); } -double PTsqrt(double arg) +double +PTsqrt(double arg) { if (arg < 0.0) -#ifdef EXPERIMENTAL_CODE - return (HUGE); -#else - arg = -arg; -#endif + return (HUGE); return (sqrt(arg)); } -double PTtan(double arg) +double +PTtan(double arg) { return (tan(MODULUS(arg, M_PI))); } -double PTtanh(double arg) +double +PTtanh(double arg) { return (tanh(arg)); } -double PTuminus(double arg) +double +PTuminus(double arg) { - return (-arg); + return (- arg); } + diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index 3ba608d29..86e5be0f5 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -290,20 +290,6 @@ handlekeypressed(Widget w, caddr_t clientdata, caddr_t calldata) } -# ifdef notdef -void -keyhandler(clientdata, source, id) -caddr_t clientdata; -int *source; -XtInputId id; -{ - -# ifdef notdef - KEYwaiting = TRUE; -# endif - -} -# endif void handlebuttonev(Widget w, caddr_t clientdata, caddr_t calldata) @@ -322,17 +308,6 @@ handlebuttonev(Widget w, caddr_t clientdata, caddr_t calldata) } -# ifdef notdef -handlemotionev(w, clientdata, calldata) -Widget w; -caddr_t clientdata, calldata; -{ - - XMotionEvent *motionev = (XMotionEvent *) calldata; - - switch -} -# endif /* Recover from bad NewViewPort call. */ #define RECOVERNEWVIEWPORT() free((char *) graph);\ @@ -524,16 +499,7 @@ X11_Arc(int x0, int y0, int radius, double theta1, double theta2) XDrawArc(display, DEVDEP(currentgraph).window, DEVDEP(currentgraph).gc, x0 - radius, currentgraph->absolute.height - radius - y0, - 2 * radius, 2 * radius, t1, t2); -# ifdef notdef - printf("at %d, %d, %g %g x %d :: (%d, %d)\n", - x0, y0, theta1, theta2, radius, t1, t2); - printf("skip\n"); - XSync(display, 0); - printf("XDrawArc(%d, %d, %d, %d, %d, %d)\n", x0 - radius, - currentgraph->absolute.height - radius - y0, - 2 * radius, 2 * radius, t1, t2); -# endif + 2 * radius, 2 * radius, t1, t2); } } @@ -578,19 +544,6 @@ X11_SetLinestyle(int linestyleid) if (currentgraph->linestyle != linestyleid) { -# ifdef notdef - switch (linestyleid %3) { - case 0: - values.line_style = LineSolid; - break; - case 1: - values.line_style = LineOnOffDash; - break; - case 2: - values.line_style = LineDoubleDash; - break; - } -# endif if ((linestyleid == 0 || numdispplanes > 1) && linestyleid != 1) { /* solid if linestyle 0 or if has color, allow only one * dashed linestyle */ @@ -878,14 +831,7 @@ redraw(Widget w, caddr_t client_data, caddr_t call_data) int n = 1; DEVDEP(graph).isopen = 1; -# ifdef notdef - /* if there is a resize, let the resize routine handle the exposures */ - if (XCheckWindowEvent(display, DEVDEP(graph).window, - (long) StructureNotifyMask, &ev)) { - resize(w, client_data, &ev); - return; - } -# endif + rects[0].x = pev->x; rects[0].y = pev->y; @@ -935,37 +881,7 @@ resize(Widget w, caddr_t client_data, caddr_t call_data) } -# ifdef notdef -/* stolen from CP/lexical.c */ -/* A special 'getc' so that we can deal with ^D properly. There is no way for - * stdio to know if we have typed a ^D after some other characters, so - * don't use buffering at all... - */ -static int inchar(fp) - FILE *fp; -{ - - char c; - int i; - extern int errno; - -# ifdef HAS_TERMREAD - if (cp_interactive && !cp_nocc) { - i = read((int) fileno(fp), &c, 1); - if (i == 0) - return (EOF); - else if (i == -1) { - perror("read"); - return (EOF); - } else - return ((int) c); - } -# endif - c = getc(fp); - return ((int) c); -} -# endif void X11_Input(REQUEST *request, RESPONSE *response)