diff options
| author | ceastha <none@none> | 2005-08-17 13:01:58 -0700 |
|---|---|---|
| committer | ceastha <none@none> | 2005-08-17 13:01:58 -0700 |
| commit | 779fc935796a940997d18b31d64a9fec9c6b40f6 (patch) | |
| tree | e1b8081baa0be15eea64eb0cf53d601f08810b0e /usr/src/cmd/eqn | |
| parent | 3aceb801c46d1081eea8772ecb3c0d61d6ebd1e8 (diff) | |
| download | illumos-joyent-779fc935796a940997d18b31d64a9fec9c6b40f6.tar.gz | |
6269016 cmd/eqn and gcc don't get along
6272029 gcc and cmd/newform don't get along
Diffstat (limited to 'usr/src/cmd/eqn')
| -rw-r--r-- | usr/src/cmd/eqn/diacrit.c | 109 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/e.h | 38 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/eqnbox.c | 29 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/font.c | 57 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/fromto.c | 69 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/funny.c | 39 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/integral.c | 40 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/io.c | 192 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/lex.c | 210 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/lookup.c | 152 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/mark.c | 27 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/matrix.c | 52 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/move.c | 38 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/over.c | 57 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/paren.c | 74 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/pile.c | 84 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/shift.c | 137 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/size.c | 42 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/sqrt.c | 45 | ||||
| -rw-r--r-- | usr/src/cmd/eqn/text.c | 106 |
20 files changed, 889 insertions, 708 deletions
diff --git a/usr/src/cmd/eqn/diacrit.c b/usr/src/cmd/eqn/diacrit.c index cbe8087a86..883f5f1516 100644 --- a/usr/src/cmd/eqn/diacrit.c +++ b/usr/src/cmd/eqn/diacrit.c @@ -1,56 +1,64 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ +#pragma ident "%Z%%M% %I% %E% SMI" -# include "e.h" -# include "e.def" +#include "e.h" +#include "e.def" -diacrit(p1, type) int p1, type; { +void +diacrit(int p1, int type) +{ int c, t; #ifndef NEQN int effps; -#endif NEQN +#endif /* NEQN */ c = oalloc(); t = oalloc(); #ifdef NEQN nrwid(p1, ps, p1); - printf(".nr 10 %du\n", max(eht[p1]-ebase[p1]-VERT(2),0)); -#else NEQN + printf(".nr 10 %du\n", max(eht[p1]-ebase[p1]-VERT(2), 0)); +#else /* NEQN */ effps = EFFPS(ps); nrwid(p1, effps, p1); - printf(".nr 10 %du\n", VERT(max(eht[p1]-ebase[p1]-EM(1,ps),0))); /* vertical shift if high */ + + /* vertical shift if high */ + printf(".nr 10 %du\n", VERT(max(eht[p1]-ebase[p1]-EM(1, ps), 0))); + printf(".if \\n(ct>1 .nr 10 \\n(10+\\s%d.25m\\s0\n", effps); - printf(".nr %d \\s%d.1m\\s0\n", t, effps); /* horiz shift if high */ + + /* horiz shift if high */ + printf(".nr %d \\s%d.1m\\s0\n", t, effps); + printf(".if \\n(ct>1 .nr %d \\s%d.15m\\s0\n", t, effps); -#endif NEQN - switch(type) { +#endif /* NEQN */ + switch (type) { case VEC: /* vec */ #ifndef NEQN printf(".ds %d \\v'-.4m'\\s%d\\(->\\s0\\v'.4m'\n", c, max(effps-3, 6)); break; -#endif NEQN +#endif /* NEQN */ case DYAD: /* dyad */ #ifdef NEQN printf(".ds %d \\v'-12p'_\\v'12p'\n", c); -#else NEQN - printf(".ds %d \\v'-.4m'\\s%d\\z\\(<-\\(->\\s0\\v'.4m'\n", +#else /* NEQN */ + printf( + ".ds %d \\v'-.4m'\\s%d\\z\\(<-\\(->\\s0\\v'.4m'\n", c, max(effps-3, 6)); -#endif NEQN +#endif /* NEQN */ break; case HAT: printf(".ds %d ^\n", c); @@ -60,59 +68,66 @@ diacrit(p1, type) int p1, type; { break; case DOT: #ifndef NEQN - printf(".ds %d \\s%d\\v'-.67m'.\\v'.67m'\\s0\n", c, effps); -#else NEQN + printf( + ".ds %d \\s%d\\v'-.67m'.\\v'.67m'\\s0\n", c, effps); +#else /* NEQN */ printf(".ds %d \\v'-12p'.\\v'12p'\n", c); -#endif NEQN +#endif /* NEQN */ break; case DOTDOT: #ifndef NEQN - printf(".ds %d \\s%d\\v'-.67m'..\\v'.67m\\s0'\n", c, effps); -#else NEQN + printf( + ".ds %d \\s%d\\v'-.67m'..\\v'.67m\\s0'\n", + c, effps); +#else /* NEQN */ printf(".ds %d \\v'-12p'..\\v'12p'\n", c); -#endif NEQN +#endif /* NEQN */ break; case BAR: #ifndef NEQN - printf(".ds %d \\s%d\\v'.28m'\\h'.05m'\\l'\\n(%du-.1m\\(rn'\\h'.05m'\\v'-.28m'\\s0\n", - c, effps, p1); -#else NEQN - printf(".ds %d \\v'-12p'\\l'\\n(%du'\\v'12p'\n", - c, p1); -#endif NEQN + printf(".ds %d \\s%d\\v'.28m'\\h'.05m'\\l'\\n" + "(%du-.1m\\(rn'\\h'.05m'\\v'-.28m'\\s0\n", + c, effps, p1); +#else /* NEQN */ + printf(".ds %d \\v'-12p'\\l'\\n(%du'\\v'12p'\n", + c, p1); +#endif /* NEQN */ break; case UNDER: #ifndef NEQN printf(".ds %d \\l'\\n(%du\\(ul'\n", c, p1); printf(".nr %d 0\n", t); printf(".nr 10 0-%d\n", ebase[p1]); -#else NEQN +#else /* NEQN */ printf(".ds %d \\l'\\n(%du'\n", c, p1); -#endif NEQN +#endif /* NEQN */ break; - } + } nrwid(c, ps, c); #ifndef NEQN if (lfont[p1] != ITAL) printf(".nr %d 0\n", t); - printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d", - p1, p1, c, t, c); + printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d", + p1, p1, c, t, c); printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u-\\n(%du'\n", c, p1, t); /* BUG - should go to right end of widest */ -#else NEQN - printf(".as %d \\h'-\\n(%du-\\n(%du/2u'\\v'0-\\n(10u'\\*(%d", - p1, p1, c, c); +#else /* NEQN */ + printf(".as %d \\h'-\\n(%du-\\n(%du/2u'\\v'0-\\n(10u'\\*(%d", + p1, p1, c, c); printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u'\n", c, p1); -#endif NEQN +#endif /* NEQN */ #ifndef NEQN if (type != UNDER) eht[p1] += VERT(EM(0.15, ps)); /* 0.15m */ - if(dbg)printf(".\tdiacrit: %c over S%d, lf=%c, rf=%c, h=%d,b=%d\n", - type, p1, lfont[p1], rfont[p1], eht[p1], ebase[p1]); -#else NEQN + if (dbg) + printf(".\tdiacrit: %c over S%d, lf=%c, rf=%c, h=%d,b=%d\n", + type, p1, lfont[p1], rfont[p1], eht[p1], ebase[p1]); +#else /* NEQN */ if (type != UNDER) eht[p1] += VERT(1); - if (dbg) printf(".\tdiacrit: %c over S%d, h=%d, b=%d\n", type, p1, eht[p1], ebase[p1]); -#endif NEQN + if (dbg) + printf(".\tdiacrit: %c over S%d, h=%d, b=%d\n", + type, p1, eht[p1], ebase[p1]); +#endif /* NEQN */ ofree(c); ofree(t); } diff --git a/usr/src/cmd/eqn/e.h b/usr/src/cmd/eqn/e.h index 24bff0bc06..086e20a2c6 100644 --- a/usr/src/cmd/eqn/e.h +++ b/usr/src/cmd/eqn/e.h @@ -1,19 +1,25 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ -# ident "%Z%%M% %I% %E% SMI" /* "@(#)ucbeqn:e.h 1.1" */ +#ifndef _E_H +#define _E_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif #include <stdio.h> @@ -22,18 +28,18 @@ #ifndef NEQN #define ITAL '2' #define BLD '3' -#else NEQN +#else /* NEQN */ #define ITAL '1' #define BLD '1' -#endif NEQN +#endif /* NEQN */ #ifndef NEQN #define VERT(n) ((((n)+1)/3)*3) -#define POINT 72 -#define EM(m, ps) (int)((((float)(m)*(ps) * resolution) / POINT)) -#else NEQN +#define POINT 72 +#define EM(m, ps) (int)((((float)(m)*(ps) * resolution) / POINT)) +#else /* NEQN */ #define VERT(n) (20 * (n)) -#endif NEQN +#endif /* NEQN */ #define EFFPS(p) ((p) >= 6 ? (p) : 6) extern int dbg; @@ -70,3 +76,9 @@ typedef struct s_tbl { struct s_tbl *next; } tbl; extern char *spaceval; /* use in place of normal \x (for pic) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _E_H */ diff --git a/usr/src/cmd/eqn/eqnbox.c b/usr/src/cmd/eqn/eqnbox.c index 84f6cc5da4..7bd0753840 100644 --- a/usr/src/cmd/eqn/eqnbox.c +++ b/usr/src/cmd/eqn/eqnbox.c @@ -1,33 +1,34 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" -eqnbox(p1, p2, lu) { +void +eqnbox(int p1, int p2, int lu) +{ int b, h; char *sh; yyval = p1; b = max(ebase[p1], ebase[p2]); - eht[yyval] = h = b + max(eht[p1]-ebase[p1], - eht[p2]-ebase[p2]); + eht[yyval] = h = b + max(eht[p1]-ebase[p1], eht[p2]-ebase[p2]); ebase[yyval] = b; - if(dbg)printf(".\te:eb: S%d <- S%d S%d; b=%d, h=%d\n", - yyval, p1, p2, b, h); + if (dbg) + printf(".\te:eb: S%d <- S%d S%d; b=%d, h=%d\n", + yyval, p1, p2, b, h); if (rfont[p1] == ITAL && lfont[p2] == ROM) sh = "\\|"; else diff --git a/usr/src/cmd/eqn/font.c b/usr/src/cmd/eqn/font.c index 26d8937259..0c5e615707 100644 --- a/usr/src/cmd/eqn/font.c +++ b/usr/src/cmd/eqn/font.c @@ -1,23 +1,24 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ +#pragma ident "%Z%%M% %I% %E% SMI" -# include "e.h" +#include "e.h" -setfont(ch1) char ch1; { +void +setfont(char ch1) +{ /* use number '1', '2', '3' for roman, italic, bold */ yyval = ft; if (ch1 == 'r' || ch1 == 'R') @@ -30,38 +31,42 @@ setfont(ch1) char ch1; { ft = ch1; printf(".ft %c\n", ft); #ifndef NEQN - if(dbg)printf(".\tsetfont %c %c\n", ch1, ft); -#else NEQN - if(dbg)printf(".\tsetfont %c\n", ft); -#endif NEQN + if (dbg) printf(".\tsetfont %c %c\n", ch1, ft); +#else /* NEQN */ + if (dbg) printf(".\tsetfont %c\n", ft); +#endif /* NEQN */ } -font(p1, p2) int p1, p2; { +void +font(int p1, int p2) +{ /* old font in p1, new in ft */ yyval = p2; - lfont[yyval] = rfont[yyval] = ft==ITAL ? ITAL : ROM; - if(dbg)printf(".\tb:fb: S%d <- \\f%c S%d \\f%c b=%d,h=%d,lf=%c,rf=%c\n", - yyval, ft, p2, p1, ebase[yyval], eht[yyval], lfont[yyval], rfont[yyval]); - printf(".ds %d \\f%c\\*(%d\\f%c\n", - yyval, ft, p2, p1); + lfont[yyval] = rfont[yyval] = ft == ITAL ? ITAL : ROM; + if (dbg) + printf(".\tb:fb: S%d <- \\f%c S%d \\f%c b=%d,h=%d,lf=%c," + "rf=%c\n", yyval, ft, p2, p1, ebase[yyval], eht[yyval], + lfont[yyval], rfont[yyval]); + printf(".ds %d \\f%c\\*(%d\\f%c\n", yyval, ft, p2, p1); ft = p1; printf(".ft %c\n", ft); } -fatbox(p) int p; { - int sh; - +void +fatbox(int p) +{ yyval = p; - sh = ps / 4; nrwid(p, ps, p); printf(".ds %d \\*(%d\\h'-\\n(%du+0.05m'\\*(%d\n", p, p, p, p); - if(dbg)printf(".\tfat %d, sh=0.05m\n", p); + if (dbg) printf(".\tfat %d, sh=0.05m\n", p); } -globfont() { +void +globfont(void) +{ char temp[20]; - getstr(temp, 20); + (void) getstr(temp, 20); yyval = eqnreg = 0; gfont = temp[0]; switch (gfont) { diff --git a/usr/src/cmd/eqn/fromto.c b/usr/src/cmd/eqn/fromto.c index 7cfd153b0a..ab7180861b 100644 --- a/usr/src/cmd/eqn/fromto.c +++ b/usr/src/cmd/eqn/fromto.c @@ -1,23 +1,24 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" -fromto(p1, p2, p3) int p1, p2, p3; { +void +fromto(int p1, int p2, int p3) +{ int b, h1, b1, pss; yyval = oalloc(); lfont[yyval] = rfont[yyval] = 0; @@ -28,39 +29,45 @@ fromto(p1, p2, p3) int p1, p2, p3; { ps += 3; nrwid(p1, ps, p1); printf(".nr %d \\n(%d\n", yyval, p1); - if( p2>0 ) { + if (p2 > 0) { nrwid(p2, pss, p2); - printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, yyval, yyval, p2); + printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", + p2, yyval, yyval, p2); eht[yyval] += eht[p2]; b = eht[p2]; } - if( p3>0 ) { + if (p3 > 0) { nrwid(p3, pss, p3); - printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p3, yyval, yyval, p3); + printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", + p3, yyval, yyval, p3); eht[yyval] += eht[p3]; } printf(".ds %d ", yyval); /* bottom of middle box */ - if( p2>0 ) { - printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d", - eht[p2]-ebase[p2]+b1, yyval, p2, pss, p2, EFFPS(ps)); - printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\\n", - yyval, p2, -(eht[p2]-ebase[p2]+b1)); + if (p2 > 0) { + printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d", + eht[p2]-ebase[p2]+b1, yyval, p2, pss, p2, EFFPS(ps)); + printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\\n", + yyval, p2, -(eht[p2]-ebase[p2]+b1)); } #ifndef NEQN - printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n", -#else NEQN - printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du+2u/2u'\\\n", -#endif NEQN - yyval, p1, p1, yyval, p1); - if( p3>0 ) { - printf("\\v'%du'\\h'-\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d\\h'\\n(%du-\\n(%du/2u'\\v'%du'\\\n", - -(h1-b1+ebase[p3]), yyval, p3, pss, p3, EFFPS(ps), yyval, p3, (h1-b1+ebase[p3])); + printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n", + yyval, p1, p1, yyval, p1); +#else /* NEQN */ + printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du+2u/2u'\\\n", + yyval, p1, p1, yyval, p1); +#endif /* NEQN */ + if (p3 > 0) { + printf("\\v'%du'\\h'-\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d" + "\\h'\\n(%du-\\n(%du/2u'\\v'%du'\\\n", + -(h1-b1+ebase[p3]), yyval, p3, pss, p3, EFFPS(ps), + yyval, p3, (h1-b1+ebase[p3])); } printf("\n"); ebase[yyval] = b + b1; - if(dbg)printf(".\tfrom to: S%d <- %d f %d t %d; h=%d b=%d\n", - yyval, p1, p2, p3, eht[yyval], ebase[yyval]); + if (dbg) + printf(".\tfrom to: S%d <- %d f %d t %d; h=%d b=%d\n", + yyval, p1, p2, p3, eht[yyval], ebase[yyval]); ofree(p1); - if( p2>0 ) ofree(p2); - if( p3>0 ) ofree(p3); + if (p2 > 0) ofree(p2); + if (p3 > 0) ofree(p3); } diff --git a/usr/src/cmd/eqn/funny.c b/usr/src/cmd/eqn/funny.c index dc2fa0ade1..5e2ae790be 100644 --- a/usr/src/cmd/eqn/funny.c +++ b/usr/src/cmd/eqn/funny.c @@ -1,29 +1,30 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" -# include "e.def" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" +#include "e.def" #include <locale.h> -funny(n) int n; { +void +funny(int n) +{ char *f; yyval = oalloc(); - switch(n) { + switch (n) { case SUM: f = "\\(*S"; break; case UNION: @@ -33,18 +34,20 @@ funny(n) int n; { case PROD: f = "\\(*P"; break; default: - error(FATAL, gettext("funny type %d in funny"), n); + (void) error(FATAL, gettext("funny type %d in funny"), n); } #ifndef NEQN - printf(".ds %d \\s%d\\v'.3m'\\s+5%s\\s-5\\v'-.3m'\\s%d\n", yyval, ps, f, ps); + printf(".ds %d \\s%d\\v'.3m'\\s+5%s\\s-5\\v'-.3m'\\s%d\n", + yyval, ps, f, ps); eht[yyval] = VERT(EM(1.0, ps+5) - EM(0.2, ps)); ebase[yyval] = VERT(EM(0.3, ps)); -#else NEQN +#else /* NEQN */ printf(".ds %d %s\n", yyval, f); eht[yyval] = VERT(2); ebase[yyval] = 0; -#endif NEQN - if(dbg)printf(".\tfunny: S%d <- %s; h=%d b=%d\n", - yyval, f, eht[yyval], ebase[yyval]); +#endif /* NEQN */ + if (dbg) + printf(".\tfunny: S%d <- %s; h=%d b=%d\n", + yyval, f, eht[yyval], ebase[yyval]); lfont[yyval] = rfont[yyval] = ROM; } diff --git a/usr/src/cmd/eqn/integral.c b/usr/src/cmd/eqn/integral.c index 3132516068..0383c379ec 100644 --- a/usr/src/cmd/eqn/integral.c +++ b/usr/src/cmd/eqn/integral.c @@ -1,24 +1,25 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" -# include "e.def" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" +#include "e.def" -integral(p, p1, p2) { +void +integral(int p, int p1, int p2) +{ #ifndef NEQN if (p1 != 0) printf(".ds %d \\h'-0.4m'\\v'0.4m'\\*(%d\\v'-0.4m'\n", p1, p1); @@ -31,25 +32,28 @@ integral(p, p1, p2) { bshiftb(p, SUB, p1); else if (p2 != 0) bshiftb(p, SUP, p2); - if(dbg)printf(".\tintegral: S%d; h=%d b=%d\n", - p, eht[p], ebase[p]); + if (dbg) + printf(".\tintegral: S%d; h=%d b=%d\n", + p, eht[p], ebase[p]); lfont[p] = ROM; } -setintegral() { +void +setintegral(void) +{ char *f; yyval = oalloc(); f = "\\(is"; #ifndef NEQN - printf(".ds %d \\s%d\\v'.1m'\\s+4%s\\s-4\\v'-.1m'\\s%d\n", - yyval, ps, f, ps); + printf(".ds %d \\s%d\\v'.1m'\\s+4%s\\s-4\\v'-.1m'\\s%d\n", + yyval, ps, f, ps); eht[yyval] = VERT(EM(1.15, ps+4)); ebase[yyval] = VERT(EM(0.3, ps)); -#else NEQN +#else /* NEQN */ printf(".ds %d %s\n", yyval, f); eht[yyval] = VERT(2); ebase[yyval] = 0; -#endif NEQN +#endif /* NEQN */ lfont[yyval] = rfont[yyval] = ROM; } diff --git a/usr/src/cmd/eqn/io.c b/usr/src/cmd/eqn/io.c index 8740dce13a..3aaf5d8092 100644 --- a/usr/src/cmd/eqn/io.c +++ b/usr/src/cmd/eqn/io.c @@ -1,69 +1,82 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983-1988, 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ +#pragma ident "%Z%%M% %I% %E% SMI" -# include "e.h" +#include "e.h" +#include <stdlib.h> #include <locale.h> + #define MAXLINE 8192 /* maximum input line */ -char in[MAXLINE+1]; /* input buffer */ -int eqnexit(); +char in[MAXLINE+1]; /* input buffer */ int noeqn; -main(argc,argv) int argc; char *argv[];{ +void error(int, char *, char *); +static void do_inline(void); +int eqn(int, char *[]); +static int getline(char *); +static void init(void); +void nrwid(int, int, int); +int oalloc(void); +void ofree(int); +static void setfile(int, char *[]); +void setps(int); + +int +main(int argc, char *argv[]) +{ (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); - eqnexit(eqn(argc, argv)); -} - -eqnexit(n) { -#ifdef gcos - if (n) - fprintf(stderr, gettext("run terminated due to eqn error\n")); - exit(0); -#endif - exit(n); + return (eqn(argc, argv)); } -eqn(argc,argv) int argc; char *argv[];{ +int +eqn(int argc, char *argv[]) +{ int i, type; - setfile(argc,argv); + setfile(argc, argv); init_tbl(); /* install keywords in tables */ - while ((type=getline(in)) != EOF) { + while ((type = getline(in)) != EOF) { eqline = linect; - if (in[0]=='.' && in[1]=='E' && in[2]=='Q') { - for (i=11; i<100; used[i++]=0); - printf("%s",in); + if (in[0] == '.' && in[1] == 'E' && in[2] == 'Q') { + for (i = 11; i < 100; used[i++] = 0) + ; + printf("%s", in); printf(".nr 99 \\n(.s\n.nr 98 \\n(.f\n"); markline = 0; init(); yyparse(); - if (eqnreg>0) { + if (eqnreg > 0) { printf(".nr %d \\w'\\*(%d'\n", eqnreg, eqnreg); - /* printf(".if \\n(%d>\\n(.l .tm too-long eqn, file %s, between lines %d-%d\n", */ - /* eqnreg, svargv[ifile], eqline, linect); */ - printf(".nr MK %d\n", markline); /* for -ms macros */ + /* + * printf(".if \\n(%d>\\n(.l .tm too-long eqn, + * file %s, between lines %d-%d\n", + * eqnreg, svargv[ifile], eqline, linect); + */ + + /* for -ms macros */ + printf(".nr MK %d\n", markline); + printf(".if %d>\\n(.v .ne %du\n", eqnht, eqnht); printf(".rn %d 10\n", eqnreg); - if(!noeqn)printf("\\*(10\n"); + if (!noeqn) printf("\\*(10\n"); } printf(".ps \\n(99\n.ft \\n(98\n"); printf(".EN"); @@ -72,37 +85,42 @@ eqn(argc,argv) int argc; char *argv[];{ break; } if (putchar(lastchar) != '\n') - while (putchar(gtc()) != '\n'); - } - else if (type == lefteq) + while (putchar(gtc()) != '\n') + ; + } else if (type == lefteq) do_inline(); else - printf("%s",in); + printf("%s", in); } - return(0); + return (0); } -getline(s) register char *s; { - register c; - while((*s++=c=gtc())!='\n' && c!=EOF && c!=lefteq) +static int +getline(char *s) +{ + int c; + while ((*s++ = c = gtc()) != '\n' && c != EOF && c != lefteq) if (s >= in+MAXLINE) { - error( !FATAL, gettext("input line too long: %.20s\n"), in); + error(!FATAL, gettext( + "input line too long: %.20s\n"), in); in[MAXLINE] = '\0'; break; } - if (c==lefteq) + if (c == lefteq) s--; *s++ = '\0'; - return(c); + return (c); } -do_inline() { +static void +do_inline(void) +{ int ds; printf(".nr 99 \\n(.s\n.nr 98 \\n(.f\n"); ds = oalloc(); printf(".rm %d \n", ds); - do{ + do { if (*in) printf(".as %d \"%s\n", ds, in); init(); @@ -120,29 +138,32 @@ do_inline() { ofree(ds); } -putout(p1) int p1; { +void +putout(int p1) +{ extern int gsize, gfont; int before, after; - if(dbg)printf(".\tanswer <- S%d, h=%d,b=%d\n",p1, eht[p1], ebase[p1]); + if (dbg) + printf(".\tanswer <- S%d, h=%d,b=%d\n", p1, eht[p1], ebase[p1]); eqnht = eht[p1]; printf(".ds %d \\x'0'", p1); /* suppposed to leave room for a subscript or superscript */ #ifndef NEQN before = eht[p1] - ebase[p1] - VERT(EM(1.2, ps)); -#else NEQN +#else /* NEQN */ before = eht[p1] - ebase[p1] - VERT(3); /* 3 = 1.5 lines */ -#endif NEQN +#endif /* NEQN */ if (spaceval != NULL) printf("\\x'0-%s'", spaceval); else if (before > 0) printf("\\x'0-%du'", before); printf("\\f%c\\s%d\\*(%d%s\\s\\n(99\\f\\n(98", - gfont, gsize, p1, rfont[p1] == ITAL ? "\\|" : ""); + gfont, gsize, p1, rfont[p1] == ITAL ? "\\|" : ""); #ifndef NEQN after = ebase[p1] - VERT(EM(0.2, ps)); -#else NEQN +#else /* NEQN */ after = ebase[p1] - VERT(1); -#endif NEQN +#endif /* NEQN */ if (spaceval == NULL && after > 0) printf("\\x'%du'", after); putchar('\n'); @@ -154,31 +175,47 @@ putout(p1) int p1; { } -max(i,j) int i,j; { - return (i>j ? i : j); +int +max(int i, int j) +{ + return (i > j ? i : j); } -oalloc() { +int +oalloc(void) +{ int i; - for (i=11; i<100; i++) - if (used[i]++ == 0) return(i); - error( FATAL, gettext("no eqn strings left"), i); - return(0); + char ebuf[3]; + + for (i = 11; i < 100; i++) + if (used[i]++ == 0) + return (i); + (void) snprintf(ebuf, sizeof (ebuf), "%d", i); + error(FATAL, gettext("no eqn strings left"), ebuf); + return (0); } -ofree(n) int n; { +void +ofree(int n) +{ used[n] = 0; } -setps(p) int p; { +void +setps(int p) +{ printf(".ps %d\n", EFFPS(p)); } -nrwid(n1, p, n2) int n1, p, n2; { +void +nrwid(int n1, int p, int n2) +{ printf(".nr %d \\w'\\s%d\\*(%d'\n", n1, EFFPS(p), n2); } -setfile(argc, argv) int argc; char *argv[]; { +static void +setfile(int argc, char *argv[]) +{ static char *nullstr = "-"; svargc = --argc; @@ -186,18 +223,18 @@ setfile(argc, argv) int argc; char *argv[]; { while (svargc > 0 && svargv[1][0] == '-') { switch (svargv[1][1]) { - case 'd': lefteq=svargv[1][2]; righteq=svargv[1][3]; break; + case 'd': lefteq = svargv[1][2]; righteq = svargv[1][3]; break; case 's': gsize = atoi(&svargv[1][2]); break; case 'p': deltaps = atoi(&svargv[1][2]); break; case 'f': gfont = svargv[1][2]; break; case 'e': noeqn++; break; - case 0: goto endargs; + case 0: goto endargs; default: dbg = 1; } svargc--; svargv++; } - endargs: +endargs: ifile = 1; linect = 1; if (svargc <= 0) { @@ -208,9 +245,14 @@ setfile(argc, argv) int argc; char *argv[]; { openinfile(); /* opens up the first input file */ } -yyerror() {;} +void +yyerror(void) +{ +} -init() { +static void +init(void) +{ ct = 0; ps = gsize; ft = gfont; @@ -218,18 +260,20 @@ init() { printf(".ft %c\n", ft); } -error(fatal, s1, s2) int fatal; char *s1, *s2; { - if (fatal>0) +void +error(int fatal, char *s1, char *s2) +{ + if (fatal > 0) printf(gettext("eqn fatal error: ")); printf(s1, s2); printf(gettext("\nfile %s, between lines %d and %d\n"), - svargv[ifile], eqline, linect); + svargv[ifile], eqline, linect); fprintf(stderr, gettext("eqn: ")); - if (fatal>0) + if (fatal > 0) fprintf(stderr, gettext("fatal error: ")); fprintf(stderr, s1, s2); fprintf(stderr, gettext("\nfile %s, between lines %d and %d\n"), - svargv[ifile], eqline, linect); + svargv[ifile], eqline, linect); if (fatal > 0) - eqnexit(1); + exit(1); } diff --git a/usr/src/cmd/eqn/lex.c b/usr/src/cmd/eqn/lex.c index 356f466b88..aac3e7e839 100644 --- a/usr/src/cmd/eqn/lex.c +++ b/usr/src/cmd/eqn/lex.c @@ -1,19 +1,18 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ + +#pragma ident "%Z%%M% %I% %E% SMI" #include "e.h" #include "e.def" @@ -27,129 +26,145 @@ int sp; char ibuf[PUSHBACK+SSIZE]; /* pushback buffer for definitions, etc. */ char *ip = ibuf; -gtc() { - loop: +void define(int); +void delim(void); +void getstr(char *, int); +void include(void); +int openinfile(void); +void pbstr(char *); +void space(void); + +int +gtc(void) +{ +loop: if (ip > ibuf) - return(*--ip); /* already present */ + return (*--ip); /* already present */ lastchar = getc(curfile); - if (lastchar=='\n') + if (lastchar == '\n') linect++; if (lastchar != EOF) - return(lastchar); + return (lastchar); if (++ifile > svargc) { - return(EOF); + return (EOF); } - fclose(curfile); + (void) fclose(curfile); linect = 1; if (openinfile() == 0) goto loop; - return(EOF); + return (EOF); } /* * open file indexed by ifile in svargv, return non zero if fail */ -openinfile() +int +openinfile(void) { - if (strcmp(svargv[ifile], "-") == 0){ + if (strcmp(svargv[ifile], "-") == 0) { curfile = stdin; - return(0); - } else if ((curfile=fopen(svargv[ifile], "r")) != NULL){ - return(0); + return (0); + } else if ((curfile = fopen(svargv[ifile], "r")) != NULL) { + return (0); } error(FATAL, gettext("can't open file %s"), svargv[ifile]); - return(1); + return (1); } -pbstr(str) -register char *str; +void +pbstr(char *str) { - register char *p; + char *p; p = str; - while (*p++); + while (*p++) + ; --p; if (ip >= &ibuf[PUSHBACK]) - error( FATAL, gettext("pushback overflow")); + error(FATAL, gettext("pushback overflow")); while (p > str) putbak(*--p); } -yylex() { - register int c; +int +yylex(void) +{ + int c; tbl *tp, *lookup(); extern tbl **keytbl, **deftbl; - beg: - while ((c=gtc())==' ' || c=='\n') +beg: + while ((c = gtc()) == ' ' || c == '\n') ; - yylval=c; - switch(c) { + yylval = c; + switch (c) { case EOF: - return(EOF); + return (EOF); case '~': - return(SPACE); + return (SPACE); case '^': - return(THIN); + return (THIN); case '\t': - return(TAB); + return (TAB); case '{': - return('{'); + return ('{'); case '}': - return('}'); + return ('}'); case '"': - for (sp=0; (c=gtc())!='"' && c != '\n'; ) { + for (sp = 0; (c = gtc()) != '"' && c != '\n'; ) { if (c == '\\') if ((c = gtc()) != '"') token[sp++] = '\\'; token[sp++] = c; - if (sp>=SSIZE) - error(FATAL, gettext("quoted string %.20s... too long"), token); + if (sp >= SSIZE) + error(FATAL, gettext( + "quoted string %.20s... too long"), token); } - token[sp]='\0'; - yylval = (int) &token[0]; + token[sp] = '\0'; + yylval = (int)&token[0]; if (c == '\n') error(!FATAL, gettext("missing \" in %.20s"), token); - return(QTEXT); + return (QTEXT); } - if (c==righteq) - return(EOF); + if (c == righteq) + return (EOF); putbak(c); getstr(token, SSIZE); - if (dbg)printf(".\tlex token = |%s|\n", token); - if ((tp = lookup(&deftbl, token, NULL)) != NULL) { + if (dbg) printf(".\tlex token = |%s|\n", token); + if ((tp = lookup(deftbl, token, NULL)) != NULL) { putbak(' '); pbstr(tp->defn); putbak(' '); if (dbg) printf(".\tfound %s|=%s|\n", token, tp->defn); - } - else if ((tp = lookup(&keytbl, token, NULL)) == NULL) { - if(dbg)printf(".\t%s is not a keyword\n", token); - return(CONTIG); - } - else if (tp->defn == (char *) DEFINE || tp->defn == (char *) NDEFINE || tp->defn == (char *) TDEFINE) - define(tp->defn); - else if (tp->defn == (char *) DELIM) + } else if ((tp = lookup(keytbl, token, NULL)) == NULL) { + if (dbg) printf(".\t%s is not a keyword\n", token); + return (CONTIG); + } else if (tp->defn == (char *)DEFINE || + tp->defn == (char *)NDEFINE || tp->defn == (char *)TDEFINE) + define((int)tp->defn); + else if (tp->defn == (char *)DELIM) delim(); - else if (tp->defn == (char *) GSIZE) + else if (tp->defn == (char *)GSIZE) globsize(); - else if (tp->defn == (char *) GFONT) + else if (tp->defn == (char *)GFONT) globfont(); - else if (tp->defn == (char *) INCLUDE) + else if (tp->defn == (char *)INCLUDE) include(); - else if (tp->defn == (char *) SPACE) + else if (tp->defn == (char *)SPACE) space(); else { - return((int) tp->defn); + return ((int)tp->defn); } goto beg; } -getstr(s, n) char *s; register int n; { - register int c; - register char *p; +void +getstr(char *s, int n) +{ + int c; + char *p; p = s; while ((c = gtc()) == ' ' || c == '\n') @@ -158,8 +173,8 @@ getstr(s, n) char *s; register int n; { *s = 0; return; } - while (c != ' ' && c != '\t' && c != '\n' && c != '{' && c != '}' - && c != '"' && c != '~' && c != '^' && c != righteq) { + while (c != ' ' && c != '\t' && c != '\n' && c != '{' && c != '}' && + c != '"' && c != '~' && c != '^' && c != righteq) { if (c == '\\') if ((c = gtc()) != '"') *p++ = '\\'; @@ -168,60 +183,69 @@ getstr(s, n) char *s; register int n; { error(FATAL, gettext("token %.20s... too long"), s); c = gtc(); } - if (c=='{' || c=='}' || c=='"' || c=='~' || c=='^' || c=='\t' || c==righteq) + if (c == '{' || c == '}' || c == '"' || c == '~' || c == '^' || + c == '\t' || c == righteq) putbak(c); *p = '\0'; - yylval = (int) s; + yylval = (int)s; } -cstr(s, quote, maxs) char *s; int quote; { +int +cstr(char *s, int quote, int maxs) +{ int del, c, i; s[0] = 0; - while((del=gtc()) == ' ' || del == '\t'); - if (quote) - for (i=0; (c=gtc()) != del && c != EOF;) { + while ((del = gtc()) == ' ' || del == '\t') + ; + if (quote) { + for (i = 0; (c = gtc()) != del && c != EOF; ) { s[i++] = c; if (i >= maxs) - return(1); /* disaster */ + return (1); /* disaster */ } - else { + } else { if (del == '\n') return (1); s[0] = del; - for (i=1; (c=gtc())!=' ' && c!= '\t' && c!='\n' && c!=EOF;) { - s[i++]=c; + for (i = 1; (c = gtc()) != ' ' && c != '\t' && + c != '\n' && c != EOF; /* empty */) { + s[i++] = c; if (i >= maxs) - return(1); /* disaster */ + return (1); /* disaster */ } } s[i] = '\0'; if (c == EOF) error(FATAL, gettext("Unexpected end of input at %.20s"), s); - return(0); + return (0); } -define(type) int type; { +void +define(int type) +{ char *strsave(), *p1, *p2; tbl *lookup(); extern tbl **deftbl; getstr(token, SSIZE); /* get name */ if (type != DEFINE) { - cstr(token, 1, SSIZE); /* skip the definition too */ + (void) cstr(token, 1, SSIZE); /* skip the definition too */ return; } p1 = strsave(token); if (cstr(token, 1, SSIZE)) - error(FATAL, gettext("Unterminated definition at %.20s"), token); + error(FATAL, gettext( + "Unterminated definition at %.20s"), token); p2 = strsave(token); - lookup(&deftbl, p1, p2); - if (dbg)printf(".\tname %s defined as %s\n", p1, p2); + lookup(deftbl, p1, p2); + if (dbg) printf(".\tname %s defined as %s\n", p1, p2); } char *spaceval = NULL; -space() /* collect line of form "space amt" to replace \x in output */ +void +space(void) /* collect line of form "space amt" to replace \x in output */ { char *strsave(); @@ -231,24 +255,28 @@ space() /* collect line of form "space amt" to replace \x in output */ } -char *strsave(s) -char *s; +char * +strsave(char *s) { char *malloc(); - register char *q; + char *q; q = malloc(strlen(s)+1); if (q == NULL) error(FATAL, gettext("out of space in strsave on %s"), s); strcpy(q, s); - return(q); + return (q); } -include() { +void +include(void) +{ error(!FATAL, gettext("Include not yet implemented")); } -delim() { +void +delim(void) +{ yyval = eqnreg = 0; if (cstr(token, 0, SSIZE)) error(FATAL, gettext("Bizarre delimiters at %.20s"), token); diff --git a/usr/src/cmd/eqn/lookup.c b/usr/src/cmd/eqn/lookup.c index 495b3fdbc0..169830e508 100644 --- a/usr/src/cmd/eqn/lookup.c +++ b/usr/src/cmd/eqn/lookup.c @@ -1,21 +1,20 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" #include "e.def" #include <locale.h> @@ -28,43 +27,43 @@ tbl *deftbl[TBLSIZE]; /* user-defined names */ struct { char *key; int keyval; -} keyword[] ={ - "sub", SUB, - "sup", SUP, - ".EN", EOF, - "from", FROM, - "to", TO, - "sum", SUM, - "hat", HAT, - "vec", VEC, - "dyad", DYAD, - "dot", DOT, - "dotdot", DOTDOT, - "bar", BAR, - "tilde", TILDE, - "under", UNDER, - "prod", PROD, - "int", INT, - "integral", INT, - "union", UNION, - "inter", INTER, - "pile", PILE, - "lpile", LPILE, - "cpile", CPILE, - "rpile", RPILE, - "over", OVER, - "sqrt", SQRT, - "above", ABOVE, - "size", SIZE, - "font", FONT, - "fat", FAT, - "roman", ROMAN, - "italic", ITALIC, - "bold", BOLD, - "left", LEFT, - "right", RIGHT, - "delim", DELIM, - "define", DEFINE, +} keyword[] = { + "sub", SUB, + "sup", SUP, + ".EN", EOF, + "from", FROM, + "to", TO, + "sum", SUM, + "hat", HAT, + "vec", VEC, + "dyad", DYAD, + "dot", DOT, + "dotdot", DOTDOT, + "bar", BAR, + "tilde", TILDE, + "under", UNDER, + "prod", PROD, + "int", INT, + "integral", INT, + "union", UNION, + "inter", INTER, + "pile", PILE, + "lpile", LPILE, + "cpile", CPILE, + "rpile", RPILE, + "over", OVER, + "sqrt", SQRT, + "above", ABOVE, + "size", SIZE, + "font", FONT, + "fat", FAT, + "roman", ROMAN, + "italic", ITALIC, + "bold", BOLD, + "left", LEFT, + "right", RIGHT, + "delim", DELIM, + "define", DEFINE, #ifdef NEQN /* make ndefine synonym for define, tdefine a no-op */ @@ -73,33 +72,33 @@ struct { #else /* tdefine = define, ndefine = no-op */ - "tdefine", DEFINE, - "ndefine", NDEFINE, + "tdefine", DEFINE, + "ndefine", NDEFINE, #endif - "gsize", GSIZE, - ".gsize", GSIZE, - "gfont", GFONT, - "include", INCLUDE, - "up", UP, - "down", DOWN, - "fwd", FWD, - "back", BACK, - "mark", MARK, - "lineup", LINEUP, - "matrix", MATRIX, - "col", COL, - "lcol", LCOL, - "ccol", CCOL, - "rcol", RCOL, + "gsize", GSIZE, + ".gsize", GSIZE, + "gfont", GFONT, + "include", INCLUDE, + "up", UP, + "down", DOWN, + "fwd", FWD, + "back", BACK, + "mark", MARK, + "lineup", LINEUP, + "matrix", MATRIX, + "col", COL, + "lcol", LCOL, + "ccol", CCOL, + "rcol", RCOL, 0, 0 }; struct { char *res; char *resval; -} resword[] ={ +} resword[] = { ">=", "\\(>=", "<=", "\\(<=", "==", "\\(==", @@ -199,13 +198,13 @@ struct { 0, 0 }; -tbl *lookup(tblp, name, defn) /* find name in tbl. if defn non-null, install */ -tbl **tblp; -char *name, *defn; +/* find name in tbl. if defn non-null, install */ +tbl * +lookup(tbl **tblp, char *name, char *defn) { - register tbl *p; - register int h; - register unsigned char *s = (unsigned char *)name; + tbl *p; + int h; + unsigned char *s = (unsigned char *)name; char *malloc(); for (h = 0; *s != '\0'; ) @@ -216,27 +215,28 @@ char *name, *defn; if (strcmp(name, p->name) == 0) { /* found it */ if (defn != NULL) p->defn = defn; - return(p); + return (p); } /* didn't find it */ if (defn == NULL) - return(NULL); + return (NULL); p = (tbl *) malloc(sizeof (tbl)); if (p == NULL) - error(FATAL, gettext("out of space in lookup")); + error(FATAL, gettext("out of space in lookup"), NULL); p->name = name; p->defn = defn; p->next = tblp[h]; tblp[h] = p; - return(p); + return (p); } -init_tbl() /* initialize all tables */ +void +init_tbl(void) /* initialize all tables */ { int i; for (i = 0; keyword[i].key != NULL; i++) - lookup(keytbl, keyword[i].key, keyword[i].keyval); + lookup(keytbl, keyword[i].key, (char *)keyword[i].keyval); for (i = 0; resword[i].res != NULL; i++) lookup(restbl, resword[i].res, resword[i].resval); } diff --git a/usr/src/cmd/eqn/mark.c b/usr/src/cmd/eqn/mark.c index 87b631c9ca..c9a0fcd7ee 100644 --- a/usr/src/cmd/eqn/mark.c +++ b/usr/src/cmd/eqn/mark.c @@ -1,34 +1,37 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ + +#pragma ident "%Z%%M% %I% %E% SMI" #include "e.h" -mark(p1) int p1; { +void +mark(int p1) +{ markline = 1; printf(".ds %d \\k(97\\*(%d\n", p1, p1); yyval = p1; - if(dbg)printf(".\tmark %d\n", p1); + if (dbg) printf(".\tmark %d\n", p1); } -lineup(p1) { +void +lineup(int p1) +{ markline = 1; if (p1 == 0) { yyval = oalloc(); printf(".ds %d \\h'|\\n(97u'\n", yyval); } - if(dbg)printf(".\tlineup %d\n", p1); + if (dbg) printf(".\tlineup %d\n", p1); } diff --git a/usr/src/cmd/eqn/matrix.c b/usr/src/cmd/eqn/matrix.c index 31af1282bb..1304954265 100644 --- a/usr/src/cmd/eqn/matrix.c +++ b/usr/src/cmd/eqn/matrix.c @@ -1,64 +1,67 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ + +#pragma ident "%Z%%M% %I% %E% SMI" #include "e.h" -column(type, p1) int type, p1; { +void +column(int type, int p1) +{ int i; lp[p1] = ct - p1 - 1; - if( dbg ){ + if (dbg) { printf(".\t%d column of", type); - for( i=p1+1; i<ct; i++ ) + for (i = p1 + 1; i < ct; i++) printf(" S%d", lp[i]); - printf(", rows=%d\n",lp[p1]); + printf(", rows=%d\n", lp[p1]); } lp[ct++] = type; } -matrix(p1) int p1; { +void +matrix(int p1) +{ int nrow, ncol, i, j, k, hb, b, val[100]; char *space; space = "\\ \\ "; nrow = lp[p1]; /* disaster if rows inconsistent */ ncol = 0; - for( i=p1; i<ct; i += lp[i]+2 ){ + for (i = p1; i < ct; i += lp[i] + 2) { ncol++; - if(dbg)printf(".\tcolct=%d\n",lp[i]); + if (dbg) printf(".\tcolct=%d\n", lp[i]); } - for( k=1; k<=nrow; k++ ) { + for (k = 1; k <= nrow; k++) { hb = b = 0; j = p1 + k; - for( i=0; i<ncol; i++ ) { + for (i = 0; i < ncol; i++) { hb = max(hb, eht[lp[j]]-ebase[lp[j]]); b = max(b, ebase[lp[j]]); j += nrow + 2; } - if(dbg)printf(".\trow %d: b=%d, hb=%d\n", k, b, hb); + if (dbg) printf(".\trow %d: b=%d, hb=%d\n", k, b, hb); j = p1 + k; - for( i=0; i<ncol; i++ ) { + for (i = 0; i < ncol; i++) { ebase[lp[j]] = b; eht[lp[j]] = b + hb; j += nrow + 2; } } j = p1; - for( i=0; i<ncol; i++ ) { + for (i = 0; i < ncol; i++) { lpile(lp[j+lp[j]+1], j+1, j+lp[j]+1); val[i] = yyval; j += nrow + 2; @@ -67,11 +70,12 @@ matrix(p1) int p1; { eht[yyval] = eht[val[0]]; ebase[yyval] = ebase[val[0]]; lfont[yyval] = rfont[yyval] = 0; - if(dbg)printf(".\tmatrix S%d: r=%d, c=%d, h=%d, b=%d\n", - yyval,nrow,ncol,eht[yyval],ebase[yyval]); + if (dbg) + printf(".\tmatrix S%d: r=%d, c=%d, h=%d, b=%d\n", + yyval, nrow, ncol, eht[yyval], ebase[yyval]); printf(".ds %d \"", yyval); - for( i=0; i<ncol; i++ ) { - printf("\\*(%d%s", val[i], i==ncol-1 ? "" : space); + for (i = 0; i < ncol; i++) { + printf("\\*(%d%s", val[i], i == ncol-1 ? "" : space); ofree(val[i]); } printf("\n"); diff --git a/usr/src/cmd/eqn/move.c b/usr/src/cmd/eqn/move.c index f7e8a53002..b32a76ba0b 100644 --- a/usr/src/cmd/eqn/move.c +++ b/usr/src/cmd/eqn/move.c @@ -1,39 +1,41 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" -# include "e.def" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" +#include "e.def" -move(dir, amt, p) int dir, amt, p; { +void +move(int dir, int amt, int p) +{ int a; yyval = p; #ifndef NEQN a = VERT(EM(amt/100.0, EFFPS(ps))); -#else NEQN - a = VERT( (amt+49)/50 ); /* nearest number of half-lines */ -#endif NEQN +#else /* NEQN */ + a = VERT((amt+49)/50); /* nearest number of half-lines */ +#endif /* NEQN */ printf(".ds %d ", yyval); - if( dir == FWD || dir == BACK ) /* fwd, back */ - printf("\\h'%s%du'\\*(%d\n", (dir==BACK) ? "-" : "", a, p); + if (dir == FWD || dir == BACK) /* fwd, back */ + printf("\\h'%s%du'\\*(%d\n", (dir == BACK) ? "-" : "", a, p); else if (dir == UP) printf("\\v'-%du'\\*(%d\\v'%du'\n", a, p, a); else if (dir == DOWN) printf("\\v'%du'\\*(%d\\v'-%du'\n", a, p, a); - if(dbg)printf(".\tmove %d dir %d amt %d; h=%d b=%d\n", - p, dir, a, eht[yyval], ebase[yyval]); + if (dbg) + printf(".\tmove %d dir %d amt %d; h=%d b=%d\n", + p, dir, a, eht[yyval], ebase[yyval]); } diff --git a/usr/src/cmd/eqn/over.c b/usr/src/cmd/eqn/over.c index 1389898d9f..639616df9a 100644 --- a/usr/src/cmd/eqn/over.c +++ b/usr/src/cmd/eqn/over.c @@ -1,23 +1,24 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" +#pragma ident "%Z%%M% %I% %E% SMI" -boverb(p1, p2) int p1, p2; { +#include "e.h" + +void +boverb(int p1, int p2) +{ int h, b, treg, d; treg = oalloc(); @@ -25,32 +26,34 @@ boverb(p1, p2) int p1, p2; { #ifndef NEQN d = VERT(EM(0.3, ps)); h = eht[p1] + eht[p2] + d; -#else NEQN +#else /* NEQN */ d = VERT(1); h = eht[p1] + eht[p2]; -#endif NEQN +#endif /* NEQN */ b = eht[p2] - d; - if(dbg)printf(".\tb:bob: S%d <- S%d over S%d; b=%d, h=%d\n", - yyval, p1, p2, b, h); + if (dbg) + printf(".\tb:bob: S%d <- S%d over S%d; b=%d, h=%d\n", + yyval, p1, p2, b, h); nrwid(p1, ps, p1); nrwid(p2, ps, p2); printf(".nr %d \\n(%d\n", treg, p1); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2); #ifndef NEQN printf(".nr %d \\n(%d+\\s%d.5m\\s0\n", treg, treg, EFFPS(ps)); -#endif NEQN - printf(".ds %d \\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\\n", - yyval, eht[p2]-ebase[p2]-d, treg, p2, p2); - printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n", -#ifndef NEQN - p2, p1, -(eht[p2]-ebase[p2]+d+ebase[p1]), p1); - printf("\\h'-\\n(%du-\\n(%du/2u+.1m'\\v'%du'\\l'\\n(%du-.2m'\\h'.1m'\\v'%du'\n", - treg, p1, ebase[p1]+d, treg, d); -#else NEQN - p2, p1, -eht[p2]+ebase[p2]-ebase[p1], p1); - printf("\\h'-\\n(%du-\\n(%du-2u/2u'\\v'%du'\\l'\\n(%du'\\v'%du'\n", - treg, p1, ebase[p1], treg, d); -#endif NEQN +#endif /* NEQN */ + printf(".ds %d \\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\\n", + yyval, eht[p2]-ebase[p2]-d, treg, p2, p2); +#ifndef NEQN + printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n", + p2, p1, -(eht[p2]-ebase[p2]+d+ebase[p1]), p1); + printf("\\h'-\\n(%du-\\n(%du/2u+.1m'\\v'%du'\\l'\\n" + "(%du-.2m'\\h'.1m'\\v'%du'\n", treg, p1, ebase[p1]+d, treg, d); +#else /* NEQN */ + printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n", + p2, p1, -eht[p2]+ebase[p2]-ebase[p1], p1); + printf("\\h'-\\n(%du-\\n(%du-2u/2u'\\v'%du'\\l'\\n(%du'\\v'%du'\n", + treg, p1, ebase[p1], treg, d); +#endif /* NEQN */ ebase[yyval] = b; eht[yyval] = h; lfont[yyval] = rfont[yyval] = 0; diff --git a/usr/src/cmd/eqn/paren.c b/usr/src/cmd/eqn/paren.c index 893faca20e..3ac66be2fa 100644 --- a/usr/src/cmd/eqn/paren.c +++ b/usr/src/cmd/eqn/paren.c @@ -1,52 +1,59 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" + +extern int max(); -paren(leftc, p1, rightc) int p1, leftc, rightc; { +void brack(int, char *, char *, char *); + +void +paren(int leftc, int p1, int rightc) +{ int n, m, h1, j, b1, v; h1 = eht[p1]; b1 = ebase[p1]; yyval = p1; #ifndef NEQN lfont[yyval] = rfont[yyval] = 0; n = (h1 + EM(1.0, EFFPS(ps)) - 1) / EM(1.0, EFFPS(ps)); -#else NEQN +#else /* NEQN */ n = max(b1+VERT(1), h1-b1-VERT(1)) / VERT(1); -#endif NEQN - if( n<2 ) n = 1; +#endif /* NEQN */ + if (n < 2) n = 1; m = n-2; - if (leftc=='{' || rightc == '}') { - n = n%2 ? n : ++n; - if( n<3 ) n=3; + if (leftc == '{' || rightc == '}') { + if ((n % 2) == 0) { + n++; + } + if (n < 3) n = 3; m = n-3; } #ifndef NEQN eht[yyval] = VERT(EM(n, ps)); ebase[yyval] = b1 + (eht[yyval]-h1)/2; v = b1 - h1/2 + VERT(EM(0.4, ps)); -#else NEQN +#else /* NEQN */ eht[yyval] = VERT(2 * n); ebase[yyval] = (n)/2 * VERT(2); if (n%2 == 0) ebase[yyval] -= VERT(1); v = b1 - h1/2 + VERT(1); -#endif NEQN +#endif /* NEQN */ printf(".ds %d \\|\\v'%du'", yyval, v); - switch( leftc ) { + switch (leftc) { case 'n': /* nothing */ case '\0': break; @@ -64,9 +71,9 @@ paren(leftc, p1, rightc) int p1, leftc, rightc; { break; case '{': printf("\\b'\\(lt"); - for(j = 0; j < m; j += 2) printf("\\(bv"); + for (j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(lk"); - for(j = 0; j < m; j += 2) printf("\\(bv"); + for (j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(lb'"); break; case '(': @@ -79,13 +86,14 @@ paren(leftc, p1, rightc) int p1, leftc, rightc; { brack(m, "\\(bv", "\\(bv", "\\(bv"); break; default: - brack(m, (char *) &leftc, (char *) &leftc, (char *) &leftc); + brack(m, (char *)&leftc, (char *)&leftc, + (char *)&leftc); break; } printf("\\v'%du'\\*(%d", -v, p1); - if( rightc ) { + if (rightc) { printf("\\|\\v'%du'", v); - switch( rightc ) { + switch (rightc) { case 'f': /* floor */ if (n <= 1) printf("\\(rf"); @@ -100,9 +108,9 @@ paren(leftc, p1, rightc) int p1, leftc, rightc; { break; case '}': printf("\\b'\\(rt"); - for(j = 0; j< m; j += 2)printf("\\(bv"); + for (j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(rk"); - for(j = 0; j< m; j += 2) printf("\\(bv"); + for (j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(rb'"); break; case ']': @@ -115,20 +123,24 @@ paren(leftc, p1, rightc) int p1, leftc, rightc; { brack(m, "\\(bv", "\\(bv", "\\(bv"); break; default: - brack(m, (char *) &rightc, (char *) &rightc, (char *) &rightc); + brack(m, (char *)&rightc, (char *)&rightc, + (char *)&rightc); break; } printf("\\v'%du'", -v); } printf("\n"); - if(dbg)printf(".\tcurly: h=%d b=%d n=%d v=%d l=%c, r=%c\n", - eht[yyval], ebase[yyval], n, v, leftc, rightc); + if (dbg) + printf(".\tcurly: h=%d b=%d n=%d v=%d l=%c, r=%c\n", + eht[yyval], ebase[yyval], n, v, leftc, rightc); } -brack(m, t, c, b) int m; char *t, *c, *b; { +void +brack(int m, char *t, char *c, char *b) +{ int j; printf("\\b'%s", t); - for( j=0; j<m; j++) + for (j = 0; j < m; j++) printf("%s", c); printf("%s'", b); } diff --git a/usr/src/cmd/eqn/pile.c b/usr/src/cmd/eqn/pile.c index 170ed6968a..48fe129de1 100644 --- a/usr/src/cmd/eqn/pile.c +++ b/usr/src/cmd/eqn/pile.c @@ -1,87 +1,89 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" -lpile(type, p1, p2) int type, p1, p2; { +void +lpile(int type, int p1, int p2) +{ int bi, hi, i, gap, h, b, nlist, nlist2, mid; yyval = oalloc(); #ifndef NEQN gap = VERT(EM(0.4, ps)); /* 4/10 m between blocks */ -#else NEQN +#else /* NEQN */ gap = VERT(1); -#endif NEQN - if( type=='-' ) gap = 0; +#endif /* NEQN */ + if (type == '-') gap = 0; nlist = p2 - p1; nlist2 = (nlist+1)/2; mid = p1 + nlist2 -1; h = 0; - for( i=p1; i<p2; i++ ) + for (i = p1; i < p2; i++) h += eht[lp[i]]; eht[yyval] = h + (nlist-1)*gap; b = 0; - for( i=p2-1; i>mid; i-- ) + for (i = p2-1; i > mid; i--) b += eht[lp[i]] + gap; - ebase[yyval] = (nlist%2) ? b + ebase[lp[mid]] #ifndef NEQN - : b - VERT(EM(0.5, ps)) - gap; -#else NEQN - : b - VERT(1) - gap; -#endif NEQN - if(dbg) { + ebase[yyval] = (nlist%2) ? b + ebase[lp[mid]] + : b - VERT(EM(0.5, ps)) - gap; +#else /* NEQN */ + ebase[yyval] = (nlist%2) ? b + ebase[lp[mid]] + : b - VERT(1) - gap; +#endif /* NEQN */ + if (dbg) { printf(".\tS%d <- %c pile of:", yyval, type); - for( i=p1; i<p2; i++) + for (i = p1; i < p2; i++) printf(" S%d", lp[i]); printf(";h=%d b=%d\n", eht[yyval], ebase[yyval]); } nrwid(lp[p1], ps, lp[p1]); printf(".nr %d \\n(%d\n", yyval, lp[p1]); - for( i = p1+1; i<p2; i++ ) { + for (i = p1+1; i < p2; i++) { nrwid(lp[i], ps, lp[i]); - printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", - lp[i], yyval, yyval, lp[i]); + printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", + lp[i], yyval, yyval, lp[i]); } - printf(".ds %d \\v'%du'\\h'%du*\\n(%du'\\\n", yyval, ebase[yyval], - type=='R' ? 1 : 0, yyval); - for(i = p2-1; i >=p1; i--) { - hi = eht[lp[i]]; + printf(".ds %d \\v'%du'\\h'%du*\\n(%du'\\\n", yyval, ebase[yyval], + type == 'R' ? 1 : 0, yyval); + for (i = p2-1; i >= p1; i--) { + hi = eht[lp[i]]; bi = ebase[lp[i]]; - switch(type) { + switch (type) { case 'L': - printf("\\v'%du'\\*(%d\\h'-\\n(%du'\\v'0-%du'\\\n", - -bi, lp[i], lp[i], hi-bi+gap); + printf("\\v'%du'\\*(%d\\h'-\\n(%du'\\v'0-%du'\\\n", + -bi, lp[i], lp[i], hi-bi+gap); continue; case 'R': - printf("\\v'%du'\\h'-\\n(%du'\\*(%d\\v'0-%du'\\\n", - -bi, lp[i], lp[i], hi-bi+gap); + printf("\\v'%du'\\h'-\\n(%du'\\*(%d\\v'0-%du'\\\n", + -bi, lp[i], lp[i], hi-bi+gap); continue; case 'C': case '-': - printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d", - -bi, yyval, lp[i], lp[i]); - printf("\\h'-\\n(%du-\\n(%du/2u'\\v'0-%du'\\\n", - yyval, lp[i], hi-bi+gap); + printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d", + -bi, yyval, lp[i], lp[i]); + printf("\\h'-\\n(%du-\\n(%du/2u'\\v'0-%du'\\\n", + yyval, lp[i], hi-bi+gap); continue; } } - printf("\\v'%du'\\h'%du*\\n(%du'\n", eht[yyval]-ebase[yyval]+gap, - type!='R' ? 1 : 0, yyval); - for( i=p1; i<p2; i++ ) + printf("\\v'%du'\\h'%du*\\n(%du'\n", eht[yyval]-ebase[yyval]+gap, + type != 'R' ? 1 : 0, yyval); + for (i = p1; i < p2; i++) ofree(lp[i]); lfont[yyval] = rfont[yyval] = 0; } diff --git a/usr/src/cmd/eqn/shift.c b/usr/src/cmd/eqn/shift.c index 2b6198ef84..58029daac6 100644 --- a/usr/src/cmd/eqn/shift.c +++ b/usr/src/cmd/eqn/shift.c @@ -1,29 +1,30 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" #include "e.def" -bshiftb(p1, dir, p2) int p1, dir, p2; { +void +bshiftb(int p1, int dir, int p2) +{ int shval, d1, h1, b1, h2, b2; #ifndef NEQN int diffps, effps, effps2; char *sh1, *sh2; -#endif NEQN +#endif /* NEQN */ yyval = p1; h1 = eht[p1]; @@ -35,16 +36,16 @@ bshiftb(p1, dir, p2) int p1, dir, p2; { effps2 = EFFPS(ps+deltaps); diffps = deltaps; sh1 = sh2 = ""; -#endif NEQN - if( dir == SUB ) { /* subscript */ +#endif /* NEQN */ + if (dir == SUB) { /* subscript */ #ifndef NEQN /* top 1/2m above bottom of main box */ d1 = VERT(EM(0.5, effps2)); -#else NEQN +#else /* NEQN */ d1 = VERT(1); -#endif NEQN +#endif /* NEQN */ shval = - d1 + h2 - b2; - if( d1+b1 > h2 ) /* move little sub down */ + if (d1+b1 > h2) /* move little sub down */ shval = b1-b2; ebase[yyval] = b1 + max(0, h2-b1-d1); eht[yyval] = h1 + max(0, h2-b1-d1); @@ -53,22 +54,22 @@ bshiftb(p1, dir, p2) int p1, dir, p2; { sh1 = "\\|"; if (rfont[p2] == ITAL) sh2 = "\\|"; -#endif NEQN +#endif /* NEQN */ } else { /* superscript */ #ifndef NEQN /* 4/10 up main box */ d1 = VERT(EM(0.2, effps)); -#else NEQN +#else /* NEQN */ d1 = VERT(1); -#endif NEQN +#endif /* NEQN */ ebase[yyval] = b1; #ifndef NEQN - shval = -VERT( (4 * (h1-b1)) / 10 ) - b2; - if( VERT(4*(h1-b1)/10) + h2 < h1-b1 ) /* raise little super */ -#else NEQN + shval = -VERT((4 * (h1-b1)) / 10) - b2; + if (VERT(4*(h1-b1)/10) + h2 < h1-b1) /* raise little super */ +#else /* NEQN */ shval = -VERT(1) - b2; - if( VERT(1) + h2 < h1-b1 ) /* raise little super */ -#endif NEQN + if (VERT(1) + h2 < h1-b1) /* raise little super */ +#endif /* NEQN */ shval = -(h1-b1) + h2-b2 - d1; #ifndef NEQN eht[yyval] = h1 + max(0, h2-VERT((6*(h1-b1))/10)); @@ -76,107 +77,113 @@ bshiftb(p1, dir, p2) int p1, dir, p2; { sh1 = "\\|"; if (rfont[p2] == ITAL) sh2 = "\\|"; -#else NEQN +#else /* NEQN */ eht[yyval] = h1 + max(0, h2 - VERT(1)); -#endif NEQN +#endif /* NEQN */ } - if(dbg)printf(".\tb:b shift b: S%d <- S%d vert %d S%d vert %d; b=%d, h=%d\n", - yyval, p1, shval, p2, -shval, ebase[yyval], eht[yyval]); + if (dbg) + printf(".\tb:b shift b: S%d <- S%d vert %d S%d vert %d; " + "b=%d, h=%d\n", yyval, p1, shval, p2, -shval, + ebase[yyval], eht[yyval]); #ifndef NEQN - printf(".as %d \\v'%du'\\s-%d%s\\*(%d\\s+%d%s\\v'%du'\n", - yyval, shval, diffps, sh1, p2, diffps, sh2, -shval); + printf(".as %d \\v'%du'\\s-%d%s\\*(%d\\s+%d%s\\v'%du'\n", + yyval, shval, diffps, sh1, p2, diffps, sh2, -shval); ps += deltaps; if (rfont[p2] == ITAL) rfont[p1] = 0; else rfont[p1] = rfont[p2]; -#else NEQN - printf(".as %d \\v'%du'\\*(%d\\v'%du'\n", - yyval, shval, p2, -shval); -#endif NEQN +#else /* NEQN */ + printf(".as %d \\v'%du'\\*(%d\\v'%du'\n", + yyval, shval, p2, -shval); +#endif /* NEQN */ ofree(p2); } -shift(p1) int p1; { +void +shift(int p1) +{ ps -= deltaps; yyval = p1; - if(dbg)printf(".\tshift: %d;ps=%d\n", yyval, ps); + if (dbg) printf(".\tshift: %d;ps=%d\n", yyval, ps); } -shift2(p1, p2, p3) int p1, p2, p3; { +void +shift2(int p1, int p2, int p3) +{ int effps, h1, h2, h3, b1, b2, b3, subsh, d1, d2, supsh, treg; #ifndef NEQN int effps2; -#endif NEQN +#endif /* NEQN */ treg = oalloc(); yyval = p1; - if(dbg)printf(".\tshift2 s%d <- %d %d %d\n", yyval, p1, p2, p3); + if (dbg) printf(".\tshift2 s%d <- %d %d %d\n", yyval, p1, p2, p3); effps = EFFPS(ps+deltaps); #ifndef NEQN - eht[p3] = h3 = VERT( (eht[p3] * effps) / EFFPS(ps) ); + eht[p3] = h3 = VERT((eht[p3] * effps) / EFFPS(ps)); ps += deltaps; effps2 = EFFPS(ps+deltaps); -#endif NEQN +#endif /* NEQN */ h1 = eht[p1]; b1 = ebase[p1]; h2 = eht[p2]; b2 = ebase[p2]; #ifndef NEQN b3 = ebase[p3]; d1 = VERT(EM(0.5, effps2)); -#else NEQN +#else /* NEQN */ h3 = eht[p3]; b3 = ebase[p3]; d1 = VERT(1); -#endif NEQN +#endif /* NEQN */ subsh = -d1+h2-b2; - if( d1+b1 > h2 ) /* move little sub down */ + if (d1+b1 > h2) /* move little sub down */ subsh = b1-b2; #ifndef NEQN - supsh = -VERT( (4*(h1-b1))/10 ) - b3; + supsh = -VERT((4*(h1-b1))/10) - b3; d2 = VERT(EM(0.2, effps)); - if( VERT(4*(h1-b1)/10)+h3 < h1-b1 ) -#else NEQN + if (VERT(4*(h1-b1)/10)+h3 < h1-b1) +#else /* NEQN */ supsh = - VERT(1) - b3; d2 = VERT(1); - if( VERT(1)+h3 < h1-b1 ) -#endif NEQN + if (VERT(1)+h3 < h1-b1) +#endif /* NEQN */ supsh = -(h1-b1) + (h3-b3) - d2; #ifndef NEQN - eht[yyval] = h1 + max(0, h3-VERT( (6*(h1-b1))/10 )) + max(0, h2-b1-d1); -#else NEQN + eht[yyval] = h1 + max(0, h3-VERT((6*(h1-b1))/10)) + max(0, h2-b1-d1); +#else /* NEQN */ eht[yyval] = h1 + max(0, h3-VERT(1)) + max(0, h2-b1-d1); -#endif NEQN +#endif /* NEQN */ ebase[yyval] = b1+max(0, h2-b1-d1); #ifndef NEQN if (rfont[p1] == ITAL && lfont[p2] == ROM) printf(".ds %d \\|\\*(%d\n", p2, p2); if (rfont[p2] == ITAL) printf(".as %d \\|\n", p2); -#endif NEQN +#endif /* NEQN */ nrwid(p2, effps, p2); #ifndef NEQN if (rfont[p1] == ITAL && lfont[p3] == ROM) printf(".ds %d \\|\\|\\*(%d\n", p3, p3); else printf(".ds %d \\|\\*(%d\n", p3, p3); -#endif NEQN +#endif /* NEQN */ nrwid(p3, effps, p3); printf(".nr %d \\n(%d\n", treg, p3); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2); #ifndef NEQN - printf(".as %d \\v'%du'\\s%d\\*(%d\\h'-\\n(%du'\\v'%du'\\\n", - p1, subsh, effps, p2, p2, -subsh+supsh); - printf("\\s%d\\*(%d\\h'-\\n(%du+\\n(%du'\\s%d\\v'%du'\n", - effps, p3, p3, treg, effps2, -supsh); -#else NEQN - printf(".as %d \\v'%du'\\*(%d\\h'-\\n(%du'\\v'%du'\\\n", - p1, subsh, p2, p2, -subsh+supsh); - printf("\\*(%d\\h'-\\n(%du+\\n(%du'\\v'%du'\n", - p3, p3, treg, -supsh); -#endif NEQN + printf(".as %d \\v'%du'\\s%d\\*(%d\\h'-\\n(%du'\\v'%du'\\\n", + p1, subsh, effps, p2, p2, -subsh+supsh); + printf("\\s%d\\*(%d\\h'-\\n(%du+\\n(%du'\\s%d\\v'%du'\n", + effps, p3, p3, treg, effps2, -supsh); +#else /* NEQN */ + printf(".as %d \\v'%du'\\*(%d\\h'-\\n(%du'\\v'%du'\\\n", + p1, subsh, p2, p2, -subsh+supsh); + printf("\\*(%d\\h'-\\n(%du+\\n(%du'\\v'%du'\n", + p3, p3, treg, -supsh); +#endif /* NEQN */ ps += deltaps; #ifndef NEQN if (rfont[p2] == ITAL) rfont[yyval] = 0; /* lie */ -#endif NEQN +#endif /* NEQN */ ofree(p2); ofree(p3); ofree(treg); } diff --git a/usr/src/cmd/eqn/size.c b/usr/src/cmd/eqn/size.c index 86ad0873e0..d5275a766e 100644 --- a/usr/src/cmd/eqn/size.c +++ b/usr/src/cmd/eqn/size.c @@ -1,24 +1,23 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" -setsize(p) /* set size as found in p */ -char *p; +void +setsize(char *p) /* set size as found in p */ { if (*p == '+') ps += atoi(p+1); @@ -26,24 +25,29 @@ char *p; ps -= atoi(p+1); else ps = atoi(p); - if(dbg)printf(".\tsetsize %s; ps = %d\n", p, ps); + if (dbg) printf(".\tsetsize %s; ps = %d\n", p, ps); } -size(p1, p2) int p1, p2; { - /* old size in p1, new in ps */ +void +size(int p1, int p2) +{ + /* old size in p1, new in ps */ + int effps, effp1; yyval = p2; - if(dbg)printf(".\tb:sb: S%d <- \\s%d S%d \\s%d; b=%d, h=%d\n", - yyval, ps, p2, p1, ebase[yyval], eht[yyval]); + if (dbg) + printf(".\tb:sb: S%d <- \\s%d S%d \\s%d; b=%d, h=%d\n", + yyval, ps, p2, p1, ebase[yyval], eht[yyval]); effps = EFFPS(ps); effp1 = EFFPS(p1); - printf(".ds %d \\s%d\\*(%d\\s%d\n", - yyval, effps, p2, effp1); + printf(".ds %d \\s%d\\*(%d\\s%d\n", yyval, effps, p2, effp1); ps = p1; } -globsize() { +void +globsize(void) +{ char temp[20]; getstr(temp, 20); diff --git a/usr/src/cmd/eqn/sqrt.c b/usr/src/cmd/eqn/sqrt.c index cbf0d6093d..7f48952e46 100644 --- a/usr/src/cmd/eqn/sqrt.c +++ b/usr/src/cmd/eqn/sqrt.c @@ -1,48 +1,51 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" -sqrt(p2) int p2; { +void +sqrt(int p2) +{ #ifndef NEQN int nps; nps = EFFPS(((eht[p2]*9)/10+(resolution/POINT-1))/(resolution/POINT)); -#endif NEQN +#endif /* NEQN */ yyval = p2; #ifndef NEQN eht[yyval] = VERT(EM(1.2, nps)); - if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n", - yyval, p2, ebase[yyval], eht[yyval]); + if (dbg) + printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n", + yyval, p2, ebase[yyval], eht[yyval]); if (rfont[yyval] == ITAL) printf(".as %d \\|\n", yyval); -#endif NEQN +#endif /* NEQN */ nrwid(p2, ps, p2); #ifndef NEQN - printf(".ds %d \\v'%du'\\s%d\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'\\s%d", - yyval, ebase[p2], nps, p2, ps); + printf(".ds %d \\v'%du'\\s%d\\v'-.2m'\\(sr\\l'\\n(%du\\" + "(rn'\\v'.2m'\\s%d", yyval, ebase[p2], nps, p2, ps); printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2); lfont[yyval] = ROM; -#else NEQN +#else /* NEQN */ printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'", - p2, ebase[p2], -eht[p2], p2); + p2, ebase[p2], -eht[p2], p2); printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2); eht[p2] += VERT(1); - if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n", - p2, p2, ebase[p2], eht[p2]); -#endif NEQN + if (dbg) + printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n", + p2, p2, ebase[p2], eht[p2]); +#endif /* NEQN */ } diff --git a/usr/src/cmd/eqn/text.c b/usr/src/cmd/eqn/text.c index 894977a92e..5c7ae4b115 100644 --- a/usr/src/cmd/eqn/text.c +++ b/usr/src/cmd/eqn/text.c @@ -1,22 +1,21 @@ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ - /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ - -/* - * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. - * All Rights Reserved. - */ - -#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ -# include "e.h" -# include "e.def" +#pragma ident "%Z%%M% %I% %E% SMI" + +#include "e.h" +#include "e.def" #include <locale.h> int csp; @@ -26,7 +25,14 @@ char cs[420]; int lf, rf; /* temporary spots for left and right fonts */ -text(t,p1) int t; char *p1; { +void name4(int, int); +void roman(int); +void shim(void); +int trans(int, char *); + +void +text(int t, char *p1) +{ int c; char *p; tbl *tp, *lookup(); @@ -36,43 +42,48 @@ text(t,p1) int t; char *p1; { ebase[yyval] = 0; #ifndef NEQN eht[yyval] = VERT(EM(1.0, EFFPS(ps))); /* ht in machine units */ -#else NEQN +#else /* NEQN */ eht[yyval] = VERT(2); /* 2 half-spaces */ -#endif NEQN +#endif /* NEQN */ lfont[yyval] = rfont[yyval] = ROM; if (t == QTEXT) p = p1; - else if ( t == SPACE ) + else if (t == SPACE) p = "\\ "; - else if ( t == THIN ) + else if (t == THIN) p = "\\|"; - else if ( t == TAB ) + else if (t == TAB) p = "\\t"; else if ((tp = lookup(&restbl, p1, NULL)) != NULL) p = tp->defn; else { lf = rf = 0; - for (csp=psp=0; (c=p1[psp++])!='\0';) { + for (csp = psp = 0; (c = p1[psp++]) != '\0'; ) { rf = trans(c, p1); if (lf == 0) lf = rf; /* save first */ - if (csp>CSSIZE) - error(FATAL, gettext("converted token %.25s... too long") ,p1); + if (csp > CSSIZE) + error(FATAL, gettext( + "converted token %.25s... too long"), p1); } cs[csp] = '\0'; p = cs; lfont[yyval] = lf; rfont[yyval] = rf; } - if(dbg)printf(".\t%dtext: S%d <- %s; b=%d,h=%d,lf=%c,rf=%c\n", - t, yyval, p, ebase[yyval], eht[yyval], lfont[yyval], rfont[yyval]); + if (dbg) + printf(".\t%dtext: S%d <- %s; b=%d,h=%d,lf=%c,rf=%c\n", + t, yyval, p, ebase[yyval], eht[yyval], lfont[yyval], + rfont[yyval]); printf(".ds %d \"%s\n", yyval, p); } -trans(c,p1) int c; char *p1; { +int +trans(int c, char *p1) +{ int f; f = ROM; - switch( c) { + switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case ':': case ';': case '!': case '%': @@ -95,7 +106,7 @@ trans(c,p1) int c; char *p1; { case '=': if (rf == ITAL) shim(); - name4('e','q'); + name4('e', 'q'); break; case '+': if (rf == ITAL) @@ -105,26 +116,26 @@ trans(c,p1) int c; char *p1; { case '>': case '<': if (rf == ITAL) shim(); - if (p1[psp]=='=') { /* look ahead for == <= >= */ - name4(c,'='); + if (p1[psp] == '=') { /* look ahead for == <= >= */ + name4(c, '='); psp++; } else { - cs[csp++] = c; + cs[csp++] = c; } break; case '-': if (rf == ITAL) shim(); - if (p1[psp]=='>') { - name4('-','>'); psp++; + if (p1[psp] == '>') { + name4('-', '>'); psp++; } else { - name4('m','i'); + name4('m', 'i'); } break; case '/': if (rf == ITAL) shim(); - name4('s','l'); + name4('s', 'l'); break; case '~': case ' ': shim(); shim(); break; @@ -134,24 +145,29 @@ trans(c,p1) int c; char *p1; { if (rf == ITAL) shim(); cs[csp++] = c; cs[csp++] = c = p1[psp++]; cs[csp++] = p1[psp++]; - if (c=='(') cs[csp++] = p1[psp++]; - if (c=='*' && cs[csp-1] == '(') { + if (c == '(') cs[csp++] = p1[psp++]; + if (c == '*' && cs[csp-1] == '(') { cs[csp++] = p1[psp++]; cs[csp++] = p1[psp++]; } break; case '\'': - cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = rf==ITAL ? ITAL : ROM; - name4('f','m'); + cs[csp++] = '\\'; + cs[csp++] = 'f'; + cs[csp++] = rf == ITAL ? ITAL : ROM; + name4('f', 'm'); cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = 'P'; - f = rf==ITAL ? ITAL : ROM; + f = rf == ITAL ? ITAL : ROM; break; case 'f': if (ft == ITAL) { cs[csp++] = '\\'; cs[csp++] = '^'; cs[csp++] = 'f'; - cs[csp++] = '\\'; cs[csp++] = '|'; /* trying | instead of ^ */ + + /* trying | instead of ^ */ + cs[csp++] = '\\'; cs[csp++] = '|'; + f = ITAL; } else @@ -168,23 +184,29 @@ trans(c,p1) int c; char *p1; { break; default: cs[csp++] = c; - f = ft==ITAL ? ITAL : ROM; + f = ft == ITAL ? ITAL : ROM; break; } - return(f); + return (f); } -shim() { +void +shim(void) +{ cs[csp++] = '\\'; cs[csp++] = '|'; } -roman(c) int c; { +void +roman(int c) +{ cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = ROM; cs[csp++] = c; cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = 'P'; } -name4(c1,c2) int c1,c2; { +void +name4(int c1, int c2) +{ cs[csp++] = '\\'; cs[csp++] = '('; cs[csp++] = c1; |
