home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / calc / part02 < prev    next >
SHell self-extracting ARchive  |  1992-05-09  |  54.1 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: SHell self-extracting ARchive (archive/shar).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file C source, ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 73 6f 75 72 63 65 73 | 2e 75 6e 69 78 0a 46 72 |.sources|.unix.Fr|
|00000020| 6f 6d 3a 20 64 62 65 6c | 6c 40 70 64 61 63 74 2e |om: dbel|l@pdact.|
|00000030| 70 64 2e 6e 65 63 69 73 | 61 2e 6f 7a 2e 61 75 20 |pd.necis|a.oz.au |
|00000040| 28 44 61 76 69 64 20 49 | 2e 20 42 65 6c 6c 29 0a |(David I|. Bell).|
|00000050| 53 75 62 6a 65 63 74 3a | 20 76 32 36 69 30 32 38 |Subject:| v26i028|
|00000060| 3a 20 43 41 4c 43 20 2d | 20 41 6e 20 61 72 62 69 |: CALC -| An arbi|
|00000070| 74 72 61 72 79 20 70 72 | 65 63 69 73 69 6f 6e 20 |trary pr|ecision |
|00000080| 43 2d 6c 69 6b 65 20 63 | 61 6c 63 75 6c 61 74 6f |C-like c|alculato|
|00000090| 72 2c 20 50 61 72 74 30 | 32 2f 32 31 0a 53 65 6e |r, Part0|2/21.Sen|
|000000a0| 64 65 72 3a 20 75 6e 69 | 78 2d 73 6f 75 72 63 65 |der: uni|x-source|
|000000b0| 73 2d 6d 6f 64 65 72 61 | 74 6f 72 40 70 61 2e 64 |s-modera|tor@pa.d|
|000000c0| 65 63 2e 63 6f 6d 0a 41 | 70 70 72 6f 76 65 64 3a |ec.com.A|pproved:|
|000000d0| 20 76 69 78 69 65 40 70 | 61 2e 64 65 63 2e 63 6f | vixie@p|a.dec.co|
|000000e0| 6d 0a 0a 53 75 62 6d 69 | 74 74 65 64 2d 42 79 3a |m..Submi|tted-By:|
|000000f0| 20 64 62 65 6c 6c 40 70 | 64 61 63 74 2e 70 64 2e | dbell@p|dact.pd.|
|00000100| 6e 65 63 69 73 61 2e 6f | 7a 2e 61 75 20 28 44 61 |necisa.o|z.au (Da|
|00000110| 76 69 64 20 49 2e 20 42 | 65 6c 6c 29 0a 50 6f 73 |vid I. B|ell).Pos|
|00000120| 74 69 6e 67 2d 4e 75 6d | 62 65 72 3a 20 56 6f 6c |ting-Num|ber: Vol|
|00000130| 75 6d 65 20 32 36 2c 20 | 49 73 73 75 65 20 32 38 |ume 26, |Issue 28|
|00000140| 0a 41 72 63 68 69 76 65 | 2d 4e 61 6d 65 3a 20 63 |.Archive|-Name: c|
|00000150| 61 6c 63 2f 70 61 72 74 | 30 32 0a 0a 23 21 20 2f |alc/part|02..#! /|
|00000160| 62 69 6e 2f 73 68 0a 23 | 20 54 68 69 73 20 69 73 |bin/sh.#| This is|
|00000170| 20 61 20 73 68 65 6c 6c | 20 61 72 63 68 69 76 65 | a shell| archive|
|00000180| 2e 20 20 52 65 6d 6f 76 | 65 20 61 6e 79 74 68 69 |. Remov|e anythi|
|00000190| 6e 67 20 62 65 66 6f 72 | 65 20 74 68 69 73 20 6c |ng befor|e this l|
|000001a0| 69 6e 65 2c 20 74 68 65 | 6e 20 75 6e 70 61 63 6b |ine, the|n unpack|
|000001b0| 0a 23 20 69 74 20 62 79 | 20 73 61 76 69 6e 67 20 |.# it by| saving |
|000001c0| 69 74 20 69 6e 74 6f 20 | 61 20 66 69 6c 65 20 61 |it into |a file a|
|000001d0| 6e 64 20 74 79 70 69 6e | 67 20 22 73 68 20 66 69 |nd typin|g "sh fi|
|000001e0| 6c 65 22 2e 20 20 54 6f | 20 6f 76 65 72 77 72 69 |le". To| overwri|
|000001f0| 74 65 20 65 78 69 73 74 | 69 6e 67 0a 23 20 66 69 |te exist|ing.# fi|
|00000200| 6c 65 73 2c 20 74 79 70 | 65 20 22 73 68 20 66 69 |les, typ|e "sh fi|
|00000210| 6c 65 20 2d 63 22 2e 20 | 20 59 6f 75 20 63 61 6e |le -c". | You can|
|00000220| 20 61 6c 73 6f 20 66 65 | 65 64 20 74 68 69 73 20 | also fe|ed this |
|00000230| 61 73 20 73 74 61 6e 64 | 61 72 64 20 69 6e 70 75 |as stand|ard inpu|
|00000240| 74 20 76 69 61 0a 23 20 | 75 6e 73 68 61 72 2c 20 |t via.# |unshar, |
|00000250| 6f 72 20 62 79 20 74 79 | 70 69 6e 67 20 22 73 68 |or by ty|ping "sh|
|00000260| 20 3c 66 69 6c 65 22 2c | 20 65 2e 67 2e 2e 20 20 | <file",| e.g.. |
|00000270| 49 66 20 74 68 69 73 20 | 61 72 63 68 69 76 65 20 |If this |archive |
|00000280| 69 73 20 63 6f 6d 70 6c | 65 74 65 2c 20 79 6f 75 |is compl|ete, you|
|00000290| 0a 23 20 77 69 6c 6c 20 | 73 65 65 20 74 68 65 20 |.# will |see the |
|000002a0| 66 6f 6c 6c 6f 77 69 6e | 67 20 6d 65 73 73 61 67 |followin|g messag|
|000002b0| 65 20 61 74 20 74 68 65 | 20 65 6e 64 3a 0a 23 09 |e at the| end:.#.|
|000002c0| 09 22 45 6e 64 20 6f 66 | 20 61 72 63 68 69 76 65 |."End of| archive|
|000002d0| 20 32 20 28 6f 66 20 32 | 31 29 2e 22 0a 23 20 43 | 2 (of 2|1).".# C|
|000002e0| 6f 6e 74 65 6e 74 73 3a | 20 20 61 6c 6c 6f 63 2e |ontents:| alloc.|
|000002f0| 68 20 63 61 6c 63 2e 63 | 20 63 6f 6e 73 74 2e 63 |h calc.c| const.c|
|00000300| 20 68 65 6c 70 2f 63 6f | 6d 6d 61 6e 64 20 68 65 | help/co|mmand he|
|00000310| 6c 70 2f 63 6f 6e 66 69 | 67 0a 23 20 20 20 68 65 |lp/confi|g.# he|
|00000320| 6c 70 2f 64 65 66 69 6e | 65 20 68 65 6c 70 2f 6d |lp/defin|e help/m|
|00000330| 61 74 20 68 65 6c 70 2f | 74 79 70 65 73 20 6c 61 |at help/|types la|
|00000340| 62 65 6c 2e 63 20 6c 69 | 62 2f 52 45 41 44 4d 45 |bel.c li|b/README|
|00000350| 20 6c 69 62 2f 6d 6f 64 | 2e 63 61 6c 0a 23 20 20 | lib/mod|.cal.# |
|00000360| 20 6c 69 62 2f 70 6f 6c | 79 2e 63 61 6c 20 6c 69 | lib/pol|y.cal li|
|00000370| 62 2f 71 75 61 74 2e 63 | 61 6c 0a 23 20 57 72 61 |b/quat.c|al.# Wra|
|00000380| 70 70 65 64 20 62 79 20 | 64 62 65 6c 6c 40 65 6c |pped by |dbell@el|
|00000390| 6d 20 6f 6e 20 54 75 65 | 20 46 65 62 20 32 35 20 |m on Tue| Feb 25 |
|000003a0| 31 35 3a 32 30 3a 35 35 | 20 31 39 39 32 0a 50 41 |15:20:55| 1992.PA|
|000003b0| 54 48 3d 2f 62 69 6e 3a | 2f 75 73 72 2f 62 69 6e |TH=/bin:|/usr/bin|
|000003c0| 3a 2f 75 73 72 2f 75 63 | 62 20 3b 20 65 78 70 6f |:/usr/uc|b ; expo|
|000003d0| 72 74 20 50 41 54 48 0a | 69 66 20 74 65 73 74 20 |rt PATH.|if test |
|000003e0| 2d 66 20 27 61 6c 6c 6f | 63 2e 68 27 20 2d 61 20 |-f 'allo|c.h' -a |
|000003f0| 22 24 7b 31 7d 22 20 21 | 3d 20 22 2d 63 22 20 3b |"${1}" !|= "-c" ;|
|00000400| 20 74 68 65 6e 20 0a 20 | 20 65 63 68 6f 20 73 68 | then . | echo sh|
|00000410| 61 72 3a 20 57 69 6c 6c | 20 6e 6f 74 20 63 6c 6f |ar: Will| not clo|
|00000420| 62 62 65 72 20 65 78 69 | 73 74 69 6e 67 20 66 69 |bber exi|sting fi|
|00000430| 6c 65 20 5c 22 27 61 6c | 6c 6f 63 2e 68 27 5c 22 |le \"'al|loc.h'\"|
|00000440| 0a 65 6c 73 65 0a 65 63 | 68 6f 20 73 68 61 72 3a |.else.ec|ho shar:|
|00000450| 20 45 78 74 72 61 63 74 | 69 6e 67 20 5c 22 27 61 | Extract|ing \"'a|
|00000460| 6c 6c 6f 63 2e 68 27 5c | 22 20 5c 28 32 36 38 36 |lloc.h'\|" \(2686|
|00000470| 20 63 68 61 72 61 63 74 | 65 72 73 5c 29 0a 73 65 | charact|ers\).se|
|00000480| 64 20 22 73 2f 5e 58 2f | 2f 22 20 3e 27 61 6c 6c |d "s/^X/|/" >'all|
|00000490| 6f 63 2e 68 27 20 3c 3c | 27 45 4e 44 5f 4f 46 5f |oc.h' <<|'END_OF_|
|000004a0| 46 49 4c 45 27 0a 58 2f | 2a 0a 58 20 2a 20 43 6f |FILE'.X/|*.X * Co|
|000004b0| 70 79 72 69 67 68 74 20 | 28 63 29 20 31 39 39 32 |pyright |(c) 1992|
|000004c0| 20 44 61 76 69 64 20 49 | 2e 20 42 65 6c 6c 0a 58 | David I|. Bell.X|
|000004d0| 20 2a 20 50 65 72 6d 69 | 73 73 69 6f 6e 20 69 73 | * Permi|ssion is|
|000004e0| 20 67 72 61 6e 74 65 64 | 20 74 6f 20 75 73 65 2c | granted| to use,|
|000004f0| 20 64 69 73 74 72 69 62 | 75 74 65 2c 20 6f 72 20 | distrib|ute, or |
|00000500| 6d 6f 64 69 66 79 20 74 | 68 69 73 20 73 6f 75 72 |modify t|his sour|
|00000510| 63 65 2c 0a 58 20 2a 20 | 70 72 6f 76 69 64 65 64 |ce,.X * |provided|
|00000520| 20 74 68 61 74 20 74 68 | 69 73 20 63 6f 70 79 72 | that th|is copyr|
|00000530| 69 67 68 74 20 6e 6f 74 | 69 63 65 20 72 65 6d 61 |ight not|ice rema|
|00000540| 69 6e 73 20 69 6e 74 61 | 63 74 2e 0a 58 20 2a 0a |ins inta|ct..X *.|
|00000550| 58 20 2a 20 41 6c 6c 6f | 63 61 74 6f 72 20 64 65 |X * Allo|cator de|
|00000560| 66 69 6e 69 74 69 6f 6e | 73 20 28 66 61 73 74 20 |finition|s (fast |
|00000570| 6d 61 6c 6c 6f 63 20 61 | 6e 64 20 66 72 65 65 29 |malloc a|nd free)|
|00000580| 0a 58 20 2a 2f 0a 58 0a | 58 23 69 66 20 64 65 66 |.X */.X.|X#if def|
|00000590| 69 6e 65 64 28 55 4e 49 | 58 5f 4d 41 4c 4c 4f 43 |ined(UNI|X_MALLOC|
|000005a0| 29 0a 58 0a 58 23 69 6e | 63 6c 75 64 65 20 22 68 |).X.X#in|clude "h|
|000005b0| 61 76 65 5f 6d 61 6c 6c | 6f 63 2e 68 22 0a 58 23 |ave_mall|oc.h".X#|
|000005c0| 69 66 64 65 66 20 48 41 | 56 45 5f 4d 41 4c 4c 4f |ifdef HA|VE_MALLO|
|000005d0| 43 5f 48 0a 58 23 20 69 | 6e 63 6c 75 64 65 20 3c |C_H.X# i|nclude <|
|000005e0| 6d 61 6c 6c 6f 63 2e 68 | 3e 0a 58 23 65 6c 73 65 |malloc.h|>.X#else|
|000005f0| 0a 58 23 20 69 66 20 64 | 65 66 69 6e 65 64 28 5f |.X# if d|efined(_|
|00000600| 5f 53 54 44 43 5f 5f 29 | 0a 58 20 20 20 65 78 74 |_STDC__)|.X ext|
|00000610| 65 72 6e 20 76 6f 69 64 | 20 2a 6d 61 6c 6c 6f 63 |ern void| *malloc|
|00000620| 28 29 3b 0a 58 20 20 20 | 65 78 74 65 72 6e 20 76 |();.X |extern v|
|00000630| 6f 69 64 20 2a 72 65 61 | 6c 6c 6f 63 28 29 3b 0a |oid *rea|lloc();.|
|00000640| 58 20 20 20 65 78 74 65 | 72 6e 20 76 6f 69 64 20 |X exte|rn void |
|00000650| 66 72 65 65 28 29 3b 0a | 58 23 20 65 6c 73 65 0a |free();.|X# else.|
|00000660| 58 20 20 20 65 78 74 65 | 72 6e 20 63 68 61 72 20 |X exte|rn char |
|00000670| 2a 6d 61 6c 6c 6f 63 28 | 29 3b 0a 58 20 20 20 65 |*malloc(|);.X e|
|00000680| 78 74 65 72 6e 20 63 68 | 61 72 20 2a 72 65 61 6c |xtern ch|ar *real|
|00000690| 6c 6f 63 28 29 3b 0a 58 | 20 20 20 65 78 74 65 72 |loc();.X| exter|
|000006a0| 6e 20 76 6f 69 64 20 66 | 72 65 65 28 29 3b 0a 58 |n void f|ree();.X|
|000006b0| 23 20 65 6e 64 69 66 0a | 58 23 65 6e 64 69 66 0a |# endif.|X#endif.|
|000006c0| 58 0a 58 23 69 6e 63 6c | 75 64 65 20 22 68 61 76 |X.X#incl|ude "hav|
|000006d0| 65 5f 73 74 72 69 6e 67 | 2e 68 22 0a 58 0a 58 23 |e_string|.h".X.X#|
|000006e0| 69 66 64 65 66 20 48 41 | 56 45 5f 53 54 52 49 4e |ifdef HA|VE_STRIN|
|000006f0| 47 5f 48 0a 58 23 20 69 | 6e 63 6c 75 64 65 20 3c |G_H.X# i|nclude <|
|00000700| 73 74 72 69 6e 67 2e 68 | 3e 0a 58 0a 58 23 65 6c |string.h|>.X.X#el|
|00000710| 73 65 0a 58 0a 58 23 20 | 69 66 64 65 66 20 4f 4c |se.X.X# |ifdef OL|
|00000720| 44 5f 42 53 44 0a 58 65 | 78 74 65 72 6e 20 76 6f |D_BSD.Xe|xtern vo|
|00000730| 69 64 20 62 63 6f 70 79 | 28 29 3b 0a 58 65 78 74 |id bcopy|();.Xext|
|00000740| 65 72 6e 20 76 6f 69 64 | 20 62 66 69 6c 6c 28 29 |ern void| bfill()|
|00000750| 3b 0a 58 65 78 74 65 72 | 6e 20 63 68 61 72 20 2a |;.Xexter|n char *|
|00000760| 69 6e 64 65 78 28 29 3b | 0a 58 23 20 65 6c 73 65 |index();|.X# else|
|00000770| 20 2f 2a 20 4f 4c 44 5f | 42 53 44 20 2a 2f 0a 58 | /* OLD_|BSD */.X|
|00000780| 65 78 74 65 72 6e 20 76 | 6f 69 64 20 6d 65 6d 63 |extern v|oid memc|
|00000790| 70 79 28 29 3b 0a 58 65 | 78 74 65 72 6e 20 76 6f |py();.Xe|xtern vo|
|000007a0| 69 64 20 6d 65 6d 73 65 | 74 28 29 3b 0a 58 23 20 |id memse|t();.X# |
|000007b0| 20 69 66 20 64 65 66 69 | 6e 65 64 28 5f 5f 53 54 | if defi|ned(__ST|
|000007c0| 44 43 5f 5f 29 0a 58 65 | 78 74 65 72 6e 20 76 6f |DC__).Xe|xtern vo|
|000007d0| 69 64 20 2a 73 74 72 63 | 68 72 28 29 3b 0a 58 23 |id *strc|hr();.X#|
|000007e0| 20 20 65 6c 73 65 0a 58 | 65 78 74 65 72 6e 20 63 | else.X|extern c|
|000007f0| 68 61 72 20 2a 73 74 72 | 63 68 72 28 29 3b 0a 58 |har *str|chr();.X|
|00000800| 23 20 20 65 6e 64 69 66 | 0a 58 23 20 65 6e 64 69 |# endif|.X# endi|
|00000810| 66 20 2f 2a 20 4f 4c 44 | 5f 42 53 44 20 2a 2f 0a |f /* OLD|_BSD */.|
|00000820| 58 65 78 74 65 72 6e 20 | 76 6f 69 64 20 73 74 72 |Xextern |void str|
|00000830| 63 70 79 28 29 3b 0a 58 | 65 78 74 65 72 6e 20 76 |cpy();.X|extern v|
|00000840| 6f 69 64 20 73 74 72 6e | 63 70 79 28 29 3b 0a 58 |oid strn|cpy();.X|
|00000850| 65 78 74 65 72 6e 20 76 | 6f 69 64 20 73 74 72 63 |extern v|oid strc|
|00000860| 61 74 28 29 3b 0a 58 65 | 78 74 65 72 6e 20 69 6e |at();.Xe|xtern in|
|00000870| 74 20 73 74 72 63 6d 70 | 28 29 3b 0a 58 65 78 74 |t strcmp|();.Xext|
|00000880| 65 72 6e 20 6c 6f 6e 67 | 20 73 74 72 6c 65 6e 28 |ern long| strlen(|
|00000890| 29 3b 09 2f 2a 20 73 68 | 6f 75 6c 64 20 62 65 20 |);./* sh|ould be |
|000008a0| 73 69 7a 65 5f 74 2c 20 | 62 75 74 20 6f 6c 64 20 |size_t, |but old |
|000008b0| 73 79 73 74 65 6d 73 20 | 64 6f 6e 27 74 20 68 61 |systems |don't ha|
|000008c0| 76 65 20 69 74 20 2a 2f | 0a 58 0a 58 23 65 6e 64 |ve it */|.X.X#end|
|000008d0| 69 66 0a 58 0a 58 23 69 | 66 64 65 66 20 4f 4c 44 |if.X.X#i|fdef OLD|
|000008e0| 5f 42 53 44 0a 58 23 75 | 6e 64 65 66 20 6d 65 6d |_BSD.X#u|ndef mem|
|000008f0| 63 70 79 0a 58 23 64 65 | 66 69 6e 65 20 6d 65 6d |cpy.X#de|fine mem|
|00000900| 63 70 79 28 73 31 2c 20 | 73 32 2c 20 6e 29 20 62 |cpy(s1, |s2, n) b|
|00000910| 63 6f 70 79 28 73 32 2c | 20 73 31 2c 20 6e 29 0a |copy(s2,| s1, n).|
|00000920| 58 23 75 6e 64 65 66 20 | 6d 65 6d 73 65 74 0a 58 |X#undef |memset.X|
|00000930| 23 64 65 66 69 6e 65 20 | 6d 65 6d 73 65 74 28 73 |#define |memset(s|
|00000940| 2c 20 63 2c 20 6e 29 20 | 62 66 69 6c 6c 28 73 2c |, c, n) |bfill(s,|
|00000950| 20 6e 2c 20 63 29 0a 58 | 23 75 6e 64 65 66 20 73 | n, c).X|#undef s|
|00000960| 74 72 63 68 72 0a 58 23 | 64 65 66 69 6e 65 20 73 |trchr.X#|define s|
|00000970| 74 72 63 68 72 28 73 2c | 20 63 29 20 69 6e 64 65 |trchr(s,| c) inde|
|00000980| 78 28 73 2c 20 63 29 0a | 58 23 65 6e 64 69 66 0a |x(s, c).|X#endif.|
|00000990| 58 0a 58 23 69 66 64 65 | 66 20 56 53 50 52 49 4e |X.X#ifde|f VSPRIN|
|000009a0| 54 46 0a 58 2f 2a 0a 58 | 20 2a 20 58 58 58 20 2d |TF.X/*.X| * XXX -|
|000009b0| 20 68 61 63 6b 20 61 6c | 65 61 72 74 0a 58 20 2a | hack al|eart.X *|
|000009c0| 0a 58 20 2a 20 53 79 73 | 74 65 6d 73 20 74 68 61 |.X * Sys|tems tha|
|000009d0| 74 20 64 6f 20 6e 6f 74 | 20 68 61 76 65 20 76 73 |t do not| have vs|
|000009e0| 70 72 69 6e 74 66 28 29 | 20 6e 65 65 64 20 73 6f |printf()| need so|
|000009f0| 6d 65 74 68 69 6e 67 2e | 20 20 49 6e 20 73 6f 6d |mething.| In som|
|00000a00| 65 20 63 61 73 65 73 0a | 58 20 2a 20 74 68 65 20 |e cases.|X * the |
|00000a10| 73 70 72 69 6e 74 66 20 | 66 75 6e 63 74 69 6f 6e |sprintf |function|
|00000a20| 20 77 69 6c 6c 20 64 65 | 61 6c 20 63 6f 72 72 65 | will de|al corre|
|00000a30| 63 74 6c 79 20 77 69 74 | 68 20 74 68 65 20 76 61 |ctly wit|h the va|
|00000a40| 5f 61 6c 69 73 74 20 33 | 72 64 20 61 72 67 2e 0a |_alist 3|rd arg..|
|00000a50| 58 20 2a 20 48 6f 70 65 | 20 66 6f 72 20 74 68 65 |X * Hope| for the|
|00000a60| 20 62 65 73 74 21 0a 58 | 20 2a 2f 0a 58 23 64 65 | best!.X| */.X#de|
|00000a70| 66 69 6e 65 20 76 73 70 | 72 69 6e 74 66 20 73 70 |fine vsp|rintf sp|
|00000a80| 72 69 6e 74 66 0a 58 23 | 65 6e 64 69 66 0a 58 0a |rintf.X#|endif.X.|
|00000a90| 58 65 78 74 65 72 6e 20 | 76 6f 69 64 20 65 78 69 |Xextern |void exi|
|00000aa0| 74 28 29 3b 0a 58 0a 58 | 23 64 65 66 69 6e 65 20 |t();.X.X|#define |
|00000ab0| 6d 65 6d 5f 61 6c 6c 6f | 63 20 6d 61 6c 6c 6f 63 |mem_allo|c malloc|
|00000ac0| 0a 58 23 64 65 66 69 6e | 65 20 6d 65 6d 5f 72 65 |.X#defin|e mem_re|
|00000ad0| 61 6c 6c 6f 63 20 72 65 | 61 6c 6c 6f 63 0a 58 23 |alloc re|alloc.X#|
|00000ae0| 64 65 66 69 6e 65 20 6d | 65 6d 5f 66 72 65 65 20 |define m|em_free |
|00000af0| 66 72 65 65 0a 58 0a 58 | 23 65 6c 73 65 20 2f 2a |free.X.X|#else /*|
|00000b00| 55 4e 49 58 5f 4d 41 4c | 4c 4f 43 2a 2f 0a 58 0a |UNIX_MAL|LOC*/.X.|
|00000b10| 58 23 64 65 66 69 6e 65 | 20 6d 61 6c 6c 6f 63 28 |X#define| malloc(|
|00000b20| 61 29 20 6d 65 6d 5f 61 | 6c 6c 6f 63 28 28 6c 6f |a) mem_a|lloc((lo|
|00000b30| 6e 67 29 20 61 29 0a 58 | 23 64 65 66 69 6e 65 20 |ng) a).X|#define |
|00000b40| 72 65 61 6c 6c 6f 63 28 | 61 2c 62 29 20 6d 65 6d |realloc(|a,b) mem|
|00000b50| 5f 72 65 61 6c 6c 6f 63 | 28 28 63 68 61 72 20 2a |_realloc|((char *|
|00000b60| 29 20 61 2c 20 28 6c 6f | 6e 67 29 20 62 29 0a 58 |) a, (lo|ng) b).X|
|00000b70| 23 64 65 66 69 6e 65 20 | 66 72 65 65 28 61 29 20 |#define |free(a) |
|00000b80| 6d 65 6d 5f 66 72 65 65 | 28 28 63 68 61 72 20 2a |mem_free|((char *|
|00000b90| 29 20 61 29 0a 58 65 78 | 74 65 72 6e 20 63 68 61 |) a).Xex|tern cha|
|00000ba0| 72 20 2a 6d 65 6d 5f 61 | 6c 6c 6f 63 28 29 3b 0a |r *mem_a|lloc();.|
|00000bb0| 58 65 78 74 65 72 6e 20 | 63 68 61 72 20 2a 6d 65 |Xextern |char *me|
|00000bc0| 6d 5f 72 65 61 6c 6c 6f | 63 28 29 3b 0a 58 65 78 |m_reallo|c();.Xex|
|00000bd0| 74 65 72 6e 20 69 6e 74 | 20 6d 65 6d 5f 66 72 65 |tern int| mem_fre|
|00000be0| 65 28 29 3b 09 09 2f 2a | 20 4d 55 53 54 20 62 65 |e();../*| MUST be|
|00000bf0| 20 69 6e 74 20 65 76 65 | 6e 20 74 68 6f 75 67 68 | int eve|n though|
|00000c00| 20 6e 6f 20 72 65 74 75 | 72 6e 20 76 61 6c 75 65 | no retu|rn value|
|00000c10| 20 2a 2f 0a 58 0a 58 23 | 65 6e 64 69 66 20 2f 2a | */.X.X#|endif /*|
|00000c20| 55 4e 49 58 5f 4d 41 4c | 4c 4f 43 2a 2f 0a 58 0a |UNIX_MAL|LOC*/.X.|
|00000c30| 58 0a 58 2f 2a 0a 58 20 | 2a 20 41 6e 20 69 74 65 |X.X/*.X |* An ite|
|00000c40| 6d 20 74 6f 20 62 65 20 | 70 6c 61 63 65 64 20 6f |m to be |placed o|
|00000c50| 6e 20 61 20 66 72 65 65 | 20 6c 69 73 74 2e 0a 58 |n a free| list..X|
|00000c60| 20 2a 20 54 68 65 73 65 | 20 69 74 65 6d 73 20 61 | * These| items a|
|00000c70| 72 65 20 6f 76 65 72 6c | 61 79 65 64 20 6f 6e 20 |re overl|ayed on |
|00000c80| 74 6f 70 20 6f 66 20 74 | 68 65 20 61 63 74 75 61 |top of t|he actua|
|00000c90| 6c 20 69 74 65 6d 20 62 | 65 69 6e 67 20 6d 61 6e |l item b|eing man|
|00000ca0| 61 67 65 64 2e 0a 58 20 | 2a 20 54 68 65 72 65 66 |aged..X |* Theref|
|00000cb0| 6f 72 65 2c 20 74 68 65 | 20 6d 61 6e 61 67 65 64 |ore, the| managed|
|00000cc0| 20 69 74 65 6d 73 20 6d | 75 73 74 20 62 65 20 61 | items m|ust be a|
|00000cd0| 74 20 6c 65 61 73 74 20 | 74 68 69 73 20 73 69 7a |t least |this siz|
|00000ce0| 65 21 0a 58 20 2a 20 41 | 6c 73 6f 2c 20 61 6c 6c |e!.X * A|lso, all|
|00000cf0| 20 69 74 65 6d 73 20 6f | 6e 20 61 20 73 69 6e 67 | items o|n a sing|
|00000d00| 6c 65 20 66 72 65 65 20 | 6c 69 73 74 20 6d 75 73 |le free |list mus|
|00000d10| 74 20 62 65 20 74 68 65 | 20 73 61 6d 65 20 73 69 |t be the| same si|
|00000d20| 7a 65 2e 0a 58 20 2a 2f | 0a 58 73 74 72 75 63 74 |ze..X */|.Xstruct|
|00000d30| 20 66 72 65 65 5f 69 74 | 65 6d 20 7b 0a 58 09 73 | free_it|em {.X.s|
|00000d40| 74 72 75 63 74 20 66 72 | 65 65 5f 69 74 65 6d 20 |truct fr|ee_item |
|00000d50| 2a 6e 65 78 74 3b 09 09 | 09 2f 2a 20 6e 65 78 74 |*next;..|./* next|
|00000d60| 20 69 74 65 6d 20 6f 6e | 20 66 72 65 65 20 6c 69 | item on| free li|
|00000d70| 73 74 20 2a 2f 0a 58 7d | 3b 0a 58 74 79 70 65 64 |st */.X}|;.Xtyped|
|00000d80| 65 66 20 73 74 72 75 63 | 74 20 66 72 65 65 5f 69 |ef struc|t free_i|
|00000d90| 74 65 6d 20 46 52 45 45 | 49 54 45 4d 3b 0a 58 0a |tem FREE|ITEM;.X.|
|00000da0| 58 0a 58 2f 2a 0a 58 20 | 2a 20 54 68 65 20 61 63 |X.X/*.X |* The ac|
|00000db0| 74 75 61 6c 20 66 72 65 | 65 20 6c 69 73 74 20 68 |tual fre|e list h|
|00000dc0| 65 61 64 65 72 2e 0a 58 | 20 2a 2f 0a 58 74 79 70 |eader..X| */.Xtyp|
|00000dd0| 65 64 65 66 20 73 74 72 | 75 63 74 20 7b 0a 58 09 |edef str|uct {.X.|
|00000de0| 6c 6f 6e 67 09 09 69 74 | 65 6d 73 69 7a 65 3b 09 |long..it|emsize;.|
|00000df0| 2f 2a 20 73 69 7a 65 20 | 6f 66 20 61 6e 20 69 74 |/* size |of an it|
|00000e00| 65 6d 20 62 65 69 6e 67 | 20 6d 61 6e 61 67 65 64 |em being| managed|
|00000e10| 20 2a 2f 0a 58 09 6c 6f | 6e 67 09 09 6d 61 78 66 | */.X.lo|ng..maxf|
|00000e20| 72 65 65 3b 09 2f 2a 20 | 6d 61 78 69 6d 75 6d 20 |ree;./* |maximum |
|00000e30| 6e 75 6d 62 65 72 20 6f | 66 20 66 72 65 65 20 69 |number o|f free i|
|00000e40| 74 65 6d 73 20 2a 2f 0a | 58 09 6c 6f 6e 67 09 09 |tems */.|X.long..|
|00000e50| 63 75 72 66 72 65 65 3b | 09 2f 2a 20 63 75 72 72 |curfree;|./* curr|
|00000e60| 65 6e 74 20 6e 75 6d 62 | 65 72 20 6f 66 20 66 72 |ent numb|er of fr|
|00000e70| 65 65 20 69 74 65 6d 73 | 20 2a 2f 0a 58 09 46 52 |ee items| */.X.FR|
|00000e80| 45 45 49 54 45 4d 09 2a | 66 72 65 65 6c 69 73 74 |EEITEM.*|freelist|
|00000e90| 3b 09 2f 2a 20 74 68 65 | 20 66 72 65 65 20 6c 69 |;./* the| free li|
|00000ea0| 73 74 20 2a 2f 0a 58 7d | 20 46 52 45 45 4c 49 53 |st */.X}| FREELIS|
|00000eb0| 54 3b 0a 58 0a 58 23 69 | 66 20 64 65 66 69 6e 65 |T;.X.X#i|f define|
|00000ec0| 64 28 5f 5f 53 54 44 43 | 5f 5f 29 0a 58 74 79 70 |d(__STDC|__).Xtyp|
|00000ed0| 65 64 65 66 20 76 6f 69 | 64 20 41 4c 4c 4f 43 49 |edef voi|d ALLOCI|
|00000ee0| 54 45 4d 3b 0a 58 23 65 | 6c 73 65 0a 58 74 79 70 |TEM;.X#e|lse.Xtyp|
|00000ef0| 65 64 65 66 20 63 68 61 | 72 20 41 4c 4c 4f 43 49 |edef cha|r ALLOCI|
|00000f00| 54 45 4d 3b 0a 58 23 65 | 6e 64 69 66 0a 58 65 78 |TEM;.X#e|ndif.Xex|
|00000f10| 74 65 72 6e 20 41 4c 4c | 4f 43 49 54 45 4d 20 2a |tern ALL|OCITEM *|
|00000f20| 20 61 6c 6c 6f 63 69 74 | 65 6d 28 20 2f 2a 20 46 | allocit|em( /* F|
|00000f30| 52 45 45 4c 49 53 54 20 | 2a 20 2a 2f 20 29 3b 0a |REELIST |* */ );.|
|00000f40| 58 65 78 74 65 72 6e 20 | 76 6f 69 64 20 66 72 65 |Xextern |void fre|
|00000f50| 65 69 74 65 6d 28 20 2f | 2a 20 46 52 45 45 4c 49 |eitem( /|* FREELI|
|00000f60| 53 54 20 2a 2c 20 63 68 | 61 72 20 2a 20 2a 2f 20 |ST *, ch|ar * */ |
|00000f70| 29 3b 0a 58 65 78 74 65 | 72 6e 20 76 6f 69 64 20 |);.Xexte|rn void |
|00000f80| 6d 65 6d 5f 73 74 61 74 | 73 28 29 3b 0a 58 0a 58 |mem_stat|s();.X.X|
|00000f90| 2f 2a 20 45 4e 44 20 43 | 4f 44 45 20 2a 2f 0a 45 |/* END C|ODE */.E|
|00000fa0| 4e 44 5f 4f 46 5f 46 49 | 4c 45 0a 69 66 20 74 65 |ND_OF_FI|LE.if te|
|00000fb0| 73 74 20 32 36 38 36 20 | 2d 6e 65 20 60 77 63 20 |st 2686 |-ne `wc |
|00000fc0| 2d 63 20 3c 27 61 6c 6c | 6f 63 2e 68 27 60 3b 20 |-c <'all|oc.h'`; |
|00000fd0| 74 68 65 6e 0a 20 20 20 | 20 65 63 68 6f 20 73 68 |then. | echo sh|
|00000fe0| 61 72 3a 20 5c 22 27 61 | 6c 6c 6f 63 2e 68 27 5c |ar: \"'a|lloc.h'\|
|00000ff0| 22 20 75 6e 70 61 63 6b | 65 64 20 77 69 74 68 20 |" unpack|ed with |
|00001000| 77 72 6f 6e 67 20 73 69 | 7a 65 21 0a 66 69 0a 23 |wrong si|ze!.fi.#|
|00001010| 20 65 6e 64 20 6f 66 20 | 27 61 6c 6c 6f 63 2e 68 | end of |'alloc.h|
|00001020| 27 0a 66 69 0a 69 66 20 | 74 65 73 74 20 2d 66 20 |'.fi.if |test -f |
|00001030| 27 63 61 6c 63 2e 63 27 | 20 2d 61 20 22 24 7b 31 |'calc.c'| -a "${1|
|00001040| 7d 22 20 21 3d 20 22 2d | 63 22 20 3b 20 74 68 65 |}" != "-|c" ; the|
|00001050| 6e 20 0a 20 20 65 63 68 | 6f 20 73 68 61 72 3a 20 |n . ech|o shar: |
|00001060| 57 69 6c 6c 20 6e 6f 74 | 20 63 6c 6f 62 62 65 72 |Will not| clobber|
|00001070| 20 65 78 69 73 74 69 6e | 67 20 66 69 6c 65 20 5c | existin|g file \|
|00001080| 22 27 63 61 6c 63 2e 63 | 27 5c 22 0a 65 6c 73 65 |"'calc.c|'\".else|
|00001090| 0a 65 63 68 6f 20 73 68 | 61 72 3a 20 45 78 74 72 |.echo sh|ar: Extr|
|000010a0| 61 63 74 69 6e 67 20 5c | 22 27 63 61 6c 63 2e 63 |acting \|"'calc.c|
|000010b0| 27 5c 22 20 5c 28 34 39 | 30 35 20 63 68 61 72 61 |'\" \(49|05 chara|
|000010c0| 63 74 65 72 73 5c 29 0a | 73 65 64 20 22 73 2f 5e |cters\).|sed "s/^|
|000010d0| 58 2f 2f 22 20 3e 27 63 | 61 6c 63 2e 63 27 20 3c |X//" >'c|alc.c' <|
|000010e0| 3c 27 45 4e 44 5f 4f 46 | 5f 46 49 4c 45 27 0a 58 |<'END_OF|_FILE'.X|
|000010f0| 2f 2a 0a 58 20 2a 20 43 | 6f 70 79 72 69 67 68 74 |/*.X * C|opyright|
|00001100| 20 28 63 29 20 31 39 39 | 32 20 44 61 76 69 64 20 | (c) 199|2 David |
|00001110| 49 2e 20 42 65 6c 6c 0a | 58 20 2a 20 50 65 72 6d |I. Bell.|X * Perm|
|00001120| 69 73 73 69 6f 6e 20 69 | 73 20 67 72 61 6e 74 65 |ission i|s grante|
|00001130| 64 20 74 6f 20 75 73 65 | 2c 20 64 69 73 74 72 69 |d to use|, distri|
|00001140| 62 75 74 65 2c 20 6f 72 | 20 6d 6f 64 69 66 79 20 |bute, or| modify |
|00001150| 74 68 69 73 20 73 6f 75 | 72 63 65 2c 0a 58 20 2a |this sou|rce,.X *|
|00001160| 20 70 72 6f 76 69 64 65 | 64 20 74 68 61 74 20 74 | provide|d that t|
|00001170| 68 69 73 20 63 6f 70 79 | 72 69 67 68 74 20 6e 6f |his copy|right no|
|00001180| 74 69 63 65 20 72 65 6d | 61 69 6e 73 20 69 6e 74 |tice rem|ains int|
|00001190| 61 63 74 2e 0a 58 20 2a | 0a 58 20 2a 20 41 72 62 |act..X *|.X * Arb|
|000011a0| 69 74 72 61 72 79 20 70 | 72 65 63 69 73 69 6f 6e |itrary p|recision|
|000011b0| 20 63 61 6c 63 75 6c 61 | 74 6f 72 2e 0a 58 20 2a | calcula|tor..X *|
|000011c0| 2f 0a 58 0a 58 23 69 6e | 63 6c 75 64 65 20 3c 73 |/.X.X#in|clude <s|
|000011d0| 69 67 6e 61 6c 2e 68 3e | 0a 58 23 69 6e 63 6c 75 |ignal.h>|.X#inclu|
|000011e0| 64 65 20 3c 70 77 64 2e | 68 3e 0a 58 23 69 6e 63 |de <pwd.|h>.X#inc|
|000011f0| 6c 75 64 65 20 3c 73 79 | 73 2f 74 79 70 65 73 2e |lude <sy|s/types.|
|00001200| 68 3e 0a 58 0a 58 23 69 | 6e 63 6c 75 64 65 20 22 |h>.X.X#i|nclude "|
|00001210| 63 61 6c 63 2e 68 22 0a | 58 23 69 6e 63 6c 75 64 |calc.h".|X#includ|
|00001220| 65 20 22 66 75 6e 63 2e | 68 22 0a 58 23 69 6e 63 |e "func.|h".X#inc|
|00001230| 6c 75 64 65 20 22 6f 70 | 63 6f 64 65 73 2e 68 22 |lude "op|codes.h"|
|00001240| 0a 58 23 69 6e 63 6c 75 | 64 65 20 22 63 6f 6e 66 |.X#inclu|de "conf|
|00001250| 69 67 2e 68 22 0a 58 23 | 69 6e 63 6c 75 64 65 20 |ig.h".X#|include |
|00001260| 22 74 6f 6b 65 6e 2e 68 | 22 0a 58 23 69 6e 63 6c |"token.h|".X#incl|
|00001270| 75 64 65 20 22 73 79 6d | 62 6f 6c 2e 68 22 0a 58 |ude "sym|bol.h".X|
|00001280| 0a 58 2f 2a 0a 58 20 2a | 20 43 6f 6d 6d 6f 6e 20 |.X/*.X *| Common |
|00001290| 64 65 66 69 6e 69 74 69 | 6f 6e 73 0a 58 20 2a 2f |definiti|ons.X */|
|000012a0| 0a 58 6c 6f 6e 67 20 6d | 61 78 70 72 69 6e 74 3b |.Xlong m|axprint;|
|000012b0| 09 09 2f 2a 20 6e 75 6d | 62 65 72 20 6f 66 20 65 |../* num|ber of e|
|000012c0| 6c 65 6d 65 6e 74 73 20 | 74 6f 20 70 72 69 6e 74 |lements |to print|
|000012d0| 20 2a 2f 0a 58 69 6e 74 | 20 61 62 6f 72 74 6c 65 | */.Xint| abortle|
|000012e0| 76 65 6c 3b 09 09 2f 2a | 20 63 75 72 72 65 6e 74 |vel;../*| current|
|000012f0| 20 6c 65 76 65 6c 20 6f | 66 20 61 62 6f 72 74 73 | level o|f aborts|
|00001300| 20 2a 2f 0a 58 42 4f 4f | 4c 20 69 6e 70 75 74 77 | */.XBOO|L inputw|
|00001310| 61 69 74 3b 09 09 2f 2a | 20 54 52 55 45 20 69 66 |ait;../*| TRUE if|
|00001320| 20 69 6e 20 61 20 74 65 | 72 6d 69 6e 61 6c 20 69 | in a te|rminal i|
|00001330| 6e 70 75 74 20 77 61 69 | 74 20 2a 2f 0a 58 6a 6d |nput wai|t */.Xjm|
|00001340| 70 5f 62 75 66 20 6a 6d | 70 62 75 66 3b 09 09 2f |p_buf jm|pbuf;../|
|00001350| 2a 20 66 6f 72 20 65 72 | 72 6f 72 73 20 2a 2f 0a |* for er|rors */.|
|00001360| 58 0a 58 73 74 61 74 69 | 63 20 69 6e 74 20 71 5f |X.Xstati|c int q_|
|00001370| 66 6c 61 67 20 3d 20 46 | 41 4c 53 45 3b 09 2f 2a |flag = F|ALSE;./*|
|00001380| 20 54 52 55 45 20 3d 3e | 20 64 6f 6e 27 74 20 65 | TRUE =>| don't e|
|00001390| 78 65 63 75 74 65 20 72 | 63 20 66 69 6c 65 73 20 |xecute r|c files |
|000013a0| 2a 2f 0a 58 0a 58 63 68 | 61 72 20 2a 63 61 6c 63 |*/.X.Xch|ar *calc|
|000013b0| 70 61 74 68 3b 09 09 2f | 2a 20 24 43 41 4c 43 50 |path;../|* $CALCP|
|000013c0| 41 54 48 20 6f 72 20 64 | 65 66 61 75 6c 74 20 2a |ATH or d|efault *|
|000013d0| 2f 0a 58 63 68 61 72 20 | 2a 63 61 6c 63 72 63 3b |/.Xchar |*calcrc;|
|000013e0| 09 09 2f 2a 20 24 43 41 | 4c 43 52 43 20 6f 72 20 |../* $CA|LCRC or |
|000013f0| 64 65 66 61 75 6c 74 20 | 2a 2f 0a 58 63 68 61 72 |default |*/.Xchar|
|00001400| 20 2a 68 6f 6d 65 3b 09 | 09 2f 2a 20 24 48 4f 4d | *home;.|./* $HOM|
|00001410| 45 20 6f 72 20 64 65 66 | 61 75 6c 74 20 2a 2f 0a |E or def|ault */.|
|00001420| 58 73 74 61 74 69 63 20 | 63 68 61 72 20 2a 70 61 |Xstatic |char *pa|
|00001430| 67 65 72 3b 09 2f 2a 20 | 24 50 41 47 45 52 20 6f |ger;./* |$PAGER o|
|00001440| 72 20 64 65 66 61 75 6c | 74 20 2a 2f 0a 58 63 68 |r defaul|t */.Xch|
|00001450| 61 72 20 2a 73 68 65 6c | 6c 3b 09 09 2f 2a 20 24 |ar *shel|l;../* $|
|00001460| 53 48 45 4c 4c 20 6f 72 | 20 64 65 66 61 75 6c 74 |SHELL or| default|
|00001470| 20 2a 2f 0a 58 0a 58 73 | 74 61 74 69 63 20 76 6f | */.X.Xs|tatic vo|
|00001480| 69 64 20 69 6e 74 69 6e | 74 28 29 3b 09 2f 2a 20 |id intin|t();./* |
|00001490| 69 6e 74 65 72 72 75 70 | 74 20 72 6f 75 74 69 6e |interrup|t routin|
|000014a0| 65 20 2a 2f 0a 58 76 6f | 69 64 20 67 69 76 65 68 |e */.Xvo|id giveh|
|000014b0| 65 6c 70 28 29 3b 0a 58 | 73 74 61 74 69 63 20 76 |elp();.X|static v|
|000014c0| 6f 69 64 20 69 6e 69 74 | 65 6e 76 28 29 3b 09 2f |oid init|env();./|
|000014d0| 2a 20 69 6e 69 74 69 61 | 6c 69 7a 65 2f 64 65 66 |* initia|lize/def|
|000014e0| 61 75 6c 74 20 73 70 65 | 63 69 61 6c 20 65 6e 76 |ault spe|cial env|
|000014f0| 69 72 6f 6e 6d 65 6e 74 | 20 76 61 72 73 20 2a 2f |ironment| vars */|
|00001500| 0a 58 0a 58 65 78 74 65 | 72 6e 20 73 74 72 75 63 |.X.Xexte|rn struc|
|00001510| 74 20 70 61 73 73 77 64 | 20 2a 67 65 74 70 77 75 |t passwd| *getpwu|
|00001520| 69 64 28 29 3b 0a 58 65 | 78 74 65 72 6e 20 63 68 |id();.Xe|xtern ch|
|00001530| 61 72 20 2a 67 65 74 65 | 6e 76 28 29 3b 0a 58 65 |ar *gete|nv();.Xe|
|00001540| 78 74 65 72 6e 20 75 69 | 64 5f 74 20 67 65 74 65 |xtern ui|d_t gete|
|00001550| 75 69 64 28 29 3b 0a 58 | 0a 58 2f 2a 0a 58 20 2a |uid();.X|.X/*.X *|
|00001560| 20 54 6f 70 20 6c 65 76 | 65 6c 20 63 61 6c 63 75 | Top lev|el calcu|
|00001570| 6c 61 74 6f 72 20 72 6f | 75 74 69 6e 65 2e 0a 58 |lator ro|utine..X|
|00001580| 20 2a 2f 0a 58 6d 61 69 | 6e 28 61 72 67 63 2c 20 | */.Xmai|n(argc, |
|00001590| 61 72 67 76 29 0a 58 09 | 63 68 61 72 20 2a 2a 61 |argv).X.|char **a|
|000015a0| 72 67 76 3b 0a 58 7b 0a | 58 09 63 68 61 72 20 2a |rgv;.X{.|X.char *|
|000015b0| 73 74 72 3b 09 09 2f 2a | 20 63 75 72 72 65 6e 74 |str;../*| current|
|000015c0| 20 6f 70 74 69 6f 6e 20 | 73 74 72 69 6e 67 20 6f | option |string o|
|000015d0| 72 20 65 78 70 72 65 73 | 73 69 6f 6e 20 2a 2f 0a |r expres|sion */.|
|000015e0| 58 09 63 68 61 72 20 63 | 6d 64 62 75 66 5b 4d 41 |X.char c|mdbuf[MA|
|000015f0| 58 43 4d 44 2b 31 5d 3b | 09 2f 2a 20 63 6f 6d 6d |XCMD+1];|./* comm|
|00001600| 61 6e 64 20 6c 69 6e 65 | 20 65 78 70 72 65 73 73 |and line| express|
|00001610| 69 6f 6e 20 2a 2f 0a 58 | 0a 58 09 69 6e 69 74 65 |ion */.X|.X.inite|
|00001620| 6e 76 28 29 3b 0a 58 09 | 61 72 67 63 2d 2d 3b 0a |nv();.X.|argc--;.|
|00001630| 58 09 61 72 67 76 2b 2b | 3b 0a 58 09 77 68 69 6c |X.argv++|;.X.whil|
|00001640| 65 20 28 28 61 72 67 63 | 20 3e 20 30 29 20 26 26 |e ((argc| > 0) &&|
|00001650| 20 28 2a 2a 61 72 67 76 | 20 3d 3d 20 27 2d 27 29 | (**argv| == '-')|
|00001660| 29 20 7b 0a 58 09 09 66 | 6f 72 20 28 73 74 72 20 |) {.X..f|or (str |
|00001670| 3d 20 26 61 72 67 76 5b | 30 5d 5b 31 5d 3b 20 2a |= &argv[|0][1]; *|
|00001680| 73 74 72 3b 20 73 74 72 | 2b 2b 29 20 73 77 69 74 |str; str|++) swit|
|00001690| 63 68 20 28 2a 73 74 72 | 29 20 7b 0a 58 09 09 09 |ch (*str|) {.X...|
|000016a0| 63 61 73 65 20 27 68 27 | 3a 0a 58 09 09 09 09 67 |case 'h'|:.X....g|
|000016b0| 69 76 65 68 65 6c 70 28 | 44 45 46 41 55 4c 54 43 |ivehelp(|DEFAULTC|
|000016c0| 41 4c 43 48 45 4c 50 29 | 3b 0a 58 09 09 09 09 65 |ALCHELP)|;.X....e|
|000016d0| 78 69 74 28 30 29 3b 0a | 58 09 09 09 09 62 72 65 |xit(0);.|X....bre|
|000016e0| 61 6b 3b 0a 58 09 09 09 | 63 61 73 65 20 27 71 27 |ak;.X...|case 'q'|
|000016f0| 3a 0a 58 09 09 09 09 71 | 5f 66 6c 61 67 20 3d 20 |:.X....q|_flag = |
|00001700| 54 52 55 45 3b 0a 58 09 | 09 09 09 62 72 65 61 6b |TRUE;.X.|...break|
|00001710| 3b 0a 58 09 09 09 64 65 | 66 61 75 6c 74 3a 0a 58 |;.X...de|fault:.X|
|00001720| 09 09 09 09 70 72 69 6e | 74 66 28 22 55 6e 6b 6e |....prin|tf("Unkn|
|00001730| 6f 77 6e 20 6f 70 74 69 | 6f 6e 5c 6e 22 29 3b 0a |own opti|on\n");.|
|00001740| 58 09 09 09 09 65 78 69 | 74 28 31 29 3b 0a 58 09 |X....exi|t(1);.X.|
|00001750| 09 7d 0a 58 09 09 61 72 | 67 63 2d 2d 3b 0a 58 09 |.}.X..ar|gc--;.X.|
|00001760| 09 61 72 67 76 2b 2b 3b | 0a 58 09 7d 0a 58 09 73 |.argv++;|.X.}.X.s|
|00001770| 74 72 20 3d 20 63 6d 64 | 62 75 66 3b 0a 58 09 2a |tr = cmd|buf;.X.*|
|00001780| 73 74 72 20 3d 20 27 5c | 30 27 3b 0a 58 09 77 68 |str = '\|0';.X.wh|
|00001790| 69 6c 65 20 28 2d 2d 61 | 72 67 63 20 3e 3d 20 30 |ile (--a|rgc >= 0|
|000017a0| 29 20 7b 0a 58 09 09 2a | 73 74 72 2b 2b 20 3d 20 |) {.X..*|str++ = |
|000017b0| 27 20 27 3b 0a 58 09 09 | 73 74 72 63 70 79 28 73 |' ';.X..|strcpy(s|
|000017c0| 74 72 2c 20 2a 61 72 67 | 76 2b 2b 29 3b 0a 58 09 |tr, *arg|v++);.X.|
|000017d0| 09 73 74 72 20 2b 3d 20 | 73 74 72 6c 65 6e 28 73 |.str += |strlen(s|
|000017e0| 74 72 29 3b 0a 58 09 09 | 73 74 72 5b 30 5d 20 3d |tr);.X..|str[0] =|
|000017f0| 20 27 5c 6e 27 3b 0a 58 | 09 09 73 74 72 5b 31 5d | '\n';.X|..str[1]|
|00001800| 20 3d 20 27 5c 30 27 3b | 0a 58 09 7d 0a 58 09 73 | = '\0';|.X.}.X.s|
|00001810| 74 72 20 3d 20 63 6d 64 | 62 75 66 3b 0a 58 09 69 |tr = cmd|buf;.X.i|
|00001820| 66 20 28 2a 73 74 72 20 | 3d 3d 20 27 5c 30 27 29 |f (*str |== '\0')|
|00001830| 20 7b 0a 58 09 09 73 74 | 72 20 3d 20 4e 55 4c 4c | {.X..st|r = NULL|
|00001840| 3b 0a 58 09 09 70 72 69 | 6e 74 66 28 22 43 2d 73 |;.X..pri|ntf("C-s|
|00001850| 74 79 6c 65 20 61 72 62 | 69 74 72 61 72 79 20 70 |tyle arb|itrary p|
|00001860| 72 65 63 69 73 69 6f 6e | 20 63 61 6c 63 75 6c 61 |recision| calcula|
|00001870| 74 6f 72 2e 5c 6e 22 29 | 3b 0a 58 09 09 76 65 72 |tor.\n")|;.X..ver|
|00001880| 73 69 6f 6e 28 73 74 64 | 6f 75 74 29 3b 0a 58 09 |sion(std|out);.X.|
|00001890| 09 70 72 69 6e 74 66 28 | 22 5b 54 79 70 65 20 5c |.printf(|"[Type \|
|000018a0| 22 65 78 69 74 5c 22 20 | 74 6f 20 65 78 69 74 2c |"exit\" |to exit,|
|000018b0| 20 6f 72 20 5c 22 68 65 | 6c 70 5c 22 20 66 6f 72 | or \"he|lp\" for|
|000018c0| 20 68 65 6c 70 2e 5d 5c | 6e 5c 6e 22 29 3b 0a 58 | help.]\|n\n");.X|
|000018d0| 09 7d 0a 58 09 69 66 20 | 28 73 65 74 6a 6d 70 28 |.}.X.if |(setjmp(|
|000018e0| 6a 6d 70 62 75 66 29 20 | 3d 3d 20 30 29 20 7b 0a |jmpbuf) |== 0) {.|
|000018f0| 58 09 09 69 6e 69 74 6d | 61 73 6b 73 28 29 3b 0a |X..initm|asks();.|
|00001900| 58 09 09 69 6e 69 74 74 | 6f 6b 65 6e 73 28 29 3b |X..initt|okens();|
|00001910| 0a 58 09 09 69 6e 69 74 | 67 6c 6f 62 61 6c 73 28 |.X..init|globals(|
|00001920| 29 3b 0a 58 09 09 69 6e | 69 74 66 75 6e 63 74 69 |);.X..in|itfuncti|
|00001930| 6f 6e 73 28 29 3b 0a 58 | 09 09 69 6e 69 74 73 74 |ons();.X|..initst|
|00001940| 61 63 6b 28 29 3b 0a 58 | 09 09 72 65 73 65 74 69 |ack();.X|..reseti|
|00001950| 6e 70 75 74 28 29 3b 0a | 58 09 09 63 6c 65 61 72 |nput();.|X..clear|
|00001960| 64 69 76 65 72 73 69 6f | 6e 73 28 29 3b 0a 58 09 |diversio|ns();.X.|
|00001970| 09 73 65 74 66 70 28 73 | 74 64 6f 75 74 29 3b 0a |.setfp(s|tdout);.|
|00001980| 58 09 09 73 65 74 6d 6f | 64 65 28 4d 4f 44 45 5f |X..setmo|de(MODE_|
|00001990| 49 4e 49 54 49 41 4c 29 | 3b 0a 58 09 09 73 65 74 |INITIAL)|;.X..set|
|000019a0| 64 69 67 69 74 73 28 44 | 49 53 50 4c 41 59 5f 44 |digits(D|ISPLAY_D|
|000019b0| 45 46 41 55 4c 54 29 3b | 0a 58 09 09 6d 61 78 70 |EFAULT);|.X..maxp|
|000019c0| 72 69 6e 74 20 3d 20 4d | 41 58 50 52 49 4e 54 5f |rint = M|AXPRINT_|
|000019d0| 44 45 46 41 55 4c 54 3b | 0a 58 09 09 5f 65 70 73 |DEFAULT;|.X.._eps|
|000019e0| 69 6c 6f 6e 5f 20 3d 20 | 61 74 6f 71 28 45 50 53 |ilon_ = |atoq(EPS|
|000019f0| 49 4c 4f 4e 5f 44 45 46 | 41 55 4c 54 29 3b 0a 58 |ILON_DEF|AULT);.X|
|00001a00| 09 09 5f 65 70 73 69 6c | 6f 6e 70 72 65 63 5f 20 |.._epsil|onprec_ |
|00001a10| 3d 20 71 70 72 65 63 69 | 73 69 6f 6e 28 5f 65 70 |= qpreci|sion(_ep|
|00001a20| 73 69 6c 6f 6e 5f 29 3b | 0a 58 09 09 69 66 20 28 |silon_);|.X..if (|
|00001a30| 73 74 72 29 20 7b 0a 58 | 09 09 09 69 66 20 28 71 |str) {.X|...if (q|
|00001a40| 5f 66 6c 61 67 20 3d 3d | 20 46 41 4c 53 45 29 20 |_flag ==| FALSE) |
|00001a50| 7b 0a 58 09 09 09 09 72 | 75 6e 72 63 66 69 6c 65 |{.X....r|unrcfile|
|00001a60| 73 28 29 3b 0a 58 09 09 | 09 09 71 5f 66 6c 61 67 |s();.X..|..q_flag|
|00001a70| 20 3d 20 54 52 55 45 3b | 0a 58 09 09 09 7d 0a 58 | = TRUE;|.X...}.X|
|00001a80| 09 09 09 28 76 6f 69 64 | 29 20 6f 70 65 6e 73 74 |...(void|) openst|
|00001a90| 72 69 6e 67 28 73 74 72 | 29 3b 0a 58 09 09 09 67 |ring(str|);.X...g|
|00001aa0| 65 74 63 6f 6d 6d 61 6e | 64 73 28 29 3b 0a 58 09 |etcomman|ds();.X.|
|00001ab0| 09 09 65 78 69 74 28 30 | 29 3b 0a 58 09 09 7d 0a |..exit(0|);.X..}.|
|00001ac0| 58 09 7d 0a 58 09 69 66 | 20 28 73 74 72 29 0a 58 |X.}.X.if| (str).X|
|00001ad0| 09 09 65 78 69 74 28 31 | 29 3b 0a 58 09 61 62 6f |..exit(1|);.X.abo|
|00001ae0| 72 74 6c 65 76 65 6c 20 | 3d 20 30 3b 0a 58 09 5f |rtlevel |= 0;.X._|
|00001af0| 6d 61 74 68 5f 61 62 6f | 72 74 5f 20 3d 20 46 41 |math_abo|rt_ = FA|
|00001b00| 4c 53 45 3b 0a 58 09 69 | 6e 70 75 74 77 61 69 74 |LSE;.X.i|nputwait|
|00001b10| 20 3d 20 46 41 4c 53 45 | 3b 0a 58 09 28 76 6f 69 | = FALSE|;.X.(voi|
|00001b20| 64 29 20 73 69 67 6e 61 | 6c 28 53 49 47 49 4e 54 |d) signa|l(SIGINT|
|00001b30| 2c 20 69 6e 74 69 6e 74 | 29 3b 0a 58 09 63 6c 65 |, intint|);.X.cle|
|00001b40| 61 72 64 69 76 65 72 73 | 69 6f 6e 73 28 29 3b 0a |ardivers|ions();.|
|00001b50| 58 09 73 65 74 66 70 28 | 73 74 64 6f 75 74 29 3b |X.setfp(|stdout);|
|00001b60| 0a 58 09 72 65 73 65 74 | 69 6e 70 75 74 28 29 3b |.X.reset|input();|
|00001b70| 0a 58 09 69 66 20 28 71 | 5f 66 6c 61 67 20 3d 3d |.X.if (q|_flag ==|
|00001b80| 20 46 41 4c 53 45 29 20 | 7b 0a 58 09 09 72 75 6e | FALSE) |{.X..run|
|00001b90| 72 63 66 69 6c 65 73 28 | 29 3b 0a 58 09 09 71 5f |rcfiles(|);.X..q_|
|00001ba0| 66 6c 61 67 20 3d 20 54 | 52 55 45 3b 0a 58 09 7d |flag = T|RUE;.X.}|
|00001bb0| 0a 58 09 28 76 6f 69 64 | 29 20 6f 70 65 6e 74 65 |.X.(void|) opente|
|00001bc0| 72 6d 69 6e 61 6c 28 29 | 3b 0a 58 09 67 65 74 63 |rminal()|;.X.getc|
|00001bd0| 6f 6d 6d 61 6e 64 73 28 | 29 3b 0a 58 09 65 78 69 |ommands(|);.X.exi|
|00001be0| 74 28 30 29 3b 0a 58 09 | 2f 2a 4e 4f 54 52 45 41 |t(0);.X.|/*NOTREA|
|00001bf0| 43 48 45 44 2a 2f 0a 58 | 7d 0a 58 0a 58 0a 58 2f |CHED*/.X|}.X.X.X/|
|00001c00| 2a 0a 58 20 2a 20 69 6e | 69 74 65 6e 76 20 2d 20 |*.X * in|itenv - |
|00001c10| 6f 62 74 61 69 6e 20 24 | 43 41 4c 43 50 41 54 48 |obtain $|CALCPATH|
|00001c20| 2c 20 24 43 41 4c 43 52 | 43 2c 20 24 48 4f 4d 45 |, $CALCR|C, $HOME|
|00001c30| 2c 20 24 50 41 47 45 52 | 20 61 6e 64 20 24 53 48 |, $PAGER| and $SH|
|00001c40| 45 4c 4c 20 76 61 6c 75 | 65 73 0a 58 20 2a 0a 58 |ELL valu|es.X *.X|
|00001c50| 20 2a 20 49 66 20 24 43 | 41 4c 43 50 41 54 48 2c | * If $C|ALCPATH,|
|00001c60| 20 24 43 41 4c 43 52 43 | 2c 20 24 50 41 47 45 52 | $CALCRC|, $PAGER|
|00001c70| 20 6f 72 20 24 53 48 45 | 4c 4c 20 64 6f 20 6e 6f | or $SHE|LL do no|
|00001c80| 74 20 65 78 69 73 74 2c | 20 75 73 65 20 74 68 65 |t exist,| use the|
|00001c90| 20 64 65 66 61 75 6c 74 | 0a 58 20 2a 20 76 61 6c | default|.X * val|
|00001ca0| 75 65 73 2e 20 20 49 66 | 20 24 50 41 47 45 52 20 |ues. If| $PAGER |
|00001cb0| 6f 72 20 24 53 48 45 4c | 4c 20 69 73 20 61 6e 20 |or $SHEL|L is an |
|00001cc0| 65 6d 70 74 79 20 73 74 | 72 69 6e 67 2c 20 61 6c |empty st|ring, al|
|00001cd0| 73 6f 20 75 73 65 20 61 | 20 64 65 66 61 75 6c 74 |so use a| default|
|00001ce0| 20 76 61 6c 75 65 2e 0a | 58 20 2a 20 49 66 20 24 | value..|X * If $|
|00001cf0| 48 4f 4d 45 20 64 6f 65 | 73 20 6e 6f 74 20 65 78 |HOME doe|s not ex|
|00001d00| 69 73 74 2c 20 6f 72 20 | 69 73 20 65 6d 70 74 79 |ist, or |is empty|
|00001d10| 2c 20 75 73 65 20 74 68 | 65 20 68 6f 6d 65 20 64 |, use th|e home d|
|00001d20| 69 72 65 63 74 6f 72 79 | 0a 58 20 2a 20 69 6e 66 |irectory|.X * inf|
|00001d30| 6f 72 6d 61 74 69 6f 6e | 20 66 72 6f 6d 20 74 68 |ormation| from th|
|00001d40| 65 20 70 61 73 73 77 6f | 72 64 20 66 69 6c 65 2e |e passwo|rd file.|
|00001d50| 0a 58 20 2a 2f 0a 58 73 | 74 61 74 69 63 20 76 6f |.X */.Xs|tatic vo|
|00001d60| 69 64 0a 58 69 6e 69 74 | 65 6e 76 28 29 0a 58 7b |id.Xinit|env().X{|
|00001d70| 0a 58 09 73 74 72 75 63 | 74 20 70 61 73 73 77 64 |.X.struc|t passwd|
|00001d80| 20 2a 65 6e 74 3b 09 09 | 2f 2a 20 6f 75 72 20 70 | *ent;..|/* our p|
|00001d90| 61 73 73 77 6f 72 64 20 | 65 6e 74 72 79 20 2a 2f |assword |entry */|
|00001da0| 0a 58 0a 58 09 2f 2a 20 | 64 65 74 65 72 6d 69 6e |.X.X./* |determin|
|00001db0| 65 20 74 68 65 20 24 43 | 41 4c 43 50 41 54 48 20 |e the $C|ALCPATH |
|00001dc0| 76 61 6c 75 65 20 2a 2f | 0a 58 09 63 61 6c 63 70 |value */|.X.calcp|
|00001dd0| 61 74 68 20 3d 20 67 65 | 74 65 6e 76 28 43 41 4c |ath = ge|tenv(CAL|
|00001de0| 43 50 41 54 48 29 3b 0a | 58 09 69 66 20 28 63 61 |CPATH);.|X.if (ca|
|00001df0| 6c 63 70 61 74 68 20 3d | 3d 20 4e 55 4c 4c 29 0a |lcpath =|= NULL).|
|00001e00| 58 09 09 63 61 6c 63 70 | 61 74 68 20 3d 20 44 45 |X..calcp|ath = DE|
|00001e10| 46 41 55 4c 54 43 41 4c | 43 50 41 54 48 3b 0a 58 |FAULTCAL|CPATH;.X|
|00001e20| 0a 58 09 2f 2a 20 64 65 | 74 65 72 6d 69 6e 65 20 |.X./* de|termine |
|00001e30| 74 68 65 20 24 43 41 4c | 43 52 43 20 76 61 6c 75 |the $CAL|CRC valu|
|00001e40| 65 20 2a 2f 0a 58 09 63 | 61 6c 63 72 63 20 3d 20 |e */.X.c|alcrc = |
|00001e50| 67 65 74 65 6e 76 28 43 | 41 4c 43 52 43 29 3b 0a |getenv(C|ALCRC);.|
|00001e60| 58 09 69 66 20 28 63 61 | 6c 63 72 63 20 3d 3d 20 |X.if (ca|lcrc == |
|00001e70| 4e 55 4c 4c 29 20 7b 0a | 58 09 09 63 61 6c 63 72 |NULL) {.|X..calcr|
|00001e80| 63 20 3d 20 44 45 46 41 | 55 4c 54 43 41 4c 43 52 |c = DEFA|ULTCALCR|
|00001e90| 43 3b 0a 58 09 7d 0a 58 | 09 0a 58 09 2f 2a 20 64 |C;.X.}.X|..X./* d|
|00001ea0| 65 74 65 72 6d 69 6e 65 | 20 74 68 65 20 24 48 4f |etermine| the $HO|
|00001eb0| 4d 45 20 76 61 6c 75 65 | 20 2a 2f 0a 58 09 68 6f |ME value| */.X.ho|
|00001ec0| 6d 65 20 3d 20 67 65 74 | 65 6e 76 28 48 4f 4d 45 |me = get|env(HOME|
|00001ed0| 29 3b 0a 58 09 69 66 20 | 28 68 6f 6d 65 20 3d 3d |);.X.if |(home ==|
|00001ee0| 20 4e 55 4c 4c 20 7c 7c | 20 68 6f 6d 65 5b 30 5d | NULL ||| home[0]|
|00001ef0| 20 3d 3d 20 27 5c 30 27 | 29 20 7b 0a 58 09 09 65 | == '\0'|) {.X..e|
|00001f00| 6e 74 20 3d 20 67 65 74 | 70 77 75 69 64 28 67 65 |nt = get|pwuid(ge|
|00001f10| 74 65 75 69 64 28 29 29 | 3b 0a 58 09 09 69 66 20 |teuid())|;.X..if |
|00001f20| 28 65 6e 74 20 3d 3d 20 | 4e 55 4c 4c 29 20 7b 0a |(ent == |NULL) {.|
|00001f30| 58 09 09 09 2f 2a 20 6a | 75 73 74 20 61 73 73 75 |X.../* j|ust assu|
|00001f40| 6d 65 20 2e 20 69 73 20 | 68 6f 6d 65 20 69 66 20 |me . is |home if |
|00001f50| 61 6c 6c 20 65 6c 73 65 | 20 66 61 69 6c 73 20 2a |all else| fails *|
|00001f60| 2f 0a 58 09 09 09 68 6f | 6d 65 20 3d 20 22 2e 22 |/.X...ho|me = "."|
|00001f70| 3b 0a 58 09 09 7d 0a 58 | 09 09 68 6f 6d 65 20 3d |;.X..}.X|..home =|
|00001f80| 20 28 63 68 61 72 20 2a | 29 6d 61 6c 6c 6f 63 28 | (char *|)malloc(|
|00001f90| 73 74 72 6c 65 6e 28 65 | 6e 74 2d 3e 70 77 5f 64 |strlen(e|nt->pw_d|
|00001fa0| 69 72 29 2b 31 29 3b 0a | 58 09 09 73 74 72 63 70 |ir)+1);.|X..strcp|
|00001fb0| 79 28 68 6f 6d 65 2c 20 | 65 6e 74 2d 3e 70 77 5f |y(home, |ent->pw_|
|00001fc0| 64 69 72 29 3b 0a 58 09 | 7d 0a 58 0a 58 09 2f 2a |dir);.X.|}.X.X./*|
|00001fd0| 20 64 65 74 65 72 6d 69 | 6e 65 20 74 68 65 20 24 | determi|ne the $|
|00001fe0| 50 41 47 45 52 20 76 61 | 6c 75 65 20 2a 2f 0a 58 |PAGER va|lue */.X|
|00001ff0| 09 70 61 67 65 72 20 3d | 20 67 65 74 65 6e 76 28 |.pager =| getenv(|
|00002000| 50 41 47 45 52 29 3b 0a | 58 09 69 66 20 28 70 61 |PAGER);.|X.if (pa|
|00002010| 67 65 72 20 3d 3d 20 4e | 55 4c 4c 20 7c 7c 20 2a |ger == N|ULL || *|
|00002020| 70 61 67 65 72 20 3d 3d | 20 27 5c 30 27 29 20 7b |pager ==| '\0') {|
|00002030| 0a 58 09 09 70 61 67 65 | 72 20 3d 20 44 45 46 41 |.X..page|r = DEFA|
|00002040| 55 4c 54 43 41 4c 43 50 | 41 47 45 52 3b 0a 58 09 |ULTCALCP|AGER;.X.|
|00002050| 7d 0a 58 0a 58 09 2f 2a | 20 64 65 74 65 72 6d 69 |}.X.X./*| determi|
|00002060| 6e 65 20 74 68 65 20 24 | 53 48 45 4c 4c 20 76 61 |ne the $|SHELL va|
|00002070| 6c 75 65 20 2a 2f 0a 58 | 09 73 68 65 6c 6c 20 3d |lue */.X|.shell =|
|00002080| 20 67 65 74 65 6e 76 28 | 53 48 45 4c 4c 29 3b 0a | getenv(|SHELL);.|
|00002090| 58 09 69 66 20 28 73 68 | 65 6c 6c 20 3d 3d 20 4e |X.if (sh|ell == N|
|000020a0| 55 4c 4c 29 0a 58 09 09 | 73 68 65 6c 6c 20 3d 20 |ULL).X..|shell = |
|000020b0| 44 45 46 41 55 4c 54 53 | 48 45 4c 4c 3b 0a 58 7d |DEFAULTS|HELL;.X}|
|000020c0| 0a 58 0a 58 76 6f 69 64 | 0a 58 67 69 76 65 68 65 |.X.Xvoid|.Xgivehe|
|000020d0| 6c 70 28 74 79 70 65 29 | 0a 58 09 63 68 61 72 20 |lp(type)|.X.char |
|000020e0| 2a 74 79 70 65 3b 09 09 | 2f 2a 20 74 68 65 20 74 |*type;..|/* the t|
|000020f0| 79 70 65 20 6f 66 20 68 | 65 6c 70 20 74 6f 20 67 |ype of h|elp to g|
|00002100| 69 76 65 2c 20 4e 55 4c | 4c 20 3d 3e 20 69 6e 64 |ive, NUL|L => ind|
|00002110| 65 78 20 2a 2f 0a 58 7b | 0a 58 09 63 68 61 72 20 |ex */.X{|.X.char |
|00002120| 2a 68 65 6c 70 63 6d 64 | 3b 09 09 2f 2a 20 77 68 |*helpcmd|;../* wh|
|00002130| 61 74 20 74 6f 20 65 78 | 65 63 75 74 65 20 74 6f |at to ex|ecute to|
|00002140| 20 70 72 69 6e 74 20 68 | 65 6c 70 20 2a 2f 0a 58 | print h|elp */.X|
|00002150| 0a 58 09 2f 2a 20 63 61 | 74 63 68 20 74 68 65 20 |.X./* ca|tch the |
|00002160| 63 61 73 65 20 77 68 65 | 72 65 20 77 65 20 6a 75 |case whe|re we ju|
|00002170| 73 74 20 70 72 69 6e 74 | 20 74 68 65 20 69 6e 64 |st print| the ind|
|00002180| 65 78 20 2a 2f 0a 58 09 | 69 66 20 28 74 79 70 65 |ex */.X.|if (type|
|00002190| 20 3d 3d 20 4e 55 4c 4c | 29 20 7b 0a 58 09 09 74 | == NULL|) {.X..t|
|000021a0| 79 70 65 20 3d 20 44 45 | 46 41 55 4c 54 43 41 4c |ype = DE|FAULTCAL|
|000021b0| 43 48 45 4c 50 3b 09 09 | 2f 2a 20 74 68 65 20 68 |CHELP;..|/* the h|
|000021c0| 65 6c 70 20 69 6e 64 65 | 78 20 66 69 6c 65 20 2a |elp inde|x file *|
|000021d0| 2f 0a 58 09 7d 0a 58 0a | 58 09 2f 2a 20 66 6f 72 |/.X.}.X.|X./* for|
|000021e0| 6d 20 74 68 65 20 68 65 | 6c 70 20 63 6f 6d 6d 61 |m the he|lp comma|
|000021f0| 6e 64 20 6e 61 6d 65 20 | 2a 2f 0a 58 09 68 65 6c |nd name |*/.X.hel|
|00002200| 70 63 6d 64 20 3d 20 28 | 63 68 61 72 20 2a 29 6d |pcmd = (|char *)m|
|00002210| 61 6c 6c 6f 63 28 0a 58 | 09 09 73 69 7a 65 6f 66 |alloc(.X|..sizeof|
|00002220| 28 22 69 66 20 5b 20 21 | 20 2d 64 20 5c 22 22 29 |("if [ !| -d \"")|
|00002230| 2b 73 69 7a 65 6f 66 28 | 48 45 4c 50 44 49 52 29 |+sizeof(|HELPDIR)|
|00002240| 2b 31 2b 73 74 72 6c 65 | 6e 28 74 79 70 65 29 2b |+1+strle|n(type)+|
|00002250| 0a 58 09 09 73 69 7a 65 | 6f 66 28 22 5c 22 20 5d |.X..size|of("\" ]|
|00002260| 3b 74 68 65 6e 20 22 29 | 2b 0a 58 09 09 73 74 72 |;then ")|+.X..str|
|00002270| 6c 65 6e 28 70 61 67 65 | 72 29 2b 31 2b 31 2b 73 |len(page|r)+1+1+s|
|00002280| 69 7a 65 6f 66 28 48 45 | 4c 50 44 49 52 29 2b 31 |izeof(HE|LPDIR)+1|
|00002290| 2b 73 74 72 6c 65 6e 28 | 74 79 70 65 29 2b 31 2b |+strlen(|type)+1+|
|000022a0| 31 2b 0a 58 09 09 73 69 | 7a 65 6f 66 28 22 3b 65 |1+.X..si|zeof(";e|
|000022b0| 6c 73 65 20 65 63 68 6f | 20 6e 6f 20 73 75 63 68 |lse echo| no such|
|000022c0| 20 68 65 6c 70 3b 66 69 | 22 29 29 3b 0a 58 09 73 | help;fi|"));.X.s|
|000022d0| 70 72 69 6e 74 66 28 68 | 65 6c 70 63 6d 64 2c 20 |printf(h|elpcmd, |
|000022e0| 0a 58 09 20 20 20 20 22 | 69 66 20 5b 20 2d 72 20 |.X. "|if [ -r |
|000022f0| 5c 22 25 73 2f 25 73 5c | 22 20 5d 3b 74 68 65 6e |\"%s/%s\|" ];then|
|00002300| 20 25 73 20 5c 22 25 73 | 2f 25 73 5c 22 3b 65 6c | %s \"%s|/%s\";el|
|00002310| 73 65 20 65 63 68 6f 20 | 6e 6f 20 73 75 63 68 20 |se echo |no such |
|00002320| 68 65 6c 70 3b 66 69 22 | 2c 20 0a 58 09 20 20 20 |help;fi"|, .X. |
|00002330| 20 48 45 4c 50 44 49 52 | 2c 20 74 79 70 65 2c 20 | HELPDIR|, type, |
|00002340| 70 61 67 65 72 2c 20 48 | 45 4c 50 44 49 52 2c 20 |pager, H|ELPDIR, |
|00002350| 74 79 70 65 29 3b 0a 58 | 0a 58 09 2f 2a 20 65 78 |type);.X|.X./* ex|
|00002360| 65 63 75 74 65 20 74 68 | 65 20 68 65 6c 70 20 63 |ecute th|e help c|
|00002370| 6f 6d 6d 61 6e 64 20 2a | 2f 0a 58 09 73 79 73 74 |ommand *|/.X.syst|
|00002380| 65 6d 28 68 65 6c 70 63 | 6d 64 29 3b 0a 58 09 66 |em(helpc|md);.X.f|
|00002390| 72 65 65 28 68 65 6c 70 | 63 6d 64 29 3b 0a 58 7d |ree(help|cmd);.X}|
|000023a0| 0a 58 0a 58 0a 58 2f 2a | 0a 58 20 2a 20 49 6e 74 |.X.X.X/*|.X * Int|
|000023b0| 65 72 72 75 70 74 20 72 | 6f 75 74 69 6e 65 2e 0a |errupt r|outine..|
|000023c0| 58 20 2a 2f 0a 58 2f 2a | 41 52 47 53 55 53 45 44 |X */.X/*|ARGSUSED|
|000023d0| 2a 2f 0a 58 73 74 61 74 | 69 63 20 76 6f 69 64 0a |*/.Xstat|ic void.|
|000023e0| 58 69 6e 74 69 6e 74 28 | 61 72 67 29 0a 58 09 69 |Xintint(|arg).X.i|
|000023f0| 6e 74 20 61 72 67 3b 09 | 2f 2a 20 74 6f 20 6b 65 |nt arg;.|/* to ke|
|00002400| 65 70 20 41 4e 53 49 20 | 43 20 68 61 70 70 79 20 |ep ANSI |C happy |
|00002410| 2a 2f 0a 58 7b 0a 58 09 | 28 76 6f 69 64 29 20 73 |*/.X{.X.|(void) s|
|00002420| 69 67 6e 61 6c 28 53 49 | 47 49 4e 54 2c 20 69 6e |ignal(SI|GINT, in|
|00002430| 74 69 6e 74 29 3b 0a 58 | 09 69 66 20 28 69 6e 70 |tint);.X|.if (inp|
|00002440| 75 74 77 61 69 74 20 7c | 7c 20 28 2b 2b 61 62 6f |utwait ||| (++abo|
|00002450| 72 74 6c 65 76 65 6c 20 | 3e 3d 20 41 42 4f 52 54 |rtlevel |>= ABORT|
|00002460| 5f 4e 4f 57 29 29 0a 58 | 09 09 65 72 72 6f 72 28 |_NOW)).X|..error(|
|00002470| 22 5c 6e 41 42 4f 52 54 | 22 29 3b 0a 58 09 69 66 |"\nABORT|");.X.if|
|00002480| 20 28 61 62 6f 72 74 6c | 65 76 65 6c 20 3e 3d 20 | (abortl|evel >= |
|00002490| 41 42 4f 52 54 5f 4d 41 | 54 48 29 0a 58 09 09 5f |ABORT_MA|TH).X.._|
|000024a0| 6d 61 74 68 5f 61 62 6f | 72 74 5f 20 3d 20 54 52 |math_abo|rt_ = TR|
|000024b0| 55 45 3b 0a 58 09 70 72 | 69 6e 74 66 28 22 5c 6e |UE;.X.pr|intf("\n|
|000024c0| 5b 41 62 6f 72 74 20 6c | 65 76 65 6c 20 25 64 5d |[Abort l|evel %d]|
|000024d0| 5c 6e 22 2c 20 61 62 6f | 72 74 6c 65 76 65 6c 29 |\n", abo|rtlevel)|
|000024e0| 3b 0a 58 7d 0a 58 0a 58 | 2f 2a 20 45 4e 44 20 43 |;.X}.X.X|/* END C|
|000024f0| 4f 44 45 20 2a 2f 0a 45 | 4e 44 5f 4f 46 5f 46 49 |ODE */.E|ND_OF_FI|
|00002500| 4c 45 0a 69 66 20 74 65 | 73 74 20 34 39 30 35 20 |LE.if te|st 4905 |
|00002510| 2d 6e 65 20 60 77 63 20 | 2d 63 20 3c 27 63 61 6c |-ne `wc |-c <'cal|
|00002520| 63 2e 63 27 60 3b 20 74 | 68 65 6e 0a 20 20 20 20 |c.c'`; t|hen. |
|00002530| 65 63 68 6f 20 73 68 61 | 72 3a 20 5c 22 27 63 61 |echo sha|r: \"'ca|
|00002540| 6c 63 2e 63 27 5c 22 20 | 75 6e 70 61 63 6b 65 64 |lc.c'\" |unpacked|
|00002550| 20 77 69 74 68 20 77 72 | 6f 6e 67 20 73 69 7a 65 | with wr|ong size|
|00002560| 21 0a 66 69 0a 23 20 65 | 6e 64 20 6f 66 20 27 63 |!.fi.# e|nd of 'c|
|00002570| 61 6c 63 2e 63 27 0a 66 | 69 0a 69 66 20 74 65 73 |alc.c'.f|i.if tes|
|00002580| 74 20 2d 66 20 27 63 6f | 6e 73 74 2e 63 27 20 2d |t -f 'co|nst.c' -|
|00002590| 61 20 22 24 7b 31 7d 22 | 20 21 3d 20 22 2d 63 22 |a "${1}"| != "-c"|
|000025a0| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|000025b0| 73 68 61 72 3a 20 57 69 | 6c 6c 20 6e 6f 74 20 63 |shar: Wi|ll not c|
|000025c0| 6c 6f 62 62 65 72 20 65 | 78 69 73 74 69 6e 67 20 |lobber e|xisting |
|000025d0| 66 69 6c 65 20 5c 22 27 | 63 6f 6e 73 74 2e 63 27 |file \"'|const.c'|
|000025e0| 5c 22 0a 65 6c 73 65 0a | 65 63 68 6f 20 73 68 61 |\".else.|echo sha|
|000025f0| 72 3a 20 45 78 74 72 61 | 63 74 69 6e 67 20 5c 22 |r: Extra|cting \"|
|00002600| 27 63 6f 6e 73 74 2e 63 | 27 5c 22 20 5c 28 32 37 |'const.c|'\" \(27|
|00002610| 30 39 20 63 68 61 72 61 | 63 74 65 72 73 5c 29 0a |09 chara|cters\).|
|00002620| 73 65 64 20 22 73 2f 5e | 58 2f 2f 22 20 3e 27 63 |sed "s/^|X//" >'c|
|00002630| 6f 6e 73 74 2e 63 27 20 | 3c 3c 27 45 4e 44 5f 4f |onst.c' |<<'END_O|
|00002640| 46 5f 46 49 4c 45 27 0a | 58 2f 2a 0a 58 20 2a 20 |F_FILE'.|X/*.X * |
|00002650| 43 6f 70 79 72 69 67 68 | 74 20 28 63 29 20 31 39 |Copyrigh|t (c) 19|
|00002660| 39 32 20 44 61 76 69 64 | 20 49 2e 20 42 65 6c 6c |92 David| I. Bell|
|00002670| 0a 58 20 2a 20 50 65 72 | 6d 69 73 73 69 6f 6e 20 |.X * Per|mission |
|00002680| 69 73 20 67 72 61 6e 74 | 65 64 20 74 6f 20 75 73 |is grant|ed to us|
|00002690| 65 2c 20 64 69 73 74 72 | 69 62 75 74 65 2c 20 6f |e, distr|ibute, o|
|000026a0| 72 20 6d 6f 64 69 66 79 | 20 74 68 69 73 20 73 6f |r modify| this so|
|000026b0| 75 72 63 65 2c 0a 58 20 | 2a 20 70 72 6f 76 69 64 |urce,.X |* provid|
|000026c0| 65 64 20 74 68 61 74 20 | 74 68 69 73 20 63 6f 70 |ed that |this cop|
|000026d0| 79 72 69 67 68 74 20 6e | 6f 74 69 63 65 20 72 65 |yright n|otice re|
|000026e0| 6d 61 69 6e 73 20 69 6e | 74 61 63 74 2e 0a 58 20 |mains in|tact..X |
|000026f0| 2a 0a 58 20 2a 20 43 6f | 6e 73 74 61 6e 74 20 6e |*.X * Co|nstant n|
|00002700| 75 6d 62 65 72 20 73 74 | 6f 72 61 67 65 20 6d 6f |umber st|orage mo|
|00002710| 64 75 6c 65 2e 0a 58 20 | 2a 2f 0a 58 0a 58 23 69 |dule..X |*/.X.X#i|
|00002720| 6e 63 6c 75 64 65 20 22 | 63 61 6c 63 2e 68 22 0a |nclude "|calc.h".|
|00002730| 58 0a 58 23 64 65 66 69 | 6e 65 20 43 4f 4e 53 54 |X.X#defi|ne CONST|
|00002740| 41 4c 4c 4f 43 53 49 5a | 45 20 34 30 30 09 2f 2a |ALLOCSIZ|E 400./*|
|00002750| 20 6e 75 6d 62 65 72 20 | 6f 66 20 63 6f 6e 73 74 | number |of const|
|00002760| 61 6e 74 73 20 74 6f 20 | 61 6c 6c 6f 63 61 74 65 |ants to |allocate|
|00002770| 20 2a 2f 0a 58 0a 58 0a | 58 73 74 61 74 69 63 20 | */.X.X.|Xstatic |
|00002780| 6c 6f 6e 67 20 63 6f 6e | 73 74 63 6f 75 6e 74 3b |long con|stcount;|
|00002790| 09 09 2f 2a 20 6e 75 6d | 62 65 72 20 6f 66 20 63 |../* num|ber of c|
|000027a0| 6f 6e 73 74 61 6e 74 73 | 20 64 65 66 69 6e 65 64 |onstants| defined|
|000027b0| 20 2a 2f 0a 58 73 74 61 | 74 69 63 20 6c 6f 6e 67 | */.Xsta|tic long|
|000027c0| 20 63 6f 6e 73 74 61 76 | 61 69 6c 3b 09 09 2f 2a | constav|ail;../*|
|000027d0| 20 6e 75 6d 62 65 72 20 | 6f 66 20 63 6f 6e 73 74 | number |of const|
|000027e0| 61 6e 74 73 20 61 76 61 | 69 6c 61 62 6c 65 20 2a |ants ava|ilable *|
|000027f0| 2f 0a 58 73 74 61 74 69 | 63 20 4e 55 4d 42 45 52 |/.Xstati|c NUMBER|
|00002800| 20 2a 2a 63 6f 6e 73 74 | 74 61 62 6c 65 3b 09 2f | **const|table;./|
|00002810| 2a 20 74 61 62 6c 65 20 | 6f 66 20 63 6f 6e 73 74 |* table |of const|
|00002820| 61 6e 74 73 20 2a 2f 0a | 58 0a 58 0a 58 2f 2a 0a |ants */.|X.X.X/*.|
|00002830| 58 20 2a 20 52 65 61 64 | 20 69 6e 20 61 20 63 6f |X * Read| in a co|
|00002840| 6e 73 74 61 6e 74 20 6e | 75 6d 62 65 72 20 61 6e |nstant n|umber an|
|00002850| 64 20 61 64 64 20 69 74 | 20 74 6f 20 74 68 65 20 |d add it| to the |
|00002860| 74 61 62 6c 65 20 6f 66 | 20 63 6f 6e 73 74 61 6e |table of| constan|
|00002870| 74 20 6e 75 6d 62 65 72 | 73 2c 0a 58 20 2a 20 63 |t number|s,.X * c|
|00002880| 72 65 61 74 69 6e 67 20 | 61 20 6e 65 77 20 65 6e |reating |a new en|
|00002890| 74 72 79 20 69 66 20 6e | 65 63 65 73 73 61 72 79 |try if n|ecessary|
|000028a0| 2e 20 20 54 68 65 20 69 | 6e 63 6f 6d 69 6e 67 20 |. The i|ncoming |
|000028b0| 6e 75 6d 62 65 72 20 69 | 73 20 61 20 73 74 72 69 |number i|s a stri|
|000028c0| 6e 67 0a 58 20 2a 20 76 | 61 6c 75 65 20 77 68 69 |ng.X * v|alue whi|
|000028d0| 63 68 20 6d 75 73 74 20 | 68 61 76 65 20 61 20 63 |ch must |have a c|
|000028e0| 6f 72 72 65 63 74 20 66 | 6f 72 6d 61 74 2c 20 6f |orrect f|ormat, o|
|000028f0| 74 68 65 72 77 69 73 65 | 20 61 6e 20 75 6e 64 65 |therwise| an unde|
|00002900| 66 69 6e 65 64 20 6e 75 | 6d 62 65 72 0a 58 20 2a |fined nu|mber.X *|
|00002910| 20 77 69 6c 6c 20 72 65 | 73 75 6c 74 2e 20 20 52 | will re|sult. R|
|00002920| 65 74 75 72 6e 73 20 74 | 68 65 20 69 6e 64 65 78 |eturns t|he index|
|00002930| 20 6f 66 20 74 68 65 20 | 6e 75 6d 62 65 72 20 69 | of the |number i|
|00002940| 6e 20 74 68 65 20 63 6f | 6e 73 74 61 6e 74 20 74 |n the co|nstant t|
|00002950| 61 62 6c 65 2e 0a 58 20 | 2a 20 52 65 74 75 72 6e |able..X |* Return|
|00002960| 73 20 7a 65 72 6f 20 69 | 66 20 74 68 65 20 6e 75 |s zero i|f the nu|
|00002970| 6d 62 65 72 20 63 6f 75 | 6c 64 20 6e 6f 74 20 62 |mber cou|ld not b|
|00002980| 65 20 73 61 76 65 64 2e | 0a 58 20 2a 2f 0a 58 6c |e saved.|.X */.Xl|
|00002990| 6f 6e 67 0a 58 61 64 64 | 6e 75 6d 62 65 72 28 73 |ong.Xadd|number(s|
|000029a0| 74 72 29 0a 58 09 63 68 | 61 72 20 2a 73 74 72 3b |tr).X.ch|ar *str;|
|000029b0| 09 09 2f 2a 20 73 74 72 | 69 6e 67 20 72 65 70 72 |../* str|ing repr|
|000029c0| 65 73 65 6e 74 61 74 69 | 6f 6e 20 6f 66 20 6e 75 |esentati|on of nu|
|000029d0| 6d 62 65 72 20 2a 2f 0a | 58 7b 0a 58 09 4e 55 4d |mber */.|X{.X.NUM|
|000029e0| 42 45 52 20 2a 71 3b 0a | 58 0a 58 09 71 20 3d 20 |BER *q;.|X.X.q = |
|000029f0| 61 74 6f 71 28 73 74 72 | 29 3b 0a 58 09 69 66 20 |atoq(str|);.X.if |
|00002a00| 28 71 20 3d 3d 20 4e 55 | 4c 4c 29 0a 58 09 09 72 |(q == NU|LL).X..r|
|00002a10| 65 74 75 72 6e 20 30 3b | 0a 58 09 72 65 74 75 72 |eturn 0;|.X.retur|
|00002a20| 6e 20 61 64 64 71 63 6f | 6e 73 74 61 6e 74 28 71 |n addqco|nstant(q|
|00002a30| 29 3b 0a 58 7d 0a 58 0a | 58 0a 58 2f 2a 0a 58 20 |);.X}.X.|X.X/*.X |
|00002a40| 2a 20 41 64 64 20 61 20 | 70 61 72 74 69 63 75 6c |* Add a |particul|
|00002a50| 61 72 20 6e 75 6d 62 65 | 72 20 74 6f 20 74 68 65 |ar numbe|r to the|
|00002a60| 20 63 6f 6e 73 74 61 6e | 74 20 74 61 62 6c 65 2e | constan|t table.|
|00002a70| 0a 58 20 2a 20 52 65 74 | 75 72 6e 73 20 74 68 65 |.X * Ret|urns the|
|00002a80| 20 69 6e 64 65 78 20 6f | 66 20 74 68 65 20 6e 75 | index o|f the nu|
|00002a90| 6d 62 65 72 20 69 6e 20 | 74 68 65 20 63 6f 6e 73 |mber in |the cons|
|00002aa0| 74 61 6e 74 20 74 61 62 | 6c 65 2c 20 6f 72 20 7a |tant tab|le, or z|
|00002ab0| 65 72 6f 0a 58 20 2a 20 | 69 66 20 74 68 65 20 6e |ero.X * |if the n|
|00002ac0| 75 6d 62 65 72 20 63 6f | 75 6c 64 20 6e 6f 74 20 |umber co|uld not |
|00002ad0| 62 65 20 73 61 76 65 64 | 2e 20 20 54 68 65 20 69 |be saved|. The i|
|00002ae0| 6e 63 6f 6d 69 6e 67 20 | 6e 75 6d 62 65 72 20 69 |ncoming |number i|
|00002af0| 66 20 66 72 65 65 64 0a | 58 20 2a 20 69 66 20 69 |f freed.|X * if i|
|00002b00| 74 20 69 73 20 61 6c 72 | 65 61 64 79 20 69 6e 20 |t is alr|eady in |
|00002b10| 74 68 65 20 74 61 62 6c | 65 2e 0a 58 20 2a 2f 0a |the tabl|e..X */.|
|00002b20| 58 6c 6f 6e 67 0a 58 61 | 64 64 71 63 6f 6e 73 74 |Xlong.Xa|ddqconst|
|00002b30| 61 6e 74 28 71 29 0a 58 | 09 72 65 67 69 73 74 65 |ant(q).X|.registe|
|00002b40| 72 20 4e 55 4d 42 45 52 | 20 2a 71 3b 09 2f 2a 20 |r NUMBER| *q;./* |
|00002b50| 6e 75 6d 62 65 72 20 74 | 6f 20 62 65 20 61 64 64 |number t|o be add|
|00002b60| 65 64 20 2a 2f 0a 58 7b | 0a 58 09 72 65 67 69 73 |ed */.X{|.X.regis|
|00002b70| 74 65 72 20 4e 55 4d 42 | 45 52 20 2a 2a 74 70 3b |ter NUMB|ER **tp;|
|00002b80| 09 2f 2a 20 70 6f 69 6e | 74 65 72 20 74 6f 20 63 |./* poin|ter to c|
|00002b90| 75 72 72 65 6e 74 20 6e | 75 6d 62 65 72 20 2a 2f |urrent n|umber */|
|00002ba0| 0a 58 09 72 65 67 69 73 | 74 65 72 20 4e 55 4d 42 |.X.regis|ter NUMB|
|00002bb0| 45 52 20 2a 74 3b 09 2f | 2a 20 6e 75 6d 62 65 72 |ER *t;./|* number|
|00002bc0| 20 62 65 69 6e 67 20 74 | 65 73 74 65 64 20 2a 2f | being t|ested */|
|00002bd0| 0a 58 09 6c 6f 6e 67 20 | 69 6e 64 65 78 3b 09 09 |.X.long |index;..|
|00002be0| 2f 2a 20 69 6e 64 65 78 | 20 69 6e 74 6f 20 63 6f |/* index| into co|
|00002bf0| 6e 73 74 61 6e 74 20 74 | 61 62 6c 65 20 2a 2f 0a |nstant t|able */.|
|00002c00| 58 09 6c 6f 6e 67 20 6e | 75 6d 6c 65 6e 3b 09 09 |X.long n|umlen;..|
|00002c10| 2f 2a 20 6e 75 6d 65 72 | 61 74 6f 72 20 6c 65 6e |/* numer|ator len|
|00002c20| 67 74 68 20 2a 2f 0a 58 | 09 6c 6f 6e 67 20 64 65 |gth */.X|.long de|
|00002c30| 6e 6c 65 6e 3b 09 09 2f | 2a 20 64 65 6e 6f 6d 69 |nlen;../|* denomi|
|00002c40| 6e 61 74 6f 72 20 6c 65 | 6e 67 74 68 20 2a 2f 0a |nator le|ngth */.|
|00002c50| 58 09 48 41 4c 46 20 6e | 75 6d 6c 6f 77 3b 09 09 |X.HALF n|umlow;..|
|00002c60| 2f 2a 20 62 6f 74 74 6f | 6d 20 76 61 6c 75 65 20 |/* botto|m value |
|00002c70| 6f 66 20 6e 75 6d 65 72 | 61 74 6f 72 20 2a 2f 0a |of numer|ator */.|
|00002c80| 58 09 48 41 4c 46 20 64 | 65 6e 6c 6f 77 3b 09 09 |X.HALF d|enlow;..|
|00002c90| 2f 2a 20 62 6f 74 74 6f | 6d 20 76 61 6c 75 65 20 |/* botto|m value |
|00002ca0| 6f 66 20 64 65 6e 6f 6d | 69 6e 61 74 6f 72 20 2a |of denom|inator *|
|00002cb0| 2f 0a 58 0a 58 09 6e 75 | 6d 6c 65 6e 20 3d 20 71 |/.X.X.nu|mlen = q|
|00002cc0| 2d 3e 6e 75 6d 2e 6c 65 | 6e 3b 0a 58 09 64 65 6e |->num.le|n;.X.den|
|00002cd0| 6c 65 6e 20 3d 20 71 2d | 3e 64 65 6e 2e 6c 65 6e |len = q-|>den.len|
|00002ce0| 3b 0a 58 09 6e 75 6d 6c | 6f 77 20 3d 20 71 2d 3e |;.X.numl|ow = q->|
|00002cf0| 6e 75 6d 2e 76 5b 30 5d | 3b 0a 58 09 64 65 6e 6c |num.v[0]|;.X.denl|
|00002d00| 6f 77 20 3d 20 71 2d 3e | 64 65 6e 2e 76 5b 30 5d |ow = q->|den.v[0]|
|00002d10| 3b 0a 58 09 74 70 20 3d | 20 26 63 6f 6e 73 74 74 |;.X.tp =| &constt|
|00002d20| 61 62 6c 65 5b 31 5d 3b | 0a 58 09 66 6f 72 20 28 |able[1];|.X.for (|
|00002d30| 69 6e 64 65 78 20 3d 20 | 31 3b 20 69 6e 64 65 78 |index = |1; index|
|00002d40| 20 3c 3d 20 63 6f 6e 73 | 74 63 6f 75 6e 74 3b 20 | <= cons|tcount; |
|00002d50| 69 6e 64 65 78 2b 2b 29 | 20 7b 0a 58 09 09 74 20 |index++)| {.X..t |
|00002d60| 3d 20 2a 74 70 2b 2b 3b | 0a 58 09 09 69 66 20 28 |= *tp++;|.X..if (|
|00002d70| 28 6e 75 6d 6c 65 6e 20 | 21 3d 20 74 2d 3e 6e 75 |(numlen |!= t->nu|
|00002d80| 6d 2e 6c 65 6e 29 20 7c | 7c 20 28 6e 75 6d 6c 6f |m.len) ||| (numlo|
|00002d90| 77 20 21 3d 20 74 2d 3e | 6e 75 6d 2e 76 5b 30 5d |w != t->|num.v[0]|
|00002da0| 29 29 0a 58 09 09 09 63 | 6f 6e 74 69 6e 75 65 3b |)).X...c|ontinue;|
|00002db0| 0a 58 09 09 69 66 20 28 | 28 64 65 6e 6c 65 6e 20 |.X..if (|(denlen |
|00002dc0| 21 3d 20 74 2d 3e 64 65 | 6e 2e 6c 65 6e 29 20 7c |!= t->de|n.len) ||
|00002dd0| 7c 20 28 64 65 6e 6c 6f | 77 20 21 3d 20 74 2d 3e || (denlo|w != t->|
|00002de0| 64 65 6e 2e 76 5b 30 5d | 29 29 0a 58 09 09 09 63 |den.v[0]|)).X...c|
|00002df0| 6f 6e 74 69 6e 75 65 3b | 0a 58 09 09 69 66 20 28 |ontinue;|.X..if (|
|00002e00| 71 2d 3e 6e 75 6d 2e 73 | 69 67 6e 20 21 3d 20 74 |q->num.s|ign != t|
|00002e10| 2d 3e 6e 75 6d 2e 73 69 | 67 6e 29 0a 58 09 09 09 |->num.si|gn).X...|
|00002e20| 63 6f 6e 74 69 6e 75 65 | 3b 0a 58 09 09 69 66 20 |continue|;.X..if |
|00002e30| 28 71 63 6d 70 28 71 2c | 20 74 29 20 3d 3d 20 30 |(qcmp(q,| t) == 0|
|00002e40| 29 20 7b 0a 58 09 09 09 | 71 66 72 65 65 28 71 29 |) {.X...|qfree(q)|
|00002e50| 3b 0a 58 09 09 09 72 65 | 74 75 72 6e 20 69 6e 64 |;.X...re|turn ind|
|00002e60| 65 78 3b 0a 58 09 09 7d | 0a 58 09 7d 0a 58 09 69 |ex;.X..}|.X.}.X.i|
|00002e70| 66 20 28 63 6f 6e 73 74 | 61 76 61 69 6c 20 3c 3d |f (const|avail <=|
|00002e80| 20 30 29 20 7b 0a 58 09 | 09 69 66 20 28 63 6f 6e | 0) {.X.|.if (con|
|00002e90| 73 74 74 61 62 6c 65 20 | 3d 3d 20 4e 55 4c 4c 29 |sttable |== NULL)|
|00002ea0| 20 7b 0a 58 09 09 09 74 | 70 20 3d 20 28 4e 55 4d | {.X...t|p = (NUM|
|00002eb0| 42 45 52 20 2a 2a 29 0a | 58 09 09 09 09 6d 61 6c |BER **).|X....mal|
|00002ec0| 6c 6f 63 28 73 69 7a 65 | 6f 66 28 4e 55 4d 42 45 |loc(size|of(NUMBE|
|00002ed0| 52 20 2a 29 20 2a 20 28 | 43 4f 4e 53 54 41 4c 4c |R *) * (|CONSTALL|
|00002ee0| 4f 43 53 49 5a 45 20 2b | 20 31 29 29 3b 0a 58 09 |OCSIZE +| 1));.X.|
|00002ef0| 09 09 2a 74 70 20 3d 20 | 4e 55 4c 4c 3b 0a 58 09 |..*tp = |NULL;.X.|
|00002f00| 09 7d 20 65 6c 73 65 0a | 58 09 09 09 74 70 20 3d |.} else.|X...tp =|
|00002f10| 20 28 4e 55 4d 42 45 52 | 20 2a 2a 29 20 72 65 61 | (NUMBER| **) rea|
|00002f20| 6c 6c 6f 63 28 28 63 68 | 61 72 20 2a 29 20 63 6f |lloc((ch|ar *) co|
|00002f30| 6e 73 74 74 61 62 6c 65 | 2c 0a 58 09 09 09 73 69 |nsttable|,.X...si|
|00002f40| 7a 65 6f 66 28 4e 55 4d | 42 45 52 20 2a 29 20 2a |zeof(NUM|BER *) *|
|00002f50| 20 28 63 6f 6e 73 74 63 | 6f 75 6e 74 2b 43 4f 4e | (constc|ount+CON|
|00002f60| 53 54 41 4c 4c 4f 43 53 | 49 5a 45 20 2b 20 31 29 |STALLOCS|IZE + 1)|
|00002f70| 29 3b 0a 58 09 09 69 66 | 20 28 74 70 20 3d 3d 20 |);.X..if| (tp == |
|00002f80| 4e 55 4c 4c 29 0a 58 09 | 09 09 72 65 74 75 72 6e |NULL).X.|..return|
|00002f90| 20 30 3b 0a 58 09 09 63 | 6f 6e 73 74 74 61 62 6c | 0;.X..c|onsttabl|
|00002fa0| 65 20 3d 20 74 70 3b 0a | 58 09 09 63 6f 6e 73 74 |e = tp;.|X..const|
|00002fb0| 61 76 61 69 6c 20 3d 20 | 43 4f 4e 53 54 41 4c 4c |avail = |CONSTALL|
|00002fc0| 4f 43 53 49 5a 45 3b 0a | 58 09 7d 0a 58 09 63 6f |OCSIZE;.|X.}.X.co|
|00002fd0| 6e 73 74 61 76 61 69 6c | 2d 2d 3b 0a 58 09 63 6f |nstavail|--;.X.co|
|00002fe0| 6e 73 74 63 6f 75 6e 74 | 2b 2b 3b 0a 58 09 63 6f |nstcount|++;.X.co|
|00002ff0| 6e 73 74 74 61 62 6c 65 | 5b 63 6f 6e 73 74 63 6f |nsttable|[constco|
|00003000| 75 6e 74 5d 20 3d 20 71 | 3b 0a 58 09 72 65 74 75 |unt] = q|;.X.retu|
|00003010| 72 6e 20 63 6f 6e 73 74 | 63 6f 75 6e 74 3b 0a 58 |rn const|count;.X|
|00003020| 7d 0a 58 0a 58 0a 58 2f | 2a 0a 58 20 2a 20 52 65 |}.X.X.X/|*.X * Re|
|00003030| 74 75 72 6e 20 74 68 65 | 20 76 61 6c 75 65 20 6f |turn the| value o|
|00003040| 66 20 61 20 63 6f 6e 73 | 74 61 6e 74 20 6e 75 6d |f a cons|tant num|
|00003050| 62 65 72 20 67 69 76 65 | 6e 20 69 74 73 20 69 6e |ber give|n its in|
|00003060| 64 65 78 2e 0a 58 20 2a | 20 52 65 74 75 72 6e 73 |dex..X *| Returns|
|00003070| 20 61 64 64 72 65 73 73 | 20 6f 66 20 74 68 65 20 | address| of the |
|00003080| 6e 75 6d 62 65 72 2c 20 | 6f 72 20 4e 55 4c 4c 20 |number, |or NULL |
|00003090| 69 66 20 74 68 65 20 69 | 6e 64 65 78 20 69 73 20 |if the i|ndex is |
|000030a0| 69 6c 6c 65 67 61 6c 2e | 0a 58 20 2a 2f 0a 58 4e |illegal.|.X */.XN|
|000030b0| 55 4d 42 45 52 20 2a 0a | 58 63 6f 6e 73 74 76 61 |UMBER *.|Xconstva|
|000030c0| 6c 75 65 28 69 6e 64 65 | 78 29 0a 58 09 6c 6f 6e |lue(inde|x).X.lon|
|000030d0| 67 20 69 6e 64 65 78 3b | 0a 58 7b 0a 58 09 69 66 |g index;|.X{.X.if|
|000030e0| 20 28 28 69 6e 64 65 78 | 20 3c 3d 20 30 29 20 7c | ((index| <= 0) ||
|000030f0| 7c 20 28 69 6e 64 65 78 | 20 3e 20 63 6f 6e 73 74 || (index| > const|
|00003100| 63 6f 75 6e 74 29 29 0a | 58 09 09 72 65 74 75 72 |count)).|X..retur|
|00003110| 6e 20 4e 55 4c 4c 3b 0a | 58 09 72 65 74 75 72 6e |n NULL;.|X.return|
|00003120| 20 63 6f 6e 73 74 74 61 | 62 6c 65 5b 69 6e 64 65 | constta|ble[inde|
|00003130| 78 5d 3b 0a 58 7d 0a 58 | 0a 58 2f 2a 20 45 4e 44 |x];.X}.X|.X/* END|
|00003140| 20 43 4f 44 45 20 2a 2f | 0a 45 4e 44 5f 4f 46 5f | CODE */|.END_OF_|
|00003150| 46 49 4c 45 0a 69 66 20 | 74 65 73 74 20 32 37 30 |FILE.if |test 270|
|00003160| 39 20 2d 6e 65 20 60 77 | 63 20 2d 63 20 3c 27 63 |9 -ne `w|c -c <'c|
|00003170| 6f 6e 73 74 2e 63 27 60 | 3b 20 74 68 65 6e 0a 20 |onst.c'`|; then. |
|00003180| 20 20 20 65 63 68 6f 20 | 73 68 61 72 3a 20 5c 22 | echo |shar: \"|
|00003190| 27 63 6f 6e 73 74 2e 63 | 27 5c 22 20 75 6e 70 61 |'const.c|'\" unpa|
|000031a0| 63 6b 65 64 20 77 69 74 | 68 20 77 72 6f 6e 67 20 |cked wit|h wrong |
|000031b0| 73 69 7a 65 21 0a 66 69 | 0a 23 20 65 6e 64 20 6f |size!.fi|.# end o|
|000031c0| 66 20 27 63 6f 6e 73 74 | 2e 63 27 0a 66 69 0a 69 |f 'const|.c'.fi.i|
|000031d0| 66 20 74 65 73 74 20 2d | 66 20 27 68 65 6c 70 2f |f test -|f 'help/|
|000031e0| 63 6f 6d 6d 61 6e 64 27 | 20 2d 61 20 22 24 7b 31 |command'| -a "${1|
|000031f0| 7d 22 20 21 3d 20 22 2d | 63 22 20 3b 20 74 68 65 |}" != "-|c" ; the|
|00003200| 6e 20 0a 20 20 65 63 68 | 6f 20 73 68 61 72 3a 20 |n . ech|o shar: |
|00003210| 57 69 6c 6c 20 6e 6f 74 | 20 63 6c 6f 62 62 65 72 |Will not| clobber|
|00003220| 20 65 78 69 73 74 69 6e | 67 20 66 69 6c 65 20 5c | existin|g file \|
|00003230| 22 27 68 65 6c 70 2f 63 | 6f 6d 6d 61 6e 64 27 5c |"'help/c|ommand'\|
|00003240| 22 0a 65 6c 73 65 0a 65 | 63 68 6f 20 73 68 61 72 |".else.e|cho shar|
|00003250| 3a 20 45 78 74 72 61 63 | 74 69 6e 67 20 5c 22 27 |: Extrac|ting \"'|
|00003260| 68 65 6c 70 2f 63 6f 6d | 6d 61 6e 64 27 5c 22 20 |help/com|mand'\" |
|00003270| 5c 28 32 37 34 30 20 63 | 68 61 72 61 63 74 65 72 |\(2740 c|haracter|
|00003280| 73 5c 29 0a 73 65 64 20 | 22 73 2f 5e 58 2f 2f 22 |s\).sed |"s/^X//"|
|00003290| 20 3e 27 68 65 6c 70 2f | 63 6f 6d 6d 61 6e 64 27 | >'help/|command'|
|000032a0| 20 3c 3c 27 45 4e 44 5f | 4f 46 5f 46 49 4c 45 27 | <<'END_|OF_FILE'|
|000032b0| 0a 58 43 6f 6d 6d 61 6e | 64 20 73 65 71 75 65 6e |.XComman|d sequen|
|000032c0| 63 65 0a 58 0a 58 09 54 | 68 69 73 20 69 73 20 61 |ce.X.X.T|his is a|
|000032d0| 20 73 65 71 75 65 6e 63 | 65 20 6f 66 20 61 6e 79 | sequenc|e of any|
|000032e0| 20 74 68 65 20 66 6f 6c | 6c 6f 77 69 6e 67 20 63 | the fol|lowing c|
|000032f0| 6f 6d 6d 61 6e 64 20 66 | 6f 72 6d 61 74 73 2c 20 |ommand f|ormats, |
|00003300| 77 68 65 72 65 0a 58 09 | 65 61 63 68 20 63 6f 6d |where.X.|each com|
|00003310| 6d 61 6e 64 20 69 73 20 | 74 65 72 6d 69 6e 61 74 |mand is |terminat|
|00003320| 65 64 20 62 79 20 61 20 | 73 65 6d 69 63 6f 6c 6f |ed by a |semicolo|
|00003330| 6e 20 6f 72 20 6e 65 77 | 6c 69 6e 65 2e 20 20 4c |n or new|line. L|
|00003340| 6f 6e 67 20 63 6f 6d 6d | 61 6e 64 0a 58 09 6c 69 |ong comm|and.X.li|
|00003350| 6e 65 73 20 63 61 6e 20 | 62 65 20 65 78 74 65 6e |nes can |be exten|
|00003360| 64 65 64 20 62 79 20 75 | 73 69 6e 67 20 61 20 62 |ded by u|sing a b|
|00003370| 61 63 6b 2d 73 6c 61 73 | 68 20 66 6f 6c 6c 6f 77 |ack-slas|h follow|
|00003380| 65 64 20 62 79 20 61 20 | 6e 65 77 6c 69 6e 65 0a |ed by a |newline.|
|00003390| 58 09 63 68 61 72 61 63 | 74 65 72 2e 20 20 57 68 |X.charac|ter. Wh|
|000033a0| 65 6e 20 74 68 69 73 20 | 69 73 20 64 6f 6e 65 2c |en this |is done,|
|000033b0| 20 74 68 65 20 70 72 6f | 6d 70 74 20 73 68 6f 77 | the pro|mpt show|
|000033c0| 73 20 61 20 64 6f 75 62 | 6c 65 20 61 6e 67 6c 65 |s a doub|le angle|
|000033d0| 0a 58 09 62 72 61 63 6b | 65 74 20 74 6f 20 69 6e |.X.brack|et to in|
|000033e0| 64 69 63 61 74 65 20 74 | 68 61 74 20 74 68 65 20 |dicate t|hat the |
|000033f0| 6c 69 6e 65 20 69 73 20 | 73 74 69 6c 6c 20 69 6e |line is |still in|
|00003400| 20 70 72 6f 67 72 65 73 | 73 2e 20 20 43 65 72 74 | progres|s. Cert|
|00003410| 61 69 6e 0a 58 09 63 61 | 73 65 73 20 77 69 6c 6c |ain.X.ca|ses will|
|00003420| 20 61 75 74 6f 6d 61 74 | 69 63 61 6c 6c 79 20 70 | automat|ically p|
|00003430| 72 6f 6d 70 74 20 66 6f | 72 20 6d 6f 72 65 20 69 |rompt fo|r more i|
|00003440| 6e 70 75 74 20 69 6e 20 | 61 20 73 69 6d 69 6c 61 |nput in |a simila|
|00003450| 72 20 6d 61 6e 6e 65 72 | 2c 0a 58 09 65 76 65 6e |r manner|,.X.even|
|00003460| 20 77 69 74 68 6f 75 74 | 20 74 68 65 20 62 61 63 | without| the bac|
|00003470| 6b 2d 73 6c 61 73 68 2e | 20 20 54 68 65 20 6d 6f |k-slash.| The mo|
|00003480| 73 74 20 63 6f 6d 6d 6f | 6e 20 63 61 73 65 20 66 |st commo|n case f|
|00003490| 6f 72 20 74 68 69 73 20 | 69 73 20 77 68 65 6e 0a |or this |is when.|
|000034a0| 58 09 61 20 66 75 6e 63 | 74 69 6f 6e 20 69 73 20 |X.a func|tion is |
|000034b0| 62 65 69 6e 67 20 64 65 | 66 69 6e 65 64 2c 20 62 |being de|fined, b|
|000034c0| 75 74 20 69 73 20 6e 6f | 74 20 79 65 74 20 63 6f |ut is no|t yet co|
|000034d0| 6d 70 6c 65 74 65 64 2e | 0a 58 0a 58 09 45 61 63 |mpleted.|.X.X.Eac|
|000034e0| 68 20 63 6f 6d 6d 61 6e | 64 20 73 65 71 75 65 6e |h comman|d sequen|
|000034f0| 63 65 20 74 65 72 6d 69 | 6e 61 74 65 73 20 6f 6e |ce termi|nates on|
|00003500| 6c 79 20 6f 6e 20 61 6e | 20 65 6e 64 20 6f 66 20 |ly on an| end of |
|00003510| 66 69 6c 65 2e 20 20 49 | 6e 0a 58 09 61 64 64 69 |file. I|n.X.addi|
|00003520| 74 69 6f 6e 2c 20 63 6f | 6d 6d 61 6e 64 73 20 63 |tion, co|mmands c|
|00003530| 61 6e 20 63 6f 6e 73 69 | 73 74 20 6f 66 20 65 78 |an consi|st of ex|
|00003540| 70 72 65 73 73 69 6f 6e | 20 73 65 71 75 65 6e 63 |pression| sequenc|
|00003550| 65 73 2c 20 77 68 69 63 | 68 20 61 72 65 0a 58 09 |es, whic|h are.X.|
|00003560| 64 65 73 63 72 69 62 65 | 64 20 69 6e 20 74 68 65 |describe|d in the|
|00003570| 20 6e 65 78 74 20 73 65 | 63 74 69 6f 6e 2e 0a 58 | next se|ction..X|
|00003580| 0a 58 0a 58 09 4e 4f 54 | 45 3a 20 43 61 6c 63 20 |.X.X.NOT|E: Calc |
|00003590| 63 6f 6d 6d 61 6e 64 73 | 20 61 72 65 20 69 6e 20 |commands| are in |
|000035a0| 6c 6f 77 65 72 20 63 61 | 73 65 2e 20 20 20 55 50 |lower ca|se. UP|
|000035b0| 50 45 52 20 63 61 73 65 | 20 69 73 20 75 73 65 64 |PER case| is used|
|000035c0| 20 62 65 6c 6f 77 0a 58 | 09 20 20 20 20 20 20 66 | below.X|. f|
|000035d0| 6f 72 20 65 6d 70 68 61 | 73 69 73 20 6f 6e 6c 79 |or empha|sis only|
|000035e0| 2c 20 61 6e 64 20 73 68 | 6f 75 6c 64 20 62 65 20 |, and sh|ould be |
|000035f0| 63 6f 6e 73 69 64 65 72 | 65 64 20 69 6e 20 6c 6f |consider|ed in lo|
|00003600| 77 65 72 20 63 61 73 65 | 2e 0a 58 0a 58 0a 58 09 |wer case|..X.X.X.|
|00003610| 44 45 46 49 4e 45 20 66 | 75 6e 63 74 69 6f 6e 28 |DEFINE f|unction(|
|00003620| 70 61 72 61 6d 73 29 20 | 7b 20 62 6f 64 79 20 7d |params) |{ body }|
|00003630| 0a 58 09 44 45 46 49 4e | 45 20 66 75 6e 63 74 69 |.X.DEFIN|E functi|
|00003640| 6f 6e 28 70 61 72 61 6d | 73 29 20 3d 20 65 78 70 |on(param|s) = exp|
|00003650| 72 65 73 73 69 6f 6e 0a | 58 09 09 54 68 69 73 20 |ression.|X..This |
|00003660| 66 69 72 73 74 20 66 6f | 72 6d 20 64 65 66 69 6e |first fo|rm defin|
|00003670| 65 73 20 61 20 66 75 6c | 6c 20 66 75 6e 63 74 69 |es a ful|l functi|
|00003680| 6f 6e 20 77 68 69 63 68 | 20 63 61 6e 20 63 6f 6e |on which| can con|
|00003690| 73 69 73 74 0a 58 09 09 | 6f 66 20 64 65 63 6c 61 |sist.X..|of decla|
|000036a0| 72 61 74 69 6f 6e 73 20 | 66 6f 6c 6c 6f 77 65 64 |rations |followed|
|000036b0| 20 62 79 20 6d 61 6e 79 | 20 73 74 61 74 65 6d 65 | by many| stateme|
|000036c0| 6e 74 73 20 77 68 69 63 | 68 20 69 6d 70 6c 65 6d |nts whic|h implem|
|000036d0| 65 6e 74 0a 58 09 09 74 | 68 65 20 66 75 6e 63 74 |ent.X..t|he funct|
|000036e0| 69 6f 6e 2e 0a 58 0a 58 | 09 09 54 68 65 20 73 65 |ion..X.X|..The se|
|000036f0| 63 6f 6e 64 20 66 6f 72 | 6d 20 64 65 66 69 6e 65 |cond for|m define|
|00003700| 73 20 61 20 73 69 6d 70 | 6c 65 20 66 75 6e 63 74 |s a simp|le funct|
|00003710| 69 6f 6e 20 77 68 69 63 | 68 20 63 61 6c 63 75 6c |ion whic|h calcul|
|00003720| 61 74 65 73 0a 58 09 09 | 74 68 65 20 73 70 65 63 |ates.X..|the spec|
|00003730| 69 66 69 65 64 20 65 78 | 70 72 65 73 73 69 6f 6e |ified ex|pression|
|00003740| 20 76 61 6c 75 65 20 66 | 72 6f 6d 20 74 68 65 20 | value f|rom the |
|00003750| 73 70 65 63 69 66 69 65 | 64 20 70 61 72 61 6d 65 |specifie|d parame|
|00003760| 74 65 72 73 2e 0a 58 09 | 09 54 68 65 20 65 78 70 |ters..X.|.The exp|
|00003770| 72 65 73 73 69 6f 6e 20 | 63 61 6e 6e 6f 74 20 62 |ression |cannot b|
|00003780| 65 20 61 20 73 74 61 74 | 65 6d 65 6e 74 2e 20 20 |e a stat|ement. |
|00003790| 48 6f 77 65 76 65 72 2c | 20 74 68 65 20 63 6f 6d |However,| the com|
|000037a0| 6d 61 0a 58 09 09 61 6e | 64 20 71 75 65 73 74 69 |ma.X..an|d questi|
|000037b0| 6f 6e 20 6d 61 72 6b 20 | 6f 70 65 72 61 74 6f 72 |on mark |operator|
|000037c0| 73 20 63 61 6e 20 62 65 | 20 75 73 65 66 75 6c 2e |s can be| useful.|
|000037d0| 20 20 45 78 61 6d 70 6c | 65 73 20 6f 66 0a 58 09 | Exampl|es of.X.|
|000037e0| 09 73 69 6d 70 6c 65 20 | 66 75 6e 63 74 69 6f 6e |.simple |function|
|000037f0| 73 20 61 72 65 3a 0a 58 | 0a 58 09 09 09 64 65 66 |s are:.X|.X...def|
|00003800| 69 6e 65 20 73 75 6d 63 | 75 62 65 73 28 61 2c 20 |ine sumc|ubes(a, |
|00003810| 62 29 20 3d 20 61 5e 33 | 20 2b 20 62 5e 33 3b 0a |b) = a^3| + b^3;.|
|00003820| 58 09 09 09 64 65 66 69 | 6e 65 20 70 69 6d 6f 64 |X...defi|ne pimod|
|00003830| 28 61 29 20 3d 20 61 20 | 25 20 70 69 28 29 3b 0a |(a) = a |% pi();.|
|00003840| 58 0a 58 09 48 45 4c 50 | 0a 58 09 09 54 68 69 73 |X.X.HELP|.X..This|
|00003850| 20 64 69 73 70 6c 61 79 | 73 20 61 20 67 65 6e 65 | display|s a gene|
|00003860| 72 61 6c 20 68 65 6c 70 | 20 6d 65 73 73 61 67 65 |ral help| message|
|00003870| 2e 0a 58 0a 58 09 52 45 | 41 44 20 66 69 6c 65 6e |..X.X.RE|AD filen|
|00003880| 61 6d 65 0a 58 09 09 54 | 68 69 73 20 72 65 61 64 |ame.X..T|his read|
|00003890| 73 20 64 65 66 69 6e 69 | 74 69 6f 6e 73 20 66 72 |s defini|tions fr|
|000038a0| 6f 6d 20 74 68 65 20 73 | 70 65 63 69 66 69 65 64 |om the s|pecified|
|000038b0| 20 66 69 6c 65 6e 61 6d | 65 2e 0a 58 09 09 54 68 | filenam|e..X..Th|
|000038c0| 65 20 6e 61 6d 65 20 63 | 61 6e 20 62 65 20 71 75 |e name c|an be qu|
|000038d0| 6f 74 65 64 20 69 66 20 | 64 65 73 69 72 65 64 2e |oted if |desired.|
|000038e0| 20 20 54 68 65 20 63 61 | 6c 63 75 6c 61 74 6f 72 | The ca|lculator|
|000038f0| 0a 58 09 09 75 73 65 73 | 20 74 68 65 20 43 41 4c |.X..uses| the CAL|
|00003900| 43 50 41 54 48 20 65 6e | 76 69 72 6f 6e 6d 65 6e |CPATH en|vironmen|
|00003910| 74 20 76 61 72 69 61 62 | 6c 65 20 74 6f 20 73 65 |t variab|le to se|
|00003920| 61 72 63 68 0a 58 09 09 | 74 68 72 6f 75 67 68 20 |arch.X..|through |
|00003930| 74 68 65 20 73 70 65 63 | 69 66 69 65 64 20 64 69 |the spec|ified di|
|00003940| 72 65 63 74 6f 72 69 65 | 73 20 66 6f 72 20 74 68 |rectorie|s for th|
|00003950| 65 20 66 69 6c 65 6e 61 | 6d 65 2c 0a 58 09 09 73 |e filena|me,.X..s|
|00003960| 69 6d 69 6c 61 72 6c 79 | 20 74 6f 20 74 68 65 20 |imilarly| to the |
|00003970| 75 73 65 20 6f 66 20 74 | 68 65 20 50 41 54 48 20 |use of t|he PATH |
|00003980| 65 6e 76 69 72 6f 6e 6d | 65 6e 74 20 76 61 72 69 |environm|ent vari|
|00003990| 61 62 6c 65 2e 0a 58 09 | 09 49 66 20 43 41 4c 43 |able..X.|.If CALC|
|000039a0| 50 41 54 48 20 69 73 20 | 6e 6f 74 20 64 65 66 69 |PATH is |not defi|
|000039b0| 6e 65 64 2c 20 74 68 65 | 6e 20 61 20 64 65 66 61 |ned, the|n a defa|
|000039c0| 75 6c 74 20 70 61 74 68 | 20 6f 66 0a 58 09 09 22 |ult path| of.X.."|
|000039d0| 3a 2f 75 73 72 2f 6c 69 | 62 2f 63 61 6c 63 22 20 |:/usr/li|b/calc" |
|000039e0| 69 73 20 75 73 65 64 20 | 28 74 68 61 74 20 69 73 |is used |(that is|
|000039f0| 2c 20 74 68 65 20 63 75 | 72 72 65 6e 74 20 64 69 |, the cu|rrent di|
|00003a00| 72 65 63 74 6f 72 79 0a | 58 09 09 66 6f 6c 6c 6f |rectory.|X..follo|
|00003a10| 77 65 64 20 62 79 20 61 | 20 67 65 6e 65 72 61 6c |wed by a| general|
|00003a20| 20 63 61 6c 63 20 6c 69 | 62 72 61 72 79 20 64 69 | calc li|brary di|
|00003a30| 72 65 63 74 6f 72 79 29 | 2e 20 20 54 68 65 0a 58 |rectory)|. The.X|
|00003a40| 09 09 22 2e 63 61 6c 22 | 20 65 78 74 65 6e 73 69 |..".cal"| extensi|
|00003a50| 6f 6e 20 69 73 20 64 65 | 66 61 75 6c 74 65 64 20 |on is de|faulted |
|00003a60| 66 6f 72 20 69 6e 70 75 | 74 20 66 69 6c 65 73 2c |for inpu|t files,|
|00003a70| 20 73 6f 20 74 68 61 74 | 0a 58 09 09 69 66 20 22 | so that|.X..if "|
|00003a80| 66 69 6c 65 6e 61 6d 65 | 22 20 69 73 20 6e 6f 74 |filename|" is not|
|00003a90| 20 66 6f 75 6e 64 2c 20 | 74 68 65 6e 20 22 66 69 | found, |then "fi|
|00003aa0| 6c 65 6e 61 6d 65 2e 63 | 61 6c 22 20 69 73 20 74 |lename.c|al" is t|
|00003ab0| 68 65 6e 0a 58 09 09 73 | 65 61 72 63 68 65 64 20 |hen.X..s|earched |
|00003ac0| 66 6f 72 2e 20 20 54 68 | 65 20 63 6f 6e 74 65 6e |for. Th|e conten|
|00003ad0| 74 73 20 6f 66 20 74 68 | 65 20 66 69 6c 65 6e 61 |ts of th|e filena|
|00003ae0| 6d 65 20 61 72 65 20 63 | 6f 6d 6d 61 6e 64 0a 58 |me are c|ommand.X|
|00003af0| 09 09 73 65 71 75 65 6e | 63 65 73 20 77 68 69 63 |..sequen|ces whic|
|00003b00| 68 20 63 61 6e 20 63 6f | 6e 73 69 73 74 20 6f 66 |h can co|nsist of|
|00003b10| 20 65 78 70 72 65 73 73 | 69 6f 6e 73 20 74 6f 20 | express|ions to |
|00003b20| 65 76 61 6c 75 61 74 65 | 0a 58 09 09 6f 72 20 66 |evaluate|.X..or f|
|00003b30| 75 6e 63 74 69 6f 6e 73 | 20 74 6f 20 64 65 66 69 |unctions| to defi|
|00003b40| 6e 65 2c 20 6a 75 73 74 | 20 6c 69 6b 65 20 61 74 |ne, just| like at|
|00003b50| 20 74 68 65 20 74 6f 70 | 20 6c 65 76 65 6c 0a 58 | the top| level.X|
|00003b60| 09 09 63 6f 6d 6d 61 6e | 64 20 6c 65 76 65 6c 2e |..comman|d level.|
|00003b70| 0a 58 0a 58 09 57 52 49 | 54 45 20 66 69 6c 65 6e |.X.X.WRI|TE filen|
|00003b80| 61 6d 65 0a 58 09 09 54 | 68 69 73 20 77 72 69 74 |ame.X..T|his writ|
|00003b90| 65 73 20 74 68 65 20 76 | 61 6c 75 65 73 20 6f 66 |es the v|alues of|
|00003ba0| 20 61 6c 6c 20 67 6c 6f | 62 61 6c 20 76 61 72 69 | all glo|bal vari|
|00003bb0| 61 62 6c 65 73 20 74 6f | 20 74 68 65 0a 58 09 09 |ables to| the.X..|
|00003bc0| 73 70 65 63 69 66 69 65 | 64 20 66 69 6c 65 6e 61 |specifie|d filena|
|00003bd0| 6d 65 2c 20 69 6e 20 73 | 75 63 68 20 61 20 77 61 |me, in s|uch a wa|
|00003be0| 79 20 74 68 61 74 20 74 | 68 65 20 66 69 6c 65 20 |y that t|he file |
|00003bf0| 63 61 6e 20 62 65 0a 58 | 09 09 6c 61 74 65 72 20 |can be.X|..later |
|00003c00| 72 65 61 64 20 69 6e 20 | 6f 72 64 65 72 20 74 6f |read in |order to|
|00003c10| 20 72 65 63 72 65 61 74 | 65 20 74 68 65 20 76 61 | recreat|e the va|
|00003c20| 72 69 61 62 6c 65 20 76 | 61 6c 75 65 73 2e 0a 58 |riable v|alues..X|
|00003c30| 09 09 46 6f 72 20 73 70 | 65 65 64 20 72 65 61 73 |..For sp|eed reas|
|00003c40| 6f 6e 73 2c 20 76 61 6c | 75 65 73 20 61 72 65 20 |ons, val|ues are |
|00003c50| 77 72 69 74 74 65 6e 20 | 61 73 20 68 65 78 20 66 |written |as hex f|
|00003c60| 72 61 63 74 69 6f 6e 73 | 2e 0a 58 09 09 54 68 69 |ractions|..X..Thi|
|00003c70| 73 20 63 6f 6d 6d 61 6e | 64 20 63 75 72 72 65 6e |s comman|d curren|
|00003c80| 74 6c 79 20 6f 6e 6c 79 | 20 73 61 76 65 73 20 73 |tly only| saves s|
|00003c90| 69 6d 70 6c 65 20 74 79 | 70 65 73 2c 20 73 6f 20 |imple ty|pes, so |
|00003ca0| 74 68 61 74 0a 58 09 09 | 6d 61 74 72 69 63 65 73 |that.X..|matrices|
|00003cb0| 2c 20 6c 69 73 74 73 2c | 20 61 6e 64 20 6f 62 6a |, lists,| and obj|
|00003cc0| 65 63 74 73 20 61 72 65 | 20 6e 6f 74 20 73 61 76 |ects are| not sav|
|00003cd0| 65 64 2e 20 20 46 75 6e | 63 74 69 6f 6e 0a 58 09 |ed. Fun|ction.X.|
|00003ce0| 09 64 65 66 69 6e 69 74 | 69 6f 6e 73 20 61 72 65 |.definit|ions are|
|00003cf0| 20 61 6c 73 6f 20 6e 6f | 74 20 73 61 76 65 64 2e | also no|t saved.|
|00003d00| 0a 58 0a 58 09 51 55 49 | 54 0a 58 09 09 54 68 69 |.X.X.QUI|T.X..Thi|
|00003d10| 73 20 6c 65 61 76 65 73 | 20 74 68 65 20 63 61 6c |s leaves| the cal|
|00003d20| 63 75 6c 61 74 6f 72 2c | 20 77 68 65 6e 20 67 69 |culator,| when gi|
|00003d30| 76 65 6e 20 61 73 20 61 | 20 74 6f 70 2d 6c 65 76 |ven as a| top-lev|
|00003d40| 65 6c 0a 58 09 09 63 6f | 6d 6d 61 6e 64 2e 0a 58 |el.X..co|mmand..X|
|00003d50| 09 0a 58 0a 58 09 41 6c | 73 6f 20 73 65 65 20 74 |..X.X.Al|so see t|
|00003d60| 68 65 20 68 65 6c 70 20 | 74 6f 70 69 63 3a 0a 58 |he help |topic:.X|
|00003d70| 0a 58 09 09 73 74 61 74 | 65 6d 65 6e 74 20 20 20 |.X..stat|ement |
|00003d80| 20 20 20 20 66 6c 6f 77 | 20 63 6f 6e 74 72 6f 6c | flow| control|
|00003d90| 20 61 6e 64 20 64 65 63 | 6c 61 72 61 74 69 6f 6e | and dec|laration|
|00003da0| 20 73 74 61 74 65 6d 65 | 6e 74 73 0a 45 4e 44 5f | stateme|nts.END_|
|00003db0| 4f 46 5f 46 49 4c 45 0a | 69 66 20 74 65 73 74 20 |OF_FILE.|if test |
|00003dc0| 32 37 34 30 20 2d 6e 65 | 20 60 77 63 20 2d 63 20 |2740 -ne| `wc -c |
|00003dd0| 3c 27 68 65 6c 70 2f 63 | 6f 6d 6d 61 6e 64 27 60 |<'help/c|ommand'`|
|00003de0| 3b 20 74 68 65 6e 0a 20 | 20 20 20 65 63 68 6f 20 |; then. | echo |
|00003df0| 73 68 61 72 3a 20 5c 22 | 27 68 65 6c 70 2f 63 6f |shar: \"|'help/co|
|00003e00| 6d 6d 61 6e 64 27 5c 22 | 20 75 6e 70 61 63 6b 65 |mmand'\"| unpacke|
|00003e10| 64 20 77 69 74 68 20 77 | 72 6f 6e 67 20 73 69 7a |d with w|rong siz|
|00003e20| 65 21 0a 66 69 0a 23 20 | 65 6e 64 20 6f 66 20 27 |e!.fi.# |end of '|
|00003e30| 68 65 6c 70 2f 63 6f 6d | 6d 61 6e 64 27 0a 66 69 |help/com|mand'.fi|
|00003e40| 0a 69 66 20 74 65 73 74 | 20 2d 66 20 27 68 65 6c |.if test| -f 'hel|
|00003e50| 70 2f 63 6f 6e 66 69 67 | 27 20 2d 61 20 22 24 7b |p/config|' -a "${|
|00003e60| 31 7d 22 20 21 3d 20 22 | 2d 63 22 20 3b 20 74 68 |1}" != "|-c" ; th|
|00003e70| 65 6e 20 0a 20 20 65 63 | 68 6f 20 73 68 61 72 3a |en . ec|ho shar:|
|00003e80| 20 57 69 6c 6c 20 6e 6f | 74 20 63 6c 6f 62 62 65 | Will no|t clobbe|
|00003e90| 72 20 65 78 69 73 74 69 | 6e 67 20 66 69 6c 65 20 |r existi|ng file |
|00003ea0| 5c 22 27 68 65 6c 70 2f | 63 6f 6e 66 69 67 27 5c |\"'help/|config'\|
|00003eb0| 22 0a 65 6c 73 65 0a 65 | 63 68 6f 20 73 68 61 72 |".else.e|cho shar|
|00003ec0| 3a 20 45 78 74 72 61 63 | 74 69 6e 67 20 5c 22 27 |: Extrac|ting \"'|
|00003ed0| 68 65 6c 70 2f 63 6f 6e | 66 69 67 27 5c 22 20 5c |help/con|fig'\" \|
|00003ee0| 28 34 34 32 36 20 63 68 | 61 72 61 63 74 65 72 73 |(4426 ch|aracters|
|00003ef0| 5c 29 0a 73 65 64 20 22 | 73 2f 5e 58 2f 2f 22 20 |\).sed "|s/^X//" |
|00003f00| 3e 27 68 65 6c 70 2f 63 | 6f 6e 66 69 67 27 20 3c |>'help/c|onfig' <|
|00003f10| 3c 27 45 4e 44 5f 4f 46 | 5f 46 49 4c 45 27 0a 58 |<'END_OF|_FILE'.X|
|00003f20| 43 6f 6e 66 69 67 75 72 | 61 74 69 6f 6e 20 70 61 |Configur|ation pa|
|00003f30| 72 61 6d 65 74 65 72 73 | 0a 58 0a 58 09 43 6f 6e |rameters|.X.X.Con|
|00003f40| 66 69 67 75 72 61 74 69 | 6f 6e 20 70 61 72 61 6d |figurati|on param|
|00003f50| 65 74 65 72 73 20 61 66 | 66 65 63 74 20 68 6f 77 |eters af|fect how|
|00003f60| 20 74 68 65 20 63 61 6c | 63 75 6c 61 74 6f 72 20 | the cal|culator |
|00003f70| 70 65 72 66 6f 72 6d 73 | 20 63 65 72 74 61 69 6e |performs| certain|
|00003f80| 0a 58 09 6f 70 65 72 61 | 74 69 6f 6e 73 2c 20 61 |.X.opera|tions, a|
|00003f90| 6e 64 20 61 66 66 65 63 | 74 73 20 61 6c 6c 20 66 |nd affec|ts all f|
|00003fa0| 75 74 75 72 65 20 63 61 | 6c 63 75 6c 61 74 69 6f |uture ca|lculatio|
|00003fb0| 6e 73 2e 20 20 54 68 65 | 73 65 20 70 61 72 61 6d |ns. The|se param|
|00003fc0| 65 74 65 72 73 0a 58 09 | 61 66 66 65 63 74 20 74 |eters.X.|affect t|
|00003fd0| 68 65 20 61 63 63 75 72 | 61 63 79 20 6f 66 20 63 |he accur|acy of c|
|00003fe0| 61 6c 63 75 6c 61 74 69 | 6f 6e 73 2c 20 74 68 65 |alculati|ons, the|
|00003ff0| 20 64 69 73 70 6c 61 79 | 65 64 20 66 6f 72 6d 61 | display|ed forma|
|00004000| 74 20 6f 66 20 72 65 73 | 75 6c 74 73 2c 0a 58 09 |t of res|ults,.X.|
|00004010| 61 6e 64 20 77 68 69 63 | 68 20 61 6c 67 6f 72 69 |and whic|h algori|
|00004020| 74 68 6d 73 20 61 72 65 | 20 75 73 65 64 20 66 6f |thms are| used fo|
|00004030| 72 20 63 61 6c 63 75 6c | 61 74 69 6f 6e 73 2e 20 |r calcul|ations. |
|00004040| 20 54 68 65 20 70 61 72 | 61 6d 65 74 65 72 73 20 | The par|ameters |
|00004050| 61 72 65 0a 58 09 72 65 | 61 64 20 6f 72 20 73 65 |are.X.re|ad or se|
|00004060| 74 20 75 73 69 6e 67 20 | 74 68 65 20 22 63 6f 6e |t using |the "con|
|00004070| 66 69 67 22 20 62 75 69 | 6c 74 2d 69 6e 20 66 75 |fig" bui|lt-in fu|
|00004080| 6e 63 74 69 6f 6e 2e 20 | 20 54 68 65 20 66 6f 6c |nction. | The fol|
|00004090| 6c 6f 77 69 6e 67 0a 58 | 09 70 61 72 61 6d 65 74 |lowing.X|.paramet|
|000040a0| 65 72 73 20 63 61 6e 20 | 62 65 20 73 70 65 63 69 |ers can |be speci|
|000040b0| 66 69 65 64 3a 0a 58 0a | 58 09 09 22 74 72 61 63 |fied:.X.|X.."trac|
|000040c0| 65 22 09 09 74 75 72 6e | 73 20 74 72 61 63 69 6e |e"..turn|s tracin|
|000040d0| 67 20 6f 6e 20 6f 72 20 | 6f 66 66 20 28 66 6f 72 |g on or |off (for|
|000040e0| 20 64 65 62 75 67 67 69 | 6e 67 29 2e 0a 58 09 09 | debuggi|ng)..X..|
|000040f0| 22 64 69 73 70 6c 61 79 | 22 09 73 65 74 73 20 6e |"display|".sets n|
|00004100| 75 6d 62 65 72 20 6f 66 | 20 64 69 67 69 74 73 20 |umber of| digits |
|00004110| 69 6e 20 70 72 69 6e 74 | 73 2e 0a 58 09 09 22 65 |in print|s..X.."e|
|00004120| 70 73 69 6c 6f 6e 22 09 | 73 65 74 73 20 65 72 72 |psilon".|sets err|
|00004130| 6f 72 20 76 61 6c 75 65 | 20 66 6f 72 20 74 72 61 |or value| for tra|
|00004140| 6e 73 63 65 6e 64 65 6e | 74 61 6c 73 2e 0a 58 09 |nscenden|tals..X.|
|00004150| 09 22 6d 61 78 70 72 69 | 6e 74 22 09 73 65 74 73 |."maxpri|nt".sets|
|00004160| 20 6d 61 78 69 6d 75 6d | 20 6e 75 6d 62 65 72 20 | maximum| number |
|00004170| 6f 66 20 65 6c 65 6d 65 | 6e 74 73 20 70 72 69 6e |of eleme|nts prin|
|00004180| 74 65 64 2e 0a 58 09 09 | 22 6d 6f 64 65 22 09 09 |ted..X..|"mode"..|
|00004190| 73 65 74 73 20 70 72 69 | 6e 74 6f 75 74 20 6d 6f |sets pri|ntout mo|
|000041a0| 64 65 2e 0a 58 09 09 22 | 6d 75 6c 32 22 09 09 73 |de..X.."|mul2"..s|
|000041b0| 65 74 73 20 73 69 7a 65 | 20 66 6f 72 20 61 6c 74 |ets size| for alt|
|000041c0| 65 72 6e 61 74 69 76 65 | 20 6d 75 6c 74 69 70 6c |ernative| multipl|
|000041d0| 79 2e 0a 58 09 09 22 73 | 71 32 22 09 09 73 65 74 |y..X.."s|q2"..set|
|000041e0| 73 20 73 69 7a 65 20 66 | 6f 72 20 61 6c 74 65 72 |s size f|or alter|
|000041f0| 6e 61 74 69 76 65 20 73 | 71 75 61 72 69 6e 67 2e |native s|quaring.|
|00004200| 0a 58 09 09 22 70 6f 77 | 32 22 09 09 73 65 74 73 |.X.."pow|2"..sets|
|00004210| 20 73 69 7a 65 20 66 6f | 72 20 61 6c 74 65 72 6e | size fo|r altern|
|00004220| 61 74 65 20 70 6f 77 65 | 72 69 6e 67 2e 0a 58 09 |ate powe|ring..X.|
|00004230| 09 22 72 65 64 63 32 22 | 09 09 73 65 74 73 20 73 |."redc2"|..sets s|
|00004240| 69 7a 65 20 66 6f 72 20 | 61 6c 74 65 72 6e 61 74 |ize for |alternat|
|00004250| 65 20 52 45 44 43 2e 0a | 58 0a 58 09 54 68 65 20 |e REDC..|X.X.The |
|00004260| 75 73 65 20 6f 66 20 74 | 68 65 20 74 72 61 63 65 |use of t|he trace|
|00004270| 20 66 6c 61 67 20 69 73 | 20 66 6f 72 20 64 65 62 | flag is| for deb|
|00004280| 75 67 67 69 6e 67 2c 20 | 61 6e 64 20 69 74 73 20 |ugging, |and its |
|00004290| 6d 65 61 6e 69 6e 67 20 | 6d 61 79 0a 58 09 63 68 |meaning |may.X.ch|
|000042a0| 61 6e 67 65 20 69 6e 20 | 74 68 65 20 66 75 74 75 |ange in |the futu|
|000042b0| 72 65 2e 20 20 41 20 76 | 61 6c 75 65 20 6f 66 20 |re. A v|alue of |
|000042c0| 31 20 63 61 75 73 65 73 | 20 74 68 65 20 63 61 6c |1 causes| the cal|
|000042d0| 63 75 6c 61 74 6f 72 20 | 74 6f 20 70 72 69 6e 74 |culator |to print|
|000042e0| 0a 58 09 69 74 73 20 69 | 6e 74 65 72 6e 61 6c 20 |.X.its i|nternal |
|000042f0| 6f 70 63 6f 64 65 73 20 | 61 73 20 69 74 20 65 78 |opcodes |as it ex|
|00004300| 65 63 75 74 65 73 20 66 | 75 6e 63 74 69 6f 6e 73 |ecutes f|unctions|
|00004310| 2e 20 20 41 20 76 61 6c | 75 65 20 6f 66 20 7a 65 |. A val|ue of ze|
|00004320| 72 6f 0a 58 09 64 69 73 | 61 62 6c 65 73 20 74 72 |ro.X.dis|ables tr|
|00004330| 61 63 69 6e 67 20 61 67 | 61 69 6e 2e 0a 58 0a 58 |acing ag|ain..X.X|
|00004340| 09 44 69 73 70 6c 61 79 | 20 73 70 65 63 69 66 69 |.Display| specifi|
|00004350| 65 73 20 68 6f 77 20 6d | 61 6e 79 20 64 69 67 69 |es how m|any digi|
|00004360| 74 73 20 61 66 74 65 72 | 20 74 68 65 20 64 65 63 |ts after| the dec|
|00004370| 69 6d 61 6c 20 70 6f 69 | 6e 74 20 73 68 6f 75 6c |imal poi|nt shoul|
|00004380| 64 0a 58 09 62 65 20 70 | 72 69 6e 74 65 64 20 77 |d.X.be p|rinted w|
|00004390| 68 65 6e 20 70 72 69 6e | 74 69 6e 67 20 72 65 61 |hen prin|ting rea|
|000043a0| 6c 20 6f 72 20 65 78 70 | 6f 6e 65 6e 74 69 61 6c |l or exp|onential|
|000043b0| 20 6e 75 6d 62 65 72 73 | 2e 20 20 54 68 65 20 69 | numbers|. The i|
|000043c0| 6e 69 74 69 61 6c 0a 58 | 09 64 69 73 70 6c 61 79 |nitial.X|.display|
|000043d0| 20 76 61 6c 75 65 20 69 | 73 20 32 30 2e 20 20 54 | value i|s 20. T|
|000043e0| 68 69 73 20 70 61 72 61 | 6d 65 74 65 72 20 64 6f |his para|meter do|
|000043f0| 65 73 20 6e 6f 74 20 61 | 66 66 65 63 74 20 74 68 |es not a|ffect th|
|00004400| 65 20 61 63 63 75 72 61 | 63 79 0a 58 09 6f 66 20 |e accura|cy.X.of |
|00004410| 61 20 63 61 6c 63 75 6c | 61 74 69 6f 6e 2c 20 73 |a calcul|ation, s|
|00004420| 69 6e 63 65 20 69 74 20 | 6f 6e 6c 79 20 68 61 73 |ince it |only has|
|00004430| 20 6d 65 61 6e 69 6e 67 | 20 77 68 65 6e 20 70 72 | meaning| when pr|
|00004440| 69 6e 74 69 6e 67 20 72 | 65 73 75 6c 74 73 2e 0a |inting r|esults..|
|00004450| 58 0a 58 09 45 70 73 69 | 6c 6f 6e 20 73 70 65 63 |X.X.Epsi|lon spec|
|00004460| 69 66 69 65 73 20 74 68 | 65 20 72 65 71 75 69 72 |ifies th|e requir|
|00004470| 65 64 20 70 72 65 63 69 | 73 69 6f 6e 20 6f 66 20 |ed preci|sion of |
|00004480| 63 61 6c 63 75 6c 61 74 | 69 6f 6e 73 20 62 79 0a |calculat|ions by.|
|00004490| 58 09 73 65 74 74 69 6e | 67 20 74 68 65 20 6d 61 |X.settin|g the ma|
|000044a0| 78 69 6d 75 6d 20 61 6c | 6c 6f 77 65 64 20 65 72 |ximum al|lowed er|
|000044b0| 72 6f 72 20 66 6f 72 20 | 74 72 61 6e 73 63 65 6e |ror for |transcen|
|000044c0| 64 65 6e 74 61 6c 20 66 | 75 6e 63 74 69 6f 6e 73 |dental f|unctions|
|000044d0| 2e 0a 58 09 54 68 65 20 | 65 72 72 6f 72 20 69 73 |..X.The |error is|
|000044e0| 20 61 6e 20 61 62 73 6f | 6c 75 74 65 20 65 72 72 | an abso|lute err|
|000044f0| 6f 72 20 76 61 6c 75 65 | 20 66 6f 72 20 6d 61 6e |or value| for man|
|00004500| 79 20 66 75 6e 63 74 69 | 6f 6e 73 2c 20 62 75 74 |y functi|ons, but|
|00004510| 0a 58 09 66 6f 72 20 73 | 6f 6d 65 20 66 75 6e 63 |.X.for s|ome func|
|00004520| 74 69 6f 6e 73 20 69 74 | 20 69 73 20 61 20 72 65 |tions it| is a re|
|00004530| 6c 61 74 69 76 65 20 65 | 72 72 6f 72 2e 20 20 54 |lative e|rror. T|
|00004540| 68 65 20 69 6e 69 74 69 | 61 6c 20 76 61 6c 75 65 |he initi|al value|
|00004550| 0a 58 09 69 73 20 31 65 | 2d 32 30 2e 20 20 46 75 |.X.is 1e|-20. Fu|
|00004560| 6e 63 74 69 6f 6e 73 20 | 77 68 69 63 68 20 72 65 |nctions |which re|
|00004570| 71 75 69 72 65 20 61 6e | 20 65 70 73 69 6c 6f 6e |quire an| epsilon|
|00004580| 20 76 61 6c 75 65 20 61 | 63 63 65 70 74 20 61 6e | value a|ccept an|
|00004590| 0a 58 09 6f 70 74 69 6f | 6e 61 6c 20 61 72 67 75 |.X.optio|nal argu|
|000045a0| 6d 65 6e 74 20 77 68 69 | 63 68 20 6f 76 65 72 72 |ment whi|ch overr|
|000045b0| 69 64 65 73 20 74 68 69 | 73 20 64 65 66 61 75 6c |ides thi|s defaul|
|000045c0| 74 20 65 70 73 69 6c 6f | 6e 20 76 61 6c 75 65 20 |t epsilo|n value |
|000045d0| 66 6f 72 0a 58 09 74 68 | 61 74 20 73 69 6e 67 6c |for.X.th|at singl|
|000045e0| 65 20 63 61 6c 6c 2e 20 | 20 54 68 65 20 62 75 69 |e call. | The bui|
|000045f0| 6c 74 2d 69 6e 20 66 75 | 6e 63 74 69 6f 6e 20 22 |lt-in fu|nction "|
|00004600| 65 70 73 69 6c 6f 6e 22 | 20 61 6c 73 6f 20 63 61 |epsilon"| also ca|
|00004610| 6e 20 62 65 0a 58 09 75 | 73 65 64 20 74 6f 20 72 |n be.X.u|sed to r|
|00004620| 65 61 64 20 6f 72 20 73 | 65 74 20 74 68 69 73 20 |ead or s|et this |
|00004630| 76 61 6c 75 65 2c 20 61 | 6e 64 20 69 73 20 70 72 |value, a|nd is pr|
|00004640| 6f 76 69 64 65 64 20 66 | 6f 72 20 65 61 73 65 20 |ovided f|or ease |
|00004650| 6f 66 20 75 73 65 2e 0a | 58 0a 58 09 4d 6f 64 65 |of use..|X.X.Mode|
|00004660| 20 73 70 65 63 69 66 69 | 65 73 20 68 6f 77 20 6e | specifi|es how n|
|00004670| 75 6d 62 65 72 73 20 73 | 68 6f 75 6c 64 20 62 65 |umbers s|hould be|
|00004680| 20 70 72 69 6e 74 65 64 | 2e 20 20 4d 6f 64 65 20 | printed|. Mode |
|00004690| 69 73 20 61 20 73 74 72 | 69 6e 67 0a 58 09 76 61 |is a str|ing.X.va|
|000046a0| 6c 75 65 20 69 6e 64 69 | 63 61 74 69 6e 67 20 74 |lue indi|cating t|
|000046b0| 68 65 20 70 72 69 6e 74 | 6f 75 74 20 6d 65 74 68 |he print|out meth|
|000046c0| 6f 64 2e 20 20 54 68 65 | 20 69 6e 69 74 69 61 6c |od. The| initial|
|000046d0| 20 6d 6f 64 65 20 69 73 | 20 22 72 65 61 6c 22 2e | mode is| "real".|
|000046e0| 0a 58 09 50 6f 73 73 69 | 62 6c 65 20 6d 6f 64 65 |.X.Possi|ble mode|
|000046f0| 73 20 61 72 65 3a 0a 58 | 0a 58 09 09 22 66 72 61 |s are:.X|.X.."fra|
|00004700| 63 22 09 09 64 65 63 69 | 6d 61 6c 20 66 72 61 63 |c"..deci|mal frac|
|00004710| 74 69 6f 6e 73 0a 58 09 | 09 22 69 6e 74 22 09 09 |tions.X.|."int"..|
|00004720| 64 65 63 69 6d 61 6c 20 | 69 6e 74 65 67 65 72 0a |decimal |integer.|
|00004730| 58 09 09 22 72 65 61 6c | 22 09 09 64 65 63 69 6d |X.."real|"..decim|
|00004740| 61 6c 20 66 6c 6f 61 74 | 69 6e 67 20 70 6f 69 6e |al float|ing poin|
|00004750| 74 0a 58 09 09 22 65 78 | 70 22 09 09 64 65 63 69 |t.X.."ex|p"..deci|
|00004760| 6d 61 6c 20 65 78 70 6f | 6e 65 6e 74 69 61 6c 0a |mal expo|nential.|
|00004770| 58 09 09 22 68 65 78 22 | 09 09 68 65 78 20 66 72 |X.."hex"|..hex fr|
|00004780| 61 63 74 69 6f 6e 73 0a | 58 09 09 22 6f 63 74 22 |actions.|X.."oct"|
|00004790| 09 09 6f 63 74 61 6c 20 | 66 72 61 63 74 69 6f 6e |..octal |fraction|
|000047a0| 73 0a 58 09 09 22 62 69 | 6e 22 09 09 62 69 6e 61 |s.X.."bi|n"..bina|
|000047b0| 72 79 20 66 72 61 63 74 | 69 6f 6e 73 0a 58 0a 58 |ry fract|ions.X.X|
|000047c0| 09 4d 61 78 70 72 69 6e | 74 20 73 70 65 63 69 66 |.Maxprin|t specif|
|000047d0| 69 65 73 20 74 68 65 20 | 6d 61 78 69 6d 75 6d 20 |ies the |maximum |
|000047e0| 6e 75 6d 62 65 72 20 6f | 66 20 65 6c 65 6d 65 6e |number o|f elemen|
|000047f0| 74 73 20 74 6f 20 62 65 | 20 64 69 73 70 6c 61 79 |ts to be| display|
|00004800| 65 64 0a 58 09 77 68 65 | 6e 20 61 20 6d 61 74 72 |ed.X.whe|n a matr|
|00004810| 69 78 20 6f 72 20 6c 69 | 73 74 20 69 73 20 70 72 |ix or li|st is pr|
|00004820| 69 6e 74 65 64 2e 20 20 | 54 68 65 20 69 6e 69 74 |inted. |The init|
|00004830| 69 61 6c 20 76 61 6c 75 | 65 20 69 73 20 31 36 20 |ial valu|e is 16 |
|00004840| 65 6c 65 6d 65 6e 74 73 | 2e 0a 58 0a 58 09 4d 75 |elements|..X.X.Mu|
|00004850| 6c 32 20 61 6e 64 20 73 | 71 32 20 73 70 65 63 69 |l2 and s|q2 speci|
|00004860| 66 79 20 74 68 65 20 73 | 69 7a 65 73 20 6f 66 20 |fy the s|izes of |
|00004870| 6e 75 6d 62 65 72 73 20 | 61 74 20 77 68 69 63 68 |numbers |at which|
|00004880| 20 63 61 6c 63 20 73 77 | 69 74 63 68 65 73 0a 58 | calc sw|itches.X|
|00004890| 09 66 72 6f 6d 20 69 74 | 73 20 66 69 72 73 74 20 |.from it|s first |
|000048a0| 74 6f 20 69 74 73 20 73 | 65 63 6f 6e 64 20 61 6c |to its s|econd al|
|000048b0| 67 6f 72 69 74 68 6d 20 | 66 6f 72 20 6d 75 6c 74 |gorithm |for mult|
|000048c0| 69 70 6c 79 69 6e 67 20 | 61 6e 64 20 73 71 75 61 |iplying |and squa|
|000048d0| 72 69 6e 67 2e 0a 58 09 | 54 68 65 20 66 69 72 73 |ring..X.|The firs|
|000048e0| 74 20 61 6c 67 6f 72 69 | 74 68 6d 20 69 73 20 74 |t algori|thm is t|
|000048f0| 68 65 20 75 73 75 61 6c | 20 6d 65 74 68 6f 64 20 |he usual| method |
|00004900| 6f 66 20 63 72 6f 73 73 | 20 6d 75 6c 74 69 70 6c |of cross| multipl|
|00004910| 79 69 6e 67 2c 20 77 68 | 69 63 68 0a 58 09 72 75 |ying, wh|ich.X.ru|
|00004920| 6e 73 20 69 6e 20 61 20 | 74 69 6d 65 20 6f 66 20 |ns in a |time of |
|00004930| 4f 28 4e 5e 32 29 2e 20 | 20 54 68 65 20 73 65 63 |O(N^2). | The sec|
|00004940| 6f 6e 64 20 6d 65 74 68 | 6f 64 20 69 73 20 61 20 |ond meth|od is a |
|00004950| 72 65 63 75 72 73 69 76 | 65 20 61 6e 64 0a 58 09 |recursiv|e and.X.|
|00004960| 63 6f 6d 70 6c 69 63 61 | 74 65 64 20 6d 65 74 68 |complica|ted meth|
|00004970| 6f 64 20 77 68 69 63 68 | 20 72 75 6e 73 20 69 6e |od which| runs in|
|00004980| 20 61 20 74 69 6d 65 20 | 6f 66 20 4f 28 4e 5e 31 | a time |of O(N^1|
|00004990| 2e 35 38 35 29 2e 20 20 | 54 68 65 20 61 72 67 75 |.585). |The argu|
|000049a0| 6d 65 6e 74 0a 58 09 66 | 6f 72 20 74 68 65 73 65 |ment.X.f|or these|
|000049b0| 20 70 61 72 61 6d 65 74 | 65 72 73 20 69 73 20 74 | paramet|ers is t|
|000049c0| 68 65 20 6e 75 6d 62 65 | 72 20 6f 66 20 62 69 6e |he numbe|r of bin|
|000049d0| 61 72 79 20 77 6f 72 64 | 73 20 61 74 20 77 68 69 |ary word|s at whi|
|000049e0| 63 68 20 74 68 65 0a 58 | 09 73 65 63 6f 6e 64 20 |ch the.X|.second |
|000049f0| 61 6c 67 6f 72 69 74 68 | 6d 20 62 65 67 69 6e 73 |algorith|m begins|
|00004a00| 20 74 6f 20 62 65 20 75 | 73 65 64 2e 20 20 54 68 | to be u|sed. Th|
|00004a10| 65 20 6d 69 6e 69 6d 75 | 6d 20 76 61 6c 75 65 20 |e minimu|m value |
|00004a20| 69 73 20 32 2c 20 61 6e | 64 0a 58 09 74 68 65 20 |is 2, an|d.X.the |
|00004a30| 6d 61 78 69 6d 75 6d 20 | 76 61 6c 75 65 20 69 73 |maximum |value is|
|00004a40| 20 76 65 72 79 20 6c 61 | 72 67 65 2e 20 20 49 66 | very la|rge. If|
|00004a50| 20 32 20 69 73 20 75 73 | 65 64 2c 20 74 68 65 6e | 2 is us|ed, then|
|00004a60| 20 74 68 65 20 72 65 63 | 75 72 73 69 76 65 0a 58 | the rec|ursive.X|
|00004a70| 09 61 6c 67 6f 72 69 74 | 68 6d 20 69 73 20 75 73 |.algorit|hm is us|
|00004a80| 65 64 20 61 6c 6c 20 74 | 68 65 20 77 61 79 20 64 |ed all t|he way d|
|00004a90| 6f 77 6e 20 74 6f 20 73 | 69 6e 67 6c 65 20 64 69 |own to s|ingle di|
|00004aa0| 67 69 74 73 2c 20 77 68 | 69 63 68 20 62 65 63 6f |gits, wh|ich beco|
|00004ab0| 6d 65 73 0a 58 09 73 6c | 6f 77 20 73 69 6e 63 65 |mes.X.sl|ow since|
|00004ac0| 20 74 68 65 20 72 65 63 | 75 72 73 69 6f 6e 20 6f | the rec|ursion o|
|00004ad0| 76 65 72 68 65 61 64 20 | 69 73 20 68 69 67 68 2e |verhead |is high.|
|00004ae0| 20 20 49 66 20 61 20 6e | 75 6d 62 65 72 20 73 75 | If a n|umber su|
|00004af0| 63 68 20 61 73 0a 58 09 | 31 30 30 30 30 30 30 20 |ch as.X.|1000000 |
|00004b00| 69 73 20 75 73 65 64 2c | 20 74 68 65 6e 20 74 68 |is used,| then th|
|00004b10| 65 20 72 65 63 75 72 73 | 69 76 65 20 61 6c 67 6f |e recurs|ive algo|
|00004b20| 72 69 74 68 6d 20 69 73 | 20 6e 65 76 65 72 20 75 |rithm is| never u|
|00004b30| 73 65 64 2c 20 63 61 75 | 73 69 6e 67 0a 58 09 63 |sed, cau|sing.X.c|
|00004b40| 61 6c 63 75 6c 61 74 69 | 6f 6e 73 20 66 6f 72 20 |alculati|ons for |
|00004b50| 6c 61 72 67 65 20 6e 75 | 6d 62 65 72 73 20 74 6f |large nu|mbers to|
|00004b60| 20 73 6c 6f 77 20 64 6f | 77 6e 2e 20 20 46 6f 72 | slow do|wn. For|
|00004b70| 20 61 20 74 79 70 69 63 | 61 6c 20 65 78 61 6d 70 | a typic|al examp|
|00004b80| 6c 65 0a 58 09 6f 6e 20 | 61 20 33 38 36 2c 20 74 |le.X.on |a 386, t|
|00004b90| 68 65 20 74 77 6f 20 61 | 6c 67 6f 72 69 74 68 6d |he two a|lgorithm|
|00004ba0| 73 20 61 72 65 20 61 62 | 6f 75 74 20 65 71 75 61 |s are ab|out equa|
|00004bb0| 6c 20 69 6e 20 73 70 65 | 65 64 20 66 6f 72 20 61 |l in spe|ed for a|
|00004bc0| 20 76 61 6c 75 65 0a 58 | 09 6f 66 20 32 30 2c 20 | value.X|.of 20, |
|00004bd0| 77 68 69 63 68 20 69 73 | 20 61 62 6f 75 74 20 31 |which is| about 1|
|00004be0| 30 30 20 64 65 63 69 6d | 61 6c 20 64 69 67 69 74 |00 decim|al digit|
|00004bf0| 73 2e 20 20 41 20 76 61 | 6c 75 65 20 6f 66 20 7a |s. A va|lue of z|
|00004c00| 65 72 6f 20 72 65 73 65 | 74 73 0a 58 09 74 68 65 |ero rese|ts.X.the|
|00004c10| 20 70 61 72 61 6d 65 74 | 65 72 20 62 61 63 6b 20 | paramet|er back |
|00004c20| 74 6f 20 69 74 73 20 64 | 65 66 61 75 6c 74 20 76 |to its d|efault v|
|00004c30| 61 6c 75 65 2e 20 20 55 | 73 75 61 6c 6c 79 20 74 |alue. U|sually t|
|00004c40| 68 65 72 65 20 69 73 20 | 6e 6f 20 6e 65 65 64 0a |here is |no need.|
|00004c50| 58 09 74 6f 20 63 68 61 | 6e 67 65 20 74 68 65 73 |X.to cha|nge thes|
|00004c60| 65 20 70 61 72 61 6d 65 | 74 65 72 73 2e 0a 58 0a |e parame|ters..X.|
|00004c70| 58 09 50 6f 77 32 20 73 | 70 65 63 69 66 69 65 73 |X.Pow2 s|pecifies|
|00004c80| 20 74 68 65 20 73 69 7a | 65 73 20 6f 66 20 6e 75 | the siz|es of nu|
|00004c90| 6d 62 65 72 73 20 61 74 | 20 77 68 69 63 68 20 63 |mbers at| which c|
|00004ca0| 61 6c 63 20 73 77 69 74 | 63 68 65 73 20 66 72 6f |alc swit|ches fro|
|00004cb0| 6d 0a 58 09 69 74 73 20 | 66 69 72 73 74 20 74 6f |m.X.its |first to|
|00004cc0| 20 69 74 73 20 73 65 63 | 6f 6e 64 20 61 6c 67 6f | its sec|ond algo|
|00004cd0| 72 69 74 68 6d 20 66 6f | 72 20 63 61 6c 63 75 6c |rithm fo|r calcul|
|00004ce0| 61 74 69 6e 67 20 70 6f | 77 65 72 73 20 6d 6f 64 |ating po|wers mod|
|00004cf0| 75 6c 6f 0a 58 09 61 6e | 6f 74 68 65 72 20 6e 75 |ulo.X.an|other nu|
|00004d00| 6d 62 65 72 2e 20 20 54 | 68 65 20 66 69 72 73 74 |mber. T|he first|
|00004d10| 20 61 6c 67 6f 72 69 74 | 68 6d 20 66 6f 72 20 63 | algorit|hm for c|
|00004d20| 61 6c 63 75 6c 61 74 69 | 6e 67 20 6d 6f 64 75 6c |alculati|ng modul|
|00004d30| 61 72 20 70 6f 77 65 72 | 73 0a 58 09 69 73 20 62 |ar power|s.X.is b|
|00004d40| 79 20 72 65 70 65 61 74 | 65 64 20 73 71 75 61 72 |y repeat|ed squar|
|00004d50| 69 6e 67 20 61 6e 64 20 | 6d 75 6c 74 69 70 6c 79 |ing and |multiply|
|00004d60| 69 6e 67 20 61 6e 64 20 | 64 69 76 69 64 69 6e 67 |ing and |dividing|
|00004d70| 20 62 79 20 74 68 65 20 | 6d 6f 64 75 6c 75 73 2e | by the |modulus.|
|00004d80| 0a 58 09 54 68 65 20 73 | 65 63 6f 6e 64 20 6d 65 |.X.The s|econd me|
|00004d90| 74 68 6f 64 20 75 73 65 | 73 20 74 68 65 20 52 45 |thod use|s the RE|
|00004da0| 44 43 20 61 6c 67 6f 72 | 69 74 68 6d 20 67 69 76 |DC algor|ithm giv|
|00004db0| 65 6e 20 62 79 20 50 65 | 74 65 72 20 4d 6f 6e 74 |en by Pe|ter Mont|
|00004dc0| 67 6f 6d 65 72 79 0a 58 | 09 77 68 69 63 68 20 61 |gomery.X|.which a|
|00004dd0| 76 6f 69 64 73 20 64 69 | 76 69 73 69 6f 6e 73 2e |voids di|visions.|
|00004de0| 20 20 54 68 65 20 61 72 | 67 75 6d 65 6e 74 20 66 | The ar|gument f|
|00004df0| 6f 72 20 70 6f 77 32 20 | 69 73 20 74 68 65 20 73 |or pow2 |is the s|
|00004e00| 69 7a 65 20 6f 66 20 74 | 68 65 0a 58 09 6d 6f 64 |ize of t|he.X.mod|
|00004e10| 75 6c 75 73 20 61 74 20 | 77 68 69 63 68 20 74 68 |ulus at |which th|
|00004e20| 65 20 73 65 63 6f 6e 64 | 20 61 6c 67 6f 72 69 74 |e second| algorit|
|00004e30| 68 6d 20 62 65 67 69 6e | 73 20 74 6f 20 62 65 20 |hm begin|s to be |
|00004e40| 75 73 65 64 2e 0a 58 0a | 58 09 52 65 64 63 32 20 |used..X.|X.Redc2 |
|00004e50| 73 70 65 63 69 66 69 65 | 73 20 74 68 65 20 73 69 |specifie|s the si|
|00004e60| 7a 65 73 20 6f 66 20 6e | 75 6d 62 65 72 73 20 61 |zes of n|umbers a|
|00004e70| 74 20 77 68 69 63 68 20 | 63 61 6c 63 20 73 77 69 |t which |calc swi|
|00004e80| 74 63 68 65 73 20 66 72 | 6f 6d 0a 58 09 69 74 73 |tches fr|om.X.its|
|00004e90| 20 66 69 72 73 74 20 74 | 6f 20 69 74 73 20 73 65 | first t|o its se|
|00004ea0| 63 6f 6e 64 20 61 6c 67 | 6f 72 69 74 68 6d 20 77 |cond alg|orithm w|
|00004eb0| 68 65 6e 20 75 73 69 6e | 67 20 74 68 65 20 52 45 |hen usin|g the RE|
|00004ec0| 44 43 20 61 6c 67 6f 72 | 69 74 68 6d 2e 0a 58 09 |DC algor|ithm..X.|
|00004ed0| 54 68 65 20 66 69 72 73 | 74 20 61 6c 67 6f 72 69 |The firs|t algori|
|00004ee0| 74 68 6d 20 70 65 72 66 | 6f 72 6d 73 20 61 20 6d |thm perf|orms a m|
|00004ef0| 75 6c 74 69 70 6c 79 20 | 61 6e 64 20 61 20 6d 6f |ultiply |and a mo|
|00004f00| 64 75 6c 61 72 20 72 65 | 64 75 63 74 69 6f 6e 0a |dular re|duction.|
|00004f10| 58 09 74 6f 67 65 74 68 | 65 72 20 69 6e 20 6f 6e |X.togeth|er in on|
|00004f20| 65 20 6c 6f 6f 70 20 77 | 68 69 63 68 20 72 75 6e |e loop w|hich run|
|00004f30| 73 20 69 6e 20 4f 28 4e | 5e 32 29 2e 20 20 54 68 |s in O(N|^2). Th|
|00004f40| 65 20 73 65 63 6f 6e 64 | 20 61 6c 67 6f 72 69 74 |e second| algorit|
|00004f50| 68 6d 0a 58 09 64 6f 65 | 73 20 74 68 65 20 52 45 |hm.X.doe|s the RE|
|00004f60| 44 43 20 63 61 6c 63 75 | 6c 61 74 69 6f 6e 20 75 |DC calcu|lation u|
|00004f70| 73 69 6e 67 20 74 68 72 | 65 65 20 6d 75 6c 74 69 |sing thr|ee multi|
|00004f80| 70 6c 69 65 73 2c 20 61 | 6e 64 20 72 75 6e 73 20 |plies, a|nd runs |
|00004f90| 69 6e 0a 58 09 4f 28 4e | 5e 31 2e 35 38 35 29 2e |in.X.O(N|^1.585).|
|00004fa0| 20 20 54 68 65 20 61 72 | 67 75 6d 65 6e 74 20 66 | The ar|gument f|
|00004fb0| 6f 72 20 72 65 64 63 32 | 20 69 73 20 74 68 65 20 |or redc2| is the |
|00004fc0| 73 69 7a 65 20 6f 66 20 | 74 68 65 20 6d 6f 64 75 |size of |the modu|
|00004fd0| 6c 75 73 20 61 74 0a 58 | 09 77 68 69 63 68 20 74 |lus at.X|.which t|
|00004fe0| 68 65 20 73 65 63 6f 6e | 64 20 61 6c 67 6f 72 69 |he secon|d algori|
|00004ff0| 74 68 6d 20 62 65 67 69 | 6e 73 20 74 6f 20 62 65 |thm begi|ns to be|
|00005000| 20 75 73 65 64 2e 0a 58 | 0a 58 09 45 78 61 6d 70 | used..X|.X.Examp|
|00005010| 6c 65 73 20 6f 66 20 73 | 65 74 74 69 6e 67 20 73 |les of s|etting s|
|00005020| 6f 6d 65 20 70 61 72 61 | 6d 65 74 65 72 73 20 61 |ome para|meters a|
|00005030| 72 65 3a 0a 58 0a 58 09 | 09 63 6f 6e 66 69 67 28 |re:.X.X.|.config(|
|00005040| 22 6d 6f 64 65 22 2c 20 | 22 65 78 70 22 29 3b 09 |"mode", |"exp");.|
|00005050| 09 65 78 70 6f 6e 65 6e | 74 69 61 6c 20 6f 75 74 |.exponen|tial out|
|00005060| 70 75 74 0a 58 09 09 63 | 6f 6e 66 69 67 28 22 64 |put.X..c|onfig("d|
|00005070| 69 73 70 6c 61 79 22 2c | 20 35 30 29 3b 09 09 35 |isplay",| 50);..5|
|00005080| 30 20 64 69 67 69 74 73 | 20 6f 66 20 6f 75 74 70 |0 digits| of outp|
|00005090| 75 74 0a 58 09 09 65 70 | 73 69 6c 6f 6e 28 65 70 |ut.X..ep|silon(ep|
|000050a0| 73 69 6c 6f 6e 28 29 20 | 2f 20 38 29 3b 09 09 33 |silon() |/ 8);..3|
|000050b0| 20 62 69 74 73 20 6d 6f | 72 65 20 61 63 63 75 72 | bits mo|re accur|
|000050c0| 61 63 79 0a 45 4e 44 5f | 4f 46 5f 46 49 4c 45 0a |acy.END_|OF_FILE.|
|000050d0| 69 66 20 74 65 73 74 20 | 34 34 32 36 20 2d 6e 65 |if test |4426 -ne|
|000050e0| 20 60 77 63 20 2d 63 20 | 3c 27 68 65 6c 70 2f 63 | `wc -c |<'help/c|
|000050f0| 6f 6e 66 69 67 27 60 3b | 20 74 68 65 6e 0a 20 20 |onfig'`;| then. |
|00005100| 20 20 65 63 68 6f 20 73 | 68 61 72 3a 20 5c 22 27 | echo s|har: \"'|
|00005110| 68 65 6c 70 2f 63 6f 6e | 66 69 67 27 5c 22 20 75 |help/con|fig'\" u|
|00005120| 6e 70 61 63 6b 65 64 20 | 77 69 74 68 20 77 72 6f |npacked |with wro|
|00005130| 6e 67 20 73 69 7a 65 21 | 0a 66 69 0a 23 20 65 6e |ng size!|.fi.# en|
|00005140| 64 20 6f 66 20 27 68 65 | 6c 70 2f 63 6f 6e 66 69 |d of 'he|lp/confi|
|00005150| 67 27 0a 66 69 0a 69 66 | 20 74 65 73 74 20 2d 66 |g'.fi.if| test -f|
|00005160| 20 27 68 65 6c 70 2f 64 | 65 66 69 6e 65 27 20 2d | 'help/d|efine' -|
|00005170| 61 20 22 24 7b 31 7d 22 | 20 21 3d 20 22 2d 63 22 |a "${1}"| != "-c"|
|00005180| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|00005190| 73 68 61 72 3a 20 57 69 | 6c 6c 20 6e 6f 74 20 63 |shar: Wi|ll not c|
|000051a0| 6c 6f 62 62 65 72 20 65 | 78 69 73 74 69 6e 67 20 |lobber e|xisting |
|000051b0| 66 69 6c 65 20 5c 22 27 | 68 65 6c 70 2f 64 65 66 |file \"'|help/def|
|000051c0| 69 6e 65 27 5c 22 0a 65 | 6c 73 65 0a 65 63 68 6f |ine'\".e|lse.echo|
|000051d0| 20 73 68 61 72 3a 20 45 | 78 74 72 61 63 74 69 6e | shar: E|xtractin|
|000051e0| 67 20 5c 22 27 68 65 6c | 70 2f 64 65 66 69 6e 65 |g \"'hel|p/define|
|000051f0| 27 5c 22 20 5c 28 32 36 | 37 39 20 63 68 61 72 61 |'\" \(26|79 chara|
|00005200| 63 74 65 72 73 5c 29 0a | 73 65 64 20 22 73 2f 5e |cters\).|sed "s/^|
|00005210| 58 2f 2f 22 20 3e 27 68 | 65 6c 70 2f 64 65 66 69 |X//" >'h|elp/defi|
|00005220| 6e 65 27 20 3c 3c 27 45 | 4e 44 5f 4f 46 5f 46 49 |ne' <<'E|ND_OF_FI|
|00005230| 4c 45 27 0a 58 46 75 6e | 63 74 69 6f 6e 20 64 65 |LE'.XFun|ction de|
|00005240| 66 69 6e 69 74 69 6f 6e | 73 0a 58 0a 58 09 46 75 |finition|s.X.X.Fu|
|00005250| 6e 63 74 69 6f 6e 20 64 | 65 66 69 6e 69 74 69 6f |nction d|efinitio|
|00005260| 6e 73 20 61 72 65 20 69 | 6e 74 72 6f 64 75 63 65 |ns are i|ntroduce|
|00005270| 64 20 62 79 20 74 68 65 | 20 27 64 65 66 69 6e 65 |d by the| 'define|
|00005280| 27 20 6b 65 79 77 6f 72 | 64 2e 0a 58 09 4f 74 68 |' keywor|d..X.Oth|
|00005290| 65 72 20 74 68 61 6e 20 | 74 68 69 73 2c 20 74 68 |er than |this, th|
|000052a0| 65 20 62 61 73 69 63 20 | 73 74 72 75 63 74 75 72 |e basic |structur|
|000052b0| 65 20 6f 66 20 61 20 66 | 75 6e 63 74 69 6f 6e 20 |e of a f|unction |
|000052c0| 69 73 20 6c 69 6b 65 20 | 69 6e 20 43 2e 0a 58 09 |is like |in C..X.|
|000052d0| 54 68 61 74 20 69 73 2c | 20 70 61 72 61 6d 65 74 |That is,| paramet|
|000052e0| 65 72 73 20 61 72 65 20 | 73 70 65 63 69 66 69 65 |ers are |specifie|
|000052f0| 64 20 66 6f 72 20 74 68 | 65 20 66 75 6e 63 74 69 |d for th|e functi|
|00005300| 6f 6e 20 77 69 74 68 69 | 6e 20 70 61 72 65 6e 74 |on withi|n parent|
|00005310| 68 65 73 69 73 2c 0a 58 | 09 74 68 65 20 66 75 6e |hesis,.X|.the fun|
|00005320| 63 74 69 6f 6e 20 62 6f | 64 79 20 69 73 20 69 6e |ction bo|dy is in|
|00005330| 74 72 6f 64 75 63 65 64 | 20 62 79 20 61 20 6c 65 |troduced| by a le|
|00005340| 66 74 20 62 72 61 63 65 | 2c 20 76 61 72 69 61 62 |ft brace|, variab|
|00005350| 6c 65 73 20 61 72 65 0a | 58 09 64 65 63 6c 61 72 |les are.|X.declar|
|00005360| 65 64 20 66 6f 72 20 74 | 68 65 20 66 75 6e 63 74 |ed for t|he funct|
|00005370| 69 6f 6e 2c 20 73 74 61 | 74 65 6d 65 6e 74 73 20 |ion, sta|tements |
|00005380| 69 6d 70 6c 65 6d 65 6e | 74 69 6e 67 20 74 68 65 |implemen|ting the|
|00005390| 20 66 75 6e 63 74 69 6f | 6e 0a 58 09 66 6f 6c 6c | functio|n.X.foll|
|000053a0| 6f 77 2c 20 61 6e 64 20 | 74 68 65 20 66 75 6e 63 |ow, and |the func|
|000053b0| 74 69 6f 6e 20 69 73 20 | 65 6e 64 65 64 20 77 69 |tion is |ended wi|
|000053c0| 74 68 20 61 20 72 69 67 | 68 74 20 62 72 61 63 65 |th a rig|ht brace|
|000053d0| 2e 0a 58 0a 58 09 54 68 | 65 72 65 20 61 72 65 20 |..X.X.Th|ere are |
|000053e0| 73 6f 6d 65 20 73 75 62 | 74 6c 65 20 64 69 66 66 |some sub|tle diff|
|000053f0| 65 72 65 6e 63 65 73 2c | 20 68 6f 77 65 76 65 72 |erences,| however|
|00005400| 2e 20 20 54 68 65 20 74 | 79 70 65 73 20 6f 66 20 |. The t|ypes of |
|00005410| 70 61 72 61 6d 65 74 65 | 72 73 0a 58 09 61 6e 64 |paramete|rs.X.and|
|00005420| 20 76 61 72 69 61 62 6c | 65 73 20 61 72 65 20 6e | variabl|es are n|
|00005430| 6f 74 20 64 65 66 69 6e | 65 64 20 61 74 20 63 6f |ot defin|ed at co|
|00005440| 6d 70 69 6c 65 20 74 69 | 6d 65 2c 20 62 75 74 20 |mpile ti|me, but |
|00005450| 69 6e 73 74 65 61 64 20 | 61 72 65 20 74 79 70 65 |instead |are type|
|00005460| 64 0a 58 09 61 74 20 72 | 75 6e 74 69 6d 65 2e 20 |d.X.at r|untime. |
|00005470| 20 54 68 75 73 20 74 68 | 65 72 65 20 69 73 20 6e | Thus th|ere is n|
|00005480| 6f 20 64 65 66 69 6e 69 | 74 69 6f 6e 73 20 6e 65 |o defini|tions ne|
|00005490| 65 64 65 64 20 74 6f 20 | 64 69 73 74 69 6e 67 75 |eded to |distingu|
|000054a0| 69 73 68 0a 58 09 62 65 | 74 77 65 65 6e 20 69 6e |ish.X.be|tween in|
|000054b0| 74 65 67 65 72 73 2c 20 | 66 72 61 63 74 69 6f 6e |tegers, |fraction|
|000054c0| 73 2c 20 63 6f 6d 70 6c | 65 78 20 6e 75 6d 62 65 |s, compl|ex numbe|
|000054d0| 72 73 2c 20 6d 61 74 72 | 69 63 65 73 2c 20 61 6e |rs, matr|ices, an|
|000054e0| 64 20 73 6f 20 6f 6e 2e | 0a 58 09 54 68 75 73 20 |d so on.|.X.Thus |
|000054f0| 77 68 65 6e 20 64 65 63 | 6c 61 72 69 6e 67 20 70 |when dec|laring p|
|00005500| 61 72 61 6d 65 74 65 72 | 73 20 66 6f 72 20 61 20 |arameter|s for a |
|00005510| 66 75 6e 63 74 69 6f 6e | 2c 20 6f 6e 6c 79 20 74 |function|, only t|
|00005520| 68 65 20 6e 61 6d 65 20 | 6f 66 0a 58 09 74 68 65 |he name |of.X.the|
|00005530| 20 70 61 72 61 6d 65 74 | 65 72 20 69 73 20 6e 65 | paramet|er is ne|
|00005540| 65 64 65 64 2e 20 20 54 | 68 75 73 20 74 68 65 72 |eded. T|hus ther|
|00005550| 65 20 61 72 65 20 6e 65 | 76 65 72 20 61 6e 79 20 |e are ne|ver any |
|00005560| 64 65 63 6c 61 72 61 74 | 69 6f 6e 73 0a 58 09 62 |declarat|ions.X.b|
|00005570| 65 74 77 65 65 6e 20 74 | 68 65 20 66 75 6e 63 74 |etween t|he funct|
|00005580| 69 6f 6e 20 70 61 72 61 | 6d 65 74 65 72 20 6c 69 |ion para|meter li|
|00005590| 73 74 20 61 6e 64 20 74 | 68 65 20 62 6f 64 79 20 |st and t|he body |
|000055a0| 6f 66 20 74 68 65 20 66 | 75 6e 63 74 69 6f 6e 2e |of the f|unction.|
|000055b0| 0a 58 0a 58 09 46 6f 72 | 20 65 78 61 6d 70 6c 65 |.X.X.For| example|
|000055c0| 2c 20 74 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 |, the fo|llowing |
|000055d0| 66 75 6e 63 74 69 6f 6e | 20 63 6f 6d 70 75 74 65 |function| compute|
|000055e0| 73 20 61 20 66 61 63 74 | 6f 72 69 61 6c 3a 0a 58 |s a fact|orial:.X|
|000055f0| 0a 58 09 09 64 65 66 69 | 6e 65 20 66 61 63 74 6f |.X..defi|ne facto|
|00005600| 72 69 61 6c 28 6e 29 0a | 58 09 09 7b 0a 58 09 09 |rial(n).|X..{.X..|
|00005610| 09 6c 6f 63 61 6c 09 61 | 6e 73 3b 0a 58 0a 58 09 |.local.a|ns;.X.X.|
|00005620| 09 09 61 6e 73 20 3d 20 | 31 3b 0a 58 09 09 09 77 |..ans = |1;.X...w|
|00005630| 68 69 6c 65 20 28 6e 20 | 3e 20 31 29 0a 58 09 09 |hile (n |> 1).X..|
|00005640| 09 09 61 6e 73 20 2a 3d | 20 6e 2d 2d 3b 0a 58 09 |..ans *=| n--;.X.|
|00005650| 09 09 72 65 74 75 72 6e | 20 61 6e 73 3b 0a 58 09 |..return| ans;.X.|
|00005660| 09 7d 0a 58 0a 58 09 49 | 66 20 61 20 66 75 6e 63 |.}.X.X.I|f a func|
|00005670| 74 69 6f 6e 20 69 73 20 | 76 65 72 79 20 73 69 6d |tion is |very sim|
|00005680| 70 6c 65 20 61 6e 64 20 | 6a 75 73 74 20 72 65 74 |ple and |just ret|
|00005690| 75 72 6e 73 20 61 20 76 | 61 6c 75 65 2c 20 74 68 |urns a v|alue, th|
|000056a0| 65 6e 20 74 68 65 0a 58 | 09 66 75 6e 63 74 69 6f |en the.X|.functio|
|000056b0| 6e 20 63 61 6e 20 62 65 | 20 64 65 66 69 6e 65 64 |n can be| defined|
|000056c0| 20 69 6e 20 73 68 6f 72 | 74 65 6e 65 64 20 6d 61 | in shor|tened ma|
|000056d0| 6e 6e 65 72 20 62 79 20 | 75 73 69 6e 67 20 61 6e |nner by |using an|
|000056e0| 20 65 71 75 61 6c 73 20 | 73 69 67 6e 0a 58 09 69 | equals |sign.X.i|
|000056f0| 6e 20 70 6c 61 63 65 20 | 6f 66 20 74 68 65 20 6c |n place |of the l|
|00005700| 65 66 74 20 62 72 61 63 | 65 2e 20 20 49 6e 20 74 |eft brac|e. In t|
|00005710| 68 69 73 20 63 61 73 65 | 2c 20 74 68 65 20 66 75 |his case|, the fu|
|00005720| 6e 63 74 69 6f 6e 20 64 | 65 63 6c 61 72 61 74 69 |nction d|eclarati|
|00005730| 6f 6e 0a 58 09 69 73 20 | 74 65 72 6d 69 6e 61 74 |on.X.is |terminat|
|00005740| 65 64 20 62 79 20 61 20 | 6e 65 77 6c 69 6e 65 20 |ed by a |newline |
|00005750| 63 68 61 72 61 63 74 65 | 72 2c 20 61 6e 64 20 69 |characte|r, and i|
|00005760| 74 73 20 76 61 6c 75 65 | 20 69 73 20 74 68 65 20 |ts value| is the |
|00005770| 73 70 65 63 69 66 69 65 | 64 0a 58 09 65 78 70 72 |specifie|d.X.expr|
|00005780| 65 73 73 69 6f 6e 2e 20 | 20 53 74 61 74 65 6d 65 |ession. | Stateme|
|00005790| 6e 74 73 20 73 75 63 68 | 20 61 73 20 27 69 66 27 |nts such| as 'if'|
|000057a0| 20 61 72 65 20 6e 6f 74 | 20 61 6c 6c 6f 77 65 64 | are not| allowed|
|000057b0| 2e 20 20 41 6e 20 6f 70 | 74 69 6f 6e 61 6c 0a 58 |. An op|tional.X|
|000057c0| 09 73 65 6d 69 63 6f 6c | 6f 6e 20 65 6e 64 69 6e |.semicol|on endin|
|000057d0| 67 20 74 68 65 20 65 78 | 70 72 65 73 73 69 6f 6e |g the ex|pression|
|000057e0| 20 69 73 20 61 6c 6c 6f | 77 65 64 2e 20 20 41 73 | is allo|wed. As|
|000057f0| 20 61 6e 20 65 78 61 6d | 70 6c 65 2c 20 74 68 65 | an exam|ple, the|
|00005800| 0a 58 09 61 76 65 72 61 | 67 65 20 6f 66 20 74 77 |.X.avera|ge of tw|
|00005810| 6f 20 6e 75 6d 62 65 72 | 73 20 63 6f 75 6c 64 20 |o number|s could |
|00005820| 62 65 20 64 65 66 69 6e | 65 64 20 61 73 3a 0a 58 |be defin|ed as:.X|
|00005830| 0a 58 09 09 64 65 66 69 | 6e 65 20 61 76 65 72 61 |.X..defi|ne avera|
|00005840| 67 65 28 61 2c 20 62 29 | 20 3d 20 28 61 20 2b 20 |ge(a, b)| = (a + |
|00005850| 62 29 20 2f 20 32 3b 0a | 58 0a 58 09 46 75 6e 63 |b) / 2;.|X.X.Func|
|00005860| 74 69 6f 6e 73 20 63 61 | 6e 20 62 65 20 64 65 66 |tions ca|n be def|
|00005870| 69 6e 65 64 20 77 68 69 | 63 68 20 63 61 6e 20 62 |ined whi|ch can b|
|00005880| 65 20 76 65 72 79 20 63 | 6f 6d 70 6c 65 78 2e 20 |e very c|omplex. |
|00005890| 20 54 68 65 73 65 20 63 | 61 6e 20 62 65 0a 58 09 | These c|an be.X.|
|000058a0| 64 65 66 69 6e 65 64 20 | 6f 6e 20 74 68 65 20 63 |defined |on the c|
|000058b0| 6f 6d 6d 61 6e 64 20 6c | 69 6e 65 20 69 66 20 64 |ommand l|ine if d|
|000058c0| 65 73 69 72 65 64 2c 20 | 62 75 74 20 65 64 69 74 |esired, |but edit|
|000058d0| 69 6e 67 20 6f 66 20 70 | 61 72 74 69 61 6c 0a 58 |ing of p|artial.X|
|000058e0| 09 66 75 6e 63 74 69 6f | 6e 73 20 69 73 20 6e 6f |.functio|ns is no|
|000058f0| 74 20 70 6f 73 73 69 62 | 6c 65 20 70 61 73 74 20 |t possib|le past |
|00005900| 61 20 73 69 6e 67 6c 65 | 20 6c 69 6e 65 2e 20 20 |a single| line. |
|00005910| 49 66 20 61 6e 20 65 72 | 72 6f 72 20 69 73 20 6d |If an er|ror is m|
|00005920| 61 64 65 0a 58 09 6f 6e | 20 61 20 70 72 65 76 69 |ade.X.on| a previ|
|00005930| 6f 75 73 20 6c 69 6e 65 | 2c 20 74 68 65 6e 20 74 |ous line|, then t|
|00005940| 68 65 20 66 75 6e 63 74 | 69 6f 6e 20 6d 75 73 74 |he funct|ion must|
|00005950| 20 62 65 20 66 69 6e 69 | 73 68 65 64 20 28 77 69 | be fini|shed (wi|
|00005960| 74 68 20 70 72 6f 62 61 | 62 6c 65 0a 58 09 65 72 |th proba|ble.X.er|
|00005970| 72 6f 72 73 29 20 61 6e | 64 20 72 65 65 6e 74 65 |rors) an|d reente|
|00005980| 72 65 64 20 66 72 6f 6d | 20 74 68 65 20 62 65 67 |red from| the beg|
|00005990| 69 6e 6e 69 6e 67 2e 20 | 20 54 68 75 73 20 66 6f |inning. | Thus fo|
|000059a0| 72 20 63 6f 6d 70 6c 69 | 63 61 74 65 64 0a 58 09 |r compli|cated.X.|
|000059b0| 66 75 6e 63 74 69 6f 6e | 73 2c 20 69 74 20 69 73 |function|s, it is|
|000059c0| 20 62 65 73 74 20 74 6f | 20 75 73 65 20 61 6e 20 | best to| use an |
|000059d0| 65 64 69 74 6f 72 20 74 | 6f 20 63 72 65 61 74 65 |editor t|o create|
|000059e0| 20 74 68 65 20 66 75 6e | 63 74 69 6f 6e 20 69 6e | the fun|ction in|
|000059f0| 20 61 0a 58 09 66 69 6c | 65 2c 20 61 6e 64 20 74 | a.X.fil|e, and t|
|00005a00| 68 65 6e 20 65 6e 74 65 | 72 20 74 68 65 20 63 61 |hen ente|r the ca|
|00005a10| 6c 63 75 6c 61 74 6f 72 | 20 61 6e 64 20 72 65 61 |lculator| and rea|
|00005a20| 64 20 69 6e 20 74 68 65 | 20 66 69 6c 65 20 63 6f |d in the| file co|
|00005a30| 6e 74 61 69 6e 69 6e 67 | 0a 58 09 74 68 65 20 64 |ntaining|.X.the d|
|00005a40| 65 66 69 6e 69 74 69 6f | 6e 2e 0a 58 0a 58 09 54 |efinitio|n..X.X.T|
|00005a50| 68 65 20 70 61 72 61 6d | 65 74 65 72 73 20 6f 66 |he param|eters of|
|00005a60| 20 61 20 66 75 6e 63 74 | 69 6f 6e 20 63 61 6e 20 | a funct|ion can |
|00005a70| 62 65 20 72 65 66 65 72 | 65 6e 63 65 64 20 62 79 |be refer|enced by|
|00005a80| 20 6e 61 6d 65 2c 20 61 | 73 20 69 6e 0a 58 09 6e | name, a|s in.X.n|
|00005a90| 6f 72 6d 61 6c 20 43 20 | 75 73 61 67 65 2c 20 6f |ormal C |usage, o|
|00005aa0| 72 20 62 79 20 75 73 69 | 6e 67 20 74 68 65 20 27 |r by usi|ng the '|
|00005ab0| 70 61 72 61 6d 27 20 66 | 75 6e 63 74 69 6f 6e 2e |param' f|unction.|
|00005ac0| 20 20 54 68 69 73 20 66 | 75 6e 63 74 69 6f 6e 0a | This f|unction.|
|00005ad0| 58 09 72 65 74 75 72 6e | 73 20 74 68 65 20 73 70 |X.return|s the sp|
|00005ae0| 65 63 69 66 69 65 64 20 | 70 61 72 61 6d 65 74 65 |ecified |paramete|
|00005af0| 72 20 6f 66 20 74 68 65 | 20 66 75 6e 63 74 69 6f |r of the| functio|
|00005b00| 6e 20 69 74 20 69 73 20 | 69 6e 2c 20 77 68 65 72 |n it is |in, wher|
|00005b10| 65 0a 58 09 74 68 65 20 | 70 61 72 61 6d 65 74 65 |e.X.the |paramete|
|00005b20| 72 73 20 61 72 65 20 6e | 75 6d 62 65 72 65 64 20 |rs are n|umbered |
|00005b30| 73 74 61 72 74 69 6e 67 | 20 66 72 6f 6d 20 31 2e |starting| from 1.|
|00005b40| 20 20 54 68 65 20 74 6f | 74 61 6c 20 6e 75 6d 62 | The to|tal numb|
|00005b50| 65 72 0a 58 09 6f 66 20 | 70 61 72 61 6d 65 74 65 |er.X.of |paramete|
|00005b60| 72 73 20 74 6f 20 74 68 | 65 20 66 75 6e 63 74 69 |rs to th|e functi|
|00005b70| 6f 6e 20 69 73 20 72 65 | 74 75 72 6e 65 64 20 62 |on is re|turned b|
|00005b80| 79 20 75 73 69 6e 67 20 | 27 70 61 72 61 6d 28 30 |y using |'param(0|
|00005b90| 29 27 2e 0a 58 09 55 73 | 69 6e 67 20 74 68 69 73 |)'..X.Us|ing this|
|00005ba0| 20 66 75 6e 63 74 69 6f | 6e 20 61 6c 6c 6f 77 73 | functio|n allows|
|00005bb0| 20 79 6f 75 20 74 6f 20 | 69 6d 70 6c 65 6d 65 6e | you to |implemen|
|00005bc0| 74 20 76 61 72 61 72 67 | 73 2d 6c 69 6b 65 20 72 |t vararg|s-like r|
|00005bd0| 6f 75 74 69 6e 65 73 0a | 58 09 77 68 69 63 68 20 |outines.|X.which |
|00005be0| 63 61 6e 20 68 61 6e 64 | 6c 65 20 61 6e 79 20 6e |can hand|le any n|
|00005bf0| 75 6d 62 65 72 20 6f 66 | 20 63 61 6c 6c 69 6e 67 |umber of| calling|
|00005c00| 20 70 61 72 61 6d 65 74 | 65 72 73 2e 20 20 46 6f | paramet|ers. Fo|
|00005c10| 72 20 65 78 61 6d 70 6c | 65 3a 0a 58 0a 58 09 09 |r exampl|e:.X.X..|
|00005c20| 64 65 66 69 6e 65 20 73 | 63 28 29 0a 58 09 09 7b |define s|c().X..{|
|00005c30| 0a 58 09 09 09 6c 6f 63 | 61 6c 20 73 2c 20 69 3b |.X...loc|al s, i;|
|00005c40| 0a 58 0a 58 09 09 09 73 | 20 3d 20 30 3b 0a 58 09 |.X.X...s| = 0;.X.|
|00005c50| 09 09 66 6f 72 20 28 69 | 20 3d 20 31 3b 20 69 20 |..for (i| = 1; i |
|00005c60| 3c 3d 20 70 61 72 61 6d | 28 30 29 3b 20 69 2b 2b |<= param|(0); i++|
|00005c70| 29 0a 58 09 09 09 09 73 | 20 2b 3d 20 70 61 72 61 |).X....s| += para|
|00005c80| 6d 28 69 29 5e 33 3b 0a | 58 09 09 09 72 65 74 75 |m(i)^3;.|X...retu|
|00005c90| 72 6e 20 73 3b 0a 58 09 | 09 7d 0a 58 0a 58 09 64 |rn s;.X.|.}.X.X.d|
|00005ca0| 65 66 69 6e 65 73 20 61 | 20 66 75 6e 63 74 69 6f |efines a| functio|
|00005cb0| 6e 20 77 68 69 63 68 20 | 72 65 74 75 72 6e 73 20 |n which |returns |
|00005cc0| 74 68 65 20 73 75 6d 20 | 6f 66 20 74 68 65 20 63 |the sum |of the c|
|00005cd0| 75 62 65 73 20 6f 66 20 | 61 6c 6c 20 69 74 27 73 |ubes of |all it's|
|00005ce0| 0a 58 09 70 61 72 61 6d | 65 74 65 72 73 2e 0a 45 |.X.param|eters..E|
|00005cf0| 4e 44 5f 4f 46 5f 46 49 | 4c 45 0a 69 66 20 74 65 |ND_OF_FI|LE.if te|
|00005d00| 73 74 20 32 36 37 39 20 | 2d 6e 65 20 60 77 63 20 |st 2679 |-ne `wc |
|00005d10| 2d 63 20 3c 27 68 65 6c | 70 2f 64 65 66 69 6e 65 |-c <'hel|p/define|
|00005d20| 27 60 3b 20 74 68 65 6e | 0a 20 20 20 20 65 63 68 |'`; then|. ech|
|00005d30| 6f 20 73 68 61 72 3a 20 | 5c 22 27 68 65 6c 70 2f |o shar: |\"'help/|
|00005d40| 64 65 66 69 6e 65 27 5c | 22 20 75 6e 70 61 63 6b |define'\|" unpack|
|00005d50| 65 64 20 77 69 74 68 20 | 77 72 6f 6e 67 20 73 69 |ed with |wrong si|
|00005d60| 7a 65 21 0a 66 69 0a 23 | 20 65 6e 64 20 6f 66 20 |ze!.fi.#| end of |
|00005d70| 27 68 65 6c 70 2f 64 65 | 66 69 6e 65 27 0a 66 69 |'help/de|fine'.fi|
|00005d80| 0a 69 66 20 74 65 73 74 | 20 2d 66 20 27 68 65 6c |.if test| -f 'hel|
|00005d90| 70 2f 6d 61 74 27 20 2d | 61 20 22 24 7b 31 7d 22 |p/mat' -|a "${1}"|
|00005da0| 20 21 3d 20 22 2d 63 22 | 20 3b 20 74 68 65 6e 20 | != "-c"| ; then |
|00005db0| 0a 20 20 65 63 68 6f 20 | 73 68 61 72 3a 20 57 69 |. echo |shar: Wi|
|00005dc0| 6c 6c 20 6e 6f 74 20 63 | 6c 6f 62 62 65 72 20 65 |ll not c|lobber e|
|00005dd0| 78 69 73 74 69 6e 67 20 | 66 69 6c 65 20 5c 22 27 |xisting |file \"'|
|00005de0| 68 65 6c 70 2f 6d 61 74 | 27 5c 22 0a 65 6c 73 65 |help/mat|'\".else|
|00005df0| 0a 65 63 68 6f 20 73 68 | 61 72 3a 20 45 78 74 72 |.echo sh|ar: Extr|
|00005e00| 61 63 74 69 6e 67 20 5c | 22 27 68 65 6c 70 2f 6d |acting \|"'help/m|
|00005e10| 61 74 27 5c 22 20 5c 28 | 34 32 35 39 20 63 68 61 |at'\" \(|4259 cha|
|00005e20| 72 61 63 74 65 72 73 5c | 29 0a 73 65 64 20 22 73 |racters\|).sed "s|
|00005e30| 2f 5e 58 2f 2f 22 20 3e | 27 68 65 6c 70 2f 6d 61 |/^X//" >|'help/ma|
|00005e40| 74 27 20 3c 3c 27 45 4e | 44 5f 4f 46 5f 46 49 4c |t' <<'EN|D_OF_FIL|
|00005e50| 45 27 0a 58 55 73 69 6e | 67 20 6d 61 74 72 69 63 |E'.XUsin|g matric|
|00005e60| 65 73 0a 58 0a 58 09 4d | 61 74 72 69 63 65 73 20 |es.X.X.M|atrices |
|00005e70| 63 61 6e 20 68 61 76 65 | 20 66 72 6f 6d 20 31 20 |can have| from 1 |
|00005e80| 74 6f 20 34 20 64 69 6d | 65 6e 73 69 6f 6e 73 2c |to 4 dim|ensions,|
|00005e90| 20 61 6e 64 20 61 72 65 | 20 69 6e 64 65 78 65 64 | and are| indexed|
|00005ea0| 20 62 79 20 61 0a 58 09 | 6e 6f 72 6d 61 6c 2d 73 | by a.X.|normal-s|
|00005eb0| 69 7a 65 64 20 69 6e 74 | 65 67 65 72 2e 20 20 54 |ized int|eger. T|
|00005ec0| 68 65 20 6c 6f 77 65 72 | 20 61 6e 64 20 75 70 70 |he lower| and upp|
|00005ed0| 65 72 20 62 6f 75 6e 64 | 73 20 6f 66 20 61 20 6d |er bound|s of a m|
|00005ee0| 61 74 72 69 78 20 63 61 | 6e 0a 58 09 62 65 20 73 |atrix ca|n.X.be s|
|00005ef0| 70 65 63 69 66 69 65 64 | 20 61 74 20 72 75 6e 74 |pecified| at runt|
|00005f00| 69 6d 65 2e 20 20 54 68 | 65 20 65 6c 65 6d 65 6e |ime. Th|e elemen|
|00005f10| 74 73 20 6f 66 20 61 20 | 6d 61 74 72 69 78 20 61 |ts of a |matrix a|
|00005f20| 72 65 20 64 65 66 61 75 | 6c 74 65 64 0a 58 09 74 |re defau|lted.X.t|
|00005f30| 6f 20 7a 65 72 6f 65 73 | 2c 20 62 75 74 20 63 61 |o zeroes|, but ca|
|00005f40| 6e 20 62 65 20 61 73 73 | 69 67 6e 65 64 20 74 6f |n be ass|igned to|
|00005f50| 20 62 65 20 6f 66 20 61 | 6e 79 20 74 79 70 65 2e | be of a|ny type.|
|00005f60| 20 20 54 68 75 73 20 6d | 61 74 72 69 63 65 73 0a | Thus m|atrices.|
|00005f70| 58 09 63 61 6e 20 68 6f | 6c 64 20 63 6f 6d 70 6c |X.can ho|ld compl|
|00005f80| 65 78 20 6e 75 6d 62 65 | 72 73 2c 20 73 74 72 69 |ex numbe|rs, stri|
|00005f90| 6e 67 73 2c 20 6f 62 6a | 65 63 74 73 2c 20 65 74 |ngs, obj|ects, et|
|00005fa0| 63 2e 20 20 4d 61 74 72 | 69 63 65 73 20 61 72 65 |c. Matr|ices are|
|00005fb0| 0a 58 09 73 74 6f 72 65 | 64 20 69 6e 20 6d 65 6d |.X.store|d in mem|
|00005fc0| 6f 72 79 20 61 73 20 61 | 6e 20 61 72 72 61 79 20 |ory as a|n array |
|00005fd0| 73 6f 20 74 68 61 74 20 | 72 61 6e 64 6f 6d 20 61 |so that |random a|
|00005fe0| 63 63 65 73 73 20 74 6f | 20 74 68 65 20 65 6c 65 |ccess to| the ele|
|00005ff0| 6d 65 6e 74 73 0a 58 09 | 69 73 20 65 61 73 79 2e |ments.X.|is easy.|
|00006000| 0a 58 0a 58 09 4d 61 74 | 72 69 63 65 73 20 61 72 |.X.X.Mat|rices ar|
|00006010| 65 20 6e 6f 72 6d 61 6c | 6c 79 20 69 6e 64 65 78 |e normal|ly index|
|00006020| 65 64 20 75 73 69 6e 67 | 20 73 71 75 61 72 65 20 |ed using| square |
|00006030| 62 72 61 63 6b 65 74 73 | 2e 20 20 49 66 20 74 68 |brackets|. If th|
|00006040| 65 20 6d 61 74 72 69 78 | 0a 58 09 69 73 20 6d 75 |e matrix|.X.is mu|
|00006050| 6c 74 69 2d 64 69 6d 65 | 6e 73 69 6f 6e 61 6c 2c |lti-dime|nsional,|
|00006060| 20 74 68 65 6e 20 61 6e | 20 65 6c 65 6d 65 6e 74 | then an| element|
|00006070| 20 63 61 6e 20 62 65 20 | 69 6e 64 65 78 65 64 20 | can be |indexed |
|00006080| 65 69 74 68 65 72 20 62 | 79 0a 58 09 75 73 69 6e |either b|y.X.usin|
|00006090| 67 20 6d 75 6c 74 69 70 | 6c 65 20 70 61 69 72 73 |g multip|le pairs|
|000060a0| 20 6f 66 20 73 71 75 61 | 72 65 20 62 72 61 63 6b | of squa|re brack|
|000060b0| 65 74 73 20 28 61 73 20 | 69 6e 20 43 29 2c 20 6f |ets (as |in C), o|
|000060c0| 72 20 65 6c 73 65 20 62 | 79 0a 58 09 73 65 70 61 |r else b|y.X.sepa|
|000060d0| 72 61 74 69 6e 67 20 74 | 68 65 20 69 6e 64 65 78 |rating t|he index|
|000060e0| 65 73 20 62 79 20 63 6f | 6d 6d 61 73 2e 20 20 54 |es by co|mmas. T|
|000060f0| 68 75 73 20 74 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |hus the |followin|
|00006100| 67 20 74 77 6f 20 73 74 | 61 74 65 6d 65 6e 74 73 |g two st|atements|
|00006110| 0a 58 09 72 65 66 65 72 | 65 6e 63 65 20 74 68 65 |.X.refer|ence the|
|00006120| 20 73 61 6d 65 20 6d 61 | 74 72 69 78 20 65 6c 65 | same ma|trix ele|
|00006130| 6d 65 6e 74 3a 0a 58 0a | 58 09 09 78 20 3d 20 6e |ment:.X.|X..x = n|
|00006140| 61 6d 65 5b 33 5d 5b 35 | 5d 3b 0a 58 09 09 78 20 |ame[3][5|];.X..x |
|00006150| 3d 20 6e 61 6d 65 5b 33 | 2c 35 5d 3b 0a 58 0a 58 |= name[3|,5];.X.X|
|00006160| 09 54 68 65 20 64 6f 75 | 62 6c 65 2d 73 71 75 61 |.The dou|ble-squa|
|00006170| 72 65 20 62 72 61 63 6b | 65 74 20 6f 70 65 72 61 |re brack|et opera|
|00006180| 74 6f 72 20 63 61 6e 20 | 62 65 20 75 73 65 64 20 |tor can |be used |
|00006190| 6f 6e 20 61 6e 79 20 6d | 61 74 72 69 78 20 74 6f |on any m|atrix to|
|000061a0| 0a 58 09 6d 61 6b 65 20 | 72 65 66 65 72 65 6e 63 |.X.make |referenc|
|000061b0| 65 73 20 74 6f 20 74 68 | 65 20 65 6c 65 6d 65 6e |es to th|e elemen|
|000061c0| 74 73 20 65 61 73 79 20 | 61 6e 64 20 65 66 66 69 |ts easy |and effi|
|000061d0| 63 69 65 6e 74 2e 20 20 | 54 68 69 73 20 6f 70 65 |cient. |This ope|
|000061e0| 72 61 74 6f 72 0a 58 09 | 62 79 70 61 73 73 65 73 |rator.X.|bypasses|
|000061f0| 20 74 68 65 20 6e 6f 72 | 6d 61 6c 20 69 6e 64 65 | the nor|mal inde|
|00006200| 78 69 6e 67 20 6d 65 63 | 68 61 6e 69 73 6d 2c 20 |xing mec|hanism, |
|00006210| 61 6e 64 20 74 72 65 61 | 74 73 20 74 68 65 20 61 |and trea|ts the a|
|00006220| 72 72 61 79 20 61 73 20 | 69 66 0a 58 09 69 74 20 |rray as |if.X.it |
|00006230| 77 61 73 20 6f 6e 65 2d | 64 69 6d 65 6e 73 69 6f |was one-|dimensio|
|00006240| 6e 61 6c 20 61 6e 64 20 | 77 69 74 68 20 61 20 6c |nal and |with a l|
|00006250| 6f 77 65 72 20 62 6f 75 | 6e 64 20 6f 66 20 7a 65 |ower bou|nd of ze|
|00006260| 72 6f 2e 20 20 49 6e 20 | 74 68 69 73 0a 58 09 69 |ro. In |this.X.i|
|00006270| 6e 64 65 78 69 6e 67 20 | 6d 6f 64 65 2c 20 65 6c |ndexing |mode, el|
|00006280| 65 6d 65 6e 74 73 20 63 | 6f 72 72 65 73 70 6f 6e |ements c|orrespon|
|00006290| 64 20 74 6f 20 74 68 65 | 20 6e 6f 72 6d 61 6c 20 |d to the| normal |
|000062a0| 69 6e 64 65 78 69 6e 67 | 20 6d 6f 64 65 20 77 68 |indexing| mode wh|
|000062b0| 65 72 65 0a 58 09 74 68 | 65 20 72 69 67 68 74 6d |ere.X.th|e rightm|
|000062c0| 6f 73 74 20 69 6e 64 65 | 78 20 69 6e 63 72 65 61 |ost inde|x increa|
|000062d0| 73 65 73 20 6d 6f 73 74 | 20 66 72 65 71 75 65 6e |ses most| frequen|
|000062e0| 74 6c 79 2e 20 20 46 6f | 72 20 65 78 61 6d 70 6c |tly. Fo|r exampl|
|000062f0| 65 2c 20 77 68 65 6e 0a | 58 09 75 73 69 6e 67 20 |e, when.|X.using |
|00006300| 64 6f 75 62 6c 65 2d 73 | 71 75 61 72 65 20 62 72 |double-s|quare br|
|00006310| 61 63 6b 65 74 20 69 6e | 64 65 78 69 6e 67 20 6f |acket in|dexing o|
|00006320| 6e 20 61 20 74 77 6f 2d | 64 69 6d 65 6e 73 69 6f |n a two-|dimensio|
|00006330| 6e 61 6c 20 6d 61 74 72 | 69 78 2c 0a 58 09 69 6e |nal matr|ix,.X.in|
|00006340| 63 72 65 61 73 69 6e 67 | 20 69 6e 64 65 78 65 73 |creasing| indexes|
|00006350| 20 77 69 6c 6c 20 72 65 | 66 65 72 65 6e 63 65 20 | will re|ference |
|00006360| 74 68 65 20 6d 61 74 72 | 69 78 20 65 6c 65 6d 65 |the matr|ix eleme|
|00006370| 6e 74 73 20 6c 65 66 74 | 20 74 6f 20 72 69 67 68 |nts left| to righ|
|00006380| 74 2c 0a 58 09 72 6f 77 | 20 62 79 20 72 6f 77 2e |t,.X.row| by row.|
|00006390| 20 20 54 68 75 73 20 69 | 6e 20 74 68 65 20 66 6f | Thus i|n the fo|
|000063a0| 6c 6c 6f 77 69 6e 67 20 | 65 78 61 6d 70 6c 65 2c |llowing |example,|
|000063b0| 20 27 78 27 20 61 6e 64 | 20 27 79 27 20 61 72 65 | 'x' and| 'y' are|
|000063c0| 20 63 6f 70 69 65 64 0a | 58 09 66 72 6f 6d 20 74 | copied.|X.from t|
|000063d0| 68 65 20 73 61 6d 65 20 | 6d 61 74 72 69 78 20 65 |he same |matrix e|
|000063e0| 6c 65 6d 65 6e 74 3a 0a | 58 0a 58 09 09 6d 61 74 |lement:.|X.X..mat|
|000063f0| 20 6d 5b 31 3a 32 2c 20 | 31 3a 33 5d 3b 0a 58 09 | m[1:2, |1:3];.X.|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.