| int c1; | int c1; | ||||
| int n_bytes; | int n_bytes; | ||||
| int ix; | |||||
| static const unsigned char mask[4] = { 0xff, 0x1f, 0x0f, 0x07 }; | static const unsigned char mask[4] = { 0xff, 0x1f, 0x0f, 0x07 }; | ||||
| // find the start of the next/previous character | // find the start of the next/previous character | ||||
| n_bytes = 3; | n_bytes = 3; | ||||
| c1 &= mask[n_bytes]; | c1 &= mask[n_bytes]; | ||||
| int ix; | |||||
| for (ix = 0; ix < n_bytes; ix++) | for (ix = 0; ix < n_bytes; ix++) | ||||
| { | { | ||||
| if (!*buf) | if (!*buf) | ||||
| { | { | ||||
| // Read 4 bytes (least significant first) into a word | // Read 4 bytes (least significant first) into a word | ||||
| int ix; | int ix; | ||||
| unsigned char c; | |||||
| int acc = 0; | int acc = 0; | ||||
| for (ix = 0; ix < 4; ix++) { | for (ix = 0; ix < 4; ix++) { | ||||
| unsigned char c; | |||||
| c = fgetc(f) & 0xff; | c = fgetc(f) & 0xff; | ||||
| acc += (c << (ix*8)); | acc += (c << (ix*8)); | ||||
| } | } |