00001 #include "stack-c.h"
00002 #include "core_math.h"
00003 #define TRUE_ 1
00004 #define FALSE_ 0
00005
00006
00007
00008 static integer cx1 = 1;
00009 static integer c_n1 = -1;
00010
00011 integer C2F(getfastcode)(unsigned char *c, unsigned long c_len) ;
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 int C2F(cvstr)(integer * n,integer * line,char * str,integer * job,
00026 unsigned long str_len)
00027 {
00028 if (*job == 0)
00029 C2F(asciitocode)(n, line, str, &cx1, str_len);
00030 else
00031 C2F(codetoascii)(n, line, str, str_len);
00032 return 0;
00033 }
00034
00035
00036
00037
00038
00039
00040 int C2F(cvstr1)(integer *n,integer * line,char * str,integer * job,
00041 unsigned long str_len)
00042 {
00043 if (*job == 0)
00044 C2F(asciitocode)(n, line, str, &c_n1, str_len);
00045 else
00046 C2F(codetoascii)(n, line, str, str_len);
00047 return 0;
00048 }
00049
00050
00051
00052
00053
00054
00055 int C2F(codetoascii)(integer *n,integer * line,char * str,
00056 unsigned long str_len)
00057 {
00058 static integer eol = 99;
00059 int j, m;
00060
00061 for (j = 0; j < *n; ++j) {
00062 m = line[j];
00063 if (m == eol)
00064 {
00065 str[j] = '!';
00066 }
00067 else if (Abs(m) > csiz)
00068 {
00069 if (m > eol) {
00070 str[j] = (char)(m - (eol + 1));
00071 } else {
00072 str[j] = '!';
00073 }
00074 }
00075 else if (m < 0)
00076 {
00077 str[j] = C2F(cha1).alfb[Abs(m)];
00078 }
00079 else
00080 {
00081 str[j] = C2F(cha1).alfa[m];
00082 }
00083 }
00084 return 0;
00085 }
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 int C2F(asciitocode)(integer * n,integer * line,char * str,integer * flagx,unsigned long str_len)
00096 {
00097 integer j;
00098 if (*flagx == 1) {
00099 for (j = 0; j < *n ; ++j) {
00100 line[j] = C2F(getfastcode)(str+j, 1L);
00101 }
00102 } else {
00103 for (j = *n -1 ; j >= 0; --j) {
00104 line[j] = C2F(getfastcode)(str+j, 1L);
00105 }
00106 }
00107 return 0;
00108 }
00109
00110
00111
00112
00113
00114
00115
00116 integer C2F(getcode)(unsigned char * mc,unsigned long mc_len)
00117 {
00118 static integer eol = 99;
00119 integer k;
00120 for (k = 0 ; k < csiz; ++k) {
00121 if ( *mc == C2F(cha1).alfa[k])
00122 {
00123 return k ;
00124 }
00125 else if ( *mc == C2F(cha1).alfb[k]) {
00126 return - k;
00127 }
00128 }
00129
00130 switch ( *mc ) {
00131 case 0: return 100; break;
00132 case 9: return 109; break;
00133 case 10: return 110 ; break;
00134 default :
00135 return *mc + eol + 1;
00136 }
00137 }
00138
00139
00140 #include "machine.h"
00141
00142 static integer taba2s[128] =
00143 { 100,101,102,103,104,105,106,107,108,-40,
00144 110,111,112,113,114,115,116,117,118,119,
00145 120,121,122,123,124,125,126,127,128,129,
00146 130,131, 40, 38,-53, 37, 39, 56, 58, 53,
00147 41, 42, 47, 45, 52, 46, 51, 48, 0, 1,
00148 2, 3, 4, 5, 6, 7, 8, 9, 44, 43,
00149 59, 50, 60,-38,-61,-10,-11,-12,-13,-14,
00150 -15,-16,-17,-18,-19,-20,-21,-22,-23,-24,
00151 -25,-26,-27,-28,-29,-30,-31,-32,-33,-34,
00152 -35, 54, 49, 55, 62, 36,-59, 10, 11, 12,
00153 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
00154 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
00155 33, 34, 35,-54, 57,-55, 61,227 };
00156
00157
00158
00159
00160
00161
00162
00163
00164 integer C2F(getfastcode)(unsigned char *c, unsigned long c_len)
00165 {
00166 int k = *c ;
00167 if (k <= 127) {
00168 return taba2s[*c];
00169 } else {
00170 return k + 100;
00171 }
00172 }
00173
00174
00175
00176
00177
00178
00179
00180
00181