# # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright (c) 1989 by Sun Microsystems, Inc. # # cmd/eqn/Makefile # include ../Makefile.cmd SUBDIR1 = eqnchar.d SUBDIR2 = neqn.d eqn.d SUBDIRS = $(SUBDIR1) $(SUBDIR2) all : TARGET= all install : TARGET= install clean : TARGET= clean clobber : TARGET= clobber strip : TARGET= strip # # for message catalog # _msg : TARGET= catalog POFILE= eqn.po # Hammerhead: GNU Make % substitution only replaces first %; use foreach. POFILES= $(foreach d,$(SUBDIR2),$(d)/$(d).po) .KEEP_STATE : all : $(SUBDIRS) install clean clobber lint strip : $(SUBDIRS) $(POFILE): $(SUBDIR2) $(RM) $@ cat $(POFILES) > $(POFILE) $(SUBDIRS) : FRC @cd $@; pwd; $(MAKE) $(TARGET) FRC : include ../Makefile.targ Copyright (c) 1980 Regents of the University of California. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the University of California, Berkeley and its contributors. 4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PORTIONS OF EQN COMMAND FUNCTIONALITY /* * 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. */ #include "e.h" #include "e.def" void diacrit(int p1, int type) { int c, t; #ifndef NEQN int effps; #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 */ effps = EFFPS(ps); nrwid(p1, effps, p1); /* 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); /* 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) { case VEC: /* vec */ #ifndef NEQN printf(".ds %d \\v'-.4m'\\s%d\\(->\\s0\\v'.4m'\n", c, max(effps-3, 6)); break; #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", c, max(effps-3, 6)); #endif /* NEQN */ break; case HAT: printf(".ds %d ^\n", c); break; case TILDE: printf(".ds %d ~\n", c); break; case DOT: #ifndef 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 */ break; case DOTDOT: #ifndef 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 */ 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 */ 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 */ printf(".ds %d \\l'\\n(%du'\n", c, p1); #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("\\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); printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u'\n", c, p1); #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 (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 */ ofree(c); ofree(t); } /* * 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. */ #ifndef _E_H #define _E_H #ifdef __cplusplus extern "C" { #endif #include #define FATAL 1 #define ROM '1' #ifndef NEQN #define ITAL '2' #define BLD '3' #else /* NEQN */ #define ITAL '1' #define BLD '1' #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 VERT(n) (20 * (n)) #endif /* NEQN */ #define EFFPS(p) ((p) >= 6 ? (p) : 6) extern int dbg; extern int ct; extern int lp[]; extern int used[]; /* available registers */ extern int ps; /* dflt init pt size */ extern int resolution; /* resolution of ditroff */ extern int deltaps; /* default change in ps */ extern int gsize; /* global size */ extern int gfont; /* global font */ extern int ft; /* dflt font */ extern FILE *curfile; /* current input file */ extern int ifile; /* input file number */ extern int linect; /* line number in current file */ extern int eqline; /* line where eqn started */ extern int svargc; extern char **svargv; extern int eht[]; extern int ebase[]; extern int lfont[]; extern int rfont[]; extern int yyval; extern int *yypv; extern int yylval; extern int eqnreg, eqnht; extern int lefteq, righteq; extern int lastchar; /* last character read by lex */ extern int markline; /* 1 if this EQ/EN contains mark or lineup */ typedef struct s_tbl { char *name; char *defn; struct s_tbl *next; } tbl; extern char *spaceval; /* use in place of normal \x (for pic) */ #ifdef __cplusplus } #endif #endif /* _E_H */ %{ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ %} /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ %{# # ident "%Z%%M% %I% %E% SMI" /* "@(#)ucbeqn:e.y 1.1" */ #include "e.h" #include # int fromflg; %} %term CONTIG QTEXT SPACE THIN TAB %term MATRIX LCOL CCOL RCOL COL %term MARK LINEUP %term SUM INT PROD UNION INTER %term LPILE PILE CPILE RPILE ABOVE %term DEFINE TDEFINE NDEFINE DELIM GSIZE GFONT INCLUDE %right FROM TO %left OVER SQRT %right SUP SUB %right SIZE FONT ROMAN ITALIC BOLD FAT %right UP DOWN BACK FWD %left LEFT RIGHT %right DOT DOTDOT HAT TILDE BAR UNDER VEC DYAD %% stuff : eqn { putout($1); } | error { error(!FATAL, gettext("syntax error")); } | { eqnreg = 0; } ; eqn : box | eqn box { eqnbox($1, $2, 0); } | eqn lineupbox { eqnbox($1, $2, 1); } | LINEUP { lineup(0); } ; lineupbox: LINEUP box { $$ = $2; lineup(1); } ; matrix : MATRIX { $$ = ct; } ; collist : column | collist column ; column : lcol '{' list '}' { column('L', $1); } | ccol '{' list '}' { column('C', $1); } | rcol '{' list '}' { column('R', $1); } | col '{' list '}' { column('-', $1); } ; lcol : LCOL { $$ = ct++; } ; ccol : CCOL { $$ = ct++; } ; rcol : RCOL { $$ = ct++; } ; col : COL { $$ = ct++; } ; sbox : sup box %prec SUP { $$ = $2; } ; tbox : to box %prec TO { $$ = $2; } | %prec FROM { $$ = 0; } ; box : box OVER box { boverb($1, $3); } | MARK box { mark($2); } | size box %prec SIZE { size($1, $2); } | font box %prec FONT { font($1, $2); } | FAT box { fatbox($2); } | SQRT box { sqrt($2); } | lpile '{' list '}' { lpile('L', $1, ct); ct = $1; } | cpile '{' list '}' { lpile('C', $1, ct); ct = $1; } | rpile '{' list '}' { lpile('R', $1, ct); ct = $1; } | pile '{' list '}' { lpile('-', $1, ct); ct = $1; } | box sub box sbox %prec SUB { shift2($1, $3, $4); } | box sub box %prec SUB { bshiftb($1, $2, $3); } | box sup box %prec SUP { bshiftb($1, $2, $3); } | int sub box sbox %prec SUB { integral($1, $3, $4); } | int sub box %prec SUB { integral($1, $3, 0); } | int sup box %prec SUP { integral($1, 0, $3); } | int { integral($1, 0, 0); } | left eqn right { paren($1, $2, $3); } | pbox | box from box tbox %prec FROM { fromto($1, $3, $4); fromflg=0; } | box to box %prec TO { fromto($1, 0, $3); } | box diacrit { diacrit($1, $2); } | fwd box %prec UP { move(FWD, $1, $2); } | up box %prec UP { move(UP, $1, $2); } | back box %prec UP { move(BACK, $1, $2); } | down box %prec UP { move(DOWN, $1, $2); } | matrix '{' collist '}' { matrix($1); } ; int : INT { setintegral(); } ; fwd : FWD text { $$ = atoi((char *) $1); } ; up : UP text { $$ = atoi((char *) $1); } ; back : BACK text { $$ = atoi((char *) $1); } ; down : DOWN text { $$ = atoi((char *) $1); } ; diacrit : HAT { $$ = HAT; } | VEC { $$ = VEC; } | DYAD { $$ = DYAD; } | BAR { $$ = BAR; } | UNDER { $$ = UNDER; } /* under bar */ | DOT { $$ = DOT; } | TILDE { $$ = TILDE; } | DOTDOT { $$ = DOTDOT; } /* umlaut = double dot */ ; from : FROM { $$=ps; ps -= 3; fromflg = 1; if(dbg)printf(".\tfrom: old ps %d, new ps %d, fflg %d\n", $$, ps, fromflg); } ; to : TO { $$=ps; if(fromflg==0)ps -= 3; if(dbg)printf(".\tto: old ps %d, new ps %d\n", $$, ps); } ; left : LEFT text { $$ = ((char *)$2)[0]; } | LEFT '{' { $$ = '{'; } ; right : RIGHT text { $$ = ((char *)$2)[0]; } | RIGHT '}' { $$ = '}'; } | { $$ = 0; } ; list : eqn { lp[ct++] = $1; } | list ABOVE eqn { lp[ct++] = $3; } ; lpile : LPILE { $$ = ct; } ; cpile : CPILE { $$ = ct; } ; pile : PILE { $$ = ct; } ; rpile : RPILE { $$ = ct; } ; size : SIZE text { $$ = ps; setsize((char *) $2); } ; font : ROMAN { setfont(ROM); } | ITALIC { setfont(ITAL); } | BOLD { setfont(BLD); } | FONT text { setfont(((char *)$2)[0]); } ; sub : SUB { shift(SUB); } ; sup : SUP { shift(SUP); } ; pbox : '{' eqn '}' { $$ = $2; } | QTEXT { text(QTEXT, (char *) $1); } | CONTIG { text(CONTIG, (char *) $1); } | SPACE { text(SPACE, 0); } | THIN { text(THIN, 0); } | TAB { text(TAB, 0); } | SUM { funny(SUM); } | PROD { funny(PROD); } | UNION { funny(UNION); } | INTER { funny(INTER); } /* intersection */ ; text : CONTIG | QTEXT ; %% # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Copyright (c) 2018, Joyent, Inc. # include ../../Makefile.cmd PROG = eqn CSRCS = diacrit.c eqnbox.c font.c fromto.c funny.c \ glob.c integral.c io.c lex.c lookup.c \ mark.c matrix.c move.c over.c paren.c \ pile.c shift.c size.c sqrt.c text.c SRCS = $(CSRCS:%=../%) YACCSRC = e.y COBJS = $(CSRCS:%.c=%.o) OBJS = $(YACCSRC:%.y=%.o) $(COBJS) # # for message catalog # POFILE= eqn.d.po POFILES= $(SRCS:%.c=%.po) e.po CLEANFILES = y.tab.c y.tab.h $(YACCSRC:%.y=%.c) $(YACCSRC:%.y=%.def) YFLAGS = -d CPPFLAGS = -I. -I.. $(CPPFLAGS.master) LDFLAGS += $(MAPFILE.NGB:%=-Wl,-M%) CERRWARN += -Wno-implicit-function-declaration CERRWARN += $(CNOWARN_UNINIT) # Hammerhead: Suppress pointer/int cast warnings in legacy eqn code CERRWARN += -Wno-pointer-to-int-cast CERRWARN += -Wno-int-to-pointer-cast # because of labels from yacc e.o : CERRWARN += -Wno-unused-label # not linted SMATCH=off .KEEP_STATE: all : $(PROG) catalog: $(POFILE) $(POFILE): e.def $(POFILES) $(RM) $@ cat $(POFILES) > $@ $(PROG) : $(OBJS) $(MAPFILE.NGB) $(LINK.c) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) $(POST_PROCESS) # Hammerhead: GNU Make grouped target (was dmake +) $(YACCSRC:%.y=%.c) $(YACCSRC:%.y=%.def) &: ../$(YACCSRC) $(YACC.y) ../$(YACCSRC) $(MV) y.tab.c $(YACCSRC:%.y=%.c) $(MV) y.tab.h $(YACCSRC:%.y=%.def) # Hammerhead: Use static pattern rule for GNU Make compatibility $(COBJS): %.o: ../%.c $(COMPILE.c) -o $@ $< install : all $(ROOTPROG) clean: $(RM) $(OBJS) $(CLEANFILES) include ../../Makefile.targ /* * 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. */ #include "e.h" 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]); 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 (rfont[p1] == ITAL && lfont[p2] == ROM) sh = "\\|"; else sh = ""; if (lu) { printf(".nr %d \\w'\\s%d\\*(%d%s'\n", p1, ps, p1, sh); printf(".ds %d \\h'|\\n(97u-\\n(%du'\\*(%d\n", p1, p1, p1); } printf(".as %d \"%s\\*(%d\n", yyval, sh, p2); rfont[p1] = rfont[p2]; ofree(p2); } # # ident "%Z%%M% %I% %E% SMI" # # Copyright (c) 1989 by Sun Microsystems, Inc. # # cmd/bnu/Makefile # include ../../Makefile.cmd FILES = eqnchar iso ascii greek ROOTSHPUB = $(ROOTSHLIB)/pub ROOTSHPUBFILES = $(FILES:%=$(ROOTSHPUB)/%) FILEMODE = 644 .KEEP_STATE : all : $(FILES) install : $(ROOTSHPUB) $(ROOTSHPUBFILES) clean clobber strip lint: $(ROOTSHPUB) : $(INS.dir) $(ROOTSHPUB)/% : % $(INS.file) |000 nul|001 soh|002 stx|003 etx|004 eot|005 enq|006 ack|007 bel| |010 bs |011 ht |012 nl |013 vt |014 np |015 cr |016 so |017 si | |020 dle|021 dc1|022 dc2|023 dc3|024 dc4|025 nak|026 syn|027 etb| |030 can|031 em |032 sub|033 esc|034 fs |035 gs |036 rs |037 us | |040 sp |041 ! |042 " |043 # |044 $ |045 % |046 & |047 ' | |050 ( |051 ) |052 * |053 + |054 , |055 - |056 . |057 / | |060 0 |061 1 |062 2 |063 3 |064 4 |065 5 |066 6 |067 7 | |070 8 |071 9 |072 : |073 ; |074 < |075 = |076 > |077 ? | |100 @ |101 A |102 B |103 C |104 D |105 E |106 F |107 G | |110 H |111 I |112 J |113 K |114 L |115 M |116 N |117 O | |120 P |121 Q |122 R |123 S |124 T |125 U |126 V |127 W | |130 X |131 Y |132 Z |133 [ |134 \ |135 ] |136 ^ |137 _ | |140 ` |141 a |142 b |143 c |144 d |145 e |146 f |147 g | |150 h |151 i |152 j |153 k |154 l |155 m |156 n |157 o | |160 p |161 q |162 r |163 s |164 t |165 u |166 v |167 w | |170 x |171 y |172 z |173 { |174 | |175 } |176 ~ |177 del| | 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel| | 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si | | 10 dle| 11 dc1| 12 dc2| 13 dc3| 14 dc4| 15 nak| 16 syn| 17 etb| | 18 can| 19 em | 1a sub| 1b esc| 1c fs | 1d gs | 1e rs | 1f us | | 20 sp | 21 ! | 22 " | 23 # | 24 $ | 25 % | 26 & | 27 ' | | 28 ( | 29 ) | 2a * | 2b + | 2c , | 2d - | 2e . | 2f / | | 30 0 | 31 1 | 32 2 | 33 3 | 34 4 | 35 5 | 36 6 | 37 7 | | 38 8 | 39 9 | 3a : | 3b ; | 3c < | 3d = | 3e > | 3f ? | | 40 @ | 41 A | 42 B | 43 C | 44 D | 45 E | 46 F | 47 G | | 48 H | 49 I | 4a J | 4b K | 4c L | 4d M | 4e N | 4f O | | 50 P | 51 Q | 52 R | 53 S | 54 T | 55 U | 56 V | 57 W | | 58 X | 59 Y | 5a Z | 5b [ | 5c \ | 5d ] | 5e ^ | 5f _ | | 60 ` | 61 a | 62 b | 63 c | 64 d | 65 e | 66 f | 67 g | | 68 h | 69 i | 6a j | 6b k | 6c l | 6d m | 6e n | 6f o | | 70 p | 71 q | 72 r | 73 s | 74 t | 75 u | 76 v | 77 w | | 78 x | 79 y | 7a z | 7b { | 7c | | 7d } | 7e ~ | 7f del| .EQ tdefine ciplus % "\(pl\h'-\w'\(pl\^'u'\v'.3n'\(ci\v'-.3n'" % ndefine ciplus % O+ % tdefine citimes % "\(mu\h'-\w'\(mu\^'u'\v'.3n'\(ci\v'-.3n'" % ndefine citimes % Ox % tdefine =wig % "\(~=" % ndefine =wig % ="~" % tdefine bigstar %{ roman "\v'.5n'\s+4*\s-4\v'-.5n'"}% ndefine bigstar % X|- % tdefine =dot % "\z\s+2\(eq\s-2\v'-.6m'\h'.2m'\s+2.\s-2\v'.6m'\h'.1m'" % ndefine =dot % = dot % tdefine orsign % "\e\s+1\(sl\s-1" % ndefine orsign % \e/ % tdefine andsign % "\s+1\(sl\s-1\e" % ndefine andsign % /\e % tdefine =del % "\v'.3m'\z=\v'-.6m'\h'.3n'\s-2\(*D\s+2\v'.3m'" % ndefine =del % = to DELTA % tdefine oppA % "\v'-.3n'\z\(mi\v'.3n'\e\s+1\(sl\s-1" % ndefine oppA % V- % tdefine oppE %"\s-3\v'.2m'\z\(em\v'-.5m'\z\(em\v'-.5m'\z\(em\v'.55m'\h'.9m'\z\(br\z\(br\v'.25m'\s+3" % ndefine oppE % E/ % tdefine incl % "\s-2\(or\v'-.4m'\z\(em\v'.75m'\z\(em\v'.2m'\(em\v'-.55m'\s+2" % ndefine incl % C_ % tdefine nomem % "\o'\(mo\(sl'" % ndefine nomem % C-/ % tdefine angstrom % "\fR\zA\v'-.3m'\h'.2m'\(de\v'.3m'\fP\h'.2m'" % ndefine angstrom % A to o % tdefine star %{ roman "\v'.5n'\s+2*\s-2\v'-.5n'"}% ndefine star % * % tdefine || % \(or\(or % tdefine wig % "\z>\v'.4m'\(ap\v'-.4m'" % ndefine >wig %{ > from "~" }% tdefine langle % "\v'-.3n'\s-1\z\(sl\s-1\v'1n'\e\v'-1n'\s+2\v'.3n'" % ndefine langle %<% tdefine rangle % "\v'-.3n'\s-2\z\e\s+1\v'1n'\(sl\v'-1n'\s+1\v'.3n'" % ndefine rangle %>% tdefine hbar % "\zh\v'-.6m'\h'.05m'\(ru\v'.6m'" % ndefine hbar % h\u-\d % tdefine ppd % "\o'\(ru\s-3\(or\s+3'" % ndefine ppd % _| % tdefine <-> % "\z\(<-\|\(->" % ndefine <-> % "<-->" % tdefine <=> % "\z\(lh\|\(rh" % ndefine <=> % "<=>" % tdefine |< % "\o'<\(or'" % ndefine |< % <| % tdefine |> % "\o'>\(or'" % ndefine |> % |> % tdefine ang % "\z\(sl\v'-.1n'\(ru\v'.1n'" % ndefine ang % /_ % tdefine rang % "\v'-.2n'\(or\v'.1n'\(ru\v'.1n'" % ndefine rang % L % tdefine 3dot % "\v'-.7m'\z.\v'.4m'\z.\v'.4m'.\v'-.1m'" % ndefine 3dot % .\u.\u.\d\d % tdefine thf % ".\v'-.5m'.\v'.5m'." % ndefine thf % ..\u.\d % tdefine quarter % roman \(14 % ndefine quarter % 1/4 % tdefine 3quarter % roman \(34 % ndefine 3quarter % 3/4 % tdefine degree % \(de % ndefine degree % nothing sup o % tdefine square % \(sq % ndefine square % [] % tdefine circle % \(ci % ndefine circle % O % tdefine blot % "\fB\(sq\fP" % ndefine blot % HIX % tdefine bullet % \(bu % ndefine bullet % oxe % tdefine -wig % "\(mi\h'-\w'\(mi'u-\w'\(ap'u/2u'\v'-.4n'\(ap\v'.4n'\h'\w'\(mi'u-\w'\(ap'u/2u'" % ndefine -wig % - to "~" % tdefine wig % \(ap % ndefine wig % "~" % tdefine prop % \(pt % ndefine prop % oc % tdefine empty % \(es % ndefine empty % O/ % tdefine member % \(mo % ndefine member % C- % tdefine cup % \(cu % ndefine cup % U % define cap % \(ca % define subset % \(sb % define supset % \(sp % define !subset % \(ib % define !supset % \(ip % .EN alpha A A | beta B B | gamma \ \ GAMMA G G | delta D D | DELTA W W epsilon S S | zeta Q Q | eta N N THETA T T | theta O O | lambda L L LAMBDA E E | mu M M | nu @ @ xi X X | pi J J | PI P P rho K K | sigma Y Y | SIGMA R R tau I I | phi U U | PHI F F psi V V | PSI H H | omega C C OMEGA Z Z | nabla [ [ | not _ _ partial ] ] | integral ^ ^ | 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel| | 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si | | 10 dle| 11 dc1| 12 dc2| 13 dc3| 14 dc4| 15 nak| 16 syn| 17 etb| | 18 can| 19 em | 1a sub| 1b esc| 1c fs | 1d gs | 1e rs | 1f us | | 20 sp | 21 ! | 22 " | 23 # | 24 $ | 25 % | 26 & | 27 ' | | 28 ( | 29 ) | 2a * | 2b + | 2c , | 2d - | 2e . | 2f / | | 30 0 | 31 1 | 32 2 | 33 3 | 34 4 | 35 5 | 36 6 | 37 7 | | 38 8 | 39 9 | 3a : | 3b ; | 3c < | 3d = | 3e > | 3f ? | | 40 @ | 41 A | 42 B | 43 C | 44 D | 45 E | 46 F | 47 G | | 48 H | 49 I | 4a J | 4b K | 4c L | 4d M | 4e N | 4f O | | 50 P | 51 Q | 52 R | 53 S | 54 T | 55 U | 56 V | 57 W | | 58 X | 59 Y | 5a Z | 5b [ | 5c \ | 5d ] | 5e ^ | 5f _ | | 60 ` | 61 a | 62 b | 63 c | 64 d | 65 e | 66 f | 67 g | | 68 h | 69 i | 6a j | 6b k | 6c l | 6d m | 6e n | 6f o | | 70 p | 71 q | 72 r | 73 s | 74 t | 75 u | 76 v | 77 w | | 78 x | 79 y | 7a z | 7b { | 7c | | 7d } | 7e ~ | 7f del| | a0 nbs| a1 ¡ | a2 ¢ | a3 £ | a4 ¤ | a5 ¥ | a6 ¦ | a7 § | | a8 ¨ | a9 © | aa ª | ab « | ac ¬ | ad ­ | ae ® | af ¯ | | b0 ° | b1 ± | b2 ² | b3 ³ | b4 ´ | b5 µ | b6 ¶ | b7 · | | b8 ¸ | b9 ¹ | ba º | bb » | bc ¼ | bd ½ | be ¾ | bf ¿ | | c0 À | c1 Á | c2 Â | c3 Ã | c4 Ä | c5 Å | c6 Æ | c7 Ç | | c8 È | c9 É | ca Ê | cb Ë | cc Ì | cd Í | ce Î | cf Ï | | d0 Ð | d1 Ñ | d2 Ò | d3 Ó | d4 Ô | d5 Õ | d6 Ö | d7 × | | d8 Ø | d9 Ù | da Ú | db Û | dc Ü | dd Ý | de Þ | df ß | | e0 à | e1 á | e2 â | e3 ã | e4 ä | e5 å | e6 æ | e7 ç | | e8 è | e9 é | ea ê | eb ë | ec ì | ed í | ee î | ef ï | | f0 ð | f1 ñ | f2 ò | f3 ó | f4 ô | f5 õ | f6 ö | f7 ÷ | | f8 ø | f9 ù | fa ú | fb û | fc ü | fd ý | fe þ | ff ÿ | /* * 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. */ #include "e.h" void setfont(char ch1) { /* use number '1', '2', '3' for roman, italic, bold */ yyval = ft; if (ch1 == 'r' || ch1 == 'R') ft = ROM; else if (ch1 == 'i' || ch1 == 'I') ft = ITAL; else if (ch1 == 'b' || ch1 == 'B') ft = BLD; else 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 */ } 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); ft = p1; printf(".ft %c\n", ft); } void fatbox(int p) { yyval = p; 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); } void globfont(void) { char temp[20]; (void) getstr(temp, 20); yyval = eqnreg = 0; gfont = temp[0]; switch (gfont) { case 'r': case 'R': gfont = '1'; break; case 'i': case 'I': gfont = '2'; break; case 'b': case 'B': gfont = '3'; break; } printf(".ft %c\n", gfont); ft = gfont; } /* * 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. */ #include "e.h" void fromto(int p1, int p2, int p3) { int b, h1, b1, pss; yyval = oalloc(); lfont[yyval] = rfont[yyval] = 0; h1 = eht[yyval] = eht[p1]; b1 = ebase[p1]; b = 0; pss = EFFPS(ps); ps += 3; nrwid(p1, ps, p1); printf(".nr %d \\n(%d\n", yyval, p1); if (p2 > 0) { nrwid(p2, pss, 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) { nrwid(p3, pss, 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)); } #ifndef NEQN 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]); ofree(p1); if (p2 > 0) ofree(p2); if (p3 > 0) ofree(p3); } /* * 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. */ #include "e.h" #include "e.def" #include void funny(int n) { char *f; yyval = oalloc(); switch (n) { case SUM: f = "\\(*S"; break; case UNION: f = "\\(cu"; break; case INTER: /* intersection */ f = "\\(ca"; break; case PROD: f = "\\(*P"; break; default: (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); eht[yyval] = VERT(EM(1.0, ps+5) - EM(0.2, ps)); ebase[yyval] = VERT(EM(0.3, ps)); #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]); lfont[yyval] = rfont[yyval] = ROM; } /* 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" int dbg; /* debugging print if non-zero */ int lp[80]; /* stack for things like piles and matrices */ int ct; /* pointer to lp */ int used[100]; /* available registers */ int ps; /* default init point size */ int resolution = 720; /* resolution of ditroff */ int deltaps = 3; /* default change in ps */ int gsize = 10; /* default initial point size */ int gfont = ITAL; /* italic */ int ft; /* default font */ FILE *curfile; /* current input file */ int ifile; int linect; /* line number in file */ int eqline; /* line where eqn started */ int svargc; char **svargv; int eht[100]; int ebase[100]; int lfont[100]; int rfont[100]; int eqnreg; /* register where final string appears */ int eqnht; /* inal height of equation */ int lefteq = '\0'; /* left in-line delimiter */ int righteq = '\0'; /* right in-line delimiter */ int lastchar; /* last character read by lex */ int markline = 0; /* 1 if this EQ/EN contains mark or lineup */ /* * 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. */ #include "e.h" #include "e.def" 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); if (p2 != 0) printf(".ds %d \\v'-0.3m'\\*(%d\\v'0.3m'\n", p2, p2); #endif if (p1 != 0 && p2 != 0) shift2(p, p1, p2); else if (p1 != 0) 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]); lfont[p] = ROM; } 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); eht[yyval] = VERT(EM(1.15, ps+4)); ebase[yyval] = VERT(EM(0.3, ps)); #else /* NEQN */ printf(".ds %d %s\n", yyval, f); eht[yyval] = VERT(2); ebase[yyval] = 0; #endif /* NEQN */ lfont[yyval] = rfont[yyval] = ROM; } /* * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. */ /* 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. */ #include "e.h" #include #include #define MAXLINE 8192 /* maximum input line */ char in[MAXLINE+1]; /* input buffer */ int noeqn; void error(int, char *, char *); static void do_inline(void); int eqn(int, char *[]); static int getaline(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); return (eqn(argc, argv)); } int eqn(int argc, char *argv[]) { int i, type; setfile(argc, argv); init_tbl(); /* install keywords in tables */ while ((type = getaline(in)) != EOF) { eqline = linect; 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) { 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); */ /* 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"); } printf(".ps \\n(99\n.ft \\n(98\n"); printf(".EN"); if (lastchar == EOF) { putchar('\n'); break; } if (putchar(lastchar) != '\n') while (putchar(gtc()) != '\n') ; } else if (type == lefteq) do_inline(); else printf("%s", in); } return (0); } static int getaline(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); in[MAXLINE] = '\0'; break; } if (c == lefteq) s--; *s++ = '\0'; return (c); } 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 { if (*in) printf(".as %d \"%s\n", ds, in); init(); yyparse(); if (eqnreg > 0) { printf(".as %d \\*(%d\n", ds, eqnreg); ofree(eqnreg); } printf(".ps \\n(99\n.ft \\n(98\n"); } while (getaline(in) == lefteq); if (*in) printf(".as %d \"%s", ds, in); printf(".ps \\n(99\n.ft \\n(98\n"); printf("\\*(%d\n", ds); ofree(ds); } 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]); 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 */ before = eht[p1] - ebase[p1] - VERT(3); /* 3 = 1.5 lines */ #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 ? "\\|" : ""); #ifndef NEQN after = ebase[p1] - VERT(EM(0.2, ps)); #else /* NEQN */ after = ebase[p1] - VERT(1); #endif /* NEQN */ if (spaceval == NULL && after > 0) printf("\\x'%du'", after); putchar('\n'); eqnreg = p1; if (spaceval != NULL) { free(spaceval); spaceval = NULL; } } int max(int i, int j) { return (i > j ? i : j); } int oalloc(void) { int i; 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); } void ofree(int n) { used[n] = 0; } void setps(int p) { printf(".ps %d\n", EFFPS(p)); } void nrwid(int n1, int p, int n2) { printf(".nr %d \\w'\\s%d\\*(%d'\n", n1, EFFPS(p), n2); } static void setfile(int argc, char *argv[]) { static char *nullstr = "-"; svargc = --argc; svargv = argv; while (svargc > 0 && svargv[1][0] == '-') { switch (svargv[1][1]) { 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; default: dbg = 1; } svargc--; svargv++; } endargs: ifile = 1; linect = 1; if (svargc <= 0) { curfile = stdin; svargv[1] = nullstr; } else openinfile(); /* opens up the first input file */ } void yyerror(void) { } static void init(void) { ct = 0; ps = gsize; ft = gfont; setps(ps); printf(".ft %c\n", ft); } 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); fprintf(stderr, gettext("eqn: ")); 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); if (fatal > 0) exit(1); } /* * 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. */ #include "e.h" #include "e.def" #include #define SSIZE 400 char token[SSIZE]; int sp; #define putbak(c) *ip++ = c; #define PUSHBACK 300 /* maximum pushback characters */ char ibuf[PUSHBACK+SSIZE]; /* pushback buffer for definitions, etc. */ char *ip = ibuf; extern tbl *keytbl[]; extern tbl *deftbl[]; 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 */ lastchar = getc(curfile); if (lastchar == '\n') linect++; if (lastchar != EOF) return (lastchar); if (++ifile > svargc) { return (EOF); } (void) fclose(curfile); linect = 1; if (openinfile() == 0) goto loop; return (EOF); } /* * open file indexed by ifile in svargv, return non zero if fail */ int openinfile(void) { if (strcmp(svargv[ifile], "-") == 0) { curfile = stdin; return (0); } else if ((curfile = fopen(svargv[ifile], "r")) != NULL) { return (0); } error(FATAL, gettext("can't open file %s"), svargv[ifile]); return (1); } void pbstr(char *str) { char *p; p = str; while (*p++) ; --p; if (ip >= &ibuf[PUSHBACK]) error(FATAL, gettext("pushback overflow")); while (p > str) putbak(*--p); } int yylex(void) { int c; tbl *tp, *lookup(); beg: while ((c = gtc()) == ' ' || c == '\n') ; yylval = c; switch (c) { case EOF: return (EOF); case '~': return (SPACE); case '^': return (THIN); case '\t': return (TAB); case '{': return ('{'); case '}': return ('}'); case '"': 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); } token[sp] = '\0'; yylval = (int)&token[0]; if (c == '\n') error(!FATAL, gettext("missing \" in %.20s"), token); return (QTEXT); } 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) { 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((int)tp->defn); else if (tp->defn == (char *)DELIM) delim(); else if (tp->defn == (char *)GSIZE) globsize(); else if (tp->defn == (char *)GFONT) globfont(); else if (tp->defn == (char *)INCLUDE) include(); else if (tp->defn == (char *)SPACE) space(); else { return ((int)tp->defn); } goto beg; } void getstr(char *s, int n) { int c; char *p; p = s; while ((c = gtc()) == ' ' || c == '\n') ; if (c == EOF) { *s = 0; return; } while (c != ' ' && c != '\t' && c != '\n' && c != '{' && c != '}' && c != '"' && c != '~' && c != '^' && c != righteq) { if (c == '\\') if ((c = gtc()) != '"') *p++ = '\\'; *p++ = c; if (--n <= 0) error(FATAL, gettext("token %.20s... too long"), s); c = gtc(); } if (c == '{' || c == '}' || c == '"' || c == '~' || c == '^' || c == '\t' || c == righteq) putbak(c); *p = '\0'; yylval = (int)s; } 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; ) { s[i++] = c; if (i >= maxs) return (1); /* disaster */ } } else { if (del == '\n') return (1); s[0] = del; for (i = 1; (c = gtc()) != ' ' && c != '\t' && c != '\n' && c != EOF; /* empty */) { s[i++] = c; if (i >= maxs) return (1); /* disaster */ } } s[i] = '\0'; if (c == EOF) error(FATAL, gettext("Unexpected end of input at %.20s"), s); return (0); } void define(int type) { char *strsave(), *p1, *p2; tbl *lookup(); getstr(token, SSIZE); /* get name */ if (type != DEFINE) { (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); p2 = strsave(token); lookup(deftbl, p1, p2); if (dbg) printf(".\tname %s defined as %s\n", p1, p2); } char *spaceval = NULL; void space(void) /* collect line of form "space amt" to replace \x in output */ { char *strsave(); getstr(token, SSIZE); spaceval = strsave(token); if (dbg) printf(".\tsetting space to %s\n", token); } char * strsave(char *s) { char *malloc(); 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); } void include(void) { error(!FATAL, gettext("Include not yet implemented")); } void delim(void) { yyval = eqnreg = 0; if (cstr(token, 0, SSIZE)) error(FATAL, gettext("Bizarre delimiters at %.20s"), token); lefteq = token[0]; righteq = token[1]; if (lefteq == 'o' && righteq == 'f') lefteq = righteq = '\0'; } /* * 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. */ #include "e.h" #include "e.def" #include #define TBLSIZE 100 tbl *keytbl[TBLSIZE]; /* key words */ tbl *restbl[TBLSIZE]; /* reserved words */ 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, #ifdef NEQN /* make ndefine synonym for define, tdefine a no-op */ "tdefine", TDEFINE, "ndefine", DEFINE, #else /* tdefine = define, ndefine = no-op */ "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, 0, 0 }; struct { char *res; char *resval; } resword[] = { ">=", "\\(>=", "<=", "\\(<=", "==", "\\(==", "!=", "\\(!=", "+-", "\\(+-", "->", "\\(->", "<-", "\\(<-", "inf", "\\(if", "infinity", "\\(if", "partial", "\\(pd", "half", "\\f1\\(12\\fP", "prime", "\\f1\\(fm\\fP", "dollar", "\\f1$\\fP", "nothing", "", "times", "\\(mu", "del", "\\(gr", "grad", "\\(gr", #ifdef NEQN "<<", "<<", ">>", ">>", "approx", "~\b\\d~\\u", "cdot", "\\v'-.5'.\\v'.5'", "...", "...", ",...,", ",...,", #else "<<", "<\\h'-.3m'<", ">>", ">\\h'-.3m'>", "approx", "\\v'-.2m'\\z\\(ap\\v'.25m'\\(ap\\v'-.05m'", "cdot", "\\v'-.3m'.\\v'.3m'", "...", "\\v'-.3m'\\ .\\ .\\ .\\ \\v'.3m'", ",...,", ",\\ .\\ .\\ .\\ ,\\|", #endif "alpha", "\\(*a", "beta", "\\(*b", "gamma", "\\(*g", "GAMMA", "\\(*G", "delta", "\\(*d", "DELTA", "\\(*D", "epsilon", "\\(*e", "EPSILON", "\\f1E\\fP", "omega", "\\(*w", "OMEGA", "\\(*W", "lambda", "\\(*l", "LAMBDA", "\\(*L", "mu", "\\(*m", "nu", "\\(*n", "theta", "\\(*h", "THETA", "\\(*H", "phi", "\\(*f", "PHI", "\\(*F", "pi", "\\(*p", "PI", "\\(*P", "sigma", "\\(*s", "SIGMA", "\\(*S", "xi", "\\(*c", "XI", "\\(*C", "zeta", "\\(*z", "iota", "\\(*i", "eta", "\\(*y", "kappa", "\\(*k", "rho", "\\(*r", "tau", "\\(*t", "omicron", "\\(*o", "upsilon", "\\(*u", "UPSILON", "\\(*U", "psi", "\\(*q", "PSI", "\\(*Q", "chi", "\\(*x", "and", "\\f1and\\fP", "for", "\\f1for\\fP", "if", "\\f1if\\fP", "Re", "\\f1Re\\fP", "Im", "\\f1Im\\fP", "sin", "\\f1sin\\fP", "cos", "\\f1cos\\fP", "tan", "\\f1tan\\fP", "sec", "\\f1sec\\fP", "csc", "\\f1csc\\fP", "arc", "\\f1arc\\fP", "asin", "\\f1asin\\fP", "acos", "\\f1acos\\fP", "atan", "\\f1atan\\fP", "asec", "\\f1asec\\fP", "acsc", "\\f1acsc\\fP", "sinh", "\\f1sinh\\fP", "coth", "\\f1coth\\fP", "tanh", "\\f1tanh\\fP", "cosh", "\\f1cosh\\fP", "lim", "\\f1lim\\fP", "log", "\\f1log\\fP", "max", "\\f1max\\fP", "min", "\\f1min\\fP", "ln", "\\f1ln\\fP", "exp", "\\f1exp\\fP", "det", "\\f1det\\fP", 0, 0 }; /* find name in tbl. if defn non-null, install */ tbl * lookup(tbl *tblp[], char *name, char *defn) { tbl *p; int h; unsigned char *s = (unsigned char *)name; char *malloc(); for (h = 0; *s != '\0'; ) h += *s++; h %= TBLSIZE; for (p = tblp[h]; p != NULL; p = p->next) if (strcmp(name, p->name) == 0) { /* found it */ if (defn != NULL) p->defn = defn; return (p); } /* didn't find it */ if (defn == NULL) return (NULL); p = (tbl *) malloc(sizeof (tbl)); if (p == NULL) error(FATAL, gettext("out of space in lookup"), NULL); p->name = name; p->defn = defn; p->next = tblp[h]; tblp[h] = p; return (p); } void init_tbl(void) /* initialize all tables */ { int i; for (i = 0; keyword[i].key != NULL; i++) 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); } /* * 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. */ #include "e.h" void mark(int p1) { markline = 1; printf(".ds %d \\k(97\\*(%d\n", p1, p1); yyval = p1; if (dbg) printf(".\tmark %d\n", 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); } /* * 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. */ #include "e.h" void column(int type, int p1) { int i; lp[p1] = ct - p1 - 1; if (dbg) { printf(".\t%d column of", type); for (i = p1 + 1; i < ct; i++) printf(" S%d", lp[i]); printf(", rows=%d\n", lp[p1]); } lp[ct++] = type; } 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) { ncol++; if (dbg) printf(".\tcolct=%d\n", lp[i]); } for (k = 1; k <= nrow; k++) { hb = b = 0; j = p1 + k; 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); j = p1 + k; 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++) { lpile(lp[j+lp[j]+1], j+1, j+lp[j]+1); val[i] = yyval; j += nrow + 2; } yyval = oalloc(); 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]); printf(".ds %d \"", yyval); for (i = 0; i < ncol; i++) { printf("\\*(%d%s", val[i], i == ncol-1 ? "" : space); ofree(val[i]); } printf("\n"); ct = p1; } /* * 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. */ #include "e.h" #include "e.def" 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 */ printf(".ds %d ", yyval); 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]); } # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Copyright (c) 2018, Joyent, Inc. include ../../Makefile.cmd PROG = neqn CSRCS = diacrit.c eqnbox.c font.c fromto.c funny.c \ glob.c integral.c io.c lex.c lookup.c \ mark.c matrix.c move.c over.c paren.c \ pile.c shift.c size.c sqrt.c text.c SRCS = $(CSRCS:%=../%) YACCSRC = e.y COBJS = $(CSRCS:%.c=%.o) OBJS = $(YACCSRC:%.y=%.o) $(COBJS) CLEANFILES = y.tab.c y.tab.h $(YACCSRC:%.y=%.c) $(YACCSRC:%.y=%.def) YFLAGS = -d CPPFLAGS = -DNEQN -I. -I.. $(CPPFLAGS.master) LDFLAGS += $(MAPFILE.NGB:%=-Wl,-M%) CERRWARN += -Wno-implicit-function-declaration CERRWARN += $(CNOWARN_UNINIT) # Hammerhead: Suppress pointer/int cast warnings in legacy eqn code CERRWARN += -Wno-pointer-to-int-cast CERRWARN += -Wno-int-to-pointer-cast # because of labels from yacc e.o : CERRWARN += -Wno-unused-label # not linted SMATCH=off # # for message catalog # POFILE= neqn.d.po POFILES= e.po .KEEP_STATE: all : $(PROG) $(PROG) : $(OBJS) $(MAPFILE.NGB) $(LINK.c) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) $(POST_PROCESS) catalog: $(POFILE) $(POFILE): $(POFILES) $(RM) $@ cat $(POFILES) > $@ # Hammerhead: GNU Make grouped target (was dmake +) $(YACCSRC:%.y=%.c) $(YACCSRC:%.y=%.def) &: ../$(YACCSRC) $(YACC.y) ../$(YACCSRC) $(MV) y.tab.c $(YACCSRC:%.y=%.c) $(MV) y.tab.h $(YACCSRC:%.y=%.def) # Hammerhead: Use static pattern rule for GNU Make compatibility $(COBJS): %.o: ../%.c $(COMPILE.c) -o $@ $< install : all $(ROOTPROG) clean: $(RM) $(OBJS) $(CLEANFILES) include ../../Makefile.targ /* * 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. */ #include "e.h" void boverb(int p1, int p2) { int h, b, treg, d; treg = oalloc(); yyval = p1; #ifndef NEQN d = VERT(EM(0.3, ps)); h = eht[p1] + eht[p2] + d; #else /* NEQN */ d = VERT(1); h = eht[p1] + eht[p2]; #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); 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); #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; ofree(p2); ofree(treg); } /* * 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. */ #include "e.h" extern int max(); 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 */ n = max(b1+VERT(1), h1-b1-VERT(1)) / VERT(1); #endif /* NEQN */ if (n < 2) n = 1; m = n-2; 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 */ 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 */ printf(".ds %d \\|\\v'%du'", yyval, v); switch (leftc) { case 'n': /* nothing */ case '\0': break; case 'f': /* floor */ if (n <= 1) printf("\\(lf"); else brack(m, "\\(bv", "\\(bv", "\\(lf"); break; case 'c': /* ceiling */ if (n <= 1) printf("\\(lc"); else brack(m, "\\(lc", "\\(bv", "\\(bv"); break; case '{': printf("\\b'\\(lt"); for (j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(lk"); for (j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(lb'"); break; case '(': brack(m, "\\(lt", "\\(bv", "\\(lb"); break; case '[': brack(m, "\\(lc", "\\(bv", "\\(lf"); break; case '|': brack(m, "\\(bv", "\\(bv", "\\(bv"); break; default: brack(m, (char *)&leftc, (char *)&leftc, (char *)&leftc); break; } printf("\\v'%du'\\*(%d", -v, p1); if (rightc) { printf("\\|\\v'%du'", v); switch (rightc) { case 'f': /* floor */ if (n <= 1) printf("\\(rf"); else brack(m, "\\(bv", "\\(bv", "\\(rf"); break; case 'c': /* ceiling */ if (n <= 1) printf("\\(rc"); else brack(m, "\\(rc", "\\(bv", "\\(bv"); break; case '}': printf("\\b'\\(rt"); for (j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(rk"); for (j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(rb'"); break; case ']': brack(m, "\\(rc", "\\(bv", "\\(rf"); break; case ')': brack(m, "\\(rt", "\\(bv", "\\(rb"); break; case '|': brack(m, "\\(bv", "\\(bv", "\\(bv"); break; default: 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); } void brack(int m, char *t, char *c, char *b) { int j; printf("\\b'%s", t); for (j = 0; j < m; j++) printf("%s", c); printf("%s'", b); } /* * 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. */ #include "e.h" 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 */ gap = VERT(1); #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++) h += eht[lp[i]]; eht[yyval] = h + (nlist-1)*gap; b = 0; for (i = p2-1; i > mid; i--) b += eht[lp[i]] + gap; #ifndef NEQN 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++) 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++) { nrwid(lp[i], ps, 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]]; bi = ebase[lp[i]]; switch (type) { case 'L': 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); 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); 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++) ofree(lp[i]); lfont[yyval] = rfont[yyval] = 0; } /* * 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. */ #include "e.h" #include "e.def" 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 */ yyval = p1; h1 = eht[p1]; b1 = ebase[p1]; h2 = eht[p2]; b2 = ebase[p2]; #ifndef NEQN effps = EFFPS(ps); effps2 = EFFPS(ps+deltaps); diffps = deltaps; sh1 = sh2 = ""; #endif /* NEQN */ if (dir == SUB) { /* subscript */ #ifndef NEQN /* top 1/2m above bottom of main box */ d1 = VERT(EM(0.5, effps2)); #else /* NEQN */ d1 = VERT(1); #endif /* NEQN */ shval = - d1 + h2 - b2; 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); #ifndef NEQN if (rfont[p1] == ITAL && lfont[p2] == ROM) sh1 = "\\|"; if (rfont[p2] == ITAL) sh2 = "\\|"; #endif /* NEQN */ } else { /* superscript */ #ifndef NEQN /* 4/10 up main box */ d1 = VERT(EM(0.2, effps)); #else /* NEQN */ d1 = VERT(1); #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(1) - b2; 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)); if (rfont[p1] == ITAL) sh1 = "\\|"; if (rfont[p2] == ITAL) sh2 = "\\|"; #else /* NEQN */ eht[yyval] = h1 + max(0, h2 - VERT(1)); #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]); #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); 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 */ ofree(p2); } void shift(int p1) { ps -= deltaps; yyval = p1; if (dbg) printf(".\tshift: %d;ps=%d\n", yyval, ps); } 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 */ treg = oalloc(); yyval = p1; 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)); ps += deltaps; effps2 = EFFPS(ps+deltaps); #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 */ h3 = eht[p3]; b3 = ebase[p3]; d1 = VERT(1); #endif /* NEQN */ subsh = -d1+h2-b2; if (d1+b1 > h2) /* move little sub down */ subsh = b1-b2; #ifndef NEQN supsh = -VERT((4*(h1-b1))/10) - b3; d2 = VERT(EM(0.2, effps)); 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 */ 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(1)) + max(0, h2-b1-d1); #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 */ 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 */ 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 */ ps += deltaps; #ifndef NEQN if (rfont[p2] == ITAL) rfont[yyval] = 0; /* lie */ #endif /* NEQN */ ofree(p2); ofree(p3); ofree(treg); } /* * 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. */ #include "e.h" void setsize(char *p) /* set size as found in p */ { if (*p == '+') ps += atoi(p+1); else if (*p == '-') ps -= atoi(p+1); else ps = atoi(p); if (dbg) printf(".\tsetsize %s; ps = %d\n", p, 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]); effps = EFFPS(ps); effp1 = EFFPS(p1); printf(".ds %d \\s%d\\*(%d\\s%d\n", yyval, effps, p2, effp1); ps = p1; } void globsize(void) { char temp[20]; getstr(temp, 20); if (temp[0] == '+') gsize += atoi(temp+1); else if (temp[0] == '-') gsize -= atoi(temp+1); else gsize = atoi(temp); yyval = eqnreg = 0; setps(gsize); ps = gsize; if (gsize >= 12) /* sub and sup size change */ deltaps = gsize / 4; else deltaps = gsize / 3; } /* * 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. */ #include "e.h" void sqrt(int p2) { #ifndef NEQN int nps; nps = EFFPS(((eht[p2]*9)/10+(resolution/POINT-1))/(resolution/POINT)); #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 (rfont[yyval] == ITAL) printf(".as %d \\|\n", yyval); #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("\\v'%du'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2); lfont[yyval] = ROM; #else /* NEQN */ printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'", 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 */ } /* * 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. */ #include "e.h" #include "e.def" #include int csp; int psp; #define CSSIZE 400 char cs[420]; int lf, rf; /* temporary spots for left and right fonts */ 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(); extern tbl *restbl[]; yyval = oalloc(); ebase[yyval] = 0; #ifndef NEQN eht[yyval] = VERT(EM(1.0, EFFPS(ps))); /* ht in machine units */ #else /* NEQN */ eht[yyval] = VERT(2); /* 2 half-spaces */ #endif /* NEQN */ lfont[yyval] = rfont[yyval] = ROM; if (t == QTEXT) p = p1; else if (t == SPACE) p = "\\ "; else if (t == THIN) p = "\\|"; 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'; ) { rf = trans(c, p1); if (lf == 0) lf = rf; /* save first */ 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]); printf(".ds %d \"%s\n", yyval, p); } int trans(int c, char *p1) { int f; f = ROM; 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 '%': case '(': case '[': case ')': case ']': case ',': if (rf == ITAL) shim(); roman(c); break; case '.': if (rf == ROM) roman(c); else cs[csp++] = c; f = rf; break; case '|': if (rf == ITAL) shim(); shim(); roman(c); shim(); break; case '=': if (rf == ITAL) shim(); name4('e', 'q'); break; case '+': if (rf == ITAL) shim(); name4('p', 'l'); break; case '>': case '<': if (rf == ITAL) shim(); if (p1[psp] == '=') { /* look ahead for == <= >= */ name4(c, '='); psp++; } else { cs[csp++] = c; } break; case '-': if (rf == ITAL) shim(); if (p1[psp] == '>') { name4('-', '>'); psp++; } else { name4('m', 'i'); } break; case '/': if (rf == ITAL) shim(); name4('s', 'l'); break; case '~': case ' ': shim(); shim(); break; case '^': shim(); break; case '\\': /* troff - pass 2 or 3 more chars */ 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] == '(') { 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++] = 'P'; f = rf == ITAL ? ITAL : ROM; break; case 'f': if (ft == ITAL) { cs[csp++] = '\\'; cs[csp++] = '^'; cs[csp++] = 'f'; /* trying | instead of ^ */ cs[csp++] = '\\'; cs[csp++] = '|'; f = ITAL; } else cs[csp++] = 'f'; break; case 'j': if (ft == ITAL) { cs[csp++] = '\\'; cs[csp++] = '^'; cs[csp++] = 'j'; f = ITAL; } else cs[csp++] = 'j'; break; default: cs[csp++] = c; f = ft == ITAL ? ITAL : ROM; break; } return (f); } void shim(void) { cs[csp++] = '\\'; cs[csp++] = '|'; } void roman(int c) { cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = ROM; cs[csp++] = c; cs[csp++] = '\\'; cs[csp++] = 'f'; cs[csp++] = 'P'; } void name4(int c1, int c2) { cs[csp++] = '\\'; cs[csp++] = '('; cs[csp++] = c1; cs[csp++] = c2; }