CM6 subformat decoding function.
The function decodes an integer value from CM6 subformat. It takes an input stream to read from. This is necessary since the function has to skip line-ends on its own. If you want to read from a character string, use string streams. The numerical value returned is just the next decoded integer value from the stream. It is a second difference value. You still have to remove second differences afterwards.
209 static int ichar[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
210 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,2,3,4,5,6,7,
211 8,9,10,11,0,0,0,0,0,0,0,12,13,14,15,16,17,18,19,20,21,22,
212 23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,0,0,0,0,0,0,
213 38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,
214 57,58,59,60,61,62,63,0,0,0,0,0,0},
215 isign=020, ioflow=040, mask1=017, mask2=037, m127=0177;
217 int k, inn, jsign=0, joflow=0;
223 while (inchar ==
'\n') { is.get(inchar); }
225 throw Terror(
"ERROR (CM6::decode): illegal whitespace");
227 throw Terror(
"ERROR (CM6::decode): illegal end of file");
232 k = int(
int(inchar) & m127);
235 jsign = (inn & isign);
236 joflow = (inn & ioflow);
237 retval = (long)(inn & mask1);
245 while (inchar ==
'\n') { is.get(inchar); }
247 throw Terror(
"ERROR (CM6::decode): illegal whitespace");
249 throw Terror(
"ERROR (CM6::decode): illegal end of file");
252 k = int(
int(inchar) & m127);
254 joflow = (inn & ioflow);
255 retval = retval +
intT(inn & mask2);
259 if (jsign != 0) retval = -retval;