v14i040: pac - the ultimate UNIX calculator, part 2 of 5

Istvan Mohos istvan at hhb.UUCP
Sat Aug 4 09:19:22 AEST 1990


Posting-number: Volume 14, Issue 40
Submitted-by: istvan at hhb.UUCP (Istvan Mohos)
Archive-name: pac/part02

==============================CUT HERE==============================
#!/bin/sh
# This is part 02 of a multipart archive
if touch 2>&1 | fgrep '[-amc]' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
# ============= maps.h ==============
echo "x - extracting maps.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > maps.h &&
X/* maps.h */
X/**********************************************************************
X*    File Name     : maps.h
X*    Function      : input character mapping to line edit functions
X*    Author        : Istvan Mohos, 1987
X***********************************************************************/
X
X#ifdef AMORTMAP
Xstatic char loan_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0,  0,  9, 10,  0,  1,  0,  0, 11,  7,  0,  0,  8,  0,  0,  0,  
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X     10,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  2,  0,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0,  0,  0,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  3,  0,  4,  0,  0,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL  */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 11
X};
X
Xstatic char date_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0,  0,  0, 10,  0,  1,  0,  0, 11,  7,  0,  0,  0,  0,  0,  0,  
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X     10,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  2,  0,  2,  2,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0,  0,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  3,  0,  4,  0,  0,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0, 11
X};
X
Xstatic char amort_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0,  0,  0, 10,  0,  1,  0,  0, 11,  7,  0,  0,  0,  0,  0,  0,  
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X     10,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  2,  0,  2,  2,  2,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0,  2,  0,  0,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  3,  2,  4,  0,  2,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0, 11
X};
X#endif
X
X#ifdef ATOIMAP
Xstatic char a_ed_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0,  0,  0,  0,  0,  1,  0,  0, 11,  7,  0,  0,  0,  0,  0,  0,  
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X     10,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0,  0,  0,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      0,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  3,  0,  4,  0,  0,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 11
X};
X
Xchar *lotab[33] = {"asc NUL", "SOH  ^A", "STX  ^B", "ETX  ^C",
X                   "EOT  ^D", "ENQ  ^E", "ACK  ^F", "BEL  ^G",
X                   "BS   ^H", "HT   ^I", "LF   ^J", "VT   ^K",
X                   "NP   ^L", "CR   ^M", "SO   ^N", "SI   ^O",
X                   "DLE  ^P", "DC1  ^Q", "DC2  ^R", "DC3  ^S",
X                   "DC4  ^T", "NAK  ^U", "SYN  ^V", "ETB  ^W",
X                   "CAN  ^X", "EM   ^Y", "SUB  ^Z", "ESC  ^[",
X                   "FS   ^|", "GS   ^]", "RS   ^`", "US   ^/",
X                   "asc  SP"
X};
X
X#endif
X
X#ifdef CONVMAP
Xstatic char c_ed_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0,  0,  0, 10,  0,  1,  0,  0, 11,  7,  0,  0,  0,  0,  0,  0,  
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0,  0,  0,  0,  
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X      2,  0,  0,  0,  0,  2,  0,  0,  2,  2,  2,  2,  0,  2,  2,  2,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  2, 20,  0, 19,  0,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  3,  2,  4,  2,  2,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0, 11
X};
X
Xstatic char eq_ed_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0,  0,  0, 10,  0,  1,  0,  0, 11,  7,  0,  0,  0,  0,  0,  0,  
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0,  0,  0,  0,  
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X      2,  0,  0,  0,  0,  2,  0,  0,  2,  2,  2,  2,  0,  2,  2,  2,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0, 20,  0, 19,  0,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  3,  2,  4,  2,  0,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 11
X};
X
Xstatic char c_sel_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0,  0,  0,  0,  0,  1,  0,  0, 11,  7,  0,  0,  0,  0,  0,  0,  
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      0,  0,  0, 17,  0,  0,  0,  0,  0, 17,  0,  0,  0,  0,  0,  0,  
X/*    P   Q  17   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0,  0,  0, 17,  0,  0,  0,  0,  0, 17,  0,  0,  0,  0,  0,  0,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL   */
X      0,  0, 17,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 11
X};
X#endif
X
X#ifdef FILEMAP
Xstatic char f_ed_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0,  0,  0, 10,  0,  1,  0,  0, 11,  7,  0,  0,  0,  0,  0,  0,  
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X      0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,  0,  0,  0,  0,  
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X     10,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  2,  0,  2,  2,  2,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0, 20,  2, 19,  0,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  3,  2,  4,  0,  2,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0,  0,  0, 11
X};
X#endif
X
X#ifdef PACMAP
Xstatic char cal_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0, 17, 17, 10, 17,  1, 17, 17, 11,  7, 17, 17, 17, 17, 17, 17,  
X#ifdef DESIGN
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X     17,  0, 18,  0, 17, 17,  0,  0, 17, 17,  0, 20,  0,  0,  0,  0,  
X#else
X     17,  0, 18, 17, 17,  0,  0,  0, 17,  0,  0, 20,  0,  0,  0,  0,  
X#endif
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X      2,  2,  0,  2,  0,  2,  0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  2, 20, 17, 19,  2,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  3,  2,  4,  2,  2,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL  */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2, 13, 15, 14,  0, 16
X};
X#endif
X
X#ifdef TOTALMAP
Xstatic char tot_map[128] = {
X/*   NL  ^A  ^B  ^C  ^D  ^E  ^F  ^G  ^H  ^I  ^J  ^K  ^L  ^M  ^N  ^O   */
X      0,  0,  0, 12,  0,  1, 12,  0, 11,  7,  0,  0,  0,  0,  0,  0,  
X/*   ^P  ^Q  ^R  ^S  ^T  ^U  ^V  ^W  ^X  ^Y  ^Z  ^[  ^|  ^]  ^`  ^/   */
X     12,  0,  0,  0,  8,  0,  0,  0,  0,  0,  0, 20,  0,  0,  0,  0,  
X/*   SP   !   "   #   $   %   &   '   (   )   *   +   ,   -   .   /   */
X     10,  0,  0, 21,  0,  0,  0,  0,  0,  0,  2,  2,  0,  2,  2,  0,  
X/*    0   1   2   3   4   5   6   7   8   9   :   ;   <   =   >   ?   */
X      2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  0,  0, 20,  0, 19,  0,  
X/*    @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   */
X      2, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,  
X/*    P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   */
X     12, 12, 12, 12, 12,  0,  0,  0,  0,  0,  0,  3,  0,  4,  0,  0,  
X/*    `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   */
X      0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,  
X/*    p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~  DL  */
X     12, 12, 12, 12, 12,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 11
X};
X#endif
X
X#ifdef INTERMAP
Xstatic char *hundred[] = {
X       "",        "", "1100100", "10201",
X       "1210", "400", "244",     "202",
X       "144",  "121", "100",     "91",
X       "84",   "79",  "72",      "6A",
X       "64" };
X
Xstatic char *sixteen[] = {
X       "",    "",   "10000",  "121",
X       "100", "31", "24",     "22",
X       "20",  "17", "16",     "15",
X       "14",  "13", "12",     "11",
X       "10" };
X
X static char *factab[] = {
X/*0*/ "x 0",
X/*1*/ "x 1",
X/*2*/ "x 2",
X/*3*/ "x 6",
X/*4*/ "x 18",
X/*5*/ "x 78",
X/*6*/ "x 2D0",
X/*7*/ "x 13B0",
X/*8*/ "x 9D80",
X/*9*/ "x 58980",
X/*10*/ "x 375F00",
X/*11*/ "x 2611500",
X/*12*/ "x 1C8CFC00",
X/*13*/ "x 17328CC00",
X/*14*/ "x 144C3B2800",
X/*15*/ "x 13077775800",
X/*16*/ "x 130777758000",
X/*17*/ "x 1437EEECD8000",
X/*18*/ "x 16BEECCA730000",
X/*19*/ "x 1B02B9306890000",
X/*20*/ "x 21C3677C82B40000",
X/*21*/ "x 2C5077D36B8C40000",
X/*22*/ "x 3CEEA4C2B3E0D80000",
X/*23*/ "x 57970CD7E2933680000",
X/*24*/ "x 83629343D3DCD1C00000",
X/*25*/ "x CD4A0619FB0907BC00000",
X/*26*/ "x 14D9849EA37EEAC91800000",
X/*27*/ "x 232F0FCBB3E62C3358800000",
X/*28*/ "x 3D925BA47AD2CD59DAE000000",
X/*29*/ "x 6F99461A1E9E1432DCB6000000",
X/*30*/ "x D13F6370F96865DF5DD54000000",
X/*31*/ "x 1956AD0AAE33A4560C5CD2C000000",
X/*32*/ "x 32AD5A155C6748AC18B9A580000000",
X/*33*/ "x 688589CC0E9505E2F2FEE5580000000",
X/*34*/ "x DE1BC4D19EFCAC82445DA75B00000000",
X/*35*/ "x FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
X};
X#endif
SHAR_EOF
$TOUCH -am 0221163890 maps.h &&
chmod 0644 maps.h ||
echo "restore of maps.h failed"
set `wc -c maps.h`;Wc_c=$1
if test "$Wc_c" != "14314"; then
	echo original size 14314, current size $Wc_c
fi
# ============= toktab.h ==============
echo "x - extracting toktab.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > toktab.h &&
X/* toktab.h */
X/**********************************************************************
X*    File Name     : toktab.h
X*    Function      : token definitions, token table
X*    Author        : Istvan Mohos, 1987
X***********************************************************************/
X
X/* to add token:
X   insert in toklist, spacefilled to WORDSIZE, in ascii alpha sequence;
X   increment LISTSIZE;
X   add token #define, in the SAME ORDER as in toklist;
X   renumber defines (0  to  LISTSIZE - 1);
X   if token contains weird char, adjust map in pac.c to allow it;
X   describe action in interpret.c;
X*/
X
X#define WORDSIZE  9        /* maximum token size, not including \0 */
X#define LISTSIZE  158      /* number of pac tokens */
X
X#ifdef PACTOK
Xstatic char *toklist[] = {
X"!        ",
X"#        ",
X"\'        ",
X";        ",
X"?        ",
X"X        ",
X"\\        ",
X"amass    ",
X"and      ",
X"arct     ",
X"astro    ",
X"at       ",
X"atto     ",
X"au       ",
X"auto     ",
X"autoconv ",
X"autotime ",
X"avogadro ",
X"boltzmann",
X"break    ",
X"bye      ",
X"chroma   ",
X"clr      ",
X"cm       ",
X"comma    ",
X"cos      ",
X"define   ",
X"dontsave ",
X"dp       ",
X"ds       ",
X"dup      ",
X"earthmass",
X"earthrad ",
X"echarge  ",
X"emass    ",
X"euler    ",
X"exa      ",
X"exit     ",
X"exp      ",
X"faraday  ",
X"femto    ",
X"fix      ",
X"fo       ",
X"for      ",
X"format   ",
X"g        ",
X"gas      ",
X"giga     ",
X"gravity  ",
X"h        ",
X"hardform ",
X"heat     ",
X"help     ",
X"hf       ",
X"i        ",
X"ib       ",
X"ibase    ",
X"if       ",
X"init     ",
X"j        ",
X"ju       ",
X"justify  ",
X"k        ",
X"kilo     ",
X"l        ",
X"le       ",
X"left     ",
X"length   ",
X"light    ",
X"lightyear",
X"log      ",
X"m        ",
X"mega     ",
X"micro    ",
X"milli    ",
X"mod      ",
X"mohos    ",
X"moonmass ",
X"moonrad  ",
X"n        ",
X"nano     ",
X"natural  ",
X"nmass    ",
X"not      ",
X"o        ",
X"ob       ",
X"obase    ",
X"off      ",
X"on       ",
X"or       ",
X"p        ",
X"parallax ",
X"parsec   ",
X"pd       ",
X"pdelta   ",
X"pdiff    ",
X"pe       ",
X"pequal   ",
X"peta     ",
X"pi       ",
X"pico     ",
X"planck   ",
X"pll      ",
X"pm       ",
X"pmass    ",
X"pminus   ",
X"po       ",
X"pof      ",
X"pop      ",
X"pp       ",
X"pplus    ",
X"pr       ",
X"precision",
X"psh      ",
X"pv       ",
X"pversus  ",
X"q        ",
X"quit     ",
X"r        ",
X"ri       ",
X"right    ",
X"rydberg  ",
X"s        ",
X"sb       ",
X"scale    ",
X"sin      ",
X"sound    ",
X"sp       ",
X"space    ",
X"sqrt     ",
X"st       ",
X"stack    ",
X"staybase ",
X"stefan   ",
X"sto      ",
X"sunmass  ",
X"sunrad   ",
X"swp      ",
X"t        ",
X"te       ",
X"tera     ",
X"terse    ",
X"to       ",
X"tomoon   ",
X"tosun    ",
X"tw       ",
X"twoscomp ",
X"u        ",
X"v        ",
X"ver      ",
X"verbose  ",
X"w        ",
X"while    ",
X"wien     ",
X"x        ",
X"xor      ",
X"xt       ",
X"xterse   "
X};
X#endif
X
X/* pac token table definitions, ordered EXACTLY as toklist,
X   numbered sequentially from 0.  When adding or removing tokens, this
X   list gets renumbered. */
X
X#define BANG             0
X#define SHARP            1
X#define TICK             2
X#define SEMI             3
X#define QUESTION         4
X#define X_UPPER          5
X#define BACKSLASH        6
X#define AMASS            7
X#define AND              8
X#define ARCT             9
X#define ASTRO           10
X#define AT              11
X#define ATTO            12
X#define AU              13
X#define AUTO            14
X#define AUTOCONV        15
X#define AUTOTIME        16
X#define AVOGADRO        17
X#define BOLTZMANN       18
X#define BREAK           19
X#define BYE             20
X#define CHROMA          21
X#define CLR             22
X#define CM              23
X#define COMMA           24
X#define COS             25
X#define DEFINE          26
X#define DONTSAVE        27
X#define DP              28
X#define DS              29
X#define DUP             30
X#define EARTHMASS       31
X#define EARTHRAD        32
X#define ECHARGE         33
X#define EMASS           34
X#define EULER           35
X#define EXA             36
X#define EXIT            37
X#define EXP             38
X#define FARADAY         39
X#define FEMTO           40
X#define FIX             41
X#define FO              42
X#define FOR             43
X#define FORMAT          44
X#define G_              45
X#define GAS             46
X#define GIGA            47
X#define GRAVITY         48
X#define H_              49
X#define HARDFORM        50
X#define HEAT            51
X#define HELP            52
X#define HF              53
X#define I_              54
X#define IB              55
X#define IBASE           56
X#define IF              57
X#define INIT_           58
X#define J_              59
X#define JU              60
X#define JUSTIFY         61
X#define K_              62
X#define KILO            63
X#define L_              64
X#define LE              65
X#define LEFT            66
X#define LENGTH          67
X#define LIGHT           68
X#define LIGHTYEAR       69
X#define LOG             70
X#define M_              71
X#define MEGA            72
X#define MICRO           73
X#define MILLI           74
X#define MOD             75
X#define MOHOS           76
X#define MOONMASS        77
X#define MOONRAD         78
X#define N_              79
X#define NANO            80
X#define NATURAL         81
X#define NMASS           82
X#define NOT             83
X#define O_              84
X#define OB              85
X#define OBASE           86
X#define OFF             87
X#define ON              88
X#define OR              89
X#define P_              90
X#define PARALLAX        91
X#define PARSEC          92
X#define PD              93
X#define PDELTA          94
X#define PDIFF           95
X#define PE              96
X#define PEQUAL          97
X#define PETA            98
X#define PI              99
X#define PICO           100
X#define PLANCK         101
X#define PLL            102
X#define PM             103
X#define PMASS          104
X#define PMINUS         105
X#define PO             106
X#define POF            107
X#define POP            108
X#define PP             109
X#define PPLUS          110
X#define PR             111
X#define PRECISION      112
X#define PSH            113
X#define PV             114
X#define PVERSUS        115
X#define Q_             116
X#define QUIT           117
X#define R_             118
X#define RI             119
X#define RIGHT          120
X#define RYDBERG        121
X#define S_             122
X#define SB             123
X#define SCALE          124
X#define SIN            125
X#define SOUND          126
X#define SP             127
X#define SPACE          128
X#define SQRT           129
X#define ST             130
X#define STACK          131
X#define STAYBASE       132
X#define STEFAN         133
X#define STO            134
X#define SUNMASS        135
X#define SUNRAD         136
X#define SWP            137
X#define T_             138
X#define TE             139
X#define TERA           140
X#define TERSE          141
X#define TO             142
X#define TOMOON         143
X#define TOSUN          144
X#define TW             145
X#define TWOSCOMP       146
X#define U_             147
X#define V_             148
X#define VER            149
X#define VERBOSE        150
X#define W_             151
X#define WHILE          152
X#define WIEN           153
X#define X_LOWER        154
X#define XOR            155
X#define XT             156
X#define XTERSE         157
SHAR_EOF
$TOUCH -am 0221163890 toktab.h &&
chmod 0644 toktab.h ||
echo "restore of toktab.h failed"
set `wc -c toktab.h`;Wc_c=$1
if test "$Wc_c" != "7256"; then
	echo original size 7256, current size $Wc_c
fi
# ============= amort.c ==============
echo "x - extracting amort.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > amort.c &&
X/* amort.c */
X/**********************************************************************
X*    File Name     : amort.c
X*    Function      : amortization (loan) routines of pac
X*    Author        : Istvan Mohos, 1987
X***********************************************************************/
X
X#include "defs.h"
X#define AMORTMAP
X#include "maps.h"
X#undef AMORTMAP
X
Xshow_loan(play)
Xint play;
X{
X    int thisline = AMTY;
X    int ck, did_input, Too_big;
X    char floatbuf[LOANSIZ + 1];
X    int pyp, pxp, ryr, rxr;
X    static char *fid = "show_loan";
X
X    _TR
X    CYX;
X    show_float(Amt, AMTY, 2);
X    show_float(Rate, PRCY, 3);
X    show_float(Years, YRY, 2);
X    mvaddstr(DATY, LOANX, "begin mo/year");
X    Too_big = show_pymt();
X
X    if (!play)
X        year();
X    else {
X        while(TRUE) {
X
X            switch(thisline) {
X            case AMTY:
X                if (Amt == 0.)
X                    clear_wline(thisline, LOANX, LOANR, 0, 1);
X                break;
X            case PRCY:
X                if (Rate == 0.)
X                    clear_wline(thisline, LOANX, LOANR, 0, 1);
X                break;
X            case YRY:
X                if (Years == 0.)
X                    clear_wline(thisline, LOANX, LOANR, 0, 1);
X                break;
X            }
X
X            if ((ck = ledit(floatbuf, loan_map, thisline, LOANX,
X                LOANR, 0, 1, 1)) == 1)
X                break;
X            did_input = strlen(floatbuf);
X
X            if (ck == 2 && Pymt > 0. && !Too_big) {
X                ryr=CY, rxr=CX;
X                ck = printamort();
X                move(CY=ryr, CX=rxr);
X                pfresh();
X                if (ck == 2)
X                    break;
X                continue;
X            }
X
X            if (did_input) {
X                switch(thisline) {
X                    case AMTY:
X                        Amt = atof(floatbuf);
X                        break;
X                    case PRCY:
X                        Rate = atof(floatbuf);
X                        break;
X                    case YRY:
X                        Years = atof(floatbuf);
X                        break;
X                }
X                Too_big = show_pymt();
X            }
X
X            if (++thisline > YRY)
X                thisline = AMTY;
X        }
X        PYX;
X        pfresh();
X    }
X    TR_
X}
X
Xshow_pymt()
X{
X    double nonzero;
X    char reformat[32];
X    static char *fid = "show_pymt";
X
X    _TR
X    Months = Years * 12.;
X    I_mo = (Rate / 100.) / 12.;
X    nonzero = 1. - pow(1. + I_mo, - Months);
X    if (nonzero == 0. || I_mo == 0.)
X        Pymt = Showpymt = 0.;
X    else {
X        Pymt = Amt * (I_mo / nonzero);
X        Showpymt = Pymt + .00999999;
X    }
X
X    sprintf(reformat, "%.2f", Showpymt);
X    Showpymt = atof(reformat);
X    if (show_float(Showpymt, PAYY, 2)) {
X        TR_
X        return(-1);
X    }
X    TR_
X    return(0);
X}
X
Xshow_float(value, where, decimals)
Xdouble value;
Xint where, decimals;
X{
X    char loanbuf[32];
X    char *lp = loanbuf;
X    register char *cp;
X    static char *fid = "show_float";
X
X    _TR
X    strcpy (lp, Sp13);
X    sprintf(lp,  "%.*f",decimals , value);
X    (strlen(lp) < 13) ? (*(lp + strlen(lp)) = ' ') : (*(lp + 13) = 0);
X
X    cp = lp + 13;
X    if (where > YRY)
X        for (; --cp >= lp;)
X            if (*cp == '.')
X                break;
X
X    if (cp >= lp) {
X        mvaddstr(where, LOANX, lp);
X        TR_
X        return(0);
X    }
X
X    mvaddstr(where, LOANX, "overflow     ");
X    TR_
X    return(-1);
X}
X
Xprintamort()
X{
X    double a_amt, ppay, ipay, yppay, yipay;
X    FILE *fp;
X    char *token, *np;
X    int ck, startmonth, startyear, yr;
X    int pyp, pxp;
X    register int ri;
X    int lastmonth;
X    char round[32];
X    char datebuf[LOANSIZ + 1];
X    static char savedate[LOANSIZ + 1];
X    char namebuf[TITSIZ + 1];
X    char spaceless[TITSIZ + 1];
X    int did_input;
X    static char *fid = "printamort";
X
X    _TR
X    if (strlen(savedate))
X        mvaddstr(DATY, LOANX, savedate);
X
X    if ((ck = ledit(&datebuf[0], date_map, DATY,
X        LOANX, LOANR, 0, 1, 0)) == 1) {
X        TR_
X        return(1);
X    }
X    if (ck == 2) {  /* types ^B, I have no idea what this does */
X        TR_
X        return(2);
X    }
X    did_input = datebuf[0];
X
X    if ((token = pactok(&datebuf[0], " .,/:")) == ZERO)
X        startmonth = 1, startyear = atoi(Thisyear);
X    if ((startmonth = whichmonth(token)) == 0)
X        startmonth = 1;
X    if ((token = pactok(ZERO, " .,/:")) == ZERO)
X        startyear = atoi(Thisyear);
X    else if ((startyear = atoi(token)) < 1)
X        startyear = atoi(Thisyear);
X    else if (startyear < 1900)
X        startyear += 1900;
X
X    move(DATY, LOANX);
X    printw("%.2d/%.4d      ", startmonth, startyear);
X    if (did_input)
X        sprintf(savedate, "%.2d/%.4d      ", startmonth, startyear);
X    pfresh();
X
X    Basq[EDITREQ] = Bb[LOANREQ];
X    CYX;  /* to save the caller'r coordinates */
X    update();  /* this returns to the original coordinates,
X                  but does'nt pfresh */
Xretry:
X
X    ledit(namebuf, amort_map, BOT, FBOUND, RBOUND, 1, 1, 0);
X
X    if (strlen(namebuf) == 0) {
X        strcpy(spaceless, Amortname);
X        for (np = spaceless; *np > 32; np++);
X        *np = '\0';
X        standout();
X        mvaddstr(BOT, FBOUND, Amortname);
X        standend();
X        pfresh();
X    }
X    else {
X        strcpy(Amortname, namebuf);
X        strcpy(spaceless, namebuf);
X    }
X
X    if ((fp = fopen(spaceless, "w")) == NULL) {
X        standout();
X        mvaddstr(BOT, ULEFT, "can't access:");
X        pfresh();
X        goto retry;
X    }
X    
X    fprintf(fp, "\
XAMORTIZATION SCHEDULE\n\n");
X    fprintf(fp, "\
X        PREPARED FOR    %s\n", Amortname);
X    fprintf(fp, "\
X        LOAN AMOUNT     %.2f\n", Amt);
X    fprintf(fp, "\
X        MONTHLY PAYMENT %.2f\n", Showpymt);
X    fprintf(fp, "\
X        LENDING RATE    %.3f%c\n", Rate, '\045');
X    fprintf(fp, "\
X        TERM YEARS      %.2f\n\n", Years);
X
X/* format field widths
X12345678901 1234567890123 12345678901234567890 12345678901234567890 XX
X*/
X    fprintf(fp, "\
XPAYMENT         DUE               PRINCIPAL          INTEREST           NEW\n");
X    fprintf(fp, "\
XNUMBER          DATE              PAYMENT            PAYMENT            BALANCE\n\n");
X
X    a_amt = Amt;
X    ck = startmonth;
X    Intrst = yppay = yipay = 0.;
X    yr = 1;
X    for (ri = 1, lastmonth = (int)Months; ri < lastmonth; ri++) {
X        ipay = I_mo * a_amt;
X        sprintf(round, "%.2f", ipay);
X        ipay = atof(round);
X        yipay += ipay;
X        ppay = Pymt - ipay + .009999999;
X        sprintf(round, "%.2f", ppay);
X        ppay = atof(round);
X        yppay += ppay;
X        a_amt -= ppay;
X        fprintf(fp, "\
X  %4d      %.2d/01/%.4d    %17.2f %17.2f %17.2f\n",
X            ri, ck, startyear, ppay, ipay, a_amt);
X        if (++ck > 12)
X            ck = 1;
X        if (((ri - 1) % 12) == (12 - startmonth)) {
X            fprintf(fp, "\
XYEAR %.2d TOTAL:            %17.2f %17.2f\n\n", yr++, yppay, yipay);
X            Intrst += yipay;
X            ++startyear;
X            yppay = yipay = 0.;
X        }
X    }
X    ipay = I_mo * a_amt;
X    sprintf(round, "%.2f", ipay);
X    ipay = atof(round);
X    yipay += ipay;
X    ppay = Pymt - ipay + .009999999;
X    sprintf(round, "%.2f", ppay);
X    ppay = atof(round);
X    a_amt -= ppay;
X    ppay += a_amt;
X    yppay += ppay;
X    a_amt = 0.;
X    Intrst += yipay;
X    fprintf(fp, "\
X  %4d      %.2d/01/%.4d    %17.2f %17.2f %17.2f\n",
X        ri, ck, startyear, ppay, ipay, a_amt);
X    fprintf(fp, "\
XYEAR %.2d TOTAL:            %17.2f %17.2f\n\n", yr, yppay, yipay);
X    fprintf(fp, "\
XGRAND TOTAL:              %17.2f %17.2f\n", Amt, Intrst);
X    fclose(fp);
X
X    strcpy(Bb[LOANREQ] + BUFSTOP, Amortname);
X    rev_clear(Bb[LOANREQ] + TITSIZ);
X    Basq[EDITREQ] = ZERO;
X
X    PYX;
X    update();
X    TR_
X    return(0);
X}
X
SHAR_EOF
$TOUCH -am 0221163890 amort.c &&
chmod 0644 amort.c ||
echo "restore of amort.c failed"
set `wc -c amort.c`;Wc_c=$1
if test "$Wc_c" != "7762"; then
	echo original size 7762, current size $Wc_c
fi
# ============= atoi.c ==============
echo "x - extracting atoi.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > atoi.c &&
X/* atoi.c */
X/**********************************************************************
X*    File Name     : atoi.c
X*    Function      : ascii/decimal/octal/hex converter of pac
X*    Author        : Istvan Mohos, 1987
X***********************************************************************/
X
X#include "defs.h"
X#define ATOIMAP
X#include "maps.h"
X#undef ATOIMAP
X
Xbyte_conv(from)
Xint from;
X{
X    char c, bbuf[10], *bb;
X    int pyp, pxp;
X    int ri, ffd, value;
X    static char *fid = "byte_conv";
X
X    _TR
X    CYX;
X    switch(from) {
X        case 4:
X            mvaddstr(UTOP + 1, ATOIX, "ENTER 3");
X            mvaddstr(UTOP + 2, ATOIX, "DECIMAL");
X            mvaddstr(UTOP + 3, ATOIX, "DIGITS ");
X            value = -1;
X            while(value == -1) {
X                mvaddstr(UTOP, ATOIX, "dec    ");
X
X                ledit(bbuf, a_ed_map, UTOP, ATOIX+4, ATOIX+6, 0, 1, 1);
X                if (!*bbuf)
X                    continue;
X                value = 0;
X                upcase(bbuf);
X                bb = bbuf;
X                for (ri = strlen(bbuf); --ri >= 0; bb++) {
X                    value *= 10;
X                    value += (*bb > 57) ? (*bb - 55) : (*bb - 48);
X                }
X                if (value < 0 || value > 127) {
X                    value = -1;
X                    continue;
X                }
X            }
X            move(UTOP, ATOIX);
X            printw("dec %3d", value);
X
X            move(UTOP + 1, ATOIX);
X            if (value == 127)
X                printw("asc DEL");
X            else if (value < 33)
X                printw("%s",lotab[value]);
X            else
X                printw("asc   %c",value);
X
X            move(UTOP + 2, ATOIX);
X            printw("oct %.3o", value);
X
X            move(UTOP + 3, ATOIX);
X            printw("hex  %.2x", value);
X            break;
X        case 1:
X        default:
X            ri = 0;
X#ifdef sun
X            signal(SIGHUP,  Save_sig[ri++]);
X            signal(SIGINT,  Save_sig[ri++]);
X            signal(SIGQUIT, Save_sig[ri++]);
X            signal(SIGTERM, Save_sig[ri++]);
X#else
X            Save_sig[ri++] = signal(SIGHUP,  SIG_IGN);
X            Save_sig[ri++] = signal(SIGINT,  SIG_IGN);
X            Save_sig[ri++] = signal(SIGQUIT, SIG_IGN);
X            Save_sig[ri++] = signal(SIGTERM, SIG_IGN);
X#endif /* sun */
X
X#ifndef REALUNIX
X#ifdef sun
X            signal(SIGTSTP, Save_sig[ri++]);
X            signal(SIGCONT, Save_sig[ri++]);
X#else
X            Save_sig[ri++] = signal(SIGTSTP, SIG_IGN);
X            Save_sig[ri++] = signal(SIGCONT, SIG_IGN);
X#endif /* sun */
X#endif /* !REALUNIX */
X
X            mvaddstr(UTOP + 1, ATOIX, "    HIT");
X            mvaddstr(UTOP + 2, ATOIX, "    ANY");
X            mvaddstr(UTOP + 3, ATOIX, "    KEY");
X            mvaddstr(UTOP, ATOIX, "asc    ");
X            move(UTOP, ATOIX + 6);
X            pfresh();
X            ffd = dup(0);
X            close(0);
X            read(ffd, &c, 1);
X            dup(ffd);
X            close(ffd);
X            value = c & 127;
X
X            move(UTOP, ATOIX);
X            if (value == 127)
X                printw("asc DEL");
X            else if (value < 33)
X                printw("%s",lotab[value]);
X            else
X                printw("asc   %c",value);
X            move(UTOP + 1, ATOIX);
X            printw("dec %3d", value);
X            move(UTOP + 2, ATOIX);
X            printw("oct %.3o", value);
X            move(UTOP + 3, ATOIX);
X            printw("hex  %.2x", value);
X
X            ri = 0;
X            signal(SIGHUP,  Save_sig[ri++]);
X            signal(SIGINT,  Save_sig[ri++]);
X            signal(SIGQUIT, Save_sig[ri++]);
X            signal(SIGTERM, Save_sig[ri++]);
X
X#ifndef REALUNIX
X            signal(SIGTSTP, Save_sig[ri++]);
X            signal(SIGCONT, Save_sig[ri++]);
X#endif
X            break;
X        case 15:
X            mvaddstr(UTOP + 1, ATOIX, "ENTER 3");
X            mvaddstr(UTOP + 2, ATOIX, "OCTAL  ");
X            mvaddstr(UTOP + 3, ATOIX, "DIGITS ");
X            value = -1;
X            while(value == -1) {
X                mvaddstr(UTOP, ATOIX, "oct    ");
X
X                ledit(bbuf, a_ed_map, UTOP, ATOIX+4, ATOIX+6, 0, 1, 1);
X                if (!*bbuf)
X                    continue;
X                value = 0;
X                upcase(bbuf);
X                bb = bbuf;
X                for (ri = strlen(bbuf); --ri >= 0; bb++) {
X                    value <<= 3;
X                    value += (*bb > 57) ? (*bb - 55) : (*bb - 48);
X                }
X                if (value < 0 || value > 127) {
X                    value = -1;
X                    continue;
X                }
X            }
X            move(UTOP, ATOIX);
X            printw("oct %.3o", value);
X
X            move(UTOP + 1, ATOIX);
X            if (value == 127)
X                printw("asc DEL");
X            else if (value < 33)
X                printw("%s",lotab[value]);
X            else
X                printw("asc   %c",value);
X            move(UTOP + 2, ATOIX);
X            printw("dec %3d", value);
X            move(UTOP + 3, ATOIX);
X            printw("hex  %.2x", value);
X            break;
X        case 24:
X            mvaddstr(UTOP + 1, ATOIX, "ENTER 2");
X            mvaddstr(UTOP + 2, ATOIX, "HEX    ");
X            mvaddstr(UTOP + 3, ATOIX, "DIGITS ");
X            value = -1;
X            while(value == -1) {
X                mvaddstr(UTOP, ATOIX, "hex    ");
X
X                ledit(bbuf, a_ed_map, UTOP, ATOIX+4, ATOIX+6, 0, 1, 1);
X                if (!*bbuf)
X                    continue;
X                value = 0;
X                upcase(bbuf);
X                bb = bbuf;
X                for (ri = strlen(bbuf); --ri >= 0; bb++) {
X                    value <<= 4;
X                    value += (*bb > 57) ? (*bb - 55) : (*bb - 48);
X                }
X                if (value < 0 || value > 127) {
X                    value = -1;
X                    continue;
X                }
X            }
X            move(UTOP, ATOIX);
X            printw("hex  %.2x", value);
X
X            move(UTOP + 1, ATOIX);
X            if (value == 127)
X                printw("asc DEL");
X            else if (value < 33)
X                printw("%s",lotab[value]);
X            else
X                printw("asc   %c",value);
X
X            move(UTOP + 2, ATOIX);
X            printw("dec %3d", value);
X            move(UTOP + 3, ATOIX);
X            printw("oct %.3o", value);
X            break;
X    }
X    PYX;
X    pfresh();
XTR_
X}
X
SHAR_EOF
$TOUCH -am 0221173890 atoi.c &&
chmod 0644 atoi.c ||
echo "restore of atoi.c failed"
set `wc -c atoi.c`;Wc_c=$1
if test "$Wc_c" != "6366"; then
	echo original size 6366, current size $Wc_c
fi
# ============= bitwise.c ==============
echo "x - extracting bitwise.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > bitwise.c &&
X/* bitwise.c */
X/**********************************************************************
X*    File Name     : bitwise.c
X*    Function      : and/or/xor/not/two's complement functions of pac
X*    Author        : Istvan Mohos, 1987
X***********************************************************************/
X
X
X#include "defs.h"
X#include "toktab.h"
X
X/* bitwise operators:
X   Ignore negative signs, if any.
X   Add preceding zeros to match digit count of integral part of numbers.
X   Add trailing zeros to match digit count of fractional part of nums.
X   Flip bits as appropriate.
X*/
X   
Xchar *
Xbitwise(oper, operand1, operand2, negflag)
Xchar *operand1, *operand2;
Xint oper, *negflag;
X{
X
X#ifdef BITTEST
X    static char debug1[LINEMAX], debug2[LINEMAX];
X    static
X#endif
X    char buf1[LINEMAX], buf2[LINEMAX];
X
X    static char bitbuf[LINEMAX];
X    char *bp = bitbuf;
X    char *pt1 = operand1;
X    char *pt2 = operand2;
X    register char *r1, *r2;
X    register int ri;
X    int leflen1, leflen2;
X    int ritlen1 = 0;
X    int ritlen2 = 0;
X    int dot1 = 0;
X    int dot2 = 0;
X    int len_of1, len_of2;
X    int maxlef, maxrit;
X    static char *fid = "bitwise";
X
X    _TR
X    *bp++ = Base_str[2];
X    *bp++ = ' ';
X
X    /* ignore signs */
X    *negflag = 0;
X    if (*pt1 == '-')
X        ++pt1;
X    len_of1 = strlen(pt1);
X    for (r1 = pt1 + len_of1; --r1 >= pt1;)
X        if (*r1 == '.') {
X            dot1 = 1;
X            break;
X        }
X    if (!dot1)
X       leflen1 = len_of1;
X    else {
X       leflen1 = r1 - pt1;
X       ritlen1 = len_of1 - leflen1 - 1;
X    }
X    
X    switch (oper) {
X        default:
X        case AND:
X        case OR:
X        case XOR:
X            if (*pt2 == '-')
X                ++pt2;
X            len_of2 = strlen(pt2);
X            for (r2 = pt2 + len_of2; --r2 >= pt2;)
X                if (*r2 == '.') {
X                    dot2 = 2;
X                    break;
X                }
X            if (!dot2)
X               leflen2 = len_of2;
X            else {
X               leflen2 = r2 - pt2;
X               ritlen2 = len_of2 - leflen2 - 2;
X            }
X        
X            maxlef = (leflen1 > leflen2) ? leflen1 : leflen2;
X            maxrit = (ritlen1 > ritlen2) ? ritlen1 : ritlen2;
X
X            r1 = buf1;
X            for (ri = maxlef - leflen1; --ri >= 0; *r1++ = '0');
X            strcpy(r1, pt1);
X            r1 += len_of1;
X            if (dot1 || dot2)
X                *r1++ = '.';
X            for (ri = maxrit - ritlen1; --ri >= 0; *r1++ = '0');
X            *r1 = '\0';
X            r1 = buf1;
X
X            r2 = buf2;
X            for (ri = maxlef - leflen2; --ri >= 0; *r2++ = '0');
X            strcpy(r2, pt2);
X            r2 += len_of2;
X            if (dot1 || dot2)
X                *r2++ = '.';
X            for (ri = maxrit - ritlen2; --ri >= 0; *r2++ = '0');
X            *r2 = '\0';
X            ri = r2 - buf2; /* not including the null */
X            r2 = buf2;
X
X            switch (oper) {
X                case AND:
X                    for (; --ri >= 0; r1++, r2++, bp++)
X                        if (*r1 == '1' && *r2 == '1')
X                            *bp = '1';
X                        else
X                            *bp = '0';
X                    break;
X                case OR:
X                    for (; --ri >= 0; r1++, r2++, bp++)
X                        if (*r1 == '1' || *r2 == '1')
X                            *bp = '1';
X                        else
X                            *bp = '0';
X                    break;
X                case XOR:
X                    for (; --ri >= 0; r1++, r2++, bp++)
X                        if ((*r1 == '1' && *r2 == '0') ||
X                            (*r1 == '0' && *r2 == '1'))
X                            *bp = '1';
X                        else
X                            *bp = '0';
X                    break;
X            }
X            *bp = '\0';
X            if (dot1 || dot2)
X                *(bitbuf + 2 + maxlef) = '.';
X
X#ifdef BITTEST
X    strcpy(debug1, pt1);
X    strcpy(debug2, pt2);
X    if (Trace && Tf != NULL)
X        fprintf(Tf,
X        "\n<<<%s>>>\n<<<%s>>>\n<<<<%s>>>\n<<<%s>>>\n<<<%s>>>\n",
X        debug1, debug2, buf1, buf2, bitbuf);
X#endif
X
X            TR_
X            return(bitbuf);
X
X        case TW:
X            if (dot1) {
X                TR_
X                return(ZERO);
X            }
X            if (atoi(pt1) == 0) {
X                strcpy(bp, "-1");
X                TR_
X                return(bitbuf);
X            }
X            /* case continues */
X        case NOT:
X
X            /* convert second number (in base 10), to size of
X               field in which to evaluate the operand */
X            if (*pt2 == '-')
X                ++pt2;
X            if ((len_of2 = atoi(pt2)) > LINEMAX - 4 - ritlen1) {
X                TR_
X                return(ZERO);
X            }
X
X            if (*pt1 == '1' && len_of2 == leflen1)
X                *negflag = 1;
X            if (leflen1 > len_of2) {
X                len_of2 = leflen1; 
X                pac_err("field too small");
X            }
X            r2 = bp;
X            for (ri = len_of2; --ri >= 0; *r2++ = '1');
X            *r2++ = '.';
X            for (ri = ritlen1; --ri >= 0; *r2++ = '1');
X            *r2-- = '\0';  /* end of result in bitbuf */
X
X            /* on last digit */
X            r1 = pt1 + leflen1 + ritlen1 + dot1 -1;
X            for (ri = ritlen1; --ri >= 0; r1--, r2--)
X                if (*r1 == '1')
X                    *r2 = '0';
X            if (dot1)
X                *r2-- = *r1--;
X            else
X                *r2-- = '\0';
X
X            for (ri = leflen1; --ri >= 0; r1--, r2--)
X                if (*r1 == '1')
X                    *r2 = '0';
X            TR_
X            return(bitbuf);
X    }
X}
SHAR_EOF
$TOUCH -am 0221163890 bitwise.c &&
chmod 0644 bitwise.c ||
echo "restore of bitwise.c failed"
set `wc -c bitwise.c`;Wc_c=$1
if test "$Wc_c" != "5666"; then
	echo original size 5666, current size $Wc_c
fi
echo "End of part 2, continue with part 3"
exit 0




More information about the Comp.sources.misc mailing list